@getpara/core-sdk 3.6.0 → 3.8.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.
@@ -46,7 +46,7 @@ __export(constants_exports, {
46
46
  TRANSACTION_REVIEW_TIMEOUT_MS: () => TRANSACTION_REVIEW_TIMEOUT_MS
47
47
  });
48
48
  module.exports = __toCommonJS(constants_exports);
49
- const PARA_CORE_VERSION = "3.6.0";
49
+ const PARA_CORE_VERSION = "3.8.0";
50
50
  const PREFIX = "@CAPSULE/";
51
51
  const PARA_PREFIX = "@PARA/";
52
52
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -129,6 +129,7 @@ class PollingService {
129
129
  onPoll,
130
130
  onCancel,
131
131
  isCanceled,
132
+ graceCheckOnCancel = false,
132
133
  id = "genericPolling"
133
134
  } = config;
134
135
  return (0, import_tracer.wrapWithSpan)(
@@ -166,6 +167,16 @@ class PollingService {
166
167
  }
167
168
  while (pollCount < maxPolls) {
168
169
  if (isOperationCanceled()) {
170
+ if (graceCheckOnCancel) {
171
+ try {
172
+ const { finished, data } = yield checkCondition();
173
+ if (finished) {
174
+ cleanup();
175
+ return finalize({ type: "COMPLETE", data });
176
+ }
177
+ } catch (e) {
178
+ }
179
+ }
169
180
  cleanup();
170
181
  onCancel == null ? void 0 : onCancel();
171
182
  return finalize({ type: "CANCEL" });
@@ -129,7 +129,18 @@ class PregenWalletService {
129
129
  }
130
130
  }
131
131
  const { supportedWalletTypes } = yield __privateGet(this, _paraCoreInterface).assertPartner();
132
- const pregenWallets = yield this.getPregenWallets();
132
+ let pregenWallets = yield this.getPregenWallets();
133
+ if (pregenWallets.length === 0 && __privateGet(this, _authService).userId) {
134
+ try {
135
+ const res = yield __privateGet(this, _paraCoreInterface).ctx.client.getPregenWallets(
136
+ {},
137
+ __privateGet(this, _paraCoreInterface).isPortal(),
138
+ __privateGet(this, _authService).userId
139
+ );
140
+ pregenWallets = res.wallets.filter((w) => __privateGet(this, _walletService).isWalletSupported((0, import_wallet2.entityToWallet)(w)));
141
+ } catch (e) {
142
+ }
143
+ }
133
144
  let recoverySecret;
134
145
  let walletIds = {};
135
146
  if (pregenWallets.length > 0) {
@@ -328,16 +328,31 @@ class WalletService {
328
328
  (id) => this.wallets[id].type === type && __privateGet(this, _pregenWalletService).isPregenWalletClaimable(this.wallets[id])
329
329
  );
330
330
  [...walletIds, ...pregenWalletIds].forEach((id) => {
331
- if (address.toLowerCase() === this.getDisplayAddress(id, { addressType: type }).toLowerCase()) {
331
+ var _a;
332
+ if (address.toLowerCase() === ((_a = this.getDisplayAddress(id, { addressType: type })) == null ? void 0 : _a.toLowerCase())) {
332
333
  wallet = this.wallets[id];
333
334
  }
334
335
  });
335
336
  });
336
- if (!wallet) {
337
+ if (wallet) {
338
+ this.assertIsValidWalletId(wallet.id, filter);
339
+ return wallet;
340
+ }
341
+ const target = address.toLowerCase();
342
+ const fallbackWallet = target ? Object.values(this.wallets).find(
343
+ (w) => !!w.type && this.isWalletUsable(w.id, __spreadProps(__spreadValues({}, filter), { type: void 0 })) && (!(filter == null ? void 0 : filter.type) || (0, import_wallet2.getEquivalentTypes)(filter.type).includes(w.type)) && (!w.pregenIdentifier || __privateGet(this, _pregenWalletService).isPregenWalletClaimable(w)) && (0, import_wallet2.getEquivalentTypes)(w.type).some((type) => {
344
+ var _a;
345
+ try {
346
+ return ((_a = this.getDisplayAddress(w.id, { addressType: type })) == null ? void 0 : _a.toLowerCase()) === target;
347
+ } catch (e) {
348
+ return false;
349
+ }
350
+ })
351
+ ) : void 0;
352
+ if (!fallbackWallet) {
337
353
  throw new Error(`wallet with address ${address} not found`);
338
354
  }
339
- this.assertIsValidWalletId(wallet.id, filter);
340
- return wallet;
355
+ return fallbackWallet;
341
356
  };
342
357
  this.findWallet = (idOrAddress, overrideType, filter = {}) => {
343
358
  var _a, _c, _d;
@@ -364,6 +364,11 @@ function createAuthStateMachine(paraCoreInterface) {
364
364
  return (_b = (_a = event.data).onCancel) == null ? void 0 : _b.call(_a);
365
365
  },
366
366
  isCanceled: event.data.isCanceled || (() => false),
367
+ // verify-oauth buffers success server-side, so closing the in-app browser
368
+ // right after authenticating (Apple's Face ID confirm is near-instant) can
369
+ // land as "cancel" for a login that already succeeded — re-check once
370
+ // before giving up (ENG-6993).
371
+ graceCheckOnCancel: true,
367
372
  id: "authenticatingOauth"
368
373
  };
369
374
  }
@@ -942,6 +947,8 @@ function createAuthStateMachine(paraCoreInterface) {
942
947
  return (_b = (_a2 = context.pollingCallbacks) == null ? void 0 : _a2.onCancel) == null ? void 0 : _b.call(_a2);
943
948
  },
944
949
  isCanceled: ((_a = context.pollingCallbacks) == null ? void 0 : _a.isCanceled) || (() => false),
950
+ // Same cancel-races-completion window as authenticating_oauth (ENG-6993).
951
+ graceCheckOnCancel: true,
945
952
  id: "resolving2fa"
946
953
  };
947
954
  },
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "3.6.0";
2
+ const PARA_CORE_VERSION = "3.8.0";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const PARA_PREFIX = "@PARA/";
5
5
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -71,6 +71,7 @@ class PollingService {
71
71
  onPoll,
72
72
  onCancel,
73
73
  isCanceled,
74
+ graceCheckOnCancel = false,
74
75
  id = "genericPolling"
75
76
  } = config;
76
77
  return wrapWithSpan(
@@ -108,6 +109,16 @@ class PollingService {
108
109
  }
109
110
  while (pollCount < maxPolls) {
110
111
  if (isOperationCanceled()) {
112
+ if (graceCheckOnCancel) {
113
+ try {
114
+ const { finished, data } = yield checkCondition();
115
+ if (finished) {
116
+ cleanup();
117
+ return finalize({ type: "COMPLETE", data });
118
+ }
119
+ } catch (e) {
120
+ }
121
+ }
111
122
  cleanup();
112
123
  onCancel == null ? void 0 : onCancel();
113
124
  return finalize({ type: "CANCEL" });
@@ -81,7 +81,18 @@ class PregenWalletService {
81
81
  }
82
82
  }
83
83
  const { supportedWalletTypes } = yield __privateGet(this, _paraCoreInterface).assertPartner();
84
- const pregenWallets = yield this.getPregenWallets();
84
+ let pregenWallets = yield this.getPregenWallets();
85
+ if (pregenWallets.length === 0 && __privateGet(this, _authService).userId) {
86
+ try {
87
+ const res = yield __privateGet(this, _paraCoreInterface).ctx.client.getPregenWallets(
88
+ {},
89
+ __privateGet(this, _paraCoreInterface).isPortal(),
90
+ __privateGet(this, _authService).userId
91
+ );
92
+ pregenWallets = res.wallets.filter((w) => __privateGet(this, _walletService).isWalletSupported(entityToWallet(w)));
93
+ } catch (e) {
94
+ }
95
+ }
85
96
  let recoverySecret;
86
97
  let walletIds = {};
87
98
  if (pregenWallets.length > 0) {
@@ -272,16 +272,31 @@ class WalletService {
272
272
  (id) => this.wallets[id].type === type && __privateGet(this, _pregenWalletService).isPregenWalletClaimable(this.wallets[id])
273
273
  );
274
274
  [...walletIds, ...pregenWalletIds].forEach((id) => {
275
- if (address.toLowerCase() === this.getDisplayAddress(id, { addressType: type }).toLowerCase()) {
275
+ var _a;
276
+ if (address.toLowerCase() === ((_a = this.getDisplayAddress(id, { addressType: type })) == null ? void 0 : _a.toLowerCase())) {
276
277
  wallet = this.wallets[id];
277
278
  }
278
279
  });
279
280
  });
280
- if (!wallet) {
281
+ if (wallet) {
282
+ this.assertIsValidWalletId(wallet.id, filter);
283
+ return wallet;
284
+ }
285
+ const target = address.toLowerCase();
286
+ const fallbackWallet = target ? Object.values(this.wallets).find(
287
+ (w) => !!w.type && this.isWalletUsable(w.id, __spreadProps(__spreadValues({}, filter), { type: void 0 })) && (!(filter == null ? void 0 : filter.type) || getEquivalentTypes(filter.type).includes(w.type)) && (!w.pregenIdentifier || __privateGet(this, _pregenWalletService).isPregenWalletClaimable(w)) && getEquivalentTypes(w.type).some((type) => {
288
+ var _a;
289
+ try {
290
+ return ((_a = this.getDisplayAddress(w.id, { addressType: type })) == null ? void 0 : _a.toLowerCase()) === target;
291
+ } catch (e) {
292
+ return false;
293
+ }
294
+ })
295
+ ) : void 0;
296
+ if (!fallbackWallet) {
281
297
  throw new Error(`wallet with address ${address} not found`);
282
298
  }
283
- this.assertIsValidWalletId(wallet.id, filter);
284
- return wallet;
299
+ return fallbackWallet;
285
300
  };
286
301
  this.findWallet = (idOrAddress, overrideType, filter = {}) => {
287
302
  var _a, _c, _d;
@@ -320,6 +320,11 @@ function createAuthStateMachine(paraCoreInterface) {
320
320
  return (_b = (_a = event.data).onCancel) == null ? void 0 : _b.call(_a);
321
321
  },
322
322
  isCanceled: event.data.isCanceled || (() => false),
323
+ // verify-oauth buffers success server-side, so closing the in-app browser
324
+ // right after authenticating (Apple's Face ID confirm is near-instant) can
325
+ // land as "cancel" for a login that already succeeded — re-check once
326
+ // before giving up (ENG-6993).
327
+ graceCheckOnCancel: true,
323
328
  id: "authenticatingOauth"
324
329
  };
325
330
  }
@@ -898,6 +903,8 @@ function createAuthStateMachine(paraCoreInterface) {
898
903
  return (_b = (_a2 = context.pollingCallbacks) == null ? void 0 : _a2.onCancel) == null ? void 0 : _b.call(_a2);
899
904
  },
900
905
  isCanceled: ((_a = context.pollingCallbacks) == null ? void 0 : _a.isCanceled) || (() => false),
906
+ // Same cancel-races-completion window as authenticating_oauth (ENG-6993).
907
+ graceCheckOnCancel: true,
901
908
  id: "resolving2fa"
902
909
  };
903
910
  },
@@ -34,6 +34,15 @@ export interface PollingConfig<T> extends PollingCallbacks {
34
34
  intervalMs?: number;
35
35
  timeoutMs?: number;
36
36
  id?: string;
37
+ /**
38
+ * Run one final `checkCondition` when cancellation is detected, and resolve COMPLETE
39
+ * if it reports finished. For polls whose condition is durable server-side (e.g.
40
+ * verify-oauth), cancellation can race an already-successful completion — the user
41
+ * closes the in-app browser after authenticating but before the next poll tick —
42
+ * and without this check the SDK reports "canceled" for a login that succeeded
43
+ * (ENG-6993).
44
+ */
45
+ graceCheckOnCancel?: boolean;
37
46
  }
38
47
  export type PollingResult<T> = {
39
48
  type: 'COMPLETE';
@@ -850,6 +850,7 @@ export declare function createAuthStateMachine(paraCoreInterface: StateMachineIn
850
850
  onPoll: () => void;
851
851
  onCancel: () => void;
852
852
  isCanceled: () => boolean;
853
+ graceCheckOnCancel: true;
853
854
  id: string;
854
855
  };
855
856
  readonly onError: {
@@ -2167,6 +2168,7 @@ export declare function createAuthStateMachine(paraCoreInterface: StateMachineIn
2167
2168
  onPoll: () => void;
2168
2169
  onCancel: () => void;
2169
2170
  isCanceled: () => boolean;
2171
+ graceCheckOnCancel: true;
2170
2172
  id: string;
2171
2173
  };
2172
2174
  readonly onError: {
@@ -850,6 +850,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
850
850
  onPoll: () => void;
851
851
  onCancel: () => void;
852
852
  isCanceled: () => boolean;
853
+ graceCheckOnCancel: true;
853
854
  id: string;
854
855
  };
855
856
  readonly onError: {
@@ -2167,6 +2168,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
2167
2168
  onPoll: () => void;
2168
2169
  onCancel: () => void;
2169
2170
  isCanceled: () => boolean;
2171
+ graceCheckOnCancel: true;
2170
2172
  id: string;
2171
2173
  };
2172
2174
  readonly onError: {
@@ -4672,6 +4674,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
4672
4674
  onPoll: () => void;
4673
4675
  onCancel: () => void;
4674
4676
  isCanceled: () => boolean;
4677
+ graceCheckOnCancel: true;
4675
4678
  id: string;
4676
4679
  };
4677
4680
  readonly onError: {
@@ -5989,6 +5992,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
5989
5992
  onPoll: () => void;
5990
5993
  onCancel: () => void;
5991
5994
  isCanceled: () => boolean;
5995
+ graceCheckOnCancel: true;
5992
5996
  id: string;
5993
5997
  };
5994
5998
  readonly onError: {
@@ -8572,6 +8576,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
8572
8576
  onPoll: () => void;
8573
8577
  onCancel: () => void;
8574
8578
  isCanceled: () => boolean;
8579
+ graceCheckOnCancel: true;
8575
8580
  id: string;
8576
8581
  };
8577
8582
  readonly onError: {
@@ -9889,6 +9894,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
9889
9894
  onPoll: () => void;
9890
9895
  onCancel: () => void;
9891
9896
  isCanceled: () => boolean;
9897
+ graceCheckOnCancel: true;
9892
9898
  id: string;
9893
9899
  };
9894
9900
  readonly onError: {
@@ -12410,6 +12416,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
12410
12416
  onPoll: () => void;
12411
12417
  onCancel: () => void;
12412
12418
  isCanceled: () => boolean;
12419
+ graceCheckOnCancel: true;
12413
12420
  id: string;
12414
12421
  };
12415
12422
  readonly onError: {
@@ -13727,6 +13734,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
13727
13734
  onPoll: () => void;
13728
13735
  onCancel: () => void;
13729
13736
  isCanceled: () => boolean;
13737
+ graceCheckOnCancel: true;
13730
13738
  id: string;
13731
13739
  };
13732
13740
  readonly onError: {
@@ -16345,6 +16353,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
16345
16353
  onPoll: () => void;
16346
16354
  onCancel: () => void;
16347
16355
  isCanceled: () => boolean;
16356
+ graceCheckOnCancel: true;
16348
16357
  id: string;
16349
16358
  };
16350
16359
  readonly onError: {
@@ -17662,6 +17671,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
17662
17671
  onPoll: () => void;
17663
17672
  onCancel: () => void;
17664
17673
  isCanceled: () => boolean;
17674
+ graceCheckOnCancel: true;
17665
17675
  id: string;
17666
17676
  };
17667
17677
  readonly onError: {
@@ -20184,6 +20194,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
20184
20194
  onPoll: () => void;
20185
20195
  onCancel: () => void;
20186
20196
  isCanceled: () => boolean;
20197
+ graceCheckOnCancel: true;
20187
20198
  id: string;
20188
20199
  };
20189
20200
  readonly onError: {
@@ -21501,6 +21512,7 @@ export declare function createCoreStateMachine(paraCoreInterface: StateMachineIn
21501
21512
  onPoll: () => void;
21502
21513
  onCancel: () => void;
21503
21514
  isCanceled: () => boolean;
21515
+ graceCheckOnCancel: true;
21504
21516
  id: string;
21505
21517
  };
21506
21518
  readonly onError: {
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "dependencies": {
5
5
  "@celo/utils": "^8.0.2",
6
6
  "@cosmjs/encoding": "^0.32.4",
7
7
  "@ethereumjs/util": "^9.1.0",
8
- "@getpara/user-management-client": "3.6.0",
8
+ "@getpara/user-management-client": "3.8.0",
9
9
  "@noble/hashes": "^1.5.0",
10
10
  "@opentelemetry/api": "^1.9.1",
11
- "@opentelemetry/context-zone": "^2.7.1",
12
- "@opentelemetry/core": "^2.7.0",
13
- "@opentelemetry/exporter-trace-otlp-http": "^0.215.0",
14
- "@opentelemetry/instrumentation": "^0.215.0",
15
- "@opentelemetry/instrumentation-fetch": "^0.215.0",
16
- "@opentelemetry/instrumentation-xml-http-request": "^0.216.0",
17
- "@opentelemetry/otlp-transformer": "^0.215.0",
18
- "@opentelemetry/resources": "^2.7.0",
19
- "@opentelemetry/sdk-trace-base": "^2.7.0",
11
+ "@opentelemetry/context-zone": "^2.9.0",
12
+ "@opentelemetry/core": "^2.9.0",
13
+ "@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
14
+ "@opentelemetry/instrumentation": "^0.220.0",
15
+ "@opentelemetry/instrumentation-fetch": "^0.220.0",
16
+ "@opentelemetry/instrumentation-xml-http-request": "^0.220.0",
17
+ "@opentelemetry/otlp-transformer": "^0.220.0",
18
+ "@opentelemetry/resources": "^2.9.0",
19
+ "@opentelemetry/sdk-trace-base": "^2.9.0",
20
20
  "@opentelemetry/semantic-conventions": "^1.40.0",
21
21
  "axios": "^1.8.4",
22
22
  "base64url": "^3.0.1",
23
23
  "elliptic": "^6.6.1",
24
24
  "libphonenumber-js": "^1.11.7",
25
- "node-forge": "^1.3.1",
25
+ "node-forge": "^1.4.0",
26
26
  "uuid": "^11.1.1",
27
27
  "xstate": "^5.24.0"
28
28
  },
@@ -41,7 +41,7 @@
41
41
  "dist",
42
42
  "package.json"
43
43
  ],
44
- "gitHead": "565535ab0cf38d65f6996fc9f1ede52d133ddac0",
44
+ "gitHead": "fc722e9eaa7a9cae9fd631b748fe70fab24d7956",
45
45
  "main": "dist/cjs/index.js",
46
46
  "module": "dist/esm/index.js",
47
47
  "scripts": {