@getpara/core-sdk 3.0.0-alpha.0 → 3.0.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.
Files changed (106) hide show
  1. package/dist/cjs/ParaCore.js +436 -86
  2. package/dist/cjs/constants.js +1 -1
  3. package/dist/cjs/cryptography/utils.js +5 -2
  4. package/dist/cjs/errors.js +10 -0
  5. package/dist/cjs/external/userManagementClient.js +21 -4
  6. package/dist/cjs/index.js +67 -1
  7. package/dist/cjs/services/AuthService.js +66 -47
  8. package/dist/cjs/services/LoginFlowService.js +30 -27
  9. package/dist/cjs/services/PollingService.js +100 -75
  10. package/dist/cjs/services/PortalUrlService.js +112 -19
  11. package/dist/cjs/services/PregenWalletService.js +125 -76
  12. package/dist/cjs/services/SessionManagementService.js +15 -8
  13. package/dist/cjs/services/SignupFlowService.js +52 -47
  14. package/dist/cjs/services/VerificationFlowService.js +13 -10
  15. package/dist/cjs/services/WalletService.js +51 -36
  16. package/dist/cjs/shares/enclave.js +46 -26
  17. package/dist/cjs/state/CoreStateManager.js +17 -5
  18. package/dist/cjs/state/actors/setupPara.js +4 -1
  19. package/dist/cjs/state/machines/walletStateMachine.js +22 -0
  20. package/dist/cjs/telemetry/config.js +15 -0
  21. package/dist/cjs/telemetry/init.js +185 -0
  22. package/dist/cjs/telemetry/modalSession.js +54 -0
  23. package/dist/cjs/telemetry/session.js +39 -0
  24. package/dist/cjs/telemetry/tracer.js +126 -0
  25. package/dist/cjs/telemetry/uxAction.js +30 -0
  26. package/dist/cjs/telemetry/uxBaggagePropagator.js +58 -0
  27. package/dist/cjs/telemetry/uxState.js +46 -0
  28. package/dist/cjs/telemetry/uxStateSpanProcessor.js +51 -0
  29. package/dist/cjs/utils/configEncoding.js +98 -0
  30. package/dist/cjs/utils/deprecation.js +13 -13
  31. package/dist/cjs/utils/formatting.js +5 -0
  32. package/dist/cjs/utils/index.js +11 -0
  33. package/dist/cjs/utils/partnerConfig.js +103 -0
  34. package/dist/cjs/utils/partnerConfigGating.js +83 -0
  35. package/dist/cjs/utils/stateErrorHelpers.js +6 -1
  36. package/dist/cjs/utils/url.js +10 -2
  37. package/dist/esm/ParaCore.js +441 -88
  38. package/dist/esm/constants.js +1 -1
  39. package/dist/esm/cryptography/utils.js +5 -2
  40. package/dist/esm/errors.js +9 -0
  41. package/dist/esm/external/userManagementClient.js +21 -4
  42. package/dist/esm/index.js +58 -4
  43. package/dist/esm/services/AuthService.js +66 -47
  44. package/dist/esm/services/LoginFlowService.js +30 -27
  45. package/dist/esm/services/PollingService.js +100 -75
  46. package/dist/esm/services/PortalUrlService.js +112 -19
  47. package/dist/esm/services/PregenWalletService.js +125 -76
  48. package/dist/esm/services/SessionManagementService.js +15 -8
  49. package/dist/esm/services/SignupFlowService.js +52 -47
  50. package/dist/esm/services/VerificationFlowService.js +13 -10
  51. package/dist/esm/services/WalletService.js +51 -36
  52. package/dist/esm/shares/enclave.js +46 -26
  53. package/dist/esm/state/CoreStateManager.js +17 -5
  54. package/dist/esm/state/actors/setupPara.js +4 -1
  55. package/dist/esm/state/machines/walletStateMachine.js +22 -0
  56. package/dist/esm/telemetry/config.js +0 -0
  57. package/dist/esm/telemetry/init.js +118 -0
  58. package/dist/esm/telemetry/modalSession.js +29 -0
  59. package/dist/esm/telemetry/session.js +16 -0
  60. package/dist/esm/telemetry/tracer.js +84 -0
  61. package/dist/esm/telemetry/uxAction.js +8 -0
  62. package/dist/esm/telemetry/uxBaggagePropagator.js +35 -0
  63. package/dist/esm/telemetry/uxState.js +21 -0
  64. package/dist/esm/telemetry/uxStateSpanProcessor.js +28 -0
  65. package/dist/esm/utils/configEncoding.js +45 -0
  66. package/dist/esm/utils/deprecation.js +11 -12
  67. package/dist/esm/utils/formatting.js +4 -0
  68. package/dist/esm/utils/index.js +6 -0
  69. package/dist/esm/utils/partnerConfig.js +67 -0
  70. package/dist/esm/utils/partnerConfigGating.js +61 -0
  71. package/dist/esm/utils/stateErrorHelpers.js +6 -1
  72. package/dist/esm/utils/url.js +10 -2
  73. package/dist/types/ParaCore.d.ts +101 -19
  74. package/dist/types/PlatformUtils.d.ts +1 -0
  75. package/dist/types/errors.d.ts +26 -0
  76. package/dist/types/external/userManagementClient.d.ts +2 -1
  77. package/dist/types/index.d.ts +15 -3
  78. package/dist/types/services/types/AuthServiceTypes.d.ts +10 -3
  79. package/dist/types/services/types/PortalUrlServiceTypes.d.ts +3 -3
  80. package/dist/types/services/types/WalletServiceTypes.d.ts +4 -0
  81. package/dist/types/state/actors/setupPara.d.ts +18 -0
  82. package/dist/types/state/machines/authStateMachine.d.ts +1 -1
  83. package/dist/types/state/machines/coreStateMachine.d.ts +30 -6
  84. package/dist/types/state/machines/walletStateMachine.d.ts +4 -0
  85. package/dist/types/state/types/core.d.ts +7 -1
  86. package/dist/types/telemetry/config.d.ts +4 -0
  87. package/dist/types/telemetry/init.d.ts +17 -0
  88. package/dist/types/telemetry/modalSession.d.ts +5 -0
  89. package/dist/types/telemetry/session.d.ts +2 -0
  90. package/dist/types/telemetry/tracer.d.ts +10 -0
  91. package/dist/types/telemetry/uxAction.d.ts +3 -0
  92. package/dist/types/telemetry/uxBaggagePropagator.d.ts +7 -0
  93. package/dist/types/telemetry/uxState.d.ts +8 -0
  94. package/dist/types/telemetry/uxStateSpanProcessor.d.ts +9 -0
  95. package/dist/types/types/config.d.ts +15 -3
  96. package/dist/types/types/coreApi.d.ts +7 -9
  97. package/dist/types/types/serviceInterfaces.d.ts +5 -3
  98. package/dist/types/types/util.d.ts +2 -15
  99. package/dist/types/utils/configEncoding.d.ts +51 -0
  100. package/dist/types/utils/deprecation.d.ts +3 -1
  101. package/dist/types/utils/formatting.d.ts +1 -0
  102. package/dist/types/utils/index.d.ts +2 -0
  103. package/dist/types/utils/partnerConfig.d.ts +28 -0
  104. package/dist/types/utils/partnerConfigGating.d.ts +48 -0
  105. package/dist/types/utils/url.d.ts +3 -2
  106. package/package.json +14 -4
@@ -97,6 +97,7 @@ var import_types = require("./types/index.js");
97
97
  var import_utils2 = require("./utils/index.js");
98
98
  var import_stateListener = require("./utils/stateListener.js");
99
99
  var import_deprecation = require("./utils/deprecation.js");
100
+ var import_partnerConfigGating = require("./utils/partnerConfigGating.js");
100
101
  var import_errors = require("./errors.js");
101
102
  var constants = __toESM(require("./constants.js"));
102
103
  var import_enclave = require("./shares/enclave.js");
@@ -108,7 +109,11 @@ var import_PregenWalletService = require("./services/PregenWalletService.js");
108
109
  var import_PortalUrlService = require("./services/PortalUrlService.js");
109
110
  var import_SessionManagementService = require("./services/SessionManagementService.js");
110
111
  var import_ExternalWalletService = require("./services/ExternalWalletService.js");
111
- var _stateManager, _authService, _walletService, _externalWalletService, _pregenWalletService, _pollingService, _portalUrlService, _sessionManagementService, _debugLogsEnabled, _ParaCore_instances, assertPartner_fn, toAuthInfo_fn, _servicesInitialized, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, waitForLoginProcess_fn, logout_fn;
112
+ var import_tracer = require("./telemetry/tracer.js");
113
+ var import_uxStateSpanProcessor = require("./telemetry/uxStateSpanProcessor.js");
114
+ var import_init = require("./telemetry/init.js");
115
+ var import_uxAction = require("./telemetry/uxAction.js");
116
+ var _stateManager, _authService, _walletService, _externalWalletService, _pregenWalletService, _pollingService, _portalUrlService, _sessionManagementService, _debugLogsEnabled, _configChangeListeners, _ParaCore_instances, notifyConfigChange_fn, _sdkConfigOverrides, _configMemo, warnPartnerConfigDrift_fn, configWithoutSdkOverrides_fn, assertPartner_fn, toAuthInfo_fn, _servicesInitialized, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, waitForLoginProcess_fn, waitForLoginProcessImpl_fn, logout_fn;
112
117
  if (typeof global !== "undefined") {
113
118
  global.Buffer = global.Buffer || import_buffer.Buffer;
114
119
  } else if (typeof window !== "undefined") {
@@ -135,6 +140,28 @@ const _ParaCore = class _ParaCore {
135
140
  this.isSwitchingWallets = false;
136
141
  this.isNativePasskey = false;
137
142
  this.isSetup = false;
143
+ // Notified whenever an input to `paraCore.config` changes — either the
144
+ // partner record (via `getPartner`) or the SDK override layer (via
145
+ // `setSdkConfigOverrides`). One signal covers both async-load and
146
+ // runtime-mutation cases, so consumers wire one subscription.
147
+ __privateAdd(this, _configChangeListeners, /* @__PURE__ */ new Set());
148
+ /**
149
+ * Phase 3 — SDK-side override layer applied on top of the partner layer.
150
+ *
151
+ * merge chain: defaults ⊕ ecosystem (future) ⊕ partner ⊕ #sdkConfigOverrides
152
+ *
153
+ * Initialized from `ConstructorOpts.configOverrides`. Mutable post-construction
154
+ * via `setSdkConfigOverrides` so reactive callers (e.g. `ParaProviderMin`'s
155
+ * `configOverrides` prop) can update it without rebuilding the ParaCore
156
+ * instance.
157
+ *
158
+ * Typed `Partial<SdkOverridableAppConfig>` — security/posture fields
159
+ * (`supportedAuthMethods`, `authConfig.twoFactorAuthEnabled`, etc.) are
160
+ * excluded at compile time, so no caller path can override them.
161
+ */
162
+ __privateAdd(this, _sdkConfigOverrides);
163
+ /** Memoization for the `config` getter — invalidates on partner / overrides identity change. */
164
+ __privateAdd(this, _configMemo);
138
165
  this.accountLinkInProgress = void 0;
139
166
  this.isWorkerInitialized = false;
140
167
  this.onRampPopup = void 0;
@@ -219,17 +246,45 @@ const _ParaCore = class _ParaCore {
219
246
  }
220
247
  throw err;
221
248
  });
222
- this.wrapMethodsWithErrorTracking = (methodNames) => {
223
- for (const methodName of methodNames) {
249
+ // Each wrapped method becomes one named span. wrapWithSpan handles recordException +
250
+ // ERROR status; the legacy /errors/sdk POST stays in trackError as a fallback during
251
+ // the cutover window — PR D removes it once we verify span error coverage in prod.
252
+ // Until telemetry is initialized (cold-start window before partner-config arrives),
253
+ // wrapWithSpan delegates to a no-op tracer so spans are dropped without overhead.
254
+ // The original method MUST be invoked inside wrapWithSpan's callback so its async
255
+ // chain (Promises, setTimeout, fetch) is created under the active-span context.
256
+ // Calling original.apply BEFORE wrapWithSpan starts the work in the root Zone —
257
+ // child spans then root independently because Zone.js can't trace context through
258
+ // Promises that were already in flight when the active span was set. All currently
259
+ // wrapped methods are async, so always returning a Promise here is safe.
260
+ this.wrapMethodsWithTracing = (entries) => {
261
+ for (const entry of entries) {
262
+ const methodName = typeof entry === "string" ? entry : entry.method;
263
+ const uxTargetId = typeof entry === "string" ? void 0 : entry.uxTargetId;
224
264
  const original = this[methodName];
225
265
  if (typeof original === "function") {
226
266
  this[methodName] = (...args) => {
227
- try {
228
- const result = original.apply(this, args);
229
- return result instanceof Promise ? result.catch((err) => this.trackError(methodName, err)) : result;
230
- } catch (err) {
231
- return this.trackError(methodName, err);
232
- }
267
+ var _a;
268
+ const attrs = __spreadValues({
269
+ "para.platform": this.platformUtils.sdkType,
270
+ "para.sdk_version": _ParaCore.version
271
+ }, ((_a = this.partner) == null ? void 0 : _a.id) ? { "para.partner_id": this.partner.id } : {});
272
+ return (0, import_tracer.wrapWithSpan)(
273
+ methodName,
274
+ (span) => __async(this, null, function* () {
275
+ if (!uxTargetId) return original.apply(this, args);
276
+ let outcome = "success";
277
+ try {
278
+ return yield original.apply(this, args);
279
+ } catch (err) {
280
+ outcome = "error";
281
+ throw err;
282
+ } finally {
283
+ (0, import_uxAction.recordActionOnSpan)(span, uxTargetId, outcome);
284
+ }
285
+ }),
286
+ attrs
287
+ ).catch((err) => this.trackError(methodName, err));
233
288
  };
234
289
  }
235
290
  }
@@ -405,6 +460,7 @@ const _ParaCore = class _ParaCore {
405
460
  }
406
461
  if (!opts) opts = {};
407
462
  __privateSet(this, _debugLogsEnabled, !!opts.enableDebugLogs);
463
+ __privateSet(this, _sdkConfigOverrides, opts.configOverrides);
408
464
  const isE2E = env === "E2E" || envOrApiKey === "E2E";
409
465
  if (isE2E && env !== import_types.Environment.SANDBOX) {
410
466
  env = import_types.Environment.SANDBOX;
@@ -497,19 +553,32 @@ const _ParaCore = class _ParaCore {
497
553
  this.initializeFromStorage();
498
554
  import_utils2.setupListeners.bind(this)();
499
555
  (0, import_utils2.autoBind)(this);
500
- this.wrapMethodsWithErrorTracking([
556
+ this.wrapMethodsWithTracing([
501
557
  "signUpOrLogIn",
558
+ // Methods marked with uxTargetId double as user-perceived UX actions —
559
+ // the wrap stamps ui.target_id / ui.outcome and emits a
560
+ // ui.action.completed event so the action's existing span IS the
561
+ // user-perceived measurement. No separate orphan span needed.
562
+ { method: "authenticateWithEmailOrPhone", uxTargetId: "sign-in" },
563
+ "authenticateWithOAuth",
502
564
  "verifyNewAccount",
565
+ "resendVerificationCode",
503
566
  "waitForLogin",
504
567
  "waitForSignup",
505
568
  "waitForWalletCreation",
506
569
  "verifyOAuth",
507
570
  "verifyTelegram",
508
571
  "verifyFarcaster",
572
+ "connectExternalWallet",
573
+ "loginExternalWallet",
574
+ "verifyExternalWallet",
575
+ "createWallet",
576
+ "createWalletPerType",
509
577
  "createPregenWallet",
510
578
  "claimPregenWallets",
511
579
  "signMessage",
512
- "signTransaction"
580
+ "signTransaction",
581
+ "logout"
513
582
  ]);
514
583
  __privateGet(this, _stateManager).start();
515
584
  }
@@ -637,6 +706,25 @@ const _ParaCore = class _ParaCore {
637
706
  });
638
707
  return () => unsubscribe();
639
708
  }
709
+ /**
710
+ * Subscribe to changes in any input to `paraCore.config`:
711
+ * - partner record updates (lazy load after a failed eager fetch, etc.)
712
+ * - SDK override layer replacement (`setSdkConfigOverrides`)
713
+ *
714
+ * The callback fires after the relevant state has settled; subscribers
715
+ * should re-read `paraCore.config` to get the new merged value. Returns
716
+ * an unsubscribe function.
717
+ *
718
+ * Used by the React layer to bump its reactive `paraConfigVersion`
719
+ * counter; non-React consumers (server SDK, telemetry, etc.) can wire
720
+ * the same signal to invalidate their caches.
721
+ */
722
+ onConfigChange(callback) {
723
+ __privateGet(this, _configChangeListeners).add(callback);
724
+ return () => {
725
+ __privateGet(this, _configChangeListeners).delete(callback);
726
+ };
727
+ }
640
728
  get authInfo() {
641
729
  var _a;
642
730
  return (_a = __privateGet(this, _authService)) == null ? void 0 : _a.authInfo;
@@ -663,6 +751,73 @@ const _ParaCore = class _ParaCore {
663
751
  get externalWalletConnectionType() {
664
752
  return __privateGet(this, _externalWalletService).externalWalletConnectionType;
665
753
  }
754
+ /**
755
+ * Resolved partner app config: partner ⊕ SDK overrides.
756
+ * Read-only view; safe to call before `getPartner` returns (yields `{}` via
757
+ * the merge of no layers).
758
+ *
759
+ * Memoized on `(this.partner, this.#sdkConfigOverrides)` identity. Multiple
760
+ * consumers read this (assertConfigAllowed at 9 sites, PortalUrlService,
761
+ * ExternalWalletWrapper); without memoization each access re-allocates a
762
+ * fresh merged object graph. Cache invalidates whenever `this.partner` is
763
+ * replaced (via getPartner) or `setSdkConfigOverrides` is called.
764
+ */
765
+ get config() {
766
+ if (__privateGet(this, _configMemo) && __privateGet(this, _configMemo).partner === this.partner && __privateGet(this, _configMemo).overrides === __privateGet(this, _sdkConfigOverrides)) {
767
+ return __privateGet(this, _configMemo).result;
768
+ }
769
+ const partnerLayer = this.partner ? (0, import_utils2.partnerToAppConfigLayer)(this.partner) : void 0;
770
+ const result = (0, import_utils2.mergePartnerAppConfig)(import_utils2.DEFAULT_PARTNER_APP_CONFIG, partnerLayer, __privateGet(this, _sdkConfigOverrides));
771
+ __privateSet(this, _configMemo, { partner: this.partner, overrides: __privateGet(this, _sdkConfigOverrides), result });
772
+ return result;
773
+ }
774
+ /**
775
+ * Read-only accessor for the raw partner record. Returns `undefined` until
776
+ * `getPartner` resolves (typically during `setup()`).
777
+ *
778
+ * The vast majority of partner-driven UX should consume `this.config`
779
+ * instead — that layer applies SDK overrides, exposes a stable shape, and
780
+ * is memoized. Use this getter only for fields that live on `PartnerEntity`
781
+ * but aren't promoted onto `PartnerAppConfig` (e.g. `logoUrl`, internal
782
+ * policy state). Whatever this returns is exactly what the public
783
+ * `getPartner(id)` API resolved on the last fetch — no additional
784
+ * processing.
785
+ */
786
+ get partnerRecord() {
787
+ return this.partner;
788
+ }
789
+ /**
790
+ * Replace the SDK-side override layer. Generic surface — any post-construction
791
+ * caller (React provider, server-sdk, custom integration) can update overrides
792
+ * without rebuilding the ParaCore instance.
793
+ *
794
+ * Replaces wholesale (last writer wins). Pass undefined to clear.
795
+ */
796
+ setSdkConfigOverrides(overrides) {
797
+ __privateSet(this, _sdkConfigOverrides, overrides);
798
+ __privateSet(this, _configMemo, void 0);
799
+ __privateMethod(this, _ParaCore_instances, notifyConfigChange_fn).call(this);
800
+ }
801
+ /**
802
+ * Read the raw SDK override layer (NOT the merged config). Used by analytics
803
+ * to distinguish "what the consumer passed" from "what the resolver
804
+ * produced." For the resolved view, use `paraCore.config`.
805
+ *
806
+ * @internal — analytics-only. App code should read `paraCore.config` instead;
807
+ * this getter exposes pre-merge values that can change shape across
808
+ * versions without notice.
809
+ *
810
+ * @remarks Redaction contract — any analytics consumer dispatching this
811
+ * value to an external sink MUST sanitize first. Specifically `rpcUrl`
812
+ * commonly embeds API keys (Alchemy `/v2/<key>`, Infura `/v3/<key>`).
813
+ * Today the React modal owns redaction in
814
+ * `react-sdk-lite/src/modal/ParaModal.tsx` (`sanitizeSdkConfigOverridesForAnalytics`).
815
+ * When Phase 7's non-React analytics lands here, lift that helper next
816
+ * to this getter so all consumers share one sanitizer.
817
+ */
818
+ get sdkConfigOverrides() {
819
+ return __privateGet(this, _sdkConfigOverrides);
820
+ }
666
821
  get userId() {
667
822
  var _a;
668
823
  return (_a = __privateGet(this, _authService)) == null ? void 0 : _a.userId;
@@ -752,6 +907,27 @@ const _ParaCore = class _ParaCore {
752
907
  var _a;
753
908
  return (_a = this.partner) == null ? void 0 : _a.cosmosPrefix;
754
909
  }
910
+ /**
911
+ * Auth methods the partner has enabled. Read off the raw partner record —
912
+ * partner-authoritative and excluded from `SdkOverridableAppConfig`, so it
913
+ * does NOT participate in the override merge chain.
914
+ *
915
+ * Named `supportedAuthMethodsList` (not `supportedAuthMethods`) to avoid
916
+ * colliding with the existing protected async `supportedAuthMethods(auth)`
917
+ * method that performs a backend lookup. Different concept, different shape.
918
+ */
919
+ get supportedAuthMethodsList() {
920
+ var _a, _b;
921
+ return (_b = (_a = this.partner) == null ? void 0 : _a.supportedAuthMethods) != null ? _b : [import_user_management_client.AuthMethod.BASIC_LOGIN];
922
+ }
923
+ /**
924
+ * Balance display config from the partner record. Partner-authoritative;
925
+ * excluded from `SdkOverridableAppConfig`.
926
+ */
927
+ get balancesConfig() {
928
+ var _a;
929
+ return (_a = this.partner) == null ? void 0 : _a.balancesConfig;
930
+ }
755
931
  get supportedAccountLinks() {
756
932
  var _a, _b;
757
933
  return (_b = (_a = this.partner) == null ? void 0 : _a.supportedAccountLinks) != null ? _b : [...import_user_management_client.LINKED_ACCOUNT_TYPES];
@@ -1008,6 +1184,9 @@ const _ParaCore = class _ParaCore {
1008
1184
  },
1009
1185
  get accountLinkInProgress() {
1010
1186
  return self2.accountLinkInProgress;
1187
+ },
1188
+ get config() {
1189
+ return self2.config;
1011
1190
  }
1012
1191
  };
1013
1192
  }
@@ -1383,6 +1562,29 @@ const _ParaCore = class _ParaCore {
1383
1562
  }
1384
1563
  const res = yield this.ctx.client.getPartner(partnerId);
1385
1564
  this.partner = res.data.partner;
1565
+ __privateMethod(this, _ParaCore_instances, warnPartnerConfigDrift_fn).call(this);
1566
+ __privateMethod(this, _ParaCore_instances, notifyConfigChange_fn).call(this);
1567
+ const telemetry = res.data.partner.telemetry;
1568
+ if ((telemetry == null ? void 0 : telemetry.enabled) && this.ctx.env) {
1569
+ void (0, import_init.initTelemetry)({
1570
+ tunnelUrl: `${(0, import_userManagementClient.getBaseUrl)(this.ctx.env)}telemetry`,
1571
+ sampleRate: telemetry.sample_rate,
1572
+ sdkType: this.platformUtils.sdkType,
1573
+ sdkVersion: _ParaCore.version,
1574
+ partnerId: this.partner.id,
1575
+ // Only true in DEV — adds localhost to the trace-propagation allow-list
1576
+ // so FE → local user-management requests carry traceparent. Never set in
1577
+ // sandbox/beta/prod, where localhost shouldn't appear in our request URLs.
1578
+ isDev: this.ctx.env === import_types.Environment.DEV,
1579
+ // Portal pages run the same ParaCore code path as the partner-app SDK, but
1580
+ // they're a different process boundary (popup/iframe) and a different surface
1581
+ // for ops to debug. Pass through the portal posture so initTelemetry can stamp
1582
+ // the right `service.name` and split SDK-side vs portal-side spans in the
1583
+ // backend. Uses the class-level isPortal() (same logic the rest of the SDK
1584
+ // gates portal-only paths on).
1585
+ isPortal: this.isPortal()
1586
+ });
1587
+ }
1386
1588
  return this.partner;
1387
1589
  });
1388
1590
  }
@@ -1408,15 +1610,30 @@ const _ParaCore = class _ParaCore {
1408
1610
  if (!wallet) {
1409
1611
  throw new Error("wallet not found");
1410
1612
  }
1411
- if (wallet.scheme !== "DKLS") {
1412
- throw new Error("invalid wallet scheme");
1413
- }
1414
- return yield this.platformUtils.getPrivateKey(
1415
- this.ctx,
1416
- this.userId,
1417
- wallet.id,
1418
- wallet.signer,
1419
- this.retrieveSessionCookie()
1613
+ return (0, import_tracer.wrapWithSpan)(
1614
+ "mpc.export",
1615
+ () => __async(this, null, function* () {
1616
+ if (wallet.scheme === "ED25519") {
1617
+ return yield this.platformUtils.getED25519PrivateKey(
1618
+ this.ctx,
1619
+ this.userId,
1620
+ wallet.id,
1621
+ wallet.signer,
1622
+ this.retrieveSessionCookie()
1623
+ );
1624
+ }
1625
+ if (wallet.scheme !== "DKLS") {
1626
+ throw new Error("invalid wallet scheme");
1627
+ }
1628
+ return yield this.platformUtils.getPrivateKey(
1629
+ this.ctx,
1630
+ this.userId,
1631
+ wallet.id,
1632
+ wallet.signer,
1633
+ this.retrieveSessionCookie()
1634
+ );
1635
+ }),
1636
+ { "wallet.scheme": wallet.scheme, "wallet.id": wallet.id, "wallet.type": wallet.type }
1420
1637
  );
1421
1638
  });
1422
1639
  }
@@ -1471,6 +1688,19 @@ const _ParaCore = class _ParaCore {
1471
1688
  return yield __privateGet(this, _authService).signExternalWalletVerification(params);
1472
1689
  });
1473
1690
  }
1691
+ // Direct-to-wallet sign for an external-wallet user who's already authenticated.
1692
+ // The signExternalWalletVerification() path above dispatches a state-machine event
1693
+ // that's only handled from the `awaiting_wallet_signature` state — after login
1694
+ // the machine has moved past that, so the event is silently dropped and the
1695
+ // wallet never gets prompted. The re-auth flow (popup-driven SIWE for export-key
1696
+ // / transaction-review) needs the signature regardless of machine state, so it
1697
+ // routes here and reads the signature back synchronously.
1698
+ signExternalWalletMessageForReauth(params) {
1699
+ return __async(this, null, function* () {
1700
+ const _a = yield __privateGet(this, _externalWalletService).signMessage(params), { signature } = _a, rest = __objRest(_a, ["signature"]);
1701
+ return __spreadValues({ externalWallet: params.externalWallet, signedMessage: signature }, rest);
1702
+ });
1703
+ }
1474
1704
  verifyExternalWalletLink(opts) {
1475
1705
  return __async(this, null, function* () {
1476
1706
  const accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this, ["EXTERNAL_WALLET"]);
@@ -1547,6 +1777,8 @@ const _ParaCore = class _ParaCore {
1547
1777
  */
1548
1778
  verify2fa(_0) {
1549
1779
  return __async(this, arguments, function* ({ auth, verificationCode }) {
1780
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
1781
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, { kind: "2fa" });
1550
1782
  const res = yield this.ctx.client.verify2FA(auth, verificationCode);
1551
1783
  return {
1552
1784
  initiatedAt: res.data.initiatedAt,
@@ -1562,6 +1794,8 @@ const _ParaCore = class _ParaCore {
1562
1794
  * */
1563
1795
  setup2fa() {
1564
1796
  return __async(this, null, function* () {
1797
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
1798
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, { kind: "2fa" });
1565
1799
  const userId = this.assertUserId();
1566
1800
  const res = yield this.ctx.client.setup2FA(userId);
1567
1801
  return res;
@@ -1574,6 +1808,8 @@ const _ParaCore = class _ParaCore {
1574
1808
  */
1575
1809
  enable2fa(_0) {
1576
1810
  return __async(this, arguments, function* ({ verificationCode }) {
1811
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
1812
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, { kind: "2fa" });
1577
1813
  const userId = this.assertUserId();
1578
1814
  yield this.ctx.client.enable2FA(userId, verificationCode);
1579
1815
  });
@@ -1582,8 +1818,8 @@ const _ParaCore = class _ParaCore {
1582
1818
  * Resend a verification email for the current user.
1583
1819
  */
1584
1820
  resendVerificationCode(_0) {
1585
- return __async(this, arguments, function* ({ type: reason = "SIGNUP" }) {
1586
- return yield __privateGet(this, _authService).resendVerificationCode({ type: reason });
1821
+ return __async(this, arguments, function* ({ type: reason = "SIGNUP", deliveryChannel }) {
1822
+ return yield __privateGet(this, _authService).resendVerificationCode({ type: reason, deliveryChannel });
1587
1823
  });
1588
1824
  }
1589
1825
  /**
@@ -1758,6 +1994,8 @@ const _ParaCore = class _ParaCore {
1758
1994
  */
1759
1995
  getOAuthUrl(params) {
1760
1996
  return __async(this, null, function* () {
1997
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
1998
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, { kind: "oauth", method: params.method });
1761
1999
  return yield __privateGet(this, _portalUrlService).getOAuthUrl(params);
1762
2000
  });
1763
2001
  }
@@ -1831,6 +2069,8 @@ const _ParaCore = class _ParaCore {
1831
2069
  }
1832
2070
  verifyOAuth(params) {
1833
2071
  return __async(this, null, function* () {
2072
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
2073
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, { kind: "oauth", method: params.method });
1834
2074
  return yield this.verifyOAuthProcess(__spreadProps(__spreadValues({}, params), { isLinkAccount: false }));
1835
2075
  });
1836
2076
  }
@@ -2002,8 +2242,6 @@ const _ParaCore = class _ParaCore {
2002
2242
  });
2003
2243
  }
2004
2244
  /**
2005
- * @deprecated Use the REST API (`POST /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
2006
- *
2007
2245
  * Creates a new pregenerated wallet.
2008
2246
  *
2009
2247
  * @param {Object} opts the options object.
@@ -2014,13 +2252,10 @@ const _ParaCore = class _ParaCore {
2014
2252
  **/
2015
2253
  createPregenWallet(params) {
2016
2254
  return __async(this, null, function* () {
2017
- (0, import_deprecation.warnPregenDeprecation)("createPregenWallet");
2018
2255
  return yield __privateGet(this, _pregenWalletService).createPregenWallet(params);
2019
2256
  });
2020
2257
  }
2021
2258
  /**
2022
- * @deprecated Use the REST API (`POST /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
2023
- *
2024
2259
  * Creates new pregenerated wallets for each desired type.
2025
2260
  * If no types are provided, this method will create one for each of the non-optional types
2026
2261
  * specified in the instance's `supportedWalletTypes` array that are not already present.
@@ -2032,13 +2267,10 @@ const _ParaCore = class _ParaCore {
2032
2267
  **/
2033
2268
  createPregenWalletPerType(params) {
2034
2269
  return __async(this, null, function* () {
2035
- (0, import_deprecation.warnPregenDeprecation)("createPregenWalletPerType");
2036
2270
  return yield __privateGet(this, _pregenWalletService).createPregenWalletPerType(params);
2037
2271
  });
2038
2272
  }
2039
2273
  /**
2040
- * @deprecated Use the REST API (`POST /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
2041
- *
2042
2274
  * Claims a pregenerated wallet.
2043
2275
  * @param {Object} opts the options object.
2044
2276
  * @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
@@ -2047,13 +2279,10 @@ const _ParaCore = class _ParaCore {
2047
2279
  **/
2048
2280
  claimPregenWallets() {
2049
2281
  return __async(this, arguments, function* (params = {}) {
2050
- (0, import_deprecation.warnPregenDeprecation)("claimPregenWallets");
2051
2282
  return yield __privateGet(this, _pregenWalletService).claimPregenWallets(params);
2052
2283
  });
2053
2284
  }
2054
2285
  /**
2055
- * @deprecated Use the REST API (`PATCH /v1/wallets/:id`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
2056
- *
2057
2286
  * Updates the identifier for a pregen wallet.
2058
2287
  * @param {Object} opts the options object.
2059
2288
  * @param {string} opts.walletId the pregen wallet ID
@@ -2062,13 +2291,10 @@ const _ParaCore = class _ParaCore {
2062
2291
  **/
2063
2292
  updatePregenWalletIdentifier(params) {
2064
2293
  return __async(this, null, function* () {
2065
- (0, import_deprecation.warnPregenDeprecation)("updatePregenWalletIdentifier");
2066
2294
  return yield __privateGet(this, _pregenWalletService).updatePregenWalletIdentifier(params);
2067
2295
  });
2068
2296
  }
2069
2297
  /**
2070
- * @deprecated Use the REST API (`GET /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
2071
- *
2072
2298
  * Checks if a pregen Wallet exists for the given identifier with the current partner.
2073
2299
  * @param {Object} opts the options object.
2074
2300
  * @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
@@ -2077,13 +2303,10 @@ const _ParaCore = class _ParaCore {
2077
2303
  **/
2078
2304
  hasPregenWallet(params) {
2079
2305
  return __async(this, null, function* () {
2080
- (0, import_deprecation.warnPregenDeprecation)("hasPregenWallet");
2081
2306
  return yield __privateGet(this, _pregenWalletService).hasPregenWallet(params);
2082
2307
  });
2083
2308
  }
2084
2309
  /**
2085
- * @deprecated Use the REST API (`GET /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
2086
- *
2087
2310
  * Get pregen wallets for the given identifier.
2088
2311
  * @param {Object} opts the options object.
2089
2312
  * @param {string} opts.pregenIdentifier - the identifier of the user claiming the wallet
@@ -2092,12 +2315,13 @@ const _ParaCore = class _ParaCore {
2092
2315
  **/
2093
2316
  getPregenWallets() {
2094
2317
  return __async(this, arguments, function* (params = {}) {
2095
- (0, import_deprecation.warnPregenDeprecation)("getPregenWallets");
2096
2318
  return yield __privateGet(this, _pregenWalletService).getPregenWallets(params);
2097
2319
  });
2098
2320
  }
2099
2321
  createGuestWallets() {
2100
2322
  return __async(this, null, function* () {
2323
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
2324
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, { kind: "guest" });
2101
2325
  return yield __privateGet(this, _pregenWalletService).createGuestWallets();
2102
2326
  });
2103
2327
  }
@@ -2137,6 +2361,9 @@ const _ParaCore = class _ParaCore {
2137
2361
  }
2138
2362
  getTransactionReviewUrl(transactionId, timeoutMs) {
2139
2363
  return __async(this, null, function* () {
2364
+ if (this.isExternalWalletAuth) {
2365
+ yield this.ctx.client.sessionAddPortalVerification();
2366
+ }
2140
2367
  const authMethods = yield this.supportedUserAuthMethods();
2141
2368
  const result = yield this.constructPortalUrl("txReview", {
2142
2369
  pathId: transactionId,
@@ -2164,11 +2391,11 @@ const _ParaCore = class _ParaCore {
2164
2391
  });
2165
2392
  }
2166
2393
  /**
2167
- * Requests testnet funds from the faucet for the specified wallet.
2394
+ * Submits a testnet faucet funding transaction for the specified wallet.
2168
2395
  * @param {RequestFaucetParams} params the options object.
2169
2396
  * @param {string} params.walletId the id of the wallet to fund.
2170
2397
  * @param {string} [params.chain] optional chain identifier to target a specific testnet.
2171
- * @returns the faucet transaction details, including the transaction hash and amount sent.
2398
+ * @returns the submitted faucet transaction details. Wait for the returned transaction hash to confirm before spending.
2172
2399
  */
2173
2400
  requestFaucet(params) {
2174
2401
  return __async(this, null, function* () {
@@ -2197,14 +2424,17 @@ const _ParaCore = class _ParaCore {
2197
2424
  onPoll,
2198
2425
  onTransactionReviewUrl
2199
2426
  }) {
2200
- var _a;
2201
2427
  __privateGet(this, _walletService).assertIsValidWalletId(walletId);
2202
2428
  const wallet = this.wallets[walletId];
2203
2429
  let signerId = this.userId;
2204
2430
  if (wallet.partnerId && !wallet.userId) {
2205
2431
  signerId = wallet.partnerId;
2206
2432
  }
2207
- let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2433
+ let signRes = yield (0, import_tracer.wrapWithSpan)(
2434
+ "mpc.sign",
2435
+ () => this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 }),
2436
+ { "wallet.scheme": wallet.scheme, "wallet.id": walletId }
2437
+ );
2208
2438
  let timeStart = Date.now();
2209
2439
  const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
2210
2440
  if (signRes.pendingTransactionId) {
@@ -2231,7 +2461,16 @@ const _ParaCore = class _ParaCore {
2231
2461
  yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2232
2462
  let pendingTransaction;
2233
2463
  try {
2234
- pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2464
+ pendingTransaction = yield (0, import_tracer.wrapWithSpan)(
2465
+ "tx.review.poll",
2466
+ (span) => __async(this, null, function* () {
2467
+ var _a;
2468
+ const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2469
+ span.setAttribute("polling.status", (res == null ? void 0 : res.approvedAt) ? "approved" : "pending");
2470
+ return res;
2471
+ }),
2472
+ { "pending_transaction.id": signRes.pendingTransactionId }
2473
+ );
2235
2474
  } catch (e) {
2236
2475
  const error = new import_errors.TransactionReviewDenied();
2237
2476
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
@@ -2241,7 +2480,11 @@ const _ParaCore = class _ParaCore {
2241
2480
  onPoll == null ? void 0 : onPoll();
2242
2481
  continue;
2243
2482
  } else {
2244
- signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2483
+ signRes = yield (0, import_tracer.wrapWithSpan)(
2484
+ "mpc.sign",
2485
+ () => this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 }),
2486
+ { "wallet.scheme": wallet.scheme, "wallet.id": walletId, "mpc.attempt": "post-review" }
2487
+ );
2245
2488
  break;
2246
2489
  }
2247
2490
  }
@@ -2311,22 +2554,25 @@ const _ParaCore = class _ParaCore {
2311
2554
  onPoll,
2312
2555
  onTransactionReviewUrl
2313
2556
  }) {
2314
- var _a;
2315
2557
  __privateGet(this, _walletService).assertIsValidWalletId(walletId);
2316
2558
  const wallet = this.wallets[walletId];
2317
2559
  let signerId = this.userId;
2318
2560
  if (wallet.partnerId && !wallet.userId) {
2319
2561
  signerId = wallet.partnerId;
2320
2562
  }
2321
- let signRes = yield this.platformUtils.signTransaction(
2322
- this.ctx,
2323
- signerId,
2324
- walletId,
2325
- this.wallets[walletId].signer,
2326
- rlpEncodedTxBase64,
2327
- chainId,
2328
- this.retrieveSessionCookie(),
2329
- wallet.scheme === "DKLS"
2563
+ let signRes = yield (0, import_tracer.wrapWithSpan)(
2564
+ "mpc.sign",
2565
+ () => this.platformUtils.signTransaction(
2566
+ this.ctx,
2567
+ signerId,
2568
+ walletId,
2569
+ this.wallets[walletId].signer,
2570
+ rlpEncodedTxBase64,
2571
+ chainId,
2572
+ this.retrieveSessionCookie(),
2573
+ wallet.scheme === "DKLS"
2574
+ ),
2575
+ { "wallet.scheme": wallet.scheme, "wallet.id": walletId, "tx.kind": "transaction" }
2330
2576
  );
2331
2577
  let timeStart = Date.now();
2332
2578
  const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
@@ -2350,9 +2596,19 @@ const _ParaCore = class _ParaCore {
2350
2596
  break;
2351
2597
  }
2352
2598
  yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2599
+ const pendingTxId = signRes.pendingTransactionId;
2353
2600
  let pendingTransaction;
2354
2601
  try {
2355
- pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2602
+ pendingTransaction = yield (0, import_tracer.wrapWithSpan)(
2603
+ "tx.review.poll",
2604
+ (span) => __async(this, null, function* () {
2605
+ var _a;
2606
+ const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, pendingTxId)).data) == null ? void 0 : _a.pendingTransaction;
2607
+ span.setAttribute("polling.status", (res == null ? void 0 : res.approvedAt) ? "approved" : "pending");
2608
+ return res;
2609
+ }),
2610
+ { "pending_transaction.id": pendingTxId }
2611
+ );
2356
2612
  } catch (e) {
2357
2613
  const error = new import_errors.TransactionReviewDenied();
2358
2614
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
@@ -2362,15 +2618,19 @@ const _ParaCore = class _ParaCore {
2362
2618
  onPoll == null ? void 0 : onPoll();
2363
2619
  continue;
2364
2620
  } else {
2365
- signRes = yield this.platformUtils.signTransaction(
2366
- this.ctx,
2367
- signerId,
2368
- walletId,
2369
- this.wallets[walletId].signer,
2370
- rlpEncodedTxBase64,
2371
- chainId,
2372
- this.retrieveSessionCookie(),
2373
- wallet.scheme === "DKLS"
2621
+ signRes = yield (0, import_tracer.wrapWithSpan)(
2622
+ "mpc.sign",
2623
+ () => this.platformUtils.signTransaction(
2624
+ this.ctx,
2625
+ signerId,
2626
+ walletId,
2627
+ this.wallets[walletId].signer,
2628
+ rlpEncodedTxBase64,
2629
+ chainId,
2630
+ this.retrieveSessionCookie(),
2631
+ wallet.scheme === "DKLS"
2632
+ ),
2633
+ { "wallet.scheme": wallet.scheme, "wallet.id": walletId, "tx.kind": "transaction", "mpc.attempt": "post-review" }
2374
2634
  );
2375
2635
  break;
2376
2636
  }
@@ -2642,7 +2902,8 @@ const _ParaCore = class _ParaCore {
2642
2902
  useLocalFiles: this.ctx.useLocalFiles,
2643
2903
  useDKLS: this.ctx.useDKLS,
2644
2904
  cosmosPrefix: this.ctx.cosmosPrefix
2645
- }
2905
+ },
2906
+ config: this.config
2646
2907
  });
2647
2908
  return `Para ${JSON.stringify(obj, null, 2)}`;
2648
2909
  }
@@ -2677,16 +2938,26 @@ const _ParaCore = class _ParaCore {
2677
2938
  }
2678
2939
  signUpOrLogIn(params) {
2679
2940
  return __async(this, null, function* () {
2941
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
2942
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, {
2943
+ kind: (0, import_user_management_client.extractAuthInfo)(params.auth, { isRequired: true }).authType
2944
+ });
2680
2945
  return yield __privateGet(this, _authService).signUpOrLogIn(params);
2681
2946
  });
2682
2947
  }
2683
2948
  authenticateWithEmailOrPhone(params) {
2684
2949
  return __async(this, null, function* () {
2950
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
2951
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, {
2952
+ kind: (0, import_user_management_client.extractAuthInfo)(params.auth, { isRequired: true }).authType
2953
+ });
2685
2954
  return yield __privateGet(this, _authService).authenticateWithEmailOrPhone(params);
2686
2955
  });
2687
2956
  }
2688
2957
  authenticateWithOAuth(params) {
2689
2958
  return __async(this, null, function* () {
2959
+ yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
2960
+ (0, import_partnerConfigGating.assertConfigAllowed)(this.config, { kind: "oauth", method: params.method });
2690
2961
  return yield __privateGet(this, _authService).authenticateWithOAuth(params);
2691
2962
  });
2692
2963
  }
@@ -2822,16 +3093,17 @@ const _ParaCore = class _ParaCore {
2822
3093
  }
2823
3094
  sendLoginCode() {
2824
3095
  return __async(this, null, function* () {
2825
- const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
3096
+ const { userId, deliveryChannel, fallbackUsed, fallbackChannel, isSmsAllowed } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
2826
3097
  yield this.setUserId(userId);
2827
- return { userId };
3098
+ return { userId, deliveryChannel, fallbackUsed, fallbackChannel, isSmsAllowed };
2828
3099
  });
2829
3100
  }
2830
3101
  exportPrivateKey() {
2831
3102
  return __async(this, arguments, function* (args = {}) {
3103
+ var _a;
2832
3104
  let walletId = args == null ? void 0 : args.walletId;
2833
3105
  if (!(args == null ? void 0 : args.walletId)) {
2834
- walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS"] });
3106
+ walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS", "ED25519"] });
2835
3107
  }
2836
3108
  const wallet = this.wallets[walletId];
2837
3109
  if (this.externalWallets[walletId]) {
@@ -2840,28 +3112,38 @@ const _ParaCore = class _ParaCore {
2840
3112
  if (!wallet || !wallet.signer) {
2841
3113
  throw new Error("Wallet not found with id: " + walletId);
2842
3114
  }
2843
- if (wallet.scheme !== "DKLS") {
2844
- throw new Error("Cannot export private key for a Solana wallet");
2845
- }
2846
3115
  if (wallet.isPregen && !!wallet.pregenIdentifier && wallet.pregenIdentifierType !== "GUEST_ID") {
2847
3116
  throw new Error("Cannot export private key for a pregenerated wallet");
2848
3117
  }
2849
3118
  if (args.shouldOpenPopup) {
2850
3119
  this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.EXPORT_PRIVATE_KEY });
2851
3120
  }
2852
- const authMethods = yield this.supportedUserAuthMethods();
2853
- const exportPrivateKeyResult = yield this.constructPortalUrl("exportPrivateKey", {
2854
- pathId: walletId,
2855
- useLegacyUrl: authMethods.has(import_user_management_client.AuthMethod.PASSKEY)
2856
- });
2857
- const exportPrivateKeyUrl = exportPrivateKeyResult.url;
2858
- if (args.shouldOpenPopup) {
2859
- this.popupWindow.location.href = exportPrivateKeyUrl;
3121
+ try {
3122
+ if (this.isExternalWalletAuth) {
3123
+ yield this.ctx.client.sessionAddPortalVerification();
3124
+ }
3125
+ const authMethods = yield this.supportedUserAuthMethods();
3126
+ const exportPrivateKeyResult = yield this.constructPortalUrl("exportPrivateKey", {
3127
+ pathId: walletId,
3128
+ useLegacyUrl: authMethods.has(import_user_management_client.AuthMethod.PASSKEY)
3129
+ });
3130
+ const exportPrivateKeyUrl = exportPrivateKeyResult.url;
3131
+ if (args.shouldOpenPopup) {
3132
+ this.popupWindow.location.href = exportPrivateKeyUrl;
3133
+ }
3134
+ return {
3135
+ url: exportPrivateKeyUrl,
3136
+ popupWindow: this.popupWindow
3137
+ };
3138
+ } catch (err) {
3139
+ if (args.shouldOpenPopup) {
3140
+ try {
3141
+ (_a = this.popupWindow) == null ? void 0 : _a.close();
3142
+ } catch (e) {
3143
+ }
3144
+ }
3145
+ throw err;
2860
3146
  }
2861
- return {
2862
- url: exportPrivateKeyUrl,
2863
- popupWindow: this.popupWindow
2864
- };
2865
3147
  });
2866
3148
  }
2867
3149
  };
@@ -2874,7 +3156,54 @@ _pollingService = new WeakMap();
2874
3156
  _portalUrlService = new WeakMap();
2875
3157
  _sessionManagementService = new WeakMap();
2876
3158
  _debugLogsEnabled = new WeakMap();
3159
+ _configChangeListeners = new WeakMap();
2877
3160
  _ParaCore_instances = new WeakSet();
3161
+ notifyConfigChange_fn = function() {
3162
+ __privateGet(this, _configChangeListeners).forEach((cb) => cb());
3163
+ };
3164
+ _sdkConfigOverrides = new WeakMap();
3165
+ _configMemo = new WeakMap();
3166
+ /**
3167
+ * Drift telemetry. Currently fires only on `rpcUrl` (the only
3168
+ * remaining override-able field that's typically authoritative server-side
3169
+ * — `rpcUrl` SDK override is legitimate for local-dev, but if a consumer
3170
+ * silently overrides it in prod we want operators to know).
3171
+ *
3172
+ * Fires once per `(scope, key)` per session.
3173
+ *
3174
+ * Comparison baseline is the merge chain WITHOUT the SDK overrides layer
3175
+ * (i.e. the authoritative chain: `defaults ⊕ ecosystem ⊕ partner`). Today
3176
+ * with no ecosystem layer this resolves to the partner record values, but
3177
+ * computing it via the merge keeps the comparison correct when ecosystem
3178
+ * ships and an org overrides `rpcUrl` for its child partners.
3179
+ *
3180
+ * `appName` and `partnerLinks.*` are no longer overridable — they're 1:1
3181
+ * with the apikey/project and have no per-instance use case. Drift
3182
+ * telemetry for those was removed when they were excluded from
3183
+ * `SdkOverridableAppConfig`.
3184
+ */
3185
+ warnPartnerConfigDrift_fn = function() {
3186
+ var _a;
3187
+ if (!this.partner || !__privateGet(this, _sdkConfigOverrides)) return;
3188
+ const baseline = __privateMethod(this, _ParaCore_instances, configWithoutSdkOverrides_fn).call(this);
3189
+ const sdkRpcUrl = __privateGet(this, _sdkConfigOverrides).rpcUrl;
3190
+ if (sdkRpcUrl && sdkRpcUrl !== baseline.rpcUrl) {
3191
+ (0, import_deprecation.warnOnce)(
3192
+ "partnerConfigDrift",
3193
+ "rpcUrl",
3194
+ `rpcUrl SDK override "${sdkRpcUrl}" disagrees with the partner record "${(_a = baseline.rpcUrl) != null ? _a : "(unset)"}". This is expected for local-dev; in production, configure rpcUrl via the developer portal.`
3195
+ );
3196
+ }
3197
+ };
3198
+ /**
3199
+ * Resolved config WITHOUT the SDK override layer. Used by drift telemetry
3200
+ * to compare overrides against the authoritative chain. Slot for the
3201
+ * future ecosystem layer between `defaults` and `partner`.
3202
+ */
3203
+ configWithoutSdkOverrides_fn = function() {
3204
+ const partnerLayer = this.partner ? (0, import_utils2.partnerToAppConfigLayer)(this.partner) : void 0;
3205
+ return (0, import_utils2.mergePartnerAppConfig)(import_utils2.DEFAULT_PARTNER_APP_CONFIG, partnerLayer);
3206
+ };
2878
3207
  assertPartner_fn = function() {
2879
3208
  return __async(this, null, function* () {
2880
3209
  var _a, _b;
@@ -2939,6 +3268,26 @@ assertIsLinkingAccountOrStart_fn = function(type) {
2939
3268
  });
2940
3269
  };
2941
3270
  waitForLoginProcess_fn = function() {
3271
+ return __async(this, arguments, function* ({
3272
+ isCanceled = () => false,
3273
+ onCancel,
3274
+ onPoll,
3275
+ skipSessionRefresh = false,
3276
+ isSwitchingWallets = false
3277
+ } = {}) {
3278
+ return (0, import_tracer.wrapWithSpan)("polling.waitForLoginProcess", (span) => __async(this, null, function* () {
3279
+ span.setAttribute("polling.is_switching_wallets", isSwitchingWallets);
3280
+ return __privateMethod(this, _ParaCore_instances, waitForLoginProcessImpl_fn).call(this, {
3281
+ isCanceled,
3282
+ onCancel,
3283
+ onPoll,
3284
+ skipSessionRefresh,
3285
+ isSwitchingWallets
3286
+ });
3287
+ }));
3288
+ });
3289
+ };
3290
+ waitForLoginProcessImpl_fn = function() {
2942
3291
  return __async(this, arguments, function* ({
2943
3292
  isCanceled = () => false,
2944
3293
  onCancel,
@@ -3072,7 +3421,7 @@ waitForLoginProcess_fn = function() {
3072
3421
  yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
3073
3422
  this.devLog("[waitForLoginProcess] Setup after login complete");
3074
3423
  this.devLog("[waitForLoginProcess] Claiming pregen wallets");
3075
- yield __privateGet(this, _pregenWalletService).claimPregenWallets();
3424
+ yield this.claimPregenWallets();
3076
3425
  this.devLog("[waitForLoginProcess] Pregen wallets claimed");
3077
3426
  const resp = {
3078
3427
  needsWallet: needsWallet || Object.values(this.wallets).length === 0,
@@ -3133,6 +3482,7 @@ logout_fn = function() {
3133
3482
  __privateGet(this, _authService).userId = void 0;
3134
3483
  __privateGet(this, _sessionManagementService).sessionCookie = void 0;
3135
3484
  this.isEnclaveUser = false;
3485
+ (0, import_uxStateSpanProcessor.setCurrentUserId)(void 0);
3136
3486
  if (isSessionActive) {
3137
3487
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGOUT_EVENT, null);
3138
3488
  if (!skipStateReset) {