增加客户端登录
This commit is contained in:
parent
86e71e6d73
commit
ef8f844cc3
7
src/JCWallet.d.ts
vendored
7
src/JCWallet.d.ts
vendored
@ -14,7 +14,8 @@ declare namespace jc {
|
|||||||
|
|
||||||
declare namespace jsb {
|
declare namespace jsb {
|
||||||
export function walletSign(str: string);
|
export function walletSign(str: string);
|
||||||
export function loadLocalStorage(key: string);
|
export function loadLocalStorage(key: string): string;
|
||||||
|
export function saveLocalStorage(key: string, val: string);
|
||||||
export function signWithGoogle(id: number);
|
export function signWithGoogle(id: number);
|
||||||
export function signWithApple(id: number);
|
export function signWithApple(id: number);
|
||||||
export function signWithTikTok(id: number);
|
export function signWithTikTok(id: number);
|
||||||
@ -33,6 +34,10 @@ declare namespace jsb {
|
|||||||
export function walletDecrypt(str: string): string;
|
export function walletDecrypt(str: string): string;
|
||||||
export function beginBuy(id: number, productId: string, orderId: string): string;
|
export function beginBuy(id: number, productId: string, orderId: string): string;
|
||||||
export function queryPurchase(id: number): string;
|
export function queryPurchase(id: number): string;
|
||||||
|
export function getClientId(id: number);
|
||||||
|
export function passStorageState(id: number, account: string);
|
||||||
|
export function storagePass(id: number, account: string, pass: string);
|
||||||
|
export function authGetStoragePass(id: number, key: string);
|
||||||
export function queryProducts(id: number, str: string): string;
|
export function queryProducts(id: number, str: string): string;
|
||||||
export function finishTransaction(id: number, str: string);
|
export function finishTransaction(id: number, str: string);
|
||||||
export function walletSecKey(id: string, openid: string, key_master: string, salt: string, pass: string): string;
|
export function walletSecKey(id: string, openid: string, key_master: string, salt: string, pass: string): string;
|
||||||
|
@ -26,6 +26,11 @@ export function twitterAuth(idToken: string) {
|
|||||||
return POST_JSON(url, { code: idToken });
|
return POST_JSON(url, { code: idToken });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clientAuth(idToken: string) {
|
||||||
|
const url = `${WALLET_API_HOST}/wallet/login/client`;
|
||||||
|
return POST_JSON(url, { code: idToken });
|
||||||
|
}
|
||||||
|
|
||||||
export function getWalletInfo() {
|
export function getWalletInfo() {
|
||||||
const url = `${WALLET_API_HOST}/wallet/info`;
|
const url = `${WALLET_API_HOST}/wallet/info`;
|
||||||
return GET_JSON(url);
|
return GET_JSON(url);
|
||||||
|
24
src/index.ts
24
src/index.ts
@ -104,7 +104,19 @@ export default class JCWallet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public preLogin(channel: number) {
|
public get platform() {
|
||||||
|
// @ts-ignore
|
||||||
|
if (window.JavascriptJavaBridge) {
|
||||||
|
console.log('regist android jsb.reflection');
|
||||||
|
return 'android';
|
||||||
|
// @ts-ignore
|
||||||
|
} else if (window.JavaScriptObjCBridge) {
|
||||||
|
return 'ios';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public preLogin(channel: number, env: string = 'dev') {
|
||||||
|
this.env = env;
|
||||||
return walletPreLogin(channel);
|
return walletPreLogin(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,6 +512,16 @@ export default class JCWallet {
|
|||||||
await syncWalletEnv();
|
await syncWalletEnv();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public saveLocalItem(key: string, value: string) {
|
||||||
|
jsb.saveLocalStorage(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public loadLocalItem(key: string) {
|
||||||
|
let val = jsb.loadLocalStorage(key);
|
||||||
|
console.log('loadLocalItem:: ' + val);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// window.jc = window.jc || {wallet: new JCWallet()};
|
// window.jc = window.jc || {wallet: new JCWallet()};
|
||||||
|
@ -11,6 +11,7 @@ export function request(url, option) {
|
|||||||
}
|
}
|
||||||
headers.append('api_version', VERSION_CODE + '');
|
headers.append('api_version', VERSION_CODE + '');
|
||||||
headers.append('api_env', jc.wallet.env);
|
headers.append('api_env', jc.wallet.env);
|
||||||
|
headers.append('api_platform', jc.wallet.platform);
|
||||||
let optionInt: any = {
|
let optionInt: any = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
mode: 'cors',
|
mode: 'cors',
|
||||||
|
@ -4,6 +4,7 @@ import { loadMnemonic, saveMnemonic } from './DataManage';
|
|||||||
import { NativeSvr } from '../services/NativeSvr';
|
import { NativeSvr } from '../services/NativeSvr';
|
||||||
import {
|
import {
|
||||||
appleAuth,
|
appleAuth,
|
||||||
|
clientAuth,
|
||||||
facebookAuth,
|
facebookAuth,
|
||||||
getWalletInfo,
|
getWalletInfo,
|
||||||
googleAuth,
|
googleAuth,
|
||||||
@ -69,6 +70,10 @@ export async function walletPreLogin(channel: number) {
|
|||||||
let res: any = await new NativeSvr().signWithTwitter();
|
let res: any = await new NativeSvr().signWithTwitter();
|
||||||
window.debug && console.log('native twitter res: ' + res);
|
window.debug && console.log('native twitter res: ' + res);
|
||||||
tokenRes = await twitterAuth(res);
|
tokenRes = await twitterAuth(res);
|
||||||
|
} else if (channel == 10) {
|
||||||
|
let res: any = await new NativeSvr().clientLogin();
|
||||||
|
console.log('native client res: ' + res);
|
||||||
|
tokenRes = await clientAuth(res);
|
||||||
} else {
|
} else {
|
||||||
let res: any = await new NativeSvr().signWithGoogle();
|
let res: any = await new NativeSvr().signWithGoogle();
|
||||||
window.debug && console.log('native google res: ' + res);
|
window.debug && console.log('native google res: ' + res);
|
||||||
|
@ -99,4 +99,28 @@ export class NativeSvr {
|
|||||||
jsb.finishTransaction(id, transactionId);
|
jsb.finishTransaction(id, transactionId);
|
||||||
return this._subscribeToCallResponse(id);
|
return this._subscribeToCallResponse(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public authGetStoragePass(key: string) {
|
||||||
|
let id = payloadId();
|
||||||
|
jsb.authGetStoragePass(id, key);
|
||||||
|
return this._subscribeToCallResponse(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public passStorageState(key: string) {
|
||||||
|
let id = payloadId();
|
||||||
|
jsb.passStorageState(id, key);
|
||||||
|
return this._subscribeToCallResponse(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public storagePass(key: string, pass: string) {
|
||||||
|
let id = payloadId();
|
||||||
|
jsb.storagePass(id, key, pass);
|
||||||
|
return this._subscribeToCallResponse(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public clientLogin() {
|
||||||
|
let id = payloadId();
|
||||||
|
jsb.getClientId(id);
|
||||||
|
return this._subscribeToCallResponse(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user