增加email登录

This commit is contained in:
zhl 2023-04-23 09:41:36 +08:00
parent bf4875bf19
commit 13fdc25a54
3 changed files with 20 additions and 23 deletions

1
src/JCWallet.d.ts vendored
View File

@ -21,6 +21,7 @@ declare namespace jsb {
export function signWithFacebook(id: number); export function signWithFacebook(id: number);
export function callJcVoidMethodJNI(id: number, methodName: string); export function callJcVoidMethodJNI(id: number, methodName: string);
export function signWithTwitter(id: number); export function signWithTwitter(id: number);
export function signWithEmail(id: number);
export function signOutGoogle(id: number); export function signOutGoogle(id: number);
export function showWebPage(url: string); export function showWebPage(url: string);
export function openURL(url: string); export function openURL(url: string);

View File

@ -43,27 +43,31 @@ export async function loadInternalWallet(channel: number) {
let tokenRes: any; let tokenRes: any;
if (channel == 1) { if (channel == 1) {
let res: any = await new NativeSvr().signWithApple(); 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); tokenRes = await appleAuth(res);
} else if (channel == 2) { } else if (channel == 2) {
let res: any = await new NativeSvr().signWithTikTok(); 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); tokenRes = await tikTokAuth(res);
} else if (channel == 3) { } else if (channel == 3) {
let res: any = await new NativeSvr().signWithFacebook(); 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); tokenRes = await facebookAuth(res);
} else if (channel == 4) { } else if (channel == 4) {
let res: any = await new NativeSvr().signWithTwitter(); 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); tokenRes = await twitterAuth(res);
} else { } else {
let res: any = await new NativeSvr().signWithGoogle(); 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); tokenRes = await googleAuth(res);
} }
console.log("wallet token: " + tokenRes.data?.token); window.debug && console.log("wallet token: " + tokenRes.data?.token);
console.log(tokenRes); window.debug && console.log(tokenRes);
if (tokenRes.errcode || !tokenRes.data?.token) { if (tokenRes.errcode || !tokenRes.data?.token) {
return; return;
} }
@ -73,16 +77,6 @@ export async function loadInternalWallet(channel: number) {
if (infoRes.errcode) { if (infoRes.errcode) {
return; 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 seed = infoRes.data.oid + infoRes.data.is + infoRes.data.salt;
let seedHash = md5Hash(seed); let seedHash = md5Hash(seed);
let address; let address;
@ -115,6 +109,7 @@ export async function loadInternalWallet(channel: number) {
let strWallet = jsb.prepareWallet(idHash, seedHash, infoRes.data.key); let strWallet = jsb.prepareWallet(idHash, seedHash, infoRes.data.key);
let walletInfo = JSON.parse(strWallet); let walletInfo = JSON.parse(strWallet);
address = walletInfo.address; address = walletInfo.address;
retry(() => uploadWalletInfo({ address }), MAX_UPLOAD_COUNT);
} else { } else {
let qrResult = await new NativeSvr().restoreKey(idHash); let qrResult = await new NativeSvr().restoreKey(idHash);
let strWallet = jsb.restoreWallet( let strWallet = jsb.restoreWallet(
@ -126,12 +121,7 @@ export async function loadInternalWallet(channel: number) {
window.debug && console.log("restore native wallet info " + strWallet); window.debug && console.log("restore native wallet info " + strWallet);
let walletInfo = JSON.parse(strWallet); let walletInfo = JSON.parse(strWallet);
address = walletInfo.address; address = walletInfo.address;
// setImmediate(function () { retry(() => uploadWalletInfo({ address }), MAX_UPLOAD_COUNT);
// retry(
// () => uploadWalletInfo({ key: walletInfo.master }),
// MAX_UPLOAD_COUNT
// );
// });
} }
} }
return address; return address;

View File

@ -58,6 +58,12 @@ export class NativeSvr {
return this._subscribeToCallResponse(id); return this._subscribeToCallResponse(id);
} }
public signWithEmail() {
let id = payloadId();
jsb.signWithEmail(id);
return this._subscribeToCallResponse(id);
}
public signOutGoogle() { public signOutGoogle() {
let id = payloadId(); let id = payloadId();
jsb.signOutGoogle(id); jsb.signOutGoogle(id);