@getpara/server-sdk 3.5.1 → 3.6.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.
@@ -66,7 +66,7 @@ class Para extends import_core_sdk.default {
66
66
  * @param {TPregenIdentifierType} opts.pregenIdentifierType - the type of the identifier.
67
67
  * @returns {Promise<string | undefined>} A promise that rejects with an error.
68
68
  */
69
- this.claimPregenWallets = (_) => __async(this, null, function* () {
69
+ this.claimPregenWallets = (_) => __async(null, null, function* () {
70
70
  throw new Error(
71
71
  "claimPregenWallets is not available in the server SDK. This function is only supported on the client side. Please ensure you are using the client SDK to call this method."
72
72
  );
package/dist/cjs/index.js CHANGED
@@ -16,16 +16,16 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var src_exports = {};
20
- __export(src_exports, {
19
+ var index_exports = {};
20
+ __export(index_exports, {
21
21
  Para: () => import_ParaServer.Para,
22
- default: () => src_default
22
+ default: () => index_default
23
23
  });
24
- module.exports = __toCommonJS(src_exports);
25
- __reExport(src_exports, require("@getpara/core-sdk"), module.exports);
24
+ module.exports = __toCommonJS(index_exports);
25
+ __reExport(index_exports, require("@getpara/core-sdk"), module.exports);
26
26
  var import_ParaServer = require("./ParaServer.js");
27
- __reExport(src_exports, require("@getpara/viem-v2-integration/aa"), module.exports);
28
- var src_default = import_ParaServer.Para;
27
+ __reExport(index_exports, require("@getpara/viem-v2-integration/aa"), module.exports);
28
+ var index_default = import_ParaServer.Para;
29
29
  // Annotate the CommonJS export names for ESM import in node:
30
30
  0 && (module.exports = {
31
31
  Para,
@@ -91,14 +91,14 @@ function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, wallet
91
91
  });
92
92
  }
93
93
  function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
94
- return new Promise((resolve, reject) => __async(this, null, function* () {
94
+ return new Promise((resolve, reject) => __async(null, null, function* () {
95
95
  const workId = uuid.v4();
96
96
  try {
97
97
  const worker = yield (0, import_workerWrapper.setupWorker)(
98
98
  ctx,
99
- (res) => __async(this, null, function* () {
99
+ (res) => __async(null, null, function* () {
100
100
  try {
101
- yield (0, import_core_sdk.waitUntilTrue)(() => __async(this, null, function* () {
101
+ yield (0, import_core_sdk.waitUntilTrue)(() => __async(null, null, function* () {
102
102
  return isKeygenComplete(ctx, userId, res.walletId);
103
103
  }), 15e3, 1e3);
104
104
  resolve({
@@ -142,7 +142,7 @@ function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
142
142
  }));
143
143
  }
144
144
  function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
145
- return new Promise((resolve, reject) => __async(this, null, function* () {
145
+ return new Promise((resolve, reject) => __async(null, null, function* () {
146
146
  const workId = uuid.v4();
147
147
  try {
148
148
  const email = void 0;
@@ -152,10 +152,10 @@ function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey,
152
152
  }
153
153
  const worker = yield (0, import_workerWrapper.setupWorker)(
154
154
  ctx,
155
- (res) => __async(this, null, function* () {
155
+ (res) => __async(null, null, function* () {
156
156
  try {
157
157
  yield (0, import_core_sdk.waitUntilTrue)(
158
- () => __async(this, null, function* () {
158
+ () => __async(null, null, function* () {
159
159
  return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
160
160
  }),
161
161
  15e3,
@@ -201,14 +201,14 @@ function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey,
201
201
  }));
202
202
  }
203
203
  function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}, type) {
204
- return new Promise((resolve, reject) => __async(this, null, function* () {
204
+ return new Promise((resolve, reject) => __async(null, null, function* () {
205
205
  const workId = uuid.v4();
206
206
  try {
207
207
  const worker = yield (0, import_workerWrapper.setupWorker)(
208
208
  ctx,
209
- (res) => __async(this, null, function* () {
209
+ (res) => __async(null, null, function* () {
210
210
  try {
211
- yield (0, import_core_sdk.waitUntilTrue)(() => __async(this, null, function* () {
211
+ yield (0, import_core_sdk.waitUntilTrue)(() => __async(null, null, function* () {
212
212
  return isKeygenComplete(ctx, userId, res.walletId);
213
213
  }), 15e3, 1e3);
214
214
  resolve({
@@ -249,7 +249,7 @@ function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}, type) {
249
249
  }));
250
250
  }
251
251
  function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type) {
252
- return new Promise((resolve, reject) => __async(this, null, function* () {
252
+ return new Promise((resolve, reject) => __async(null, null, function* () {
253
253
  const workId = uuid.v4();
254
254
  try {
255
255
  const email = void 0;
@@ -259,10 +259,10 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
259
259
  }
260
260
  const worker = yield (0, import_workerWrapper.setupWorker)(
261
261
  ctx,
262
- (res) => __async(this, null, function* () {
262
+ (res) => __async(null, null, function* () {
263
263
  try {
264
264
  yield (0, import_core_sdk.waitUntilTrue)(
265
- () => __async(this, null, function* () {
265
+ () => __async(null, null, function* () {
266
266
  return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
267
267
  }),
268
268
  15e3,
@@ -307,12 +307,12 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
307
307
  }
308
308
  function initializeWorker(ctx) {
309
309
  return __async(this, null, function* () {
310
- return new Promise((resolve, reject) => __async(this, null, function* () {
310
+ return new Promise((resolve, reject) => __async(null, null, function* () {
311
311
  const workId = uuid.v4();
312
312
  try {
313
313
  const worker = yield (0, import_workerWrapper.setupWorker)(
314
314
  ctx,
315
- () => __async(this, null, function* () {
315
+ () => __async(null, null, function* () {
316
316
  resolve();
317
317
  }),
318
318
  (error) => {
@@ -55,12 +55,12 @@ var uuid = __toESM(require("uuid"));
55
55
  var import_workerWrapper = require("../workers/workerWrapper.js");
56
56
  function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
57
57
  return __async(this, null, function* () {
58
- return new Promise((resolve, reject) => __async(this, null, function* () {
58
+ return new Promise((resolve, reject) => __async(null, null, function* () {
59
59
  const workId = uuid.v4();
60
60
  try {
61
61
  const worker = yield (0, import_workerWrapper.setupWorker)(
62
62
  ctx,
63
- (res) => __async(this, null, function* () {
63
+ (res) => __async(null, null, function* () {
64
64
  resolve(res.privateKey);
65
65
  }),
66
66
  (error) => {
@@ -96,12 +96,12 @@ function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
96
96
  }
97
97
  function getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie) {
98
98
  return __async(this, null, function* () {
99
- return new Promise((resolve, reject) => __async(this, null, function* () {
99
+ return new Promise((resolve, reject) => __async(null, null, function* () {
100
100
  const workId = uuid.v4();
101
101
  try {
102
102
  const worker = yield (0, import_workerWrapper.setupWorker)(
103
103
  ctx,
104
- (res) => __async(this, null, function* () {
104
+ (res) => __async(null, null, function* () {
105
105
  resolve(res.privateKey);
106
106
  }),
107
107
  (error) => {
@@ -57,12 +57,12 @@ var uuid = __toESM(require("uuid"));
57
57
  var import_workerWrapper = require("../workers/workerWrapper.js");
58
58
  function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
59
59
  return __async(this, null, function* () {
60
- return new Promise((resolve, reject) => __async(this, null, function* () {
60
+ return new Promise((resolve, reject) => __async(null, null, function* () {
61
61
  const workId = uuid.v4();
62
62
  try {
63
63
  const worker = yield (0, import_workerWrapper.setupWorker)(
64
64
  ctx,
65
- (sendTransactionRes) => __async(this, null, function* () {
65
+ (sendTransactionRes) => __async(null, null, function* () {
66
66
  resolve(sendTransactionRes);
67
67
  }),
68
68
  (error) => {
@@ -98,12 +98,12 @@ function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCooki
98
98
  }
99
99
  function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
100
100
  return __async(this, null, function* () {
101
- return new Promise((resolve, reject) => __async(this, null, function* () {
101
+ return new Promise((resolve, reject) => __async(null, null, function* () {
102
102
  const workId = uuid.v4();
103
103
  try {
104
104
  const worker = yield (0, import_workerWrapper.setupWorker)(
105
105
  ctx,
106
- (sendTransactionRes) => __async(this, null, function* () {
106
+ (sendTransactionRes) => __async(null, null, function* () {
107
107
  resolve(sendTransactionRes);
108
108
  }),
109
109
  (error) => {
@@ -138,12 +138,12 @@ function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCooki
138
138
  }
139
139
  function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
140
140
  return __async(this, null, function* () {
141
- return new Promise((resolve, reject) => __async(this, null, function* () {
141
+ return new Promise((resolve, reject) => __async(null, null, function* () {
142
142
  const workId = uuid.v4();
143
143
  try {
144
144
  const worker = yield (0, import_workerWrapper.setupWorker)(
145
145
  ctx,
146
- (signMessageRes) => __async(this, null, function* () {
146
+ (signMessageRes) => __async(null, null, function* () {
147
147
  resolve(signMessageRes);
148
148
  }),
149
149
  (error) => {
@@ -178,12 +178,12 @@ function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKL
178
178
  }
179
179
  function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
180
180
  return __async(this, null, function* () {
181
- return new Promise((resolve, reject) => __async(this, null, function* () {
181
+ return new Promise((resolve, reject) => __async(null, null, function* () {
182
182
  const workId = uuid.v4();
183
183
  try {
184
184
  const worker = yield (0, import_workerWrapper.setupWorker)(
185
185
  ctx,
186
- (signMessageRes) => __async(this, null, function* () {
186
+ (signMessageRes) => __async(null, null, function* () {
187
187
  resolve(signMessageRes);
188
188
  }),
189
189
  (error) => {
@@ -104,7 +104,7 @@ function ed25519Keygen(ctx, userId, _sessionCookie, _emailProps, type = "SOLANA"
104
104
  scheme: "ED25519",
105
105
  type
106
106
  });
107
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
107
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
108
108
  try {
109
109
  const newSigner = yield new Promise(
110
110
  (resolve, reject) => global.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
@@ -131,7 +131,7 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, _sessionC
131
131
  scheme: "ED25519",
132
132
  type
133
133
  });
134
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
134
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
135
135
  try {
136
136
  const newSigner = yield new Promise(
137
137
  (resolve, reject) => global.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
@@ -151,7 +151,7 @@ function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
151
151
  return __async(this, null, function* () {
152
152
  const protocolId = uuid.v4();
153
153
  const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, base64Bytes, "ED25519", void 0, protocolId);
154
- const signRes = function() {
154
+ const signRes = (function() {
155
155
  return __async(this, null, function* () {
156
156
  try {
157
157
  const base64Sig = yield new Promise(
@@ -169,7 +169,7 @@ function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
169
169
  });
170
170
  }
171
171
  });
172
- }();
172
+ })();
173
173
  signRes.catch(() => {
174
174
  });
175
175
  const { pendingTransactionId } = yield preSignMessageRes;
@@ -193,7 +193,7 @@ function keygen(ctx, userId, type, secretKey) {
193
193
  walletId
194
194
  };
195
195
  }
196
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
196
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
197
197
  const signerConfigUser = ctx.useDKLS ? configDKLSBase(walletId, "USER", ctx.disableWebSockets) : configCGGMPBase(serverUrl, walletId, "USER");
198
198
  const createAccountFn = ctx.useDKLS ? global.dklsCreateAccount : global.createAccountV2;
199
199
  try {
@@ -237,7 +237,7 @@ function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type,
237
237
  walletId
238
238
  };
239
239
  }
240
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
240
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
241
241
  const signerConfigUser = ctx.useDKLS ? configDKLSBase(walletId, "USER", ctx.disableWebSockets) : configCGGMPBase(serverUrl, walletId, "USER");
242
242
  const createAccountFn = ctx.useDKLS ? global.dklsCreateAccount : global.createAccountV2;
243
243
  try {
@@ -271,9 +271,9 @@ function signMessage(ctx, share, walletId, userId, message) {
271
271
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
272
272
  return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
273
273
  }
274
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
274
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
275
275
  const signMessageFn = ctx.useDKLS ? global.dklsSignMessage : global.signMessage;
276
- const signMessageRes = function() {
276
+ const signMessageRes = (function() {
277
277
  return __async(this, null, function* () {
278
278
  try {
279
279
  return yield new Promise(
@@ -288,7 +288,7 @@ function signMessage(ctx, share, walletId, userId, message) {
288
288
  throw (0, import_mpcWorkerError.wrapMpcError)(`error signing for account with userId ${userId} and walletId ${walletId}`, mpcErr, { protocolId });
289
289
  }
290
290
  });
291
- }();
291
+ })();
292
292
  signMessageRes.catch(() => {
293
293
  });
294
294
  const { pendingTransactionId } = yield preSignMessageRes;
@@ -310,9 +310,9 @@ function signTransaction(ctx, share, walletId, userId, tx, chainId) {
310
310
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
311
311
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
312
312
  }
313
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
313
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
314
314
  const signTransactionFn = ctx.useDKLS ? global.dklsSendTransaction : global.sendTransaction;
315
- const signTxRes = function() {
315
+ const signTxRes = (function() {
316
316
  return __async(this, null, function* () {
317
317
  try {
318
318
  return yield new Promise(
@@ -329,7 +329,7 @@ function signTransaction(ctx, share, walletId, userId, tx, chainId) {
329
329
  });
330
330
  }
331
331
  });
332
- }();
332
+ })();
333
333
  signTxRes.catch(() => {
334
334
  });
335
335
  const {
@@ -353,9 +353,9 @@ function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
353
353
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
354
354
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
355
355
  }
356
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
356
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
357
357
  const sendTransactionFn = ctx.useDKLS ? global.dklsSendTransaction : global.sendTransaction;
358
- const sendTxRes = function() {
358
+ const sendTxRes = (function() {
359
359
  return __async(this, null, function* () {
360
360
  try {
361
361
  return yield new Promise(
@@ -374,7 +374,7 @@ function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
374
374
  );
375
375
  }
376
376
  });
377
- }();
377
+ })();
378
378
  sendTxRes.catch(() => {
379
379
  });
380
380
  const {
@@ -391,7 +391,7 @@ function refresh(ctx, share, walletId, userId) {
391
391
  const {
392
392
  data: { protocolId }
393
393
  } = yield ctx.client.refreshKeys(userId, walletId, void 0, void 0, void 0, true);
394
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
394
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
395
395
  const refreshFn = ctx.useDKLS ? global.dklsRefresh : global.refresh;
396
396
  try {
397
397
  return yield new Promise(
@@ -246,6 +246,9 @@ function handleMessage(e) {
246
246
  env,
247
247
  apiKey,
248
248
  cosmosPrefix = "cosmos",
249
+ apiBaseUrlOverride,
250
+ portalUrlOverride,
251
+ mpcNetworkUrlOverride,
249
252
  offloadMPCComputationURL,
250
253
  disableWorkers,
251
254
  sessionCookie,
@@ -256,7 +259,16 @@ function handleMessage(e) {
256
259
  const ctx = {
257
260
  env,
258
261
  apiKey,
259
- client: (0, import_core_sdk.initClient)({ env, version: import_core_sdk.paraVersion, apiKey, retrieveSessionCookie: () => sessionCookie }),
262
+ client: (0, import_core_sdk.initClient)({
263
+ env,
264
+ version: import_core_sdk.paraVersion,
265
+ apiKey,
266
+ retrieveSessionCookie: () => sessionCookie,
267
+ apiBaseUrlOverride
268
+ }),
269
+ apiBaseUrlOverride,
270
+ portalUrlOverride,
271
+ mpcNetworkUrlOverride,
260
272
  offloadMPCComputationURL,
261
273
  mpcComputationClient: offloadMPCComputationURL ? import_core_sdk.mpcComputationClient.initClient(offloadMPCComputationURL, !!disableWorkers) : void 0,
262
274
  useDKLS,
@@ -268,7 +280,7 @@ function handleMessage(e) {
268
280
  if (!wasmLoaded && (!ctx.offloadMPCComputationURL || ctx.useDKLS)) {
269
281
  yield loadWasm(ctx);
270
282
  if (global.initWasm) {
271
- const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
283
+ const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
272
284
  yield new Promise(
273
285
  (resolve, reject) => global.initWasm((err, initResult) => {
274
286
  if (err) {
@@ -1,7 +1,21 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
5
19
  var __export = (target, all) => {
6
20
  for (var name in all)
7
21
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -54,6 +68,10 @@ function removeWorkId(workId, skipClearTimeout) {
54
68
  }
55
69
  clearTimeout(timeoutId);
56
70
  }
71
+ function withLocalDevUrlOverrides(ctx, message) {
72
+ const overrides = __spreadValues(__spreadValues(__spreadValues({}, ctx.apiBaseUrlOverride ? { apiBaseUrlOverride: ctx.apiBaseUrlOverride } : {}), ctx.portalUrlOverride ? { portalUrlOverride: ctx.portalUrlOverride } : {}), ctx.mpcNetworkUrlOverride ? { mpcNetworkUrlOverride: ctx.mpcNetworkUrlOverride } : {});
73
+ return Object.keys(overrides).length > 0 ? __spreadValues(__spreadValues({}, message), overrides) : message;
74
+ }
57
75
  function resetWorker() {
58
76
  if (worker) {
59
77
  worker.terminate();
@@ -80,7 +98,7 @@ function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
80
98
  const workerFileName = isDeno ? "mpcWorkerServer-esm.js" : "mpcWorkerServer-bundle.js";
81
99
  const workerRes = yield fetch(`${(0, import_core_sdk.getPortalBaseURL)(ctx)}/static/js/${workerFileName}`);
82
100
  worker = new import_worker_threads.Worker(yield workerRes.text(), { eval: true });
83
- const onmessage = (message) => __async(this, null, function* () {
101
+ const onmessage = (message) => __async(null, null, function* () {
84
102
  const { workId: messageWorkId } = message;
85
103
  if (!resFunctionMap[messageWorkId]) {
86
104
  console.warn(`received message for unknown workId: ${messageWorkId}`);
@@ -120,7 +138,14 @@ function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
120
138
  worker = void 0;
121
139
  });
122
140
  }
123
- return worker;
141
+ return new Proxy(worker, {
142
+ get(target, prop, receiver) {
143
+ if (prop === "postMessage") {
144
+ return (message) => target.postMessage(withLocalDevUrlOverrides(ctx, message));
145
+ }
146
+ return Reflect.get(target, prop, receiver);
147
+ }
148
+ });
124
149
  });
125
150
  }
126
151
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,4 +1,4 @@
1
- import "./chunk-FTA5RKYX.js";
1
+ import "./chunk-GM7WFPGG.js";
2
2
  import ParaCore from "@getpara/core-sdk";
3
3
  import { ServerUtils } from "./ServerUtils.js";
4
4
  class Para extends ParaCore {
@@ -1,4 +1,4 @@
1
- import "./chunk-FTA5RKYX.js";
1
+ import "./chunk-GM7WFPGG.js";
2
2
  class ServerLocalStorage {
3
3
  constructor() {
4
4
  this.localStorage = {};
@@ -1,4 +1,4 @@
1
- import "./chunk-FTA5RKYX.js";
1
+ import "./chunk-GM7WFPGG.js";
2
2
  class ServerSessionStorage {
3
3
  constructor() {
4
4
  this.sessionStorage = {};
@@ -1,4 +1,4 @@
1
- import "./chunk-FTA5RKYX.js";
1
+ import "./chunk-GM7WFPGG.js";
2
2
  import http from "node:http";
3
3
  import https from "node:https";
4
4
  import { ServerLocalStorage } from "./ServerLocalStorage.js";
@@ -0,0 +1,12 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ try {
4
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5
+ } catch (e) {
6
+ throw mod = 0, e;
7
+ }
8
+ };
9
+
10
+ export {
11
+ __commonJS
12
+ };
package/dist/esm/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import "./chunk-FTA5RKYX.js";
1
+ import "./chunk-GM7WFPGG.js";
2
2
  export * from "@getpara/core-sdk";
3
3
  import { Para as ParaServer } from "./ParaServer.js";
4
- var src_default = ParaServer;
4
+ var index_default = ParaServer;
5
5
  export * from "@getpara/viem-v2-integration/aa";
6
6
  export {
7
7
  ParaServer as Para,
8
- src_default as default
8
+ index_default as default
9
9
  };
@@ -1,4 +1,4 @@
1
- import "../chunk-FTA5RKYX.js";
1
+ import "../chunk-GM7WFPGG.js";
2
2
  import * as uuid from "uuid";
3
3
  import { waitUntilTrue } from "@getpara/core-sdk";
4
4
  import { setupWorker } from "../workers/workerWrapper.js";
@@ -1,4 +1,4 @@
1
- import "../chunk-FTA5RKYX.js";
1
+ import "../chunk-GM7WFPGG.js";
2
2
  import * as uuid from "uuid";
3
3
  import { setupWorker } from "../workers/workerWrapper.js";
4
4
  async function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
@@ -1,4 +1,4 @@
1
- import "../chunk-FTA5RKYX.js";
1
+ import "../chunk-GM7WFPGG.js";
2
2
  import * as uuid from "uuid";
3
3
  import { setupWorker } from "../workers/workerWrapper.js";
4
4
  async function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __commonJS
3
- } from "../chunk-FTA5RKYX.js";
3
+ } from "../chunk-GM7WFPGG.js";
4
4
  var require_wasm_exec = __commonJS({
5
5
  "src/wasm/wasm_exec.js"(exports, module) {
6
6
  const globalThisCopy = global;
@@ -1,4 +1,4 @@
1
- import "../chunk-FTA5RKYX.js";
1
+ import "../chunk-GM7WFPGG.js";
2
2
  function toError(value) {
3
3
  return value instanceof Error ? value : new Error(String(value));
4
4
  }
@@ -1,4 +1,4 @@
1
- import "../chunk-FTA5RKYX.js";
1
+ import "../chunk-GM7WFPGG.js";
2
2
  import { getBaseMPCNetworkUrl } from "@getpara/core-sdk";
3
3
  import * as uuid from "uuid";
4
4
  import { wrapMpcError } from "./mpcWorkerError.js";
@@ -36,7 +36,7 @@ async function ed25519Keygen(ctx, userId, _sessionCookie, _emailProps, type = "S
36
36
  scheme: "ED25519",
37
37
  type
38
38
  });
39
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
39
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
40
40
  try {
41
41
  const newSigner = await new Promise(
42
42
  (resolve, reject) => global.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
@@ -61,7 +61,7 @@ async function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, _se
61
61
  scheme: "ED25519",
62
62
  type
63
63
  });
64
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
64
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
65
65
  try {
66
66
  const newSigner = await new Promise(
67
67
  (resolve, reject) => global.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
@@ -79,7 +79,7 @@ async function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, _se
79
79
  async function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
80
80
  const protocolId = uuid.v4();
81
81
  const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, base64Bytes, "ED25519", void 0, protocolId);
82
- const signRes = async function() {
82
+ const signRes = (async function() {
83
83
  try {
84
84
  const base64Sig = await new Promise(
85
85
  (resolve, reject) => global.ed25519Sign(share, protocolId, base64Bytes, (err, result) => {
@@ -95,7 +95,7 @@ async function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
95
95
  protocolId
96
96
  });
97
97
  }
98
- }();
98
+ })();
99
99
  signRes.catch(() => {
100
100
  });
101
101
  const { pendingTransactionId } = await preSignMessageRes;
@@ -117,7 +117,7 @@ async function keygen(ctx, userId, type, secretKey) {
117
117
  walletId
118
118
  };
119
119
  }
120
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
120
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
121
121
  const signerConfigUser = ctx.useDKLS ? configDKLSBase(walletId, "USER", ctx.disableWebSockets) : configCGGMPBase(serverUrl, walletId, "USER");
122
122
  const createAccountFn = ctx.useDKLS ? global.dklsCreateAccount : global.createAccountV2;
123
123
  try {
@@ -159,7 +159,7 @@ async function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType,
159
159
  walletId
160
160
  };
161
161
  }
162
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
162
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
163
163
  const signerConfigUser = ctx.useDKLS ? configDKLSBase(walletId, "USER", ctx.disableWebSockets) : configCGGMPBase(serverUrl, walletId, "USER");
164
164
  const createAccountFn = ctx.useDKLS ? global.dklsCreateAccount : global.createAccountV2;
165
165
  try {
@@ -191,9 +191,9 @@ async function signMessage(ctx, share, walletId, userId, message) {
191
191
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
192
192
  return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
193
193
  }
194
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
194
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
195
195
  const signMessageFn = ctx.useDKLS ? global.dklsSignMessage : global.signMessage;
196
- const signMessageRes = async function() {
196
+ const signMessageRes = (async function() {
197
197
  try {
198
198
  return await new Promise(
199
199
  (resolve, reject) => signMessageFn(share, serverUrl, message, protocolId, (err, result) => {
@@ -206,7 +206,7 @@ async function signMessage(ctx, share, walletId, userId, message) {
206
206
  } catch (mpcErr) {
207
207
  throw wrapMpcError(`error signing for account with userId ${userId} and walletId ${walletId}`, mpcErr, { protocolId });
208
208
  }
209
- }();
209
+ })();
210
210
  signMessageRes.catch(() => {
211
211
  });
212
212
  const { pendingTransactionId } = await preSignMessageRes;
@@ -226,9 +226,9 @@ async function signTransaction(ctx, share, walletId, userId, tx, chainId) {
226
226
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
227
227
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
228
228
  }
229
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
229
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
230
230
  const signTransactionFn = ctx.useDKLS ? global.dklsSendTransaction : global.sendTransaction;
231
- const signTxRes = async function() {
231
+ const signTxRes = (async function() {
232
232
  try {
233
233
  return await new Promise(
234
234
  (resolve, reject) => signTransactionFn(share, serverUrl, tx, chainId, protocolId, (err, result) => {
@@ -243,7 +243,7 @@ async function signTransaction(ctx, share, walletId, userId, tx, chainId) {
243
243
  protocolId
244
244
  });
245
245
  }
246
- }();
246
+ })();
247
247
  signTxRes.catch(() => {
248
248
  });
249
249
  const {
@@ -265,9 +265,9 @@ async function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
265
265
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
266
266
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
267
267
  }
268
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
268
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
269
269
  const sendTransactionFn = ctx.useDKLS ? global.dklsSendTransaction : global.sendTransaction;
270
- const sendTxRes = async function() {
270
+ const sendTxRes = (async function() {
271
271
  try {
272
272
  return await new Promise(
273
273
  (resolve, reject) => sendTransactionFn(share, serverUrl, tx, chainId, protocolId, (err, result) => {
@@ -284,7 +284,7 @@ async function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
284
284
  { protocolId }
285
285
  );
286
286
  }
287
- }();
287
+ })();
288
288
  sendTxRes.catch(() => {
289
289
  });
290
290
  const {
@@ -299,7 +299,7 @@ async function refresh(ctx, share, walletId, userId) {
299
299
  const {
300
300
  data: { protocolId }
301
301
  } = await ctx.client.refreshKeys(userId, walletId, void 0, void 0, void 0, true);
302
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
302
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
303
303
  const refreshFn = ctx.useDKLS ? global.dklsRefresh : global.refresh;
304
304
  try {
305
305
  return await new Promise(
@@ -220,6 +220,9 @@ function handleMessage(e) {
220
220
  env,
221
221
  apiKey,
222
222
  cosmosPrefix = "cosmos",
223
+ apiBaseUrlOverride,
224
+ portalUrlOverride,
225
+ mpcNetworkUrlOverride,
223
226
  offloadMPCComputationURL,
224
227
  disableWorkers,
225
228
  sessionCookie,
@@ -230,7 +233,16 @@ function handleMessage(e) {
230
233
  const ctx = {
231
234
  env,
232
235
  apiKey,
233
- client: initClient({ env, version: paraVersion, apiKey, retrieveSessionCookie: () => sessionCookie }),
236
+ client: initClient({
237
+ env,
238
+ version: paraVersion,
239
+ apiKey,
240
+ retrieveSessionCookie: () => sessionCookie,
241
+ apiBaseUrlOverride
242
+ }),
243
+ apiBaseUrlOverride,
244
+ portalUrlOverride,
245
+ mpcNetworkUrlOverride,
234
246
  offloadMPCComputationURL,
235
247
  mpcComputationClient: offloadMPCComputationURL ? mpcComputationClient.initClient(offloadMPCComputationURL, !!disableWorkers) : void 0,
236
248
  useDKLS,
@@ -242,7 +254,7 @@ function handleMessage(e) {
242
254
  if (!wasmLoaded && (!ctx.offloadMPCComputationURL || ctx.useDKLS)) {
243
255
  yield loadWasm(ctx);
244
256
  if (global.initWasm) {
245
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
257
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
246
258
  yield new Promise(
247
259
  (resolve, reject) => global.initWasm((err, initResult) => {
248
260
  if (err) {
@@ -1,4 +1,4 @@
1
- import "../chunk-FTA5RKYX.js";
1
+ import "../chunk-GM7WFPGG.js";
2
2
  import { Worker } from "worker_threads";
3
3
  import { getPortalBaseURL } from "@getpara/core-sdk";
4
4
  const CLEAR_WORKER_TIMEOUT_MS = 1e3 * 90;
@@ -12,6 +12,14 @@ function removeWorkId(workId, skipClearTimeout) {
12
12
  }
13
13
  clearTimeout(timeoutId);
14
14
  }
15
+ function withLocalDevUrlOverrides(ctx, message) {
16
+ const overrides = {
17
+ ...ctx.apiBaseUrlOverride ? { apiBaseUrlOverride: ctx.apiBaseUrlOverride } : {},
18
+ ...ctx.portalUrlOverride ? { portalUrlOverride: ctx.portalUrlOverride } : {},
19
+ ...ctx.mpcNetworkUrlOverride ? { mpcNetworkUrlOverride: ctx.mpcNetworkUrlOverride } : {}
20
+ };
21
+ return Object.keys(overrides).length > 0 ? { ...message, ...overrides } : message;
22
+ }
15
23
  function resetWorker() {
16
24
  if (worker) {
17
25
  worker.terminate();
@@ -77,7 +85,14 @@ async function setupWorker(ctx, resFunction, errorFunction, workId, errorContext
77
85
  worker = void 0;
78
86
  });
79
87
  }
80
- return worker;
88
+ return new Proxy(worker, {
89
+ get(target, prop, receiver) {
90
+ if (prop === "postMessage") {
91
+ return (message) => target.postMessage(withLocalDevUrlOverrides(ctx, message));
92
+ }
93
+ return Reflect.get(target, prop, receiver);
94
+ }
95
+ });
81
96
  }
82
97
  export {
83
98
  resetWorker,
@@ -3,6 +3,9 @@ interface Message {
3
3
  env: Environment;
4
4
  apiKey: string;
5
5
  cosmosPrefix?: string;
6
+ apiBaseUrlOverride?: string;
7
+ portalUrlOverride?: string;
8
+ mpcNetworkUrlOverride?: string;
6
9
  offloadMPCComputationURL?: string;
7
10
  disableWorkers?: boolean;
8
11
  functionType: string;
@@ -12,7 +15,7 @@ interface Message {
12
15
  disableWebSockets?: boolean;
13
16
  workId: string;
14
17
  }
15
- export declare function requestWasmWithRetries(ctx: Ctx, retries?: number): Promise<import("axios").AxiosResponse<any, any>>;
18
+ export declare function requestWasmWithRetries(ctx: Ctx, retries?: number): Promise<import("axios").AxiosResponse<any, any, {}>>;
16
19
  /**
17
20
  * Executes an operation with retry capabilities
18
21
  * @param operation The function to execute
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/server-sdk",
3
- "version": "3.5.1",
3
+ "version": "3.6.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "3.5.1",
6
- "@getpara/user-management-client": "3.5.1",
7
- "@getpara/viem-v2-integration": "3.5.1",
8
- "uuid": "^11.1.0",
5
+ "@getpara/core-sdk": "3.6.0",
6
+ "@getpara/user-management-client": "3.6.0",
7
+ "@getpara/viem-v2-integration": "3.6.0",
8
+ "uuid": "^11.1.1",
9
9
  "ws": "^8.14.2"
10
10
  },
11
11
  "devDependencies": {
@@ -16,7 +16,7 @@
16
16
  "dist",
17
17
  "package.json"
18
18
  ],
19
- "gitHead": "362fc377edf3cca5f743679498ff4908921c8468",
19
+ "gitHead": "565535ab0cf38d65f6996fc9f1ede52d133ddac0",
20
20
  "main": "dist/cjs/index.js",
21
21
  "module": "dist/esm/index.js",
22
22
  "scripts": {
@@ -1,8 +0,0 @@
1
- var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __commonJS = (cb, mod) => function __require() {
3
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
- };
5
-
6
- export {
7
- __commonJS
8
- };