@getpara/web-sdk 3.5.1 → 3.7.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.
package/dist/index.js CHANGED
@@ -10,13 +10,13 @@ import { createCredential, generateSignature, parseCredentialCreationRes } from
10
10
  import { truncateEthAddress, isPasskeySupported, offRampSend, getChainLogoUrl, getCurrencyLogoUrl } from "./utils/index.js";
11
11
  export * from "./utils/isMobile.js";
12
12
  export * from "./types/index.js";
13
- var src_default = ParaWeb;
13
+ var index_default = ParaWeb;
14
14
  export {
15
15
  Environment,
16
16
  ParaCore,
17
17
  ParaWeb,
18
18
  createCredential,
19
- src_default as default,
19
+ index_default as default,
20
20
  generateSignature,
21
21
  getChainLogoUrl,
22
22
  getCurrencyLogoUrl,
@@ -3,7 +3,7 @@ import {
3
3
  __async
4
4
  } from "../chunk-YJOFEY2L.js";
5
5
  import { UAParser } from "ua-parser-js";
6
- const isPasskeySupported = (userAgent) => __async(void 0, null, function* () {
6
+ const isPasskeySupported = (userAgent) => __async(null, null, function* () {
7
7
  var _a, _b, _c;
8
8
  const directPasskeyCheck = yield (_b = (_a = window == null ? void 0 : window.PublicKeyCredential) == null ? void 0 : _a.isUserVerifyingPlatformAuthenticatorAvailable) == null ? void 0 : _b.call(_a);
9
9
  if (directPasskeyCheck === true || directPasskeyCheck === false) {
@@ -17,7 +17,7 @@ function captureTraceCarrier() {
17
17
  }
18
18
  function bindCallbackToActiveContext(fn) {
19
19
  const captured = context.active();
20
- return (...args) => context.with(captured, () => fn(...args));
20
+ return ((...args) => context.with(captured, () => fn(...args)));
21
21
  }
22
22
  function isKeygenComplete(ctx, userId, walletId) {
23
23
  return __async(this, null, function* () {
@@ -40,15 +40,15 @@ function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, wallet
40
40
  });
41
41
  }
42
42
  function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCookie, emailProps = {}) {
43
- return new Promise((resolve, reject) => __async(this, null, function* () {
43
+ return new Promise((resolve, reject) => __async(null, null, function* () {
44
44
  const workId = uuid.v4();
45
45
  let worker = null;
46
46
  worker = yield setupWorker(
47
47
  ctx,
48
- bindCallbackToActiveContext((res) => __async(this, null, function* () {
48
+ bindCallbackToActiveContext((res) => __async(null, null, function* () {
49
49
  yield wrapWithSpan(
50
50
  "mpc.keygen.poll_for_address",
51
- () => waitUntilTrue(() => __async(this, null, function* () {
51
+ () => waitUntilTrue(() => __async(null, null, function* () {
52
52
  return isKeygenComplete(ctx, userId, res.walletId);
53
53
  }), 15e3, 1e3)
54
54
  );
@@ -102,16 +102,16 @@ function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCoo
102
102
  }));
103
103
  }
104
104
  function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
105
- return new Promise((resolve, reject) => __async(this, null, function* () {
105
+ return new Promise((resolve, reject) => __async(null, null, function* () {
106
106
  const workId = uuid.v4();
107
107
  let worker = null;
108
108
  worker = yield setupWorker(
109
109
  ctx,
110
- bindCallbackToActiveContext((res) => __async(this, null, function* () {
110
+ bindCallbackToActiveContext((res) => __async(null, null, function* () {
111
111
  yield wrapWithSpan(
112
112
  "mpc.prekeygen.poll_for_address",
113
113
  () => waitUntilTrue(
114
- () => __async(this, null, function* () {
114
+ () => __async(null, null, function* () {
115
115
  return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
116
116
  }),
117
117
  15e3,
@@ -152,15 +152,15 @@ function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey,
152
152
  }));
153
153
  }
154
154
  function refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId) {
155
- return new Promise((resolve, reject) => __async(this, null, function* () {
155
+ return new Promise((resolve, reject) => __async(null, null, function* () {
156
156
  const workId = uuid.v4();
157
157
  let worker = null;
158
158
  worker = yield setupWorker(
159
159
  ctx,
160
- bindCallbackToActiveContext((res) => __async(this, null, function* () {
160
+ bindCallbackToActiveContext((res) => __async(null, null, function* () {
161
161
  const refreshDone = yield wrapWithSpan(
162
162
  "mpc.refresh.poll_for_done",
163
- () => waitUntilTrue(() => __async(this, null, function* () {
163
+ () => waitUntilTrue(() => __async(null, null, function* () {
164
164
  return isRefreshComplete(ctx, userId, walletId, newPartnerId);
165
165
  }), 15e3, 1e3)
166
166
  );
@@ -195,15 +195,15 @@ function refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newP
195
195
  }));
196
196
  }
197
197
  function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}, type) {
198
- return new Promise((resolve, reject) => __async(this, null, function* () {
198
+ return new Promise((resolve, reject) => __async(null, null, function* () {
199
199
  const workId = uuid.v4();
200
200
  let worker = null;
201
201
  worker = yield setupWorker(
202
202
  ctx,
203
- bindCallbackToActiveContext((res) => __async(this, null, function* () {
203
+ bindCallbackToActiveContext((res) => __async(null, null, function* () {
204
204
  yield wrapWithSpan(
205
205
  "mpc.ed25519_keygen.poll_for_address",
206
- () => waitUntilTrue(() => __async(this, null, function* () {
206
+ () => waitUntilTrue(() => __async(null, null, function* () {
207
207
  return isKeygenComplete(ctx, userId, res.walletId);
208
208
  }), 15e3, 1e3)
209
209
  );
@@ -234,16 +234,16 @@ function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}, type) {
234
234
  }));
235
235
  }
236
236
  function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type) {
237
- return new Promise((resolve, reject) => __async(this, null, function* () {
237
+ return new Promise((resolve, reject) => __async(null, null, function* () {
238
238
  const workId = uuid.v4();
239
239
  let worker = null;
240
240
  worker = yield setupWorker(
241
241
  ctx,
242
- bindCallbackToActiveContext((res) => __async(this, null, function* () {
242
+ bindCallbackToActiveContext((res) => __async(null, null, function* () {
243
243
  yield wrapWithSpan(
244
244
  "mpc.ed25519_prekeygen.poll_for_address",
245
245
  () => waitUntilTrue(
246
- () => __async(this, null, function* () {
246
+ () => __async(null, null, function* () {
247
247
  return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
248
248
  }),
249
249
  15e3,
@@ -283,12 +283,12 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
283
283
  }
284
284
  function initializeWorker(ctx) {
285
285
  return __async(this, null, function* () {
286
- return new Promise((resolve, reject) => __async(this, null, function* () {
286
+ return new Promise((resolve, reject) => __async(null, null, function* () {
287
287
  try {
288
288
  const workId = uuid.v4();
289
289
  const worker = yield setupWorker(
290
290
  ctx,
291
- () => __async(this, null, function* () {
291
+ () => __async(null, null, function* () {
292
292
  resolve();
293
293
  }),
294
294
  (error) => {
@@ -6,12 +6,12 @@ import { setupWorker } from "../workers/workerWrapper.js";
6
6
  import * as uuid from "uuid";
7
7
  function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
8
8
  return __async(this, null, function* () {
9
- return new Promise((resolve, reject) => __async(this, null, function* () {
9
+ return new Promise((resolve, reject) => __async(null, null, function* () {
10
10
  const workId = uuid.v4();
11
11
  let worker = null;
12
12
  worker = yield setupWorker(
13
13
  ctx,
14
- (res) => __async(this, null, function* () {
14
+ (res) => __async(null, null, function* () {
15
15
  resolve((res == null ? void 0 : res.privateKey) || res);
16
16
  }),
17
17
  (error) => {
@@ -38,12 +38,12 @@ function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
38
38
  }
39
39
  function getED25519PrivateKey(ctx, userId, walletId, share, sessionCookie) {
40
40
  return __async(this, null, function* () {
41
- return new Promise((resolve, reject) => __async(this, null, function* () {
41
+ return new Promise((resolve, reject) => __async(null, null, function* () {
42
42
  const workId = uuid.v4();
43
43
  let worker = null;
44
44
  worker = yield setupWorker(
45
45
  ctx,
46
- (res) => __async(this, null, function* () {
46
+ (res) => __async(null, null, function* () {
47
47
  resolve((res == null ? void 0 : res.privateKey) || res);
48
48
  }),
49
49
  (error) => {
@@ -16,12 +16,12 @@ function captureTraceCarrier() {
16
16
  }
17
17
  function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
18
18
  return __async(this, null, function* () {
19
- return new Promise((resolve, reject) => __async(this, null, function* () {
19
+ return new Promise((resolve, reject) => __async(null, null, function* () {
20
20
  const workId = uuid.v4();
21
21
  let worker = null;
22
22
  worker = yield setupWorker(
23
23
  ctx,
24
- (sendTransactionRes) => __async(this, null, function* () {
24
+ (sendTransactionRes) => __async(null, null, function* () {
25
25
  resolve(sendTransactionRes);
26
26
  }),
27
27
  (error) => {
@@ -49,12 +49,12 @@ function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCooki
49
49
  }
50
50
  function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
51
51
  return __async(this, null, function* () {
52
- return new Promise((resolve, reject) => __async(this, null, function* () {
52
+ return new Promise((resolve, reject) => __async(null, null, function* () {
53
53
  const workId = uuid.v4();
54
54
  let worker = null;
55
55
  worker = yield setupWorker(
56
56
  ctx,
57
- (sendTransactionRes) => __async(this, null, function* () {
57
+ (sendTransactionRes) => __async(null, null, function* () {
58
58
  resolve(sendTransactionRes);
59
59
  }),
60
60
  (error) => {
@@ -82,12 +82,12 @@ function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCooki
82
82
  }
83
83
  function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc) {
84
84
  return __async(this, null, function* () {
85
- return new Promise((resolve, reject) => __async(this, null, function* () {
85
+ return new Promise((resolve, reject) => __async(null, null, function* () {
86
86
  const workId = uuid.v4();
87
87
  let worker = null;
88
88
  worker = yield setupWorker(
89
89
  ctx,
90
- (signMessageRes) => __async(this, null, function* () {
90
+ (signMessageRes) => __async(null, null, function* () {
91
91
  resolve(signMessageRes);
92
92
  }),
93
93
  (error) => {
@@ -116,12 +116,12 @@ function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKL
116
116
  }
117
117
  function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
118
118
  return __async(this, null, function* () {
119
- return new Promise((resolve, reject) => __async(this, null, function* () {
119
+ return new Promise((resolve, reject) => __async(null, null, function* () {
120
120
  const workId = uuid.v4();
121
121
  let worker = null;
122
122
  worker = yield setupWorker(
123
123
  ctx,
124
- (signMessageRes) => __async(this, null, function* () {
124
+ (signMessageRes) => __async(null, null, function* () {
125
125
  resolve(signMessageRes);
126
126
  }),
127
127
  (error) => {
@@ -46,7 +46,7 @@ function ed25519Keygen(ctx, userId, _sessionCookie, _emailProps, type = "SOLANA"
46
46
  scheme: "ED25519",
47
47
  type
48
48
  });
49
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
49
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
50
50
  try {
51
51
  const newSigner = yield new Promise(
52
52
  (resolve, reject) => globalThis.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
@@ -73,7 +73,7 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, _sessionC
73
73
  scheme: "ED25519",
74
74
  type
75
75
  });
76
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
76
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
77
77
  try {
78
78
  const newSigner = yield new Promise(
79
79
  (resolve, reject) => globalThis.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
@@ -93,7 +93,7 @@ function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
93
93
  return __async(this, null, function* () {
94
94
  const protocolId = uuid.v4();
95
95
  const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, base64Bytes, "ED25519", void 0, protocolId);
96
- const signRes = function() {
96
+ const signRes = (function() {
97
97
  return __async(this, null, function* () {
98
98
  try {
99
99
  const base64Sig = yield new Promise(
@@ -111,7 +111,7 @@ function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
111
111
  });
112
112
  }
113
113
  });
114
- }();
114
+ })();
115
115
  signRes.catch(() => {
116
116
  });
117
117
  const { pendingTransactionId } = yield preSignMessageRes;
@@ -137,7 +137,7 @@ function keygen(ctx, userId, type, secretKey) {
137
137
  walletId
138
138
  };
139
139
  }
140
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
140
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
141
141
  const signerConfigUser = ctx.useDKLS ? configDKLSBase(walletId, "USER", ctx.disableWebSockets) : configCGGMPBase(serverUrl, walletId, "USER");
142
142
  const createAccountFn = ctx.useDKLS ? globalThis.dklsCreateAccount : globalThis.createAccountV2;
143
143
  try {
@@ -175,7 +175,7 @@ function preKeygen(ctx, _partnerId, pregenIdentifier, pregenIdentifierType, type
175
175
  type,
176
176
  cosmosPrefix: type === "COSMOS" ? ctx.cosmosPrefix : void 0
177
177
  });
178
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
178
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
179
179
  const signerConfigUser = configDKLSBase(walletId, "USER", ctx.disableWebSockets);
180
180
  try {
181
181
  const newSigner = yield new Promise(
@@ -208,14 +208,14 @@ function signMessage(ctx, share, walletId, userId, message, cosmosSignDoc) {
208
208
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
209
209
  return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
210
210
  }
211
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
211
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
212
212
  const signMessageFn = ctx.useDKLS ? globalThis.dklsSignMessage : globalThis.signMessage;
213
213
  const parsedShare = JSON.parse(share);
214
214
  if (!parsedShare.disableWebSockets !== !ctx.disableWebSockets) {
215
215
  parsedShare.disableWebSockets = ctx.disableWebSockets;
216
216
  }
217
217
  share = JSON.stringify(parsedShare);
218
- const signMessageRes = function() {
218
+ const signMessageRes = (function() {
219
219
  return __async(this, null, function* () {
220
220
  try {
221
221
  return yield new Promise(
@@ -230,7 +230,7 @@ function signMessage(ctx, share, walletId, userId, message, cosmosSignDoc) {
230
230
  throw wrapMpcError(`error signing for account with userId ${userId} and walletId ${walletId}`, mpcErr, { protocolId });
231
231
  }
232
232
  });
233
- }();
233
+ })();
234
234
  signMessageRes.catch(() => {
235
235
  });
236
236
  const { pendingTransactionId } = yield preSignMessageRes;
@@ -252,14 +252,14 @@ function signTransaction(ctx, share, walletId, userId, tx, chainId) {
252
252
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
253
253
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
254
254
  }
255
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
255
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
256
256
  const signTransactionFn = ctx.useDKLS ? globalThis.dklsSendTransaction : globalThis.sendTransaction;
257
257
  const parsedShare = JSON.parse(share);
258
258
  if (!parsedShare.disableWebSockets !== !ctx.disableWebSockets) {
259
259
  parsedShare.disableWebSockets = ctx.disableWebSockets;
260
260
  }
261
261
  share = JSON.stringify(parsedShare);
262
- const signTxRes = function() {
262
+ const signTxRes = (function() {
263
263
  return __async(this, null, function* () {
264
264
  try {
265
265
  return yield new Promise(
@@ -276,7 +276,7 @@ function signTransaction(ctx, share, walletId, userId, tx, chainId) {
276
276
  });
277
277
  }
278
278
  });
279
- }();
279
+ })();
280
280
  signTxRes.catch(() => {
281
281
  });
282
282
  const {
@@ -300,14 +300,14 @@ function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
300
300
  if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
301
301
  return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
302
302
  }
303
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
303
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
304
304
  const sendTransactionFn = ctx.useDKLS ? globalThis.dklsSendTransaction : globalThis.sendTransaction;
305
305
  const parsedShare = JSON.parse(share);
306
306
  if (!parsedShare.disableWebSockets !== !ctx.disableWebSockets) {
307
307
  parsedShare.disableWebSockets = ctx.disableWebSockets;
308
308
  }
309
309
  share = JSON.stringify(parsedShare);
310
- const sendTxRes = function() {
310
+ const sendTxRes = (function() {
311
311
  return __async(this, null, function* () {
312
312
  try {
313
313
  return yield new Promise(
@@ -326,7 +326,7 @@ function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
326
326
  );
327
327
  }
328
328
  });
329
- }();
329
+ })();
330
330
  sendTxRes.catch(() => {
331
331
  });
332
332
  const {
@@ -343,7 +343,7 @@ function refresh(ctx, share, walletId, userId, oldPartnerId, newPartnerId, keySh
343
343
  const {
344
344
  data: { protocolId }
345
345
  } = yield ctx.client.refreshKeys(userId, walletId, oldPartnerId, newPartnerId, keyShareProtocolId, true);
346
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
346
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
347
347
  const refreshFn = ctx.useDKLS ? globalThis.dklsRefresh : globalThis.refresh;
348
348
  const parsedShare = JSON.parse(share);
349
349
  if (!parsedShare.disableWebSockets !== !ctx.disableWebSockets) {
@@ -3,6 +3,9 @@ export 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;
@@ -246,6 +246,9 @@ function handleMessage(e, postMessage, useFetchAdapter) {
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,
@@ -267,6 +270,7 @@ function handleMessage(e, postMessage, useFetchAdapter) {
267
270
  version: paraVersion,
268
271
  apiKey,
269
272
  useFetchAdapter,
273
+ apiBaseUrlOverride,
270
274
  retrieveSessionCookie: () => sessionCookie,
271
275
  // Threading the parent's W3C trace context through so the worker's UMC
272
276
  // requests carry the same traceparent the FE's mpc.* span would generate
@@ -274,6 +278,9 @@ function handleMessage(e, postMessage, useFetchAdapter) {
274
278
  // mpc.* span, completing the FE → worker → BE waterfall.
275
279
  staticTraceContext: __otel
276
280
  }),
281
+ apiBaseUrlOverride,
282
+ portalUrlOverride,
283
+ mpcNetworkUrlOverride,
277
284
  offloadMPCComputationURL,
278
285
  mpcComputationClient: offloadMPCComputationURL ? mpcComputationClient.initClient(offloadMPCComputationURL, !!disableWorkers) : void 0,
279
286
  useDKLS,
@@ -284,7 +291,7 @@ function handleMessage(e, postMessage, useFetchAdapter) {
284
291
  try {
285
292
  if (!wasmLoaded && (!ctx.offloadMPCComputationURL || ctx.useDKLS)) {
286
293
  yield loadWasm(ctx, wasmOverride);
287
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
294
+ const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
288
295
  if (globalThis.initWasm) {
289
296
  yield new Promise(
290
297
  (resolve, reject) => {
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import {
3
- __async
3
+ __async,
4
+ __spreadValues
4
5
  } from "../chunk-YJOFEY2L.js";
5
6
  import { getPortalBaseURL } from "@getpara/core-sdk";
6
7
  import { handleMessage, WORKER_ERROR_RESPONSE_KEY } from "./worker.js";
@@ -15,6 +16,10 @@ function removeWorkId(workId, skipClearTimeout) {
15
16
  }
16
17
  clearTimeout(timeoutId);
17
18
  }
19
+ function withLocalDevUrlOverrides(ctx, message) {
20
+ const overrides = __spreadValues(__spreadValues(__spreadValues({}, ctx.apiBaseUrlOverride ? { apiBaseUrlOverride: ctx.apiBaseUrlOverride } : {}), ctx.portalUrlOverride ? { portalUrlOverride: ctx.portalUrlOverride } : {}), ctx.mpcNetworkUrlOverride ? { mpcNetworkUrlOverride: ctx.mpcNetworkUrlOverride } : {});
21
+ return Object.keys(overrides).length > 0 ? __spreadValues(__spreadValues({}, message), overrides) : message;
22
+ }
18
23
  function deserializeWorkerError(serializedError) {
19
24
  const error = new Error(serializedError.message);
20
25
  error.name = serializedError.name;
@@ -50,10 +55,11 @@ function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
50
55
  (function() {
51
56
  return __async(this, null, function* () {
52
57
  try {
58
+ const messageWithOverrides = withLocalDevUrlOverrides(ctx, message);
53
59
  const onmessage = (event) => {
54
60
  resFunction(event.data);
55
61
  };
56
- yield handleMessage({ data: message }, (data) => onmessage({ data }), ctx.disableWorkers);
62
+ yield handleMessage({ data: messageWithOverrides }, (data) => onmessage({ data }), ctx.disableWorkers);
57
63
  } catch (error) {
58
64
  errorFunction(error);
59
65
  }
@@ -85,7 +91,7 @@ function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
85
91
  const workerBlob = new Blob([yield workerRes.text()], { type: "application/javascript" });
86
92
  const workerScriptURL = URL.createObjectURL(workerBlob);
87
93
  workerInstance = new Worker(workerScriptURL);
88
- const onmessage = (event) => __async(this, null, function* () {
94
+ const onmessage = (event) => __async(null, null, function* () {
89
95
  var _a, _b;
90
96
  const { workId: messageWorkId } = event.data;
91
97
  delete event.data.workId;
@@ -114,7 +120,14 @@ function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
114
120
  workerInstance = void 0;
115
121
  };
116
122
  }
117
- return workerInstance;
123
+ return new Proxy(workerInstance, {
124
+ get(target, prop, receiver) {
125
+ if (prop === "postMessage") {
126
+ return (message) => target.postMessage(withLocalDevUrlOverrides(ctx, message));
127
+ }
128
+ return Reflect.get(target, prop, receiver);
129
+ }
130
+ });
118
131
  });
119
132
  }
120
133
  export {
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@getpara/web-sdk",
3
- "version": "3.5.1",
3
+ "version": "3.7.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "3.5.1",
6
- "@getpara/user-management-client": "3.5.1",
5
+ "@getpara/core-sdk": "3.7.0",
6
+ "@getpara/user-management-client": "3.7.0",
7
7
  "@opentelemetry/api": "^1.9.1",
8
8
  "base64url": "^3.0.1",
9
9
  "buffer": "6.0.3",
10
10
  "cbor-web": "^9.0.2",
11
- "node-forge": "^1.3.1",
11
+ "node-forge": "^1.4.0",
12
12
  "ua-parser-js": "^2.0.2",
13
- "uuid": "^11.1.0"
13
+ "uuid": "^11.1.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/node-forge": "^1.3.11",
@@ -30,7 +30,7 @@
30
30
  "dist",
31
31
  "package.json"
32
32
  ],
33
- "gitHead": "362fc377edf3cca5f743679498ff4908921c8468",
33
+ "gitHead": "ab8876230a5d00b2c620bd23a4e3ed69762fc192",
34
34
  "main": "dist/index.js",
35
35
  "scripts": {
36
36
  "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",