修改导出密钥, 增加密码验证
This commit is contained in:
parent
a08c12c535
commit
2db473a365
7
src/JCWallet.d.ts
vendored
7
src/JCWallet.d.ts
vendored
@ -31,6 +31,13 @@ declare namespace jsb {
|
||||
export function hashSvrPass(pass: string): string;
|
||||
export function walletEncrypt(str: string): string;
|
||||
export function walletDecrypt(str: string): string;
|
||||
export function walletSecKey(
|
||||
id: string,
|
||||
openid: string,
|
||||
key_master: string,
|
||||
salt: string,
|
||||
pass: string
|
||||
): string;
|
||||
export function prepareWallet(
|
||||
id: string,
|
||||
openid: string,
|
||||
|
@ -25,6 +25,7 @@ import { singleton } from "./decorator/singleton.decorator";
|
||||
import { saveData } from "./manage/DataManage";
|
||||
import { parseUrl } from "./manage/SchemeManage";
|
||||
import {
|
||||
exportSecKey,
|
||||
loadInternalWallet,
|
||||
loginByEmail,
|
||||
verifyPassword,
|
||||
@ -119,6 +120,10 @@ export default class JCWallet {
|
||||
return verifyPassword(pass);
|
||||
}
|
||||
|
||||
public exportPrivateKey(pass: string) {
|
||||
return exportSecKey(pass);
|
||||
}
|
||||
|
||||
public emailLogin(email: string, password: string) {
|
||||
return loginByEmail(email, password);
|
||||
}
|
||||
|
@ -135,6 +135,26 @@ export async function verifyPassword(pass: string) {
|
||||
return new WalletEnv().address === address;
|
||||
}
|
||||
|
||||
export function exportSecKey(pass: string) {
|
||||
let walletEnv = new WalletEnv();
|
||||
if (!walletEnv.address || !walletEnv.key) {
|
||||
throw new ZError(10, "wallet not found");
|
||||
}
|
||||
let { id, openid } = walletEnv.tokenData;
|
||||
let resultStr = jsb.walletSecKey(
|
||||
id,
|
||||
openid,
|
||||
walletEnv.key,
|
||||
walletEnv.salt,
|
||||
pass
|
||||
);
|
||||
let result = JSON.parse(resultStr);
|
||||
if (result.address !== walletEnv.address) {
|
||||
throw new ZError(11, "address not match, perhaps wrong password");
|
||||
}
|
||||
return result.key;
|
||||
}
|
||||
|
||||
export function walletSign(str: string) {
|
||||
let result = jsb.walletSign(str);
|
||||
return result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user