@getpara/server-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.
@@ -57,6 +57,9 @@ class ServerUtils {
57
57
  getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
58
58
  return (0, import_privateKey.getPrivateKey)(ctx, userId, walletId, share, sessionCookie);
59
59
  }
60
+ getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie) {
61
+ return (0, import_privateKey.getED25519PrivateKey)(ctx, userId, walletId, share, sessionCookie);
62
+ }
60
63
  keygen(ctx, userId, type, secretKey, sessionCookie, emailProps) {
61
64
  return (0, import_keygen.keygen)(ctx, userId, type, secretKey, sessionCookie, emailProps);
62
65
  }
@@ -47,6 +47,7 @@ var __async = (__this, __arguments, generator) => {
47
47
  };
48
48
  var privateKey_exports = {};
49
49
  __export(privateKey_exports, {
50
+ getED25519PrivateKey: () => getED25519PrivateKey,
50
51
  getPrivateKey: () => getPrivateKey
51
52
  });
52
53
  module.exports = __toCommonJS(privateKey_exports);
@@ -93,7 +94,49 @@ function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
93
94
  }));
94
95
  });
95
96
  }
97
+ function getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie) {
98
+ return __async(this, null, function* () {
99
+ return new Promise((resolve, reject) => __async(this, null, function* () {
100
+ const workId = uuid.v4();
101
+ try {
102
+ const worker = yield (0, import_workerWrapper.setupWorker)(
103
+ ctx,
104
+ (res) => __async(this, null, function* () {
105
+ resolve(res.privateKey);
106
+ }),
107
+ (error) => {
108
+ reject(error);
109
+ },
110
+ workId,
111
+ {
112
+ params: { walletId, userId },
113
+ functionType: "ED25519_GET_PRIVATE_KEY",
114
+ disableWorkers: ctx.disableWorkers,
115
+ disableWebSockets: ctx.disableWebSockets
116
+ }
117
+ );
118
+ worker.postMessage({
119
+ env: ctx.env,
120
+ apiKey: ctx.apiKey,
121
+ cosmosPrefix: ctx.cosmosPrefix,
122
+ params: { share, walletId, userId },
123
+ functionType: "ED25519_GET_PRIVATE_KEY",
124
+ offloadMPCComputationURL: ctx.offloadMPCComputationURL,
125
+ disableWorkers: ctx.disableWorkers,
126
+ sessionCookie,
127
+ useDKLS: ctx.useDKLS,
128
+ disableWebSockets: ctx.disableWebSockets,
129
+ wasmOverride: ctx.wasmOverride,
130
+ workId
131
+ });
132
+ } catch (error) {
133
+ reject(error);
134
+ }
135
+ }));
136
+ });
137
+ }
96
138
  // Annotate the CommonJS export names for ESM import in node:
97
139
  0 && (module.exports = {
140
+ getED25519PrivateKey,
98
141
  getPrivateKey
99
142
  });
@@ -50,6 +50,7 @@ __export(walletUtils_exports, {
50
50
  ed25519Keygen: () => ed25519Keygen,
51
51
  ed25519PreKeygen: () => ed25519PreKeygen,
52
52
  ed25519Sign: () => ed25519Sign,
53
+ getED25519PrivateKey: () => getED25519PrivateKey,
53
54
  getPrivateKey: () => getPrivateKey,
54
55
  keygen: () => keygen,
55
56
  preKeygen: () => preKeygen,
@@ -394,11 +395,33 @@ function getPrivateKey(ctx, share, walletId, userId) {
394
395
  }
395
396
  });
396
397
  }
398
+ function getED25519PrivateKey(ctx, share, walletId, userId) {
399
+ return __async(this, null, function* () {
400
+ const paraShare = yield ctx.client.getParaShare(userId, walletId);
401
+ if (!paraShare) {
402
+ console.error("unable to retrieve Para share");
403
+ return "";
404
+ }
405
+ try {
406
+ return yield new Promise(
407
+ (resolve, reject) => global.ed25519GetPrivateKey(share, paraShare, (err, result) => {
408
+ if (err) {
409
+ reject(err);
410
+ }
411
+ resolve(result);
412
+ })
413
+ );
414
+ } catch (e) {
415
+ throw new Error(`error getting ed25519 private key for account with userId ${userId} and walletId ${walletId}`);
416
+ }
417
+ });
418
+ }
397
419
  // Annotate the CommonJS export names for ESM import in node:
398
420
  0 && (module.exports = {
399
421
  ed25519Keygen,
400
422
  ed25519PreKeygen,
401
423
  ed25519Sign,
424
+ getED25519PrivateKey,
402
425
  getPrivateKey,
403
426
  keygen,
404
427
  preKeygen,
@@ -126,6 +126,11 @@ function executeMessage(ctx, message) {
126
126
  const privateKey = yield walletUtils.getPrivateKey(ctx, share, walletId, userId);
127
127
  return { privateKey };
128
128
  }
129
+ case "ED25519_GET_PRIVATE_KEY": {
130
+ const { share, walletId, userId } = params;
131
+ const privateKey = yield walletUtils.getED25519PrivateKey(ctx, share, walletId, userId);
132
+ return { privateKey };
133
+ }
129
134
  case "ED25519_KEYGEN": {
130
135
  const { userId, type } = params;
131
136
  return walletUtils.ed25519Keygen(ctx, userId, void 0, void 0, type);
@@ -3,7 +3,7 @@ import { ServerLocalStorage } from "./ServerLocalStorage.js";
3
3
  import { ServerSessionStorage } from "./ServerSessionStorage.js";
4
4
  import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen, initializeWorker } from "./wallet/keygen.js";
5
5
  import { signMessage, sendTransaction, signTransaction, ed25519Sign } from "./wallet/signing.js";
6
- import { getPrivateKey } from "./wallet/privateKey.js";
6
+ import { getPrivateKey, getED25519PrivateKey } from "./wallet/privateKey.js";
7
7
  class ServerUtils {
8
8
  constructor() {
9
9
  this.sdkType = "SERVER";
@@ -16,6 +16,9 @@ class ServerUtils {
16
16
  getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
17
17
  return getPrivateKey(ctx, userId, walletId, share, sessionCookie);
18
18
  }
19
+ getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie) {
20
+ return getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie);
21
+ }
19
22
  keygen(ctx, userId, type, secretKey, sessionCookie, emailProps) {
20
23
  return keygen(ctx, userId, type, secretKey, sessionCookie, emailProps);
21
24
  }
@@ -40,6 +40,46 @@ async function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
40
40
  }
41
41
  });
42
42
  }
43
+ async function getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie) {
44
+ return new Promise(async (resolve, reject) => {
45
+ const workId = uuid.v4();
46
+ try {
47
+ const worker = await setupWorker(
48
+ ctx,
49
+ async (res) => {
50
+ resolve(res.privateKey);
51
+ },
52
+ (error) => {
53
+ reject(error);
54
+ },
55
+ workId,
56
+ {
57
+ params: { walletId, userId },
58
+ functionType: "ED25519_GET_PRIVATE_KEY",
59
+ disableWorkers: ctx.disableWorkers,
60
+ disableWebSockets: ctx.disableWebSockets
61
+ }
62
+ );
63
+ worker.postMessage({
64
+ env: ctx.env,
65
+ apiKey: ctx.apiKey,
66
+ cosmosPrefix: ctx.cosmosPrefix,
67
+ params: { share, walletId, userId },
68
+ functionType: "ED25519_GET_PRIVATE_KEY",
69
+ offloadMPCComputationURL: ctx.offloadMPCComputationURL,
70
+ disableWorkers: ctx.disableWorkers,
71
+ sessionCookie,
72
+ useDKLS: ctx.useDKLS,
73
+ disableWebSockets: ctx.disableWebSockets,
74
+ wasmOverride: ctx.wasmOverride,
75
+ workId
76
+ });
77
+ } catch (error) {
78
+ reject(error);
79
+ }
80
+ });
81
+ }
43
82
  export {
83
+ getED25519PrivateKey,
44
84
  getPrivateKey
45
85
  };
@@ -300,10 +300,30 @@ async function getPrivateKey(ctx, share, walletId, userId) {
300
300
  throw new Error(`error getting private key for account with userId ${userId} and walletId ${walletId}`);
301
301
  }
302
302
  }
303
+ async function getED25519PrivateKey(ctx, share, walletId, userId) {
304
+ const paraShare = await ctx.client.getParaShare(userId, walletId);
305
+ if (!paraShare) {
306
+ console.error("unable to retrieve Para share");
307
+ return "";
308
+ }
309
+ try {
310
+ return await new Promise(
311
+ (resolve, reject) => global.ed25519GetPrivateKey(share, paraShare, (err, result) => {
312
+ if (err) {
313
+ reject(err);
314
+ }
315
+ resolve(result);
316
+ })
317
+ );
318
+ } catch {
319
+ throw new Error(`error getting ed25519 private key for account with userId ${userId} and walletId ${walletId}`);
320
+ }
321
+ }
303
322
  export {
304
323
  ed25519Keygen,
305
324
  ed25519PreKeygen,
306
325
  ed25519Sign,
326
+ getED25519PrivateKey,
307
327
  getPrivateKey,
308
328
  keygen,
309
329
  preKeygen,
@@ -98,6 +98,11 @@ function executeMessage(ctx, message) {
98
98
  const privateKey = yield walletUtils.getPrivateKey(ctx, share, walletId, userId);
99
99
  return { privateKey };
100
100
  }
101
+ case "ED25519_GET_PRIVATE_KEY": {
102
+ const { share, walletId, userId } = params;
103
+ const privateKey = yield walletUtils.getED25519PrivateKey(ctx, share, walletId, userId);
104
+ return { privateKey };
105
+ }
101
106
  case "ED25519_KEYGEN": {
102
107
  const { userId, type } = params;
103
108
  return walletUtils.ed25519Keygen(ctx, userId, void 0, void 0, type);
@@ -5,6 +5,7 @@ import { ServerSessionStorage } from './ServerSessionStorage.js';
5
5
  export declare class ServerUtils implements PlatformUtils {
6
6
  sdkType: SDKType;
7
7
  getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
8
+ getED25519PrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
8
9
  keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null, sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
9
10
  signer: string;
10
11
  walletId: string;
@@ -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>;
@@ -21,3 +21,4 @@ export declare function signTransaction(ctx: Ctx, share: string, walletId: strin
21
21
  export declare function sendTransaction(ctx: Ctx, share: string, walletId: string, userId: string, tx: string, chainId: string): Promise<SignatureRes>;
22
22
  export declare function refresh(ctx: Ctx, share: string, walletId: string, userId: string): Promise<string>;
23
23
  export declare function getPrivateKey(ctx: Ctx, share: string, walletId: string, userId: string): Promise<string>;
24
+ export declare function getED25519PrivateKey(ctx: Ctx, share: string, walletId: string, userId: string): Promise<string>;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@getpara/server-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",
7
- "@getpara/viem-v2-integration": "2.26.0",
5
+ "@getpara/core-sdk": "2.28.0",
6
+ "@getpara/user-management-client": "2.28.0",
7
+ "@getpara/viem-v2-integration": "2.28.0",
8
8
  "uuid": "^11.1.0",
9
9
  "ws": "^8.14.2"
10
10
  },
@@ -16,7 +16,7 @@
16
16
  "dist",
17
17
  "package.json"
18
18
  ],
19
- "gitHead": "02eb43f55b1c5f8bed6685940b6344551610f42a",
19
+ "gitHead": "cb74d2b02aed6a8a5373249418b315d686b83b66",
20
20
  "main": "dist/cjs/index.js",
21
21
  "module": "dist/esm/index.js",
22
22
  "scripts": {