增加email登录
This commit is contained in:
parent
bf4875bf19
commit
13fdc25a54
1
src/JCWallet.d.ts
vendored
1
src/JCWallet.d.ts
vendored
@ -21,6 +21,7 @@ declare namespace jsb {
|
||||
export function signWithFacebook(id: number);
|
||||
export function callJcVoidMethodJNI(id: number, methodName: string);
|
||||
export function signWithTwitter(id: number);
|
||||
export function signWithEmail(id: number);
|
||||
export function signOutGoogle(id: number);
|
||||
export function showWebPage(url: string);
|
||||
export function openURL(url: string);
|
||||
|
@ -43,27 +43,31 @@ export async function loadInternalWallet(channel: number) {
|
||||
let tokenRes: any;
|
||||
if (channel == 1) {
|
||||
let res: any = await new NativeSvr().signWithApple();
|
||||
console.log("native apple res: " + res);
|
||||
window.debug && console.log("native apple res: " + res);
|
||||
tokenRes = await appleAuth(res);
|
||||
} else if (channel == 2) {
|
||||
let res: any = await new NativeSvr().signWithTikTok();
|
||||
console.log("native tiktok res: " + res);
|
||||
window.debug && console.log("native tiktok res: " + res);
|
||||
tokenRes = await tikTokAuth(res);
|
||||
} else if (channel == 3) {
|
||||
let res: any = await new NativeSvr().signWithFacebook();
|
||||
console.log("native facebook res: " + res);
|
||||
window.debug && console.log("native facebook res: " + res);
|
||||
tokenRes = await facebookAuth(res);
|
||||
} else if (channel == 4) {
|
||||
let res: any = await new NativeSvr().signWithTwitter();
|
||||
console.log("native twitter res: " + res);
|
||||
window.debug && console.log("native twitter res: " + res);
|
||||
tokenRes = await twitterAuth(res);
|
||||
} else if (channel == 6) {
|
||||
let res: any = await new NativeSvr().signWithEmail();
|
||||
window.debug && console.log("native twitter res: " + res);
|
||||
tokenRes = await twitterAuth(res);
|
||||
} else {
|
||||
let res: any = await new NativeSvr().signWithGoogle();
|
||||
console.log("native google res: " + res);
|
||||
window.debug && console.log("native google res: " + res);
|
||||
tokenRes = await googleAuth(res);
|
||||
}
|
||||
console.log("wallet token: " + tokenRes.data?.token);
|
||||
console.log(tokenRes);
|
||||
window.debug && console.log("wallet token: " + tokenRes.data?.token);
|
||||
window.debug && console.log(tokenRes);
|
||||
if (tokenRes.errcode || !tokenRes.data?.token) {
|
||||
return;
|
||||
}
|
||||
@ -73,16 +77,6 @@ export async function loadInternalWallet(channel: number) {
|
||||
if (infoRes.errcode) {
|
||||
return;
|
||||
}
|
||||
// let infoRes = {
|
||||
// data: {
|
||||
// oid: "636cce78a95e553cb061c0f1",
|
||||
// account: "636b6acaa95e553cb0609ce2",
|
||||
// is: "2e0316fa555a",
|
||||
// salt: "6824413b37",
|
||||
// key: "aec87426c4655cf81a6059964ca919fc8fc995886078931681ba1b6431db281c",
|
||||
// },
|
||||
// };
|
||||
console.log("wallet info: " + JSON.stringify(infoRes.data));
|
||||
let seed = infoRes.data.oid + infoRes.data.is + infoRes.data.salt;
|
||||
let seedHash = md5Hash(seed);
|
||||
let address;
|
||||
@ -115,6 +109,7 @@ export async function loadInternalWallet(channel: number) {
|
||||
let strWallet = jsb.prepareWallet(idHash, seedHash, infoRes.data.key);
|
||||
let walletInfo = JSON.parse(strWallet);
|
||||
address = walletInfo.address;
|
||||
retry(() => uploadWalletInfo({ address }), MAX_UPLOAD_COUNT);
|
||||
} else {
|
||||
let qrResult = await new NativeSvr().restoreKey(idHash);
|
||||
let strWallet = jsb.restoreWallet(
|
||||
@ -126,12 +121,7 @@ export async function loadInternalWallet(channel: number) {
|
||||
window.debug && console.log("restore native wallet info " + strWallet);
|
||||
let walletInfo = JSON.parse(strWallet);
|
||||
address = walletInfo.address;
|
||||
// setImmediate(function () {
|
||||
// retry(
|
||||
// () => uploadWalletInfo({ key: walletInfo.master }),
|
||||
// MAX_UPLOAD_COUNT
|
||||
// );
|
||||
// });
|
||||
retry(() => uploadWalletInfo({ address }), MAX_UPLOAD_COUNT);
|
||||
}
|
||||
}
|
||||
return address;
|
||||
|
@ -58,6 +58,12 @@ export class NativeSvr {
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public signWithEmail() {
|
||||
let id = payloadId();
|
||||
jsb.signWithEmail(id);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public signOutGoogle() {
|
||||
let id = payloadId();
|
||||
jsb.signOutGoogle(id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user