@getpara/server-sdk 3.19.0 → 3.21.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.
@@ -86,8 +86,22 @@ class ServerUtils {
86
86
  preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey, sessionCookie) {
87
87
  return (0, import_keygen.preKeygen)(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, false, partnerId, sessionCookie);
88
88
  }
89
- signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, _cosmosSignDoc, canonicalTransaction) {
90
- return (0, import_signing.signMessage)(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction);
89
+ signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, _cosmosSignDoc, canonicalTransaction, approvalCaseId, canonicalMessage) {
90
+ if (canonicalMessage) {
91
+ return (0, import_signing.signMessage)(
92
+ ctx,
93
+ userId,
94
+ walletId,
95
+ share,
96
+ message,
97
+ sessionCookie,
98
+ isDKLS,
99
+ canonicalTransaction,
100
+ approvalCaseId,
101
+ canonicalMessage
102
+ );
103
+ }
104
+ return (0, import_signing.signMessage)(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction, approvalCaseId);
91
105
  }
92
106
  signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS) {
93
107
  return (0, import_signing.signTransaction)(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS);
@@ -104,8 +118,21 @@ class ServerUtils {
104
118
  ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type) {
105
119
  return (0, import_keygen.ed25519PreKeygen)(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type);
106
120
  }
107
- ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction) {
108
- return (0, import_signing.ed25519Sign)(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction);
121
+ ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction, approvalCaseId, canonicalMessage) {
122
+ if (canonicalMessage) {
123
+ return (0, import_signing.ed25519Sign)(
124
+ ctx,
125
+ userId,
126
+ walletId,
127
+ share,
128
+ base64Bytes,
129
+ sessionCookie,
130
+ canonicalTransaction,
131
+ approvalCaseId,
132
+ canonicalMessage
133
+ );
134
+ }
135
+ return (0, import_signing.ed25519Sign)(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction, approvalCaseId);
109
136
  }
110
137
  openPopup(_popupUrl) {
111
138
  return __async(this, null, function* () {
@@ -2,8 +2,22 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
7
21
  var __export = (target, all) => {
8
22
  for (var name in all)
9
23
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -136,7 +150,7 @@ function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCooki
136
150
  }));
137
151
  });
138
152
  }
139
- function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction) {
153
+ function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction, approvalCaseId, canonicalMessage) {
140
154
  return __async(this, null, function* () {
141
155
  return new Promise((resolve, reject) => __async(null, null, function* () {
142
156
  const workId = uuid.v4();
@@ -160,7 +174,13 @@ function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKL
160
174
  worker.postMessage({
161
175
  env: ctx.env,
162
176
  apiKey: ctx.apiKey,
163
- params: { share, walletId, userId, message, canonicalTransaction },
177
+ params: __spreadValues(__spreadValues({
178
+ share,
179
+ walletId,
180
+ userId,
181
+ message,
182
+ canonicalTransaction
183
+ }, approvalCaseId ? { approvalCaseId } : {}), canonicalMessage ? { canonicalMessage } : {}),
164
184
  functionType: "SIGN_MESSAGE",
165
185
  offloadMPCComputationURL: ctx.offloadMPCComputationURL,
166
186
  disableWorkers: ctx.disableWorkers,
@@ -176,7 +196,7 @@ function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKL
176
196
  }));
177
197
  });
178
198
  }
179
- function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction) {
199
+ function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction, approvalCaseId, canonicalMessage) {
180
200
  return __async(this, null, function* () {
181
201
  return new Promise((resolve, reject) => __async(null, null, function* () {
182
202
  const workId = uuid.v4();
@@ -200,7 +220,13 @@ function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, c
200
220
  worker.postMessage({
201
221
  env: ctx.env,
202
222
  apiKey: ctx.apiKey,
203
- params: { share, walletId, userId, base64Bytes, canonicalTransaction },
223
+ params: __spreadValues(__spreadValues({
224
+ share,
225
+ walletId,
226
+ userId,
227
+ base64Bytes,
228
+ canonicalTransaction
229
+ }, approvalCaseId ? { approvalCaseId } : {}), canonicalMessage ? { canonicalMessage } : {}),
204
230
  functionType: "ED25519_SIGN",
205
231
  offloadMPCComputationURL: ctx.offloadMPCComputationURL,
206
232
  disableWorkers: ctx.disableWorkers,
@@ -2,8 +2,22 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
7
21
  var __export = (target, all) => {
8
22
  for (var name in all)
9
23
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -159,11 +173,32 @@ function withMPCNetworkHost(ctx, share) {
159
173
  return share;
160
174
  }
161
175
  }
162
- function ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction) {
176
+ function ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction, approvalCaseId, canonicalMessage) {
163
177
  return __async(this, null, function* () {
164
178
  const protocolId = uuid.v4();
165
179
  const hostedShare = withMPCNetworkHost(ctx, share);
166
- const preSignMessageRes = ctx.client.preSignMessage(
180
+ const preSignMessageRes = canonicalMessage ? ctx.client.preSignMessage(
181
+ userId,
182
+ walletId,
183
+ base64Bytes,
184
+ "ED25519",
185
+ void 0,
186
+ protocolId,
187
+ void 0,
188
+ canonicalTransaction,
189
+ approvalCaseId,
190
+ canonicalMessage
191
+ ) : approvalCaseId ? ctx.client.preSignMessage(
192
+ userId,
193
+ walletId,
194
+ base64Bytes,
195
+ "ED25519",
196
+ void 0,
197
+ protocolId,
198
+ void 0,
199
+ canonicalTransaction,
200
+ approvalCaseId
201
+ ) : ctx.client.preSignMessage(
167
202
  userId,
168
203
  walletId,
169
204
  base64Bytes,
@@ -194,9 +229,9 @@ function ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransac
194
229
  })();
195
230
  signRes.catch(() => {
196
231
  });
197
- const { pendingTransactionId } = yield preSignMessageRes;
232
+ const { pendingTransactionId, approvalCaseId: pendingApprovalCaseId } = yield preSignMessageRes;
198
233
  if (pendingTransactionId) {
199
- return { pendingTransactionId };
234
+ return __spreadValues({ pendingTransactionId }, pendingApprovalCaseId ? { approvalCaseId: pendingApprovalCaseId } : {});
200
235
  }
201
236
  return yield signRes;
202
237
  });
@@ -286,10 +321,10 @@ function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type,
286
321
  }
287
322
  });
288
323
  }
289
- function signMessage(ctx, share, walletId, userId, message, canonicalTransaction) {
324
+ function signMessage(ctx, share, walletId, userId, message, canonicalTransaction, approvalCaseId, canonicalMessage) {
290
325
  return __async(this, null, function* () {
291
326
  const protocolId = uuid.v4();
292
- const preSignMessageRes = ctx.client.preSignMessage(
327
+ const preSignMessageRes = canonicalMessage ? ctx.client.preSignMessage(
293
328
  userId,
294
329
  walletId,
295
330
  message,
@@ -297,8 +332,20 @@ function signMessage(ctx, share, walletId, userId, message, canonicalTransaction
297
332
  null,
298
333
  protocolId,
299
334
  true,
300
- canonicalTransaction
301
- );
335
+ canonicalTransaction,
336
+ approvalCaseId,
337
+ canonicalMessage
338
+ ) : approvalCaseId ? ctx.client.preSignMessage(
339
+ userId,
340
+ walletId,
341
+ message,
342
+ null,
343
+ null,
344
+ protocolId,
345
+ true,
346
+ canonicalTransaction,
347
+ approvalCaseId
348
+ ) : ctx.client.preSignMessage(userId, walletId, message, null, null, protocolId, true, canonicalTransaction);
302
349
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
303
350
  return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
304
351
  }
@@ -322,9 +369,9 @@ function signMessage(ctx, share, walletId, userId, message, canonicalTransaction
322
369
  })();
323
370
  signMessageRes.catch(() => {
324
371
  });
325
- const { pendingTransactionId } = yield preSignMessageRes;
372
+ const { pendingTransactionId, approvalCaseId: pendingApprovalCaseId } = yield preSignMessageRes;
326
373
  if (pendingTransactionId) {
327
- return { pendingTransactionId };
374
+ return __spreadValues({ pendingTransactionId }, pendingApprovalCaseId ? { approvalCaseId: pendingApprovalCaseId } : {});
328
375
  }
329
376
  return yield signMessageRes;
330
377
  });
@@ -364,10 +411,10 @@ function signTransaction(ctx, share, walletId, userId, tx, chainId) {
364
411
  signTxRes.catch(() => {
365
412
  });
366
413
  const {
367
- data: { pendingTransactionId }
414
+ data: { pendingTransactionId, approvalCaseId: pendingApprovalCaseId }
368
415
  } = yield signTransactionRes;
369
416
  if (pendingTransactionId) {
370
- return { pendingTransactionId };
417
+ return __spreadValues({ pendingTransactionId }, pendingApprovalCaseId ? { approvalCaseId: pendingApprovalCaseId } : {});
371
418
  }
372
419
  return yield signTxRes;
373
420
  });
@@ -409,10 +456,10 @@ function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
409
456
  sendTxRes.catch(() => {
410
457
  });
411
458
  const {
412
- data: { pendingTransactionId }
459
+ data: { pendingTransactionId, approvalCaseId: pendingApprovalCaseId }
413
460
  } = yield sendTransactionRes;
414
461
  if (pendingTransactionId) {
415
- return { pendingTransactionId };
462
+ return __spreadValues({ pendingTransactionId }, pendingApprovalCaseId ? { approvalCaseId: pendingApprovalCaseId } : {});
416
463
  }
417
464
  return yield sendTxRes;
418
465
  });
@@ -137,8 +137,22 @@ function executeMessage(ctx, message) {
137
137
  return withRetry(() => walletUtils.sendTransaction(ctx, share, walletId, userId, tx, chainId));
138
138
  }
139
139
  case "SIGN_MESSAGE": {
140
- const { share, walletId, userId, message: message2, canonicalTransaction } = params;
141
- return withRetry(() => walletUtils.signMessage(ctx, share, walletId, userId, message2, canonicalTransaction));
140
+ const { share, walletId, userId, message: message2, canonicalTransaction, approvalCaseId, canonicalMessage } = params;
141
+ return withRetry(() => {
142
+ if (canonicalMessage) {
143
+ return walletUtils.signMessage(
144
+ ctx,
145
+ share,
146
+ walletId,
147
+ userId,
148
+ message2,
149
+ canonicalTransaction,
150
+ approvalCaseId,
151
+ canonicalMessage
152
+ );
153
+ }
154
+ return walletUtils.signMessage(ctx, share, walletId, userId, message2, canonicalTransaction, approvalCaseId);
155
+ });
142
156
  }
143
157
  case "REFRESH": {
144
158
  const { share, walletId, userId } = params;
@@ -170,8 +184,20 @@ function executeMessage(ctx, message) {
170
184
  return walletUtils.ed25519Keygen(ctx, userId, void 0, void 0, type);
171
185
  }
172
186
  case "ED25519_SIGN": {
173
- const { share, walletId, userId, base64Bytes, canonicalTransaction } = params;
174
- return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction);
187
+ const { share, walletId, userId, base64Bytes, canonicalTransaction, approvalCaseId, canonicalMessage } = params;
188
+ if (canonicalMessage) {
189
+ return walletUtils.ed25519Sign(
190
+ ctx,
191
+ share,
192
+ userId,
193
+ walletId,
194
+ base64Bytes,
195
+ canonicalTransaction,
196
+ approvalCaseId,
197
+ canonicalMessage
198
+ );
199
+ }
200
+ return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction, approvalCaseId);
175
201
  }
176
202
  case "ED25519_PREKEYGEN": {
177
203
  const { email } = params;
@@ -35,8 +35,22 @@ class ServerUtils {
35
35
  preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey, sessionCookie) {
36
36
  return preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, false, partnerId, sessionCookie);
37
37
  }
38
- signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, _cosmosSignDoc, canonicalTransaction) {
39
- return signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction);
38
+ signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, _cosmosSignDoc, canonicalTransaction, approvalCaseId, canonicalMessage) {
39
+ if (canonicalMessage) {
40
+ return signMessage(
41
+ ctx,
42
+ userId,
43
+ walletId,
44
+ share,
45
+ message,
46
+ sessionCookie,
47
+ isDKLS,
48
+ canonicalTransaction,
49
+ approvalCaseId,
50
+ canonicalMessage
51
+ );
52
+ }
53
+ return signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction, approvalCaseId);
40
54
  }
41
55
  signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS) {
42
56
  return signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS);
@@ -53,8 +67,21 @@ class ServerUtils {
53
67
  ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type) {
54
68
  return ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type);
55
69
  }
56
- ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction) {
57
- return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction);
70
+ ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction, approvalCaseId, canonicalMessage) {
71
+ if (canonicalMessage) {
72
+ return ed25519Sign(
73
+ ctx,
74
+ userId,
75
+ walletId,
76
+ share,
77
+ base64Bytes,
78
+ sessionCookie,
79
+ canonicalTransaction,
80
+ approvalCaseId,
81
+ canonicalMessage
82
+ );
83
+ }
84
+ return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction, approvalCaseId);
58
85
  }
59
86
  async openPopup(_popupUrl) {
60
87
  throw new Error("OpenPopup is not implemented in the ServerUtils class.");
@@ -78,7 +78,7 @@ async function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessio
78
78
  }
79
79
  });
80
80
  }
81
- async function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction) {
81
+ async function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction, approvalCaseId, canonicalMessage) {
82
82
  return new Promise(async (resolve, reject) => {
83
83
  const workId = uuid.v4();
84
84
  try {
@@ -101,7 +101,15 @@ async function signMessage(ctx, userId, walletId, share, message, sessionCookie,
101
101
  worker.postMessage({
102
102
  env: ctx.env,
103
103
  apiKey: ctx.apiKey,
104
- params: { share, walletId, userId, message, canonicalTransaction },
104
+ params: {
105
+ share,
106
+ walletId,
107
+ userId,
108
+ message,
109
+ canonicalTransaction,
110
+ ...approvalCaseId ? { approvalCaseId } : {},
111
+ ...canonicalMessage ? { canonicalMessage } : {}
112
+ },
105
113
  functionType: "SIGN_MESSAGE",
106
114
  offloadMPCComputationURL: ctx.offloadMPCComputationURL,
107
115
  disableWorkers: ctx.disableWorkers,
@@ -116,7 +124,7 @@ async function signMessage(ctx, userId, walletId, share, message, sessionCookie,
116
124
  }
117
125
  });
118
126
  }
119
- async function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction) {
127
+ async function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction, approvalCaseId, canonicalMessage) {
120
128
  return new Promise(async (resolve, reject) => {
121
129
  const workId = uuid.v4();
122
130
  try {
@@ -139,7 +147,15 @@ async function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCoo
139
147
  worker.postMessage({
140
148
  env: ctx.env,
141
149
  apiKey: ctx.apiKey,
142
- params: { share, walletId, userId, base64Bytes, canonicalTransaction },
150
+ params: {
151
+ share,
152
+ walletId,
153
+ userId,
154
+ base64Bytes,
155
+ canonicalTransaction,
156
+ ...approvalCaseId ? { approvalCaseId } : {},
157
+ ...canonicalMessage ? { canonicalMessage } : {}
158
+ },
143
159
  functionType: "ED25519_SIGN",
144
160
  offloadMPCComputationURL: ctx.offloadMPCComputationURL,
145
161
  disableWorkers: ctx.disableWorkers,
@@ -90,10 +90,31 @@ function withMPCNetworkHost(ctx, share) {
90
90
  return share;
91
91
  }
92
92
  }
93
- async function ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction) {
93
+ async function ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction, approvalCaseId, canonicalMessage) {
94
94
  const protocolId = uuid.v4();
95
95
  const hostedShare = withMPCNetworkHost(ctx, share);
96
- const preSignMessageRes = ctx.client.preSignMessage(
96
+ const preSignMessageRes = canonicalMessage ? ctx.client.preSignMessage(
97
+ userId,
98
+ walletId,
99
+ base64Bytes,
100
+ "ED25519",
101
+ void 0,
102
+ protocolId,
103
+ void 0,
104
+ canonicalTransaction,
105
+ approvalCaseId,
106
+ canonicalMessage
107
+ ) : approvalCaseId ? ctx.client.preSignMessage(
108
+ userId,
109
+ walletId,
110
+ base64Bytes,
111
+ "ED25519",
112
+ void 0,
113
+ protocolId,
114
+ void 0,
115
+ canonicalTransaction,
116
+ approvalCaseId
117
+ ) : ctx.client.preSignMessage(
97
118
  userId,
98
119
  walletId,
99
120
  base64Bytes,
@@ -122,9 +143,9 @@ async function ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalT
122
143
  })();
123
144
  signRes.catch(() => {
124
145
  });
125
- const { pendingTransactionId } = await preSignMessageRes;
146
+ const { pendingTransactionId, approvalCaseId: pendingApprovalCaseId } = await preSignMessageRes;
126
147
  if (pendingTransactionId) {
127
- return { pendingTransactionId };
148
+ return { pendingTransactionId, ...pendingApprovalCaseId ? { approvalCaseId: pendingApprovalCaseId } : {} };
128
149
  }
129
150
  return await signRes;
130
151
  }
@@ -209,9 +230,9 @@ async function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType,
209
230
  throw wrapMpcError(`error creating account of type ${type} with walletId ${walletId}`, mpcErr, { walletId, protocolId });
210
231
  }
211
232
  }
212
- async function signMessage(ctx, share, walletId, userId, message, canonicalTransaction) {
233
+ async function signMessage(ctx, share, walletId, userId, message, canonicalTransaction, approvalCaseId, canonicalMessage) {
213
234
  const protocolId = uuid.v4();
214
- const preSignMessageRes = ctx.client.preSignMessage(
235
+ const preSignMessageRes = canonicalMessage ? ctx.client.preSignMessage(
215
236
  userId,
216
237
  walletId,
217
238
  message,
@@ -219,8 +240,20 @@ async function signMessage(ctx, share, walletId, userId, message, canonicalTrans
219
240
  null,
220
241
  protocolId,
221
242
  true,
222
- canonicalTransaction
223
- );
243
+ canonicalTransaction,
244
+ approvalCaseId,
245
+ canonicalMessage
246
+ ) : approvalCaseId ? ctx.client.preSignMessage(
247
+ userId,
248
+ walletId,
249
+ message,
250
+ null,
251
+ null,
252
+ protocolId,
253
+ true,
254
+ canonicalTransaction,
255
+ approvalCaseId
256
+ ) : ctx.client.preSignMessage(userId, walletId, message, null, null, protocolId, true, canonicalTransaction);
224
257
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
225
258
  return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
226
259
  }
@@ -242,9 +275,9 @@ async function signMessage(ctx, share, walletId, userId, message, canonicalTrans
242
275
  })();
243
276
  signMessageRes.catch(() => {
244
277
  });
245
- const { pendingTransactionId } = await preSignMessageRes;
278
+ const { pendingTransactionId, approvalCaseId: pendingApprovalCaseId } = await preSignMessageRes;
246
279
  if (pendingTransactionId) {
247
- return { pendingTransactionId };
280
+ return { pendingTransactionId, ...pendingApprovalCaseId ? { approvalCaseId: pendingApprovalCaseId } : {} };
248
281
  }
249
282
  return await signMessageRes;
250
283
  }
@@ -280,10 +313,10 @@ async function signTransaction(ctx, share, walletId, userId, tx, chainId) {
280
313
  signTxRes.catch(() => {
281
314
  });
282
315
  const {
283
- data: { pendingTransactionId }
316
+ data: { pendingTransactionId, approvalCaseId: pendingApprovalCaseId }
284
317
  } = await signTransactionRes;
285
318
  if (pendingTransactionId) {
286
- return { pendingTransactionId };
319
+ return { pendingTransactionId, ...pendingApprovalCaseId ? { approvalCaseId: pendingApprovalCaseId } : {} };
287
320
  }
288
321
  return await signTxRes;
289
322
  }
@@ -321,10 +354,10 @@ async function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
321
354
  sendTxRes.catch(() => {
322
355
  });
323
356
  const {
324
- data: { pendingTransactionId }
357
+ data: { pendingTransactionId, approvalCaseId: pendingApprovalCaseId }
325
358
  } = await sendTransactionRes;
326
359
  if (pendingTransactionId) {
327
- return { pendingTransactionId };
360
+ return { pendingTransactionId, ...pendingApprovalCaseId ? { approvalCaseId: pendingApprovalCaseId } : {} };
328
361
  }
329
362
  return await sendTxRes;
330
363
  }
@@ -111,8 +111,22 @@ function executeMessage(ctx, message) {
111
111
  return withRetry(() => walletUtils.sendTransaction(ctx, share, walletId, userId, tx, chainId));
112
112
  }
113
113
  case "SIGN_MESSAGE": {
114
- const { share, walletId, userId, message: message2, canonicalTransaction } = params;
115
- return withRetry(() => walletUtils.signMessage(ctx, share, walletId, userId, message2, canonicalTransaction));
114
+ const { share, walletId, userId, message: message2, canonicalTransaction, approvalCaseId, canonicalMessage } = params;
115
+ return withRetry(() => {
116
+ if (canonicalMessage) {
117
+ return walletUtils.signMessage(
118
+ ctx,
119
+ share,
120
+ walletId,
121
+ userId,
122
+ message2,
123
+ canonicalTransaction,
124
+ approvalCaseId,
125
+ canonicalMessage
126
+ );
127
+ }
128
+ return walletUtils.signMessage(ctx, share, walletId, userId, message2, canonicalTransaction, approvalCaseId);
129
+ });
116
130
  }
117
131
  case "REFRESH": {
118
132
  const { share, walletId, userId } = params;
@@ -144,8 +158,20 @@ function executeMessage(ctx, message) {
144
158
  return walletUtils.ed25519Keygen(ctx, userId, void 0, void 0, type);
145
159
  }
146
160
  case "ED25519_SIGN": {
147
- const { share, walletId, userId, base64Bytes, canonicalTransaction } = params;
148
- return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction);
161
+ const { share, walletId, userId, base64Bytes, canonicalTransaction, approvalCaseId, canonicalMessage } = params;
162
+ if (canonicalMessage) {
163
+ return walletUtils.ed25519Sign(
164
+ ctx,
165
+ share,
166
+ userId,
167
+ walletId,
168
+ base64Bytes,
169
+ canonicalTransaction,
170
+ approvalCaseId,
171
+ canonicalMessage
172
+ );
173
+ }
174
+ return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction, approvalCaseId);
149
175
  }
150
176
  case "ED25519_PREKEYGEN": {
151
177
  const { email } = params;
@@ -1,6 +1,6 @@
1
1
  import http from 'node:http';
2
2
  import https from 'node:https';
3
- import type { Ctx, SignatureRes, PlatformUtils, TPregenIdentifierType, TWalletType, CanonicalTransactionContext } from '@getpara/core-sdk';
3
+ import type { Ctx, SignatureRes, PlatformUtils, TPregenIdentifierType, TWalletType, CanonicalMessageContext, CanonicalTransactionContext } from '@getpara/core-sdk';
4
4
  import { BackupKitEmailProps, SDKType } from '@getpara/user-management-client';
5
5
  import { ServerLocalStorage } from './ServerLocalStorage.js';
6
6
  import { ServerSessionStorage } from './ServerSessionStorage.js';
@@ -24,7 +24,7 @@ export declare class ServerUtils implements PlatformUtils {
24
24
  signer: string;
25
25
  walletId: string;
26
26
  }>;
27
- signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie: string, isDKLS?: boolean, _cosmosSignDoc?: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
27
+ signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie: string, isDKLS?: boolean, _cosmosSignDoc?: string, canonicalTransaction?: CanonicalTransactionContext, approvalCaseId?: string, canonicalMessage?: CanonicalMessageContext): Promise<SignatureRes>;
28
28
  signTransaction(ctx: Ctx, userId: string, walletId: string, share: string, message: string, chainId: string, sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
29
29
  sendTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
30
30
  signHash(_address: string, _hash: string): Promise<{
@@ -40,7 +40,7 @@ export declare class ServerUtils implements PlatformUtils {
40
40
  signer: string;
41
41
  walletId: string;
42
42
  }>;
43
- ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
43
+ ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie: string, canonicalTransaction?: CanonicalTransactionContext, approvalCaseId?: string, canonicalMessage?: CanonicalMessageContext): Promise<SignatureRes>;
44
44
  localStorage: ServerLocalStorage;
45
45
  sessionStorage: ServerSessionStorage;
46
46
  secureStorage: any;
@@ -0,0 +1,2 @@
1
+ export * from './index.js';
2
+ export { default } from './index.js';
@@ -1,5 +1,5 @@
1
- import type { CanonicalTransactionContext, Ctx, SignatureRes } from '@getpara/core-sdk';
1
+ import type { CanonicalMessageContext, CanonicalTransactionContext, Ctx, SignatureRes } from '@getpara/core-sdk';
2
2
  export declare function signTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie?: string, isDKLS?: boolean): Promise<SignatureRes>;
3
3
  export declare function sendTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie?: string, isDKLS?: boolean): Promise<SignatureRes>;
4
- export declare function signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie?: string, isDKLS?: boolean, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
5
- export declare function ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie?: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
4
+ export declare function signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie?: string, isDKLS?: boolean, canonicalTransaction?: CanonicalTransactionContext, approvalCaseId?: string, canonicalMessage?: CanonicalMessageContext): Promise<SignatureRes>;
5
+ export declare function ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie?: string, canonicalTransaction?: CanonicalTransactionContext, approvalCaseId?: string, canonicalMessage?: CanonicalMessageContext): Promise<SignatureRes>;
@@ -1,4 +1,4 @@
1
- import { Ctx, TPregenIdentifierType, SignatureRes, TWalletType, type CanonicalTransactionContext } from '@getpara/core-sdk';
1
+ import { Ctx, TPregenIdentifierType, SignatureRes, TWalletType, type CanonicalMessageContext, type CanonicalTransactionContext } from '@getpara/core-sdk';
2
2
  export declare function ed25519Keygen(ctx: Ctx, userId: string, _sessionCookie?: string, _emailProps?: unknown, type?: TWalletType): Promise<{
3
3
  signer: string;
4
4
  walletId: string;
@@ -7,7 +7,7 @@ export declare function ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pre
7
7
  signer: string;
8
8
  walletId: string;
9
9
  }>;
10
- export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
10
+ export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string, canonicalTransaction?: CanonicalTransactionContext, approvalCaseId?: string, canonicalMessage?: CanonicalMessageContext): Promise<SignatureRes>;
11
11
  export declare function keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null): Promise<{
12
12
  signer: string;
13
13
  walletId: string;
@@ -16,7 +16,7 @@ export declare function preKeygen(ctx: Ctx, partnerId: string, pregenIdentifier:
16
16
  signer: string;
17
17
  walletId: string;
18
18
  }>;
19
- export declare function signMessage(ctx: Ctx, share: string, walletId: string, userId: string, message: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
19
+ export declare function signMessage(ctx: Ctx, share: string, walletId: string, userId: string, message: string, canonicalTransaction?: CanonicalTransactionContext, approvalCaseId?: string, canonicalMessage?: CanonicalMessageContext): Promise<SignatureRes>;
20
20
  export declare function signTransaction(ctx: Ctx, share: string, walletId: string, userId: string, tx: string, chainId: string): Promise<SignatureRes>;
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>;
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/server-sdk",
3
- "version": "3.19.0",
3
+ "version": "3.21.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "3.19.0",
6
- "@getpara/user-management-client": "3.19.0",
7
- "@getpara/viem-v2-integration": "3.19.0",
5
+ "@getpara/core-sdk": "3.21.0",
6
+ "@getpara/user-management-client": "3.21.0",
7
+ "@getpara/viem-v2-integration": "3.21.0",
8
+ "axios": "^1.8.4",
8
9
  "uuid": "^11.1.1",
10
+ "viem": "^2.39.0",
9
11
  "ws": "^8.21.0"
10
12
  },
11
13
  "devDependencies": {
@@ -16,20 +18,37 @@
16
18
  "dist",
17
19
  "package.json"
18
20
  ],
19
- "gitHead": "6bc9e2483d62220b6c6920560358c80b188c2c31",
21
+ "gitHead": "e1ca81fb06f6337aaa7cc1860584b7ba5d1d9ca8",
20
22
  "main": "dist/cjs/index.js",
21
23
  "module": "dist/esm/index.js",
22
24
  "scripts": {
23
25
  "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
24
26
  "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
25
27
  "build:esm": "rm -rf dist/esm && tsc --module es2020 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":[\"wasm_exec.js\"]}' > dist/esm/package.json",
26
- "build:types": "rm -rf dist/types && tsc --module es2020 --declarationDir dist/types --emitDeclarationOnly --declaration",
28
+ "build:types": "tsc --emitDeclarationOnly && cp scripts/index.d.mts dist/types/index.d.mts",
27
29
  "old-build": "yarn build:cjs && yarn build:esm && yarn build:types",
28
- "test": "vitest run --coverage"
30
+ "test": "vitest run --coverage",
31
+ "typecheck": "tsc --noEmit"
29
32
  },
30
33
  "sideEffects": [
31
34
  "wasm_exec.js"
32
35
  ],
33
36
  "types": "dist/types/index.d.ts",
34
- "typings": "dist/types/index.d.ts"
37
+ "typings": "dist/types/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "import": {
41
+ "types": "./dist/types/index.d.mts",
42
+ "default": "./dist/esm/index.js"
43
+ },
44
+ "require": {
45
+ "types": "./dist/types/index.d.ts",
46
+ "default": "./dist/cjs/index.js"
47
+ }
48
+ },
49
+ "./dist/cjs/workers/worker": {
50
+ "require": "./dist/cjs/workers/worker.js",
51
+ "default": "./dist/cjs/workers/worker.js"
52
+ }
53
+ }
35
54
  }