@getpara/web-sdk 2.27.0 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WebUtils.d.ts +1 -0
- package/dist/WebUtils.js +4 -1
- package/dist/utils/isMobile.d.ts +1 -0
- package/dist/utils/isMobile.js +19 -0
- package/dist/wallet/privateKey.d.ts +1 -0
- package/dist/wallet/privateKey.js +33 -0
- package/dist/workers/walletUtils.d.ts +1 -0
- package/dist/workers/walletUtils.js +21 -0
- package/dist/workers/worker.js +5 -0
- package/package.json +4 -4
package/dist/WebUtils.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare class WebUtils implements PlatformUtils {
|
|
|
8
8
|
private eventHandlers;
|
|
9
9
|
private nativeHandlers;
|
|
10
10
|
getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
|
|
11
|
+
getED25519PrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
|
|
11
12
|
keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null, // should be acceptable as null in RN as we don't pre-gen them
|
|
12
13
|
sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
|
|
13
14
|
signer: string;
|
package/dist/WebUtils.js
CHANGED
|
@@ -7,7 +7,7 @@ import { LocalStorage } from "./LocalStorage.js";
|
|
|
7
7
|
import { SessionStorage } from "./SessionStorage.js";
|
|
8
8
|
import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen, refresh, initializeWorker } from "./wallet/keygen.js";
|
|
9
9
|
import { signMessage, sendTransaction, signTransaction, ed25519Sign } from "./wallet/signing.js";
|
|
10
|
-
import { getPrivateKey } from "./wallet/privateKey.js";
|
|
10
|
+
import { getPrivateKey, getED25519PrivateKey } from "./wallet/privateKey.js";
|
|
11
11
|
import { validatePortalOrigin } from "./utils/validatePortalOrigin.js";
|
|
12
12
|
class WebUtils {
|
|
13
13
|
constructor() {
|
|
@@ -24,6 +24,9 @@ class WebUtils {
|
|
|
24
24
|
getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
25
25
|
return getPrivateKey(ctx, userId, walletId, share, sessionCookie);
|
|
26
26
|
}
|
|
27
|
+
getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
28
|
+
return getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie);
|
|
29
|
+
}
|
|
27
30
|
keygen(ctx, userId, type, secretKey, sessionCookie, emailProps = {}) {
|
|
28
31
|
return keygen(ctx, userId, type, secretKey, true, sessionCookie, emailProps);
|
|
29
32
|
}
|
package/dist/utils/isMobile.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function isLargeIOS(): boolean;
|
|
|
4
4
|
export declare function isTablet(): boolean;
|
|
5
5
|
export declare function isIOS(): boolean;
|
|
6
6
|
export declare function isMobile(): boolean;
|
|
7
|
+
export declare function isAndroidChrome(): boolean;
|
|
7
8
|
export declare function isSafari(): boolean;
|
|
8
9
|
export declare function isIOSWebview(): boolean;
|
|
9
10
|
export declare function isMobileSafari(): boolean;
|
package/dist/utils/isMobile.js
CHANGED
|
@@ -28,6 +28,24 @@ function isIOS() {
|
|
|
28
28
|
function isMobile() {
|
|
29
29
|
return isAndroid() || isIOS();
|
|
30
30
|
}
|
|
31
|
+
let cachedAndroidChromeUa;
|
|
32
|
+
let cachedAndroidChromeResult = false;
|
|
33
|
+
function isAndroidChrome() {
|
|
34
|
+
if (typeof navigator === "undefined") return false;
|
|
35
|
+
const ua = navigator.userAgent;
|
|
36
|
+
if (cachedAndroidChromeUa === ua) return cachedAndroidChromeResult;
|
|
37
|
+
const compute = () => {
|
|
38
|
+
if (!isAndroid()) return false;
|
|
39
|
+
if (/EdgA\/|SamsungBrowser\/|OPR\/|UCBrowser\/|MiuiBrowser\//.test(ua)) return false;
|
|
40
|
+
if (/Firefox\//.test(ua)) return false;
|
|
41
|
+
if (navigator.brave) return false;
|
|
42
|
+
return /Chrome\//.test(ua);
|
|
43
|
+
};
|
|
44
|
+
const result = compute();
|
|
45
|
+
cachedAndroidChromeUa = ua;
|
|
46
|
+
cachedAndroidChromeResult = result;
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
31
49
|
function isSafari() {
|
|
32
50
|
return typeof navigator !== "undefined" && /AppleWebKit/i.test(navigator.userAgent) && !/CriOS/i.test(navigator.userAgent) && !/Chrome/i.test(navigator.userAgent);
|
|
33
51
|
}
|
|
@@ -43,6 +61,7 @@ function isTelegram() {
|
|
|
43
61
|
}
|
|
44
62
|
export {
|
|
45
63
|
isAndroid,
|
|
64
|
+
isAndroidChrome,
|
|
46
65
|
isIOS,
|
|
47
66
|
isIOSWebview,
|
|
48
67
|
isLargeIOS,
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Ctx } from '@getpara/core-sdk';
|
|
2
2
|
export declare function getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie?: string): Promise<string>;
|
|
3
|
+
export declare function getED25519PrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie?: string): Promise<string>;
|
|
@@ -36,6 +36,39 @@ function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
|
36
36
|
}));
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
function getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
40
|
+
return __async(this, null, function* () {
|
|
41
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
42
|
+
const workId = uuid.v4();
|
|
43
|
+
let worker = null;
|
|
44
|
+
worker = yield setupWorker(
|
|
45
|
+
ctx,
|
|
46
|
+
(res) => __async(this, null, function* () {
|
|
47
|
+
resolve((res == null ? void 0 : res.privateKey) || res);
|
|
48
|
+
}),
|
|
49
|
+
(error) => {
|
|
50
|
+
reject(error);
|
|
51
|
+
},
|
|
52
|
+
workId
|
|
53
|
+
);
|
|
54
|
+
worker.postMessage({
|
|
55
|
+
env: ctx.env,
|
|
56
|
+
apiKey: ctx.apiKey,
|
|
57
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
58
|
+
params: { share, walletId, userId },
|
|
59
|
+
functionType: "ED25519_GET_PRIVATE_KEY",
|
|
60
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
61
|
+
disableWorkers: ctx.disableWorkers,
|
|
62
|
+
sessionCookie,
|
|
63
|
+
useDKLS: ctx.useDKLS,
|
|
64
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
65
|
+
wasmOverride: ctx.wasmOverride,
|
|
66
|
+
workId
|
|
67
|
+
});
|
|
68
|
+
}));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
39
71
|
export {
|
|
72
|
+
getED25519PrivateKey,
|
|
40
73
|
getPrivateKey
|
|
41
74
|
};
|
|
@@ -24,3 +24,4 @@ export declare function refresh(ctx: Ctx, share: string, walletId: string, userI
|
|
|
24
24
|
signer: string;
|
|
25
25
|
}>;
|
|
26
26
|
export declare function getPrivateKey(ctx: Ctx, share: string, walletId: string, userId: string): Promise<string>;
|
|
27
|
+
export declare function getED25519PrivateKey(ctx: Ctx, share: string, walletId: string, userId: string): Promise<string>;
|
|
@@ -357,10 +357,31 @@ function getPrivateKey(ctx, share, walletId, userId) {
|
|
|
357
357
|
}
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
|
+
function getED25519PrivateKey(ctx, share, walletId, userId) {
|
|
361
|
+
return __async(this, null, function* () {
|
|
362
|
+
const paraShare = yield ctx.client.getParaShare(userId, walletId);
|
|
363
|
+
if (!paraShare) {
|
|
364
|
+
return "";
|
|
365
|
+
}
|
|
366
|
+
try {
|
|
367
|
+
return yield new Promise(
|
|
368
|
+
(resolve, reject) => globalThis.ed25519GetPrivateKey(share, paraShare, (err, result) => {
|
|
369
|
+
if (err) {
|
|
370
|
+
reject(err);
|
|
371
|
+
}
|
|
372
|
+
resolve(result);
|
|
373
|
+
})
|
|
374
|
+
);
|
|
375
|
+
} catch (e) {
|
|
376
|
+
throw new Error(`error getting ed25519 private key for account with userId ${userId} and walletId ${walletId}`);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
360
380
|
export {
|
|
361
381
|
ed25519Keygen,
|
|
362
382
|
ed25519PreKeygen,
|
|
363
383
|
ed25519Sign,
|
|
384
|
+
getED25519PrivateKey,
|
|
364
385
|
getPrivateKey,
|
|
365
386
|
keygen,
|
|
366
387
|
preKeygen,
|
package/dist/workers/worker.js
CHANGED
|
@@ -110,6 +110,11 @@ function executeMessage(ctx, message) {
|
|
|
110
110
|
const privateKey = yield walletUtils.getPrivateKey(ctx, share, walletId, userId);
|
|
111
111
|
return { privateKey };
|
|
112
112
|
}
|
|
113
|
+
case "ED25519_GET_PRIVATE_KEY": {
|
|
114
|
+
const { share, walletId, userId } = params;
|
|
115
|
+
const privateKey = yield walletUtils.getED25519PrivateKey(ctx, share, walletId, userId);
|
|
116
|
+
return { privateKey };
|
|
117
|
+
}
|
|
113
118
|
case "ED25519_KEYGEN": {
|
|
114
119
|
const { userId, type } = params;
|
|
115
120
|
return walletUtils.ed25519Keygen(ctx, userId, void 0, void 0, type);
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/web-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/core-sdk": "2.
|
|
6
|
-
"@getpara/user-management-client": "2.
|
|
5
|
+
"@getpara/core-sdk": "2.29.0",
|
|
6
|
+
"@getpara/user-management-client": "2.29.0",
|
|
7
7
|
"base64url": "^3.0.1",
|
|
8
8
|
"buffer": "6.0.3",
|
|
9
9
|
"cbor-web": "^9.0.2",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist",
|
|
30
30
|
"package.json"
|
|
31
31
|
],
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "3fe797a65534cf466471441317763b1cef00b5b5",
|
|
33
33
|
"main": "dist/index.js",
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",
|