@getpara/server-sdk 3.0.0-alpha.1 → 3.1.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.
@@ -56,8 +56,6 @@ class Para extends import_core_sdk.default {
56
56
  constructor(envOrApiKey, apiKeyOrOpts, opts) {
57
57
  super(envOrApiKey, apiKeyOrOpts, opts);
58
58
  /**
59
- * @deprecated Use the REST API (`POST /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen
60
- *
61
59
  * Claims a pregenerated wallet.
62
60
  *
63
61
  * NOTE: This function is only available on the client side.
@@ -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,
@@ -255,7 +256,7 @@ function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type,
255
256
  function signMessage(ctx, share, walletId, userId, message) {
256
257
  return __async(this, null, function* () {
257
258
  const protocolId = uuid.v4();
258
- const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, message, null, null, protocolId);
259
+ const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, message, null, null, protocolId, true);
259
260
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
260
261
  return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
261
262
  }
@@ -287,7 +288,12 @@ function signMessage(ctx, share, walletId, userId, message) {
287
288
  function signTransaction(ctx, share, walletId, userId, tx, chainId) {
288
289
  return __async(this, null, function* () {
289
290
  const protocolId = uuid.v4();
290
- const signTransactionRes = ctx.client.signTransaction(userId, walletId, { transaction: tx, chainId, protocolId });
291
+ const signTransactionRes = ctx.client.signTransaction(userId, walletId, {
292
+ transaction: tx,
293
+ chainId,
294
+ protocolId,
295
+ useNewOT: true
296
+ });
291
297
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
292
298
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
293
299
  }
@@ -321,7 +327,12 @@ function signTransaction(ctx, share, walletId, userId, tx, chainId) {
321
327
  function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
322
328
  return __async(this, null, function* () {
323
329
  const protocolId = uuid.v4();
324
- const sendTransactionRes = ctx.client.sendTransaction(userId, walletId, { transaction: tx, chainId, protocolId });
330
+ const sendTransactionRes = ctx.client.sendTransaction(userId, walletId, {
331
+ transaction: tx,
332
+ chainId,
333
+ protocolId,
334
+ useNewOT: true
335
+ });
325
336
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
326
337
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
327
338
  }
@@ -356,7 +367,7 @@ function refresh(ctx, share, walletId, userId) {
356
367
  return __async(this, null, function* () {
357
368
  const {
358
369
  data: { protocolId }
359
- } = yield ctx.client.refreshKeys(userId, walletId);
370
+ } = yield ctx.client.refreshKeys(userId, walletId, void 0, void 0, void 0, true);
360
371
  const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
361
372
  const refreshFn = ctx.useDKLS ? global.dklsRefresh : global.refresh;
362
373
  try {
@@ -394,11 +405,33 @@ function getPrivateKey(ctx, share, walletId, userId) {
394
405
  }
395
406
  });
396
407
  }
408
+ function getED25519PrivateKey(ctx, share, walletId, userId) {
409
+ return __async(this, null, function* () {
410
+ const paraShare = yield ctx.client.getParaShare(userId, walletId);
411
+ if (!paraShare) {
412
+ console.error("unable to retrieve Para share");
413
+ return "";
414
+ }
415
+ try {
416
+ return yield new Promise(
417
+ (resolve, reject) => global.ed25519GetPrivateKey(share, paraShare, (err, result) => {
418
+ if (err) {
419
+ reject(err);
420
+ }
421
+ resolve(result);
422
+ })
423
+ );
424
+ } catch (e) {
425
+ throw new Error(`error getting ed25519 private key for account with userId ${userId} and walletId ${walletId}`);
426
+ }
427
+ });
428
+ }
397
429
  // Annotate the CommonJS export names for ESM import in node:
398
430
  0 && (module.exports = {
399
431
  ed25519Keygen,
400
432
  ed25519PreKeygen,
401
433
  ed25519Sign,
434
+ getED25519PrivateKey,
402
435
  getPrivateKey,
403
436
  keygen,
404
437
  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);
@@ -5,8 +5,6 @@ class Para extends ParaCore {
5
5
  constructor(envOrApiKey, apiKeyOrOpts, opts) {
6
6
  super(envOrApiKey, apiKeyOrOpts, opts);
7
7
  /**
8
- * @deprecated Use the REST API (`POST /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen
9
- *
10
8
  * Claims a pregenerated wallet.
11
9
  *
12
10
  * NOTE: This function is only available on the client side.
@@ -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
  };
@@ -176,7 +176,7 @@ async function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType,
176
176
  }
177
177
  async function signMessage(ctx, share, walletId, userId, message) {
178
178
  const protocolId = uuid.v4();
179
- const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, message, null, null, protocolId);
179
+ const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, message, null, null, protocolId, true);
180
180
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
181
181
  return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
182
182
  }
@@ -204,7 +204,12 @@ async function signMessage(ctx, share, walletId, userId, message) {
204
204
  }
205
205
  async function signTransaction(ctx, share, walletId, userId, tx, chainId) {
206
206
  const protocolId = uuid.v4();
207
- const signTransactionRes = ctx.client.signTransaction(userId, walletId, { transaction: tx, chainId, protocolId });
207
+ const signTransactionRes = ctx.client.signTransaction(userId, walletId, {
208
+ transaction: tx,
209
+ chainId,
210
+ protocolId,
211
+ useNewOT: true
212
+ });
208
213
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
209
214
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
210
215
  }
@@ -234,7 +239,12 @@ async function signTransaction(ctx, share, walletId, userId, tx, chainId) {
234
239
  }
235
240
  async function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
236
241
  const protocolId = uuid.v4();
237
- const sendTransactionRes = ctx.client.sendTransaction(userId, walletId, { transaction: tx, chainId, protocolId });
242
+ const sendTransactionRes = ctx.client.sendTransaction(userId, walletId, {
243
+ transaction: tx,
244
+ chainId,
245
+ protocolId,
246
+ useNewOT: true
247
+ });
238
248
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
239
249
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
240
250
  }
@@ -265,7 +275,7 @@ async function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
265
275
  async function refresh(ctx, share, walletId, userId) {
266
276
  const {
267
277
  data: { protocolId }
268
- } = await ctx.client.refreshKeys(userId, walletId);
278
+ } = await ctx.client.refreshKeys(userId, walletId, void 0, void 0, void 0, true);
269
279
  const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
270
280
  const refreshFn = ctx.useDKLS ? global.dklsRefresh : global.refresh;
271
281
  try {
@@ -300,10 +310,30 @@ async function getPrivateKey(ctx, share, walletId, userId) {
300
310
  throw new Error(`error getting private key for account with userId ${userId} and walletId ${walletId}`);
301
311
  }
302
312
  }
313
+ async function getED25519PrivateKey(ctx, share, walletId, userId) {
314
+ const paraShare = await ctx.client.getParaShare(userId, walletId);
315
+ if (!paraShare) {
316
+ console.error("unable to retrieve Para share");
317
+ return "";
318
+ }
319
+ try {
320
+ return await new Promise(
321
+ (resolve, reject) => global.ed25519GetPrivateKey(share, paraShare, (err, result) => {
322
+ if (err) {
323
+ reject(err);
324
+ }
325
+ resolve(result);
326
+ })
327
+ );
328
+ } catch {
329
+ throw new Error(`error getting ed25519 private key for account with userId ${userId} and walletId ${walletId}`);
330
+ }
331
+ }
303
332
  export {
304
333
  ed25519Keygen,
305
334
  ed25519PreKeygen,
306
335
  ed25519Sign,
336
+ getED25519PrivateKey,
307
337
  getPrivateKey,
308
338
  keygen,
309
339
  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);
@@ -6,8 +6,6 @@ export declare class Para extends ParaCore {
6
6
  protected getPlatformUtils(): PlatformUtils;
7
7
  isPasskeySupported(): Promise<boolean>;
8
8
  /**
9
- * @deprecated Use the REST API (`POST /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen
10
- *
11
9
  * Claims a pregenerated wallet.
12
10
  *
13
11
  * NOTE: This function is only available on the client side.
@@ -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": "3.0.0-alpha.1",
3
+ "version": "3.1.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "3.0.0-alpha.1",
6
- "@getpara/user-management-client": "3.0.0-alpha.1",
7
- "@getpara/viem-v2-integration": "3.0.0-alpha.1",
5
+ "@getpara/core-sdk": "3.1.0",
6
+ "@getpara/user-management-client": "3.1.0",
7
+ "@getpara/viem-v2-integration": "3.1.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": "839d225579de67feb5be4da225d232290b2a2a04",
19
+ "gitHead": "e73f17cd7960fdfe62ff68a972b3461e47b21eb0",
20
20
  "main": "dist/cjs/index.js",
21
21
  "module": "dist/esm/index.js",
22
22
  "scripts": {