@getpara/web-sdk 2.26.0 → 2.28.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.
@@ -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
  }
@@ -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,
@@ -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.26.0",
3
+ "version": "2.28.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "2.26.0",
6
- "@getpara/user-management-client": "2.26.0",
5
+ "@getpara/core-sdk": "2.28.0",
6
+ "@getpara/user-management-client": "2.28.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": "02eb43f55b1c5f8bed6685940b6344551610f42a",
32
+ "gitHead": "cb74d2b02aed6a8a5373249418b315d686b83b66",
33
33
  "main": "dist/index.js",
34
34
  "scripts": {
35
35
  "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",