@getpara/core-sdk 3.0.0-alpha.1 → 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.
- package/dist/cjs/ParaCore.js +436 -86
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/cryptography/utils.js +5 -2
- package/dist/cjs/errors.js +10 -0
- package/dist/cjs/external/userManagementClient.js +21 -4
- package/dist/cjs/index.js +67 -1
- package/dist/cjs/services/AuthService.js +66 -47
- package/dist/cjs/services/LoginFlowService.js +30 -27
- package/dist/cjs/services/PollingService.js +100 -75
- package/dist/cjs/services/PortalUrlService.js +112 -19
- package/dist/cjs/services/PregenWalletService.js +125 -76
- package/dist/cjs/services/SessionManagementService.js +15 -8
- package/dist/cjs/services/SignupFlowService.js +52 -47
- package/dist/cjs/services/VerificationFlowService.js +13 -10
- package/dist/cjs/services/WalletService.js +51 -36
- package/dist/cjs/shares/enclave.js +44 -24
- package/dist/cjs/state/CoreStateManager.js +17 -5
- package/dist/cjs/state/actors/setupPara.js +4 -1
- package/dist/cjs/state/machines/walletStateMachine.js +22 -0
- package/dist/cjs/telemetry/config.js +15 -0
- package/dist/cjs/telemetry/init.js +185 -0
- package/dist/cjs/telemetry/modalSession.js +54 -0
- package/dist/cjs/telemetry/session.js +39 -0
- package/dist/cjs/telemetry/tracer.js +126 -0
- package/dist/cjs/telemetry/uxAction.js +30 -0
- package/dist/cjs/telemetry/uxBaggagePropagator.js +58 -0
- package/dist/cjs/telemetry/uxState.js +46 -0
- package/dist/cjs/telemetry/uxStateSpanProcessor.js +51 -0
- package/dist/cjs/utils/configEncoding.js +98 -0
- package/dist/cjs/utils/deprecation.js +13 -13
- package/dist/cjs/utils/index.js +11 -0
- package/dist/cjs/utils/partnerConfig.js +103 -0
- package/dist/cjs/utils/partnerConfigGating.js +83 -0
- package/dist/cjs/utils/stateErrorHelpers.js +6 -1
- package/dist/cjs/utils/url.js +10 -2
- package/dist/esm/ParaCore.js +441 -88
- package/dist/esm/constants.js +1 -1
- package/dist/esm/cryptography/utils.js +5 -2
- package/dist/esm/errors.js +9 -0
- package/dist/esm/external/userManagementClient.js +21 -4
- package/dist/esm/index.js +58 -4
- package/dist/esm/services/AuthService.js +66 -47
- package/dist/esm/services/LoginFlowService.js +30 -27
- package/dist/esm/services/PollingService.js +100 -75
- package/dist/esm/services/PortalUrlService.js +112 -19
- package/dist/esm/services/PregenWalletService.js +125 -76
- package/dist/esm/services/SessionManagementService.js +15 -8
- package/dist/esm/services/SignupFlowService.js +52 -47
- package/dist/esm/services/VerificationFlowService.js +13 -10
- package/dist/esm/services/WalletService.js +51 -36
- package/dist/esm/shares/enclave.js +44 -24
- package/dist/esm/state/CoreStateManager.js +17 -5
- package/dist/esm/state/actors/setupPara.js +4 -1
- package/dist/esm/state/machines/walletStateMachine.js +22 -0
- package/dist/esm/telemetry/config.js +0 -0
- package/dist/esm/telemetry/init.js +118 -0
- package/dist/esm/telemetry/modalSession.js +29 -0
- package/dist/esm/telemetry/session.js +16 -0
- package/dist/esm/telemetry/tracer.js +84 -0
- package/dist/esm/telemetry/uxAction.js +8 -0
- package/dist/esm/telemetry/uxBaggagePropagator.js +35 -0
- package/dist/esm/telemetry/uxState.js +21 -0
- package/dist/esm/telemetry/uxStateSpanProcessor.js +28 -0
- package/dist/esm/utils/configEncoding.js +45 -0
- package/dist/esm/utils/deprecation.js +11 -12
- package/dist/esm/utils/index.js +6 -0
- package/dist/esm/utils/partnerConfig.js +67 -0
- package/dist/esm/utils/partnerConfigGating.js +61 -0
- package/dist/esm/utils/stateErrorHelpers.js +6 -1
- package/dist/esm/utils/url.js +10 -2
- package/dist/types/ParaCore.d.ts +101 -19
- package/dist/types/PlatformUtils.d.ts +1 -0
- package/dist/types/errors.d.ts +26 -0
- package/dist/types/external/userManagementClient.d.ts +2 -1
- package/dist/types/index.d.ts +15 -3
- package/dist/types/services/types/AuthServiceTypes.d.ts +10 -3
- package/dist/types/services/types/PortalUrlServiceTypes.d.ts +3 -3
- package/dist/types/services/types/WalletServiceTypes.d.ts +4 -0
- package/dist/types/state/actors/setupPara.d.ts +18 -0
- package/dist/types/state/machines/authStateMachine.d.ts +1 -1
- package/dist/types/state/machines/coreStateMachine.d.ts +30 -6
- package/dist/types/state/machines/walletStateMachine.d.ts +4 -0
- package/dist/types/state/types/core.d.ts +7 -1
- package/dist/types/telemetry/config.d.ts +4 -0
- package/dist/types/telemetry/init.d.ts +17 -0
- package/dist/types/telemetry/modalSession.d.ts +5 -0
- package/dist/types/telemetry/session.d.ts +2 -0
- package/dist/types/telemetry/tracer.d.ts +10 -0
- package/dist/types/telemetry/uxAction.d.ts +3 -0
- package/dist/types/telemetry/uxBaggagePropagator.d.ts +7 -0
- package/dist/types/telemetry/uxState.d.ts +8 -0
- package/dist/types/telemetry/uxStateSpanProcessor.d.ts +9 -0
- package/dist/types/types/config.d.ts +15 -3
- package/dist/types/types/coreApi.d.ts +7 -9
- package/dist/types/types/serviceInterfaces.d.ts +5 -3
- package/dist/types/types/util.d.ts +2 -15
- package/dist/types/utils/configEncoding.d.ts +51 -0
- package/dist/types/utils/deprecation.d.ts +3 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/partnerConfig.d.ts +28 -0
- package/dist/types/utils/partnerConfigGating.d.ts +48 -0
- package/dist/types/utils/url.d.ts +3 -2
- package/package.json +14 -4
package/dist/esm/ParaCore.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
__spreadProps,
|
|
9
9
|
__spreadValues
|
|
10
10
|
} from "./chunk-7B52C2XE.js";
|
|
11
|
-
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;
|
|
11
|
+
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;
|
|
12
12
|
import { Buffer as NodeBuffer } from "buffer";
|
|
13
13
|
if (typeof global !== "undefined") {
|
|
14
14
|
global.Buffer = global.Buffer || NodeBuffer;
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
import forge from "node-forge";
|
|
30
30
|
const { pki, jsbn } = forge;
|
|
31
31
|
import { decryptWithPrivateKey, getAsymmetricKeyPair } from "./cryptography/utils.js";
|
|
32
|
-
import { initClient } from "./external/userManagementClient.js";
|
|
32
|
+
import { getBaseUrl, initClient } from "./external/userManagementClient.js";
|
|
33
33
|
import * as mpcComputationClient from "./external/mpcComputationClient.js";
|
|
34
34
|
import {
|
|
35
35
|
Environment,
|
|
@@ -44,12 +44,16 @@ import {
|
|
|
44
44
|
getParaConnectBaseUrl,
|
|
45
45
|
jsonParse,
|
|
46
46
|
migrateWallet,
|
|
47
|
+
mergePartnerAppConfig,
|
|
48
|
+
partnerToAppConfigLayer,
|
|
49
|
+
DEFAULT_PARTNER_APP_CONFIG,
|
|
47
50
|
setupListeners,
|
|
48
51
|
WalletSchemeTypeMap,
|
|
49
52
|
isPortal
|
|
50
53
|
} from "./utils/index.js";
|
|
51
54
|
import { waitForAuthStateChange } from "./utils/stateListener.js";
|
|
52
|
-
import {
|
|
55
|
+
import { warnOnce } from "./utils/deprecation.js";
|
|
56
|
+
import { assertConfigAllowed } from "./utils/partnerConfigGating.js";
|
|
53
57
|
import { TransactionReviewDenied, TransactionReviewTimeout } from "./errors.js";
|
|
54
58
|
import * as constants from "./constants.js";
|
|
55
59
|
import { EnclaveClient } from "./shares/enclave.js";
|
|
@@ -61,6 +65,10 @@ import { PregenWalletService } from "./services/PregenWalletService.js";
|
|
|
61
65
|
import { PortalUrlService } from "./services/PortalUrlService.js";
|
|
62
66
|
import { SessionManagementService } from "./services/SessionManagementService.js";
|
|
63
67
|
import { ExternalWalletService } from "./services/ExternalWalletService.js";
|
|
68
|
+
import { wrapWithSpan } from "./telemetry/tracer.js";
|
|
69
|
+
import { setCurrentUserId } from "./telemetry/uxStateSpanProcessor.js";
|
|
70
|
+
import { initTelemetry } from "./telemetry/init.js";
|
|
71
|
+
import { recordActionOnSpan } from "./telemetry/uxAction.js";
|
|
64
72
|
const _ParaCore = class _ParaCore {
|
|
65
73
|
constructor(envOrApiKey, apiKeyOrOpts, opts) {
|
|
66
74
|
__privateAdd(this, _ParaCore_instances);
|
|
@@ -77,6 +85,28 @@ const _ParaCore = class _ParaCore {
|
|
|
77
85
|
this.isSwitchingWallets = false;
|
|
78
86
|
this.isNativePasskey = false;
|
|
79
87
|
this.isSetup = false;
|
|
88
|
+
// Notified whenever an input to `paraCore.config` changes — either the
|
|
89
|
+
// partner record (via `getPartner`) or the SDK override layer (via
|
|
90
|
+
// `setSdkConfigOverrides`). One signal covers both async-load and
|
|
91
|
+
// runtime-mutation cases, so consumers wire one subscription.
|
|
92
|
+
__privateAdd(this, _configChangeListeners, /* @__PURE__ */ new Set());
|
|
93
|
+
/**
|
|
94
|
+
* Phase 3 — SDK-side override layer applied on top of the partner layer.
|
|
95
|
+
*
|
|
96
|
+
* merge chain: defaults ⊕ ecosystem (future) ⊕ partner ⊕ #sdkConfigOverrides
|
|
97
|
+
*
|
|
98
|
+
* Initialized from `ConstructorOpts.configOverrides`. Mutable post-construction
|
|
99
|
+
* via `setSdkConfigOverrides` so reactive callers (e.g. `ParaProviderMin`'s
|
|
100
|
+
* `configOverrides` prop) can update it without rebuilding the ParaCore
|
|
101
|
+
* instance.
|
|
102
|
+
*
|
|
103
|
+
* Typed `Partial<SdkOverridableAppConfig>` — security/posture fields
|
|
104
|
+
* (`supportedAuthMethods`, `authConfig.twoFactorAuthEnabled`, etc.) are
|
|
105
|
+
* excluded at compile time, so no caller path can override them.
|
|
106
|
+
*/
|
|
107
|
+
__privateAdd(this, _sdkConfigOverrides);
|
|
108
|
+
/** Memoization for the `config` getter — invalidates on partner / overrides identity change. */
|
|
109
|
+
__privateAdd(this, _configMemo);
|
|
80
110
|
this.accountLinkInProgress = void 0;
|
|
81
111
|
this.isWorkerInitialized = false;
|
|
82
112
|
this.onRampPopup = void 0;
|
|
@@ -161,17 +191,45 @@ const _ParaCore = class _ParaCore {
|
|
|
161
191
|
}
|
|
162
192
|
throw err;
|
|
163
193
|
});
|
|
164
|
-
|
|
165
|
-
|
|
194
|
+
// Each wrapped method becomes one named span. wrapWithSpan handles recordException +
|
|
195
|
+
// ERROR status; the legacy /errors/sdk POST stays in trackError as a fallback during
|
|
196
|
+
// the cutover window — PR D removes it once we verify span error coverage in prod.
|
|
197
|
+
// Until telemetry is initialized (cold-start window before partner-config arrives),
|
|
198
|
+
// wrapWithSpan delegates to a no-op tracer so spans are dropped without overhead.
|
|
199
|
+
// The original method MUST be invoked inside wrapWithSpan's callback so its async
|
|
200
|
+
// chain (Promises, setTimeout, fetch) is created under the active-span context.
|
|
201
|
+
// Calling original.apply BEFORE wrapWithSpan starts the work in the root Zone —
|
|
202
|
+
// child spans then root independently because Zone.js can't trace context through
|
|
203
|
+
// Promises that were already in flight when the active span was set. All currently
|
|
204
|
+
// wrapped methods are async, so always returning a Promise here is safe.
|
|
205
|
+
this.wrapMethodsWithTracing = (entries) => {
|
|
206
|
+
for (const entry of entries) {
|
|
207
|
+
const methodName = typeof entry === "string" ? entry : entry.method;
|
|
208
|
+
const uxTargetId = typeof entry === "string" ? void 0 : entry.uxTargetId;
|
|
166
209
|
const original = this[methodName];
|
|
167
210
|
if (typeof original === "function") {
|
|
168
211
|
this[methodName] = (...args) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
212
|
+
var _a;
|
|
213
|
+
const attrs = __spreadValues({
|
|
214
|
+
"para.platform": this.platformUtils.sdkType,
|
|
215
|
+
"para.sdk_version": _ParaCore.version
|
|
216
|
+
}, ((_a = this.partner) == null ? void 0 : _a.id) ? { "para.partner_id": this.partner.id } : {});
|
|
217
|
+
return wrapWithSpan(
|
|
218
|
+
methodName,
|
|
219
|
+
(span) => __async(this, null, function* () {
|
|
220
|
+
if (!uxTargetId) return original.apply(this, args);
|
|
221
|
+
let outcome = "success";
|
|
222
|
+
try {
|
|
223
|
+
return yield original.apply(this, args);
|
|
224
|
+
} catch (err) {
|
|
225
|
+
outcome = "error";
|
|
226
|
+
throw err;
|
|
227
|
+
} finally {
|
|
228
|
+
recordActionOnSpan(span, uxTargetId, outcome);
|
|
229
|
+
}
|
|
230
|
+
}),
|
|
231
|
+
attrs
|
|
232
|
+
).catch((err) => this.trackError(methodName, err));
|
|
175
233
|
};
|
|
176
234
|
}
|
|
177
235
|
}
|
|
@@ -347,6 +405,7 @@ const _ParaCore = class _ParaCore {
|
|
|
347
405
|
}
|
|
348
406
|
if (!opts) opts = {};
|
|
349
407
|
__privateSet(this, _debugLogsEnabled, !!opts.enableDebugLogs);
|
|
408
|
+
__privateSet(this, _sdkConfigOverrides, opts.configOverrides);
|
|
350
409
|
const isE2E = env === "E2E" || envOrApiKey === "E2E";
|
|
351
410
|
if (isE2E && env !== Environment.SANDBOX) {
|
|
352
411
|
env = Environment.SANDBOX;
|
|
@@ -439,19 +498,32 @@ const _ParaCore = class _ParaCore {
|
|
|
439
498
|
this.initializeFromStorage();
|
|
440
499
|
setupListeners.bind(this)();
|
|
441
500
|
autoBind(this);
|
|
442
|
-
this.
|
|
501
|
+
this.wrapMethodsWithTracing([
|
|
443
502
|
"signUpOrLogIn",
|
|
503
|
+
// Methods marked with uxTargetId double as user-perceived UX actions —
|
|
504
|
+
// the wrap stamps ui.target_id / ui.outcome and emits a
|
|
505
|
+
// ui.action.completed event so the action's existing span IS the
|
|
506
|
+
// user-perceived measurement. No separate orphan span needed.
|
|
507
|
+
{ method: "authenticateWithEmailOrPhone", uxTargetId: "sign-in" },
|
|
508
|
+
"authenticateWithOAuth",
|
|
444
509
|
"verifyNewAccount",
|
|
510
|
+
"resendVerificationCode",
|
|
445
511
|
"waitForLogin",
|
|
446
512
|
"waitForSignup",
|
|
447
513
|
"waitForWalletCreation",
|
|
448
514
|
"verifyOAuth",
|
|
449
515
|
"verifyTelegram",
|
|
450
516
|
"verifyFarcaster",
|
|
517
|
+
"connectExternalWallet",
|
|
518
|
+
"loginExternalWallet",
|
|
519
|
+
"verifyExternalWallet",
|
|
520
|
+
"createWallet",
|
|
521
|
+
"createWalletPerType",
|
|
451
522
|
"createPregenWallet",
|
|
452
523
|
"claimPregenWallets",
|
|
453
524
|
"signMessage",
|
|
454
|
-
"signTransaction"
|
|
525
|
+
"signTransaction",
|
|
526
|
+
"logout"
|
|
455
527
|
]);
|
|
456
528
|
__privateGet(this, _stateManager).start();
|
|
457
529
|
}
|
|
@@ -579,6 +651,25 @@ const _ParaCore = class _ParaCore {
|
|
|
579
651
|
});
|
|
580
652
|
return () => unsubscribe();
|
|
581
653
|
}
|
|
654
|
+
/**
|
|
655
|
+
* Subscribe to changes in any input to `paraCore.config`:
|
|
656
|
+
* - partner record updates (lazy load after a failed eager fetch, etc.)
|
|
657
|
+
* - SDK override layer replacement (`setSdkConfigOverrides`)
|
|
658
|
+
*
|
|
659
|
+
* The callback fires after the relevant state has settled; subscribers
|
|
660
|
+
* should re-read `paraCore.config` to get the new merged value. Returns
|
|
661
|
+
* an unsubscribe function.
|
|
662
|
+
*
|
|
663
|
+
* Used by the React layer to bump its reactive `paraConfigVersion`
|
|
664
|
+
* counter; non-React consumers (server SDK, telemetry, etc.) can wire
|
|
665
|
+
* the same signal to invalidate their caches.
|
|
666
|
+
*/
|
|
667
|
+
onConfigChange(callback) {
|
|
668
|
+
__privateGet(this, _configChangeListeners).add(callback);
|
|
669
|
+
return () => {
|
|
670
|
+
__privateGet(this, _configChangeListeners).delete(callback);
|
|
671
|
+
};
|
|
672
|
+
}
|
|
582
673
|
get authInfo() {
|
|
583
674
|
var _a;
|
|
584
675
|
return (_a = __privateGet(this, _authService)) == null ? void 0 : _a.authInfo;
|
|
@@ -605,6 +696,73 @@ const _ParaCore = class _ParaCore {
|
|
|
605
696
|
get externalWalletConnectionType() {
|
|
606
697
|
return __privateGet(this, _externalWalletService).externalWalletConnectionType;
|
|
607
698
|
}
|
|
699
|
+
/**
|
|
700
|
+
* Resolved partner app config: partner ⊕ SDK overrides.
|
|
701
|
+
* Read-only view; safe to call before `getPartner` returns (yields `{}` via
|
|
702
|
+
* the merge of no layers).
|
|
703
|
+
*
|
|
704
|
+
* Memoized on `(this.partner, this.#sdkConfigOverrides)` identity. Multiple
|
|
705
|
+
* consumers read this (assertConfigAllowed at 9 sites, PortalUrlService,
|
|
706
|
+
* ExternalWalletWrapper); without memoization each access re-allocates a
|
|
707
|
+
* fresh merged object graph. Cache invalidates whenever `this.partner` is
|
|
708
|
+
* replaced (via getPartner) or `setSdkConfigOverrides` is called.
|
|
709
|
+
*/
|
|
710
|
+
get config() {
|
|
711
|
+
if (__privateGet(this, _configMemo) && __privateGet(this, _configMemo).partner === this.partner && __privateGet(this, _configMemo).overrides === __privateGet(this, _sdkConfigOverrides)) {
|
|
712
|
+
return __privateGet(this, _configMemo).result;
|
|
713
|
+
}
|
|
714
|
+
const partnerLayer = this.partner ? partnerToAppConfigLayer(this.partner) : void 0;
|
|
715
|
+
const result = mergePartnerAppConfig(DEFAULT_PARTNER_APP_CONFIG, partnerLayer, __privateGet(this, _sdkConfigOverrides));
|
|
716
|
+
__privateSet(this, _configMemo, { partner: this.partner, overrides: __privateGet(this, _sdkConfigOverrides), result });
|
|
717
|
+
return result;
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Read-only accessor for the raw partner record. Returns `undefined` until
|
|
721
|
+
* `getPartner` resolves (typically during `setup()`).
|
|
722
|
+
*
|
|
723
|
+
* The vast majority of partner-driven UX should consume `this.config`
|
|
724
|
+
* instead — that layer applies SDK overrides, exposes a stable shape, and
|
|
725
|
+
* is memoized. Use this getter only for fields that live on `PartnerEntity`
|
|
726
|
+
* but aren't promoted onto `PartnerAppConfig` (e.g. `logoUrl`, internal
|
|
727
|
+
* policy state). Whatever this returns is exactly what the public
|
|
728
|
+
* `getPartner(id)` API resolved on the last fetch — no additional
|
|
729
|
+
* processing.
|
|
730
|
+
*/
|
|
731
|
+
get partnerRecord() {
|
|
732
|
+
return this.partner;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Replace the SDK-side override layer. Generic surface — any post-construction
|
|
736
|
+
* caller (React provider, server-sdk, custom integration) can update overrides
|
|
737
|
+
* without rebuilding the ParaCore instance.
|
|
738
|
+
*
|
|
739
|
+
* Replaces wholesale (last writer wins). Pass undefined to clear.
|
|
740
|
+
*/
|
|
741
|
+
setSdkConfigOverrides(overrides) {
|
|
742
|
+
__privateSet(this, _sdkConfigOverrides, overrides);
|
|
743
|
+
__privateSet(this, _configMemo, void 0);
|
|
744
|
+
__privateMethod(this, _ParaCore_instances, notifyConfigChange_fn).call(this);
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Read the raw SDK override layer (NOT the merged config). Used by analytics
|
|
748
|
+
* to distinguish "what the consumer passed" from "what the resolver
|
|
749
|
+
* produced." For the resolved view, use `paraCore.config`.
|
|
750
|
+
*
|
|
751
|
+
* @internal — analytics-only. App code should read `paraCore.config` instead;
|
|
752
|
+
* this getter exposes pre-merge values that can change shape across
|
|
753
|
+
* versions without notice.
|
|
754
|
+
*
|
|
755
|
+
* @remarks Redaction contract — any analytics consumer dispatching this
|
|
756
|
+
* value to an external sink MUST sanitize first. Specifically `rpcUrl`
|
|
757
|
+
* commonly embeds API keys (Alchemy `/v2/<key>`, Infura `/v3/<key>`).
|
|
758
|
+
* Today the React modal owns redaction in
|
|
759
|
+
* `react-sdk-lite/src/modal/ParaModal.tsx` (`sanitizeSdkConfigOverridesForAnalytics`).
|
|
760
|
+
* When Phase 7's non-React analytics lands here, lift that helper next
|
|
761
|
+
* to this getter so all consumers share one sanitizer.
|
|
762
|
+
*/
|
|
763
|
+
get sdkConfigOverrides() {
|
|
764
|
+
return __privateGet(this, _sdkConfigOverrides);
|
|
765
|
+
}
|
|
608
766
|
get userId() {
|
|
609
767
|
var _a;
|
|
610
768
|
return (_a = __privateGet(this, _authService)) == null ? void 0 : _a.userId;
|
|
@@ -694,6 +852,27 @@ const _ParaCore = class _ParaCore {
|
|
|
694
852
|
var _a;
|
|
695
853
|
return (_a = this.partner) == null ? void 0 : _a.cosmosPrefix;
|
|
696
854
|
}
|
|
855
|
+
/**
|
|
856
|
+
* Auth methods the partner has enabled. Read off the raw partner record —
|
|
857
|
+
* partner-authoritative and excluded from `SdkOverridableAppConfig`, so it
|
|
858
|
+
* does NOT participate in the override merge chain.
|
|
859
|
+
*
|
|
860
|
+
* Named `supportedAuthMethodsList` (not `supportedAuthMethods`) to avoid
|
|
861
|
+
* colliding with the existing protected async `supportedAuthMethods(auth)`
|
|
862
|
+
* method that performs a backend lookup. Different concept, different shape.
|
|
863
|
+
*/
|
|
864
|
+
get supportedAuthMethodsList() {
|
|
865
|
+
var _a, _b;
|
|
866
|
+
return (_b = (_a = this.partner) == null ? void 0 : _a.supportedAuthMethods) != null ? _b : [AuthMethod.BASIC_LOGIN];
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Balance display config from the partner record. Partner-authoritative;
|
|
870
|
+
* excluded from `SdkOverridableAppConfig`.
|
|
871
|
+
*/
|
|
872
|
+
get balancesConfig() {
|
|
873
|
+
var _a;
|
|
874
|
+
return (_a = this.partner) == null ? void 0 : _a.balancesConfig;
|
|
875
|
+
}
|
|
697
876
|
get supportedAccountLinks() {
|
|
698
877
|
var _a, _b;
|
|
699
878
|
return (_b = (_a = this.partner) == null ? void 0 : _a.supportedAccountLinks) != null ? _b : [...LINKED_ACCOUNT_TYPES];
|
|
@@ -950,6 +1129,9 @@ const _ParaCore = class _ParaCore {
|
|
|
950
1129
|
},
|
|
951
1130
|
get accountLinkInProgress() {
|
|
952
1131
|
return self2.accountLinkInProgress;
|
|
1132
|
+
},
|
|
1133
|
+
get config() {
|
|
1134
|
+
return self2.config;
|
|
953
1135
|
}
|
|
954
1136
|
};
|
|
955
1137
|
}
|
|
@@ -1325,6 +1507,29 @@ const _ParaCore = class _ParaCore {
|
|
|
1325
1507
|
}
|
|
1326
1508
|
const res = yield this.ctx.client.getPartner(partnerId);
|
|
1327
1509
|
this.partner = res.data.partner;
|
|
1510
|
+
__privateMethod(this, _ParaCore_instances, warnPartnerConfigDrift_fn).call(this);
|
|
1511
|
+
__privateMethod(this, _ParaCore_instances, notifyConfigChange_fn).call(this);
|
|
1512
|
+
const telemetry = res.data.partner.telemetry;
|
|
1513
|
+
if ((telemetry == null ? void 0 : telemetry.enabled) && this.ctx.env) {
|
|
1514
|
+
void initTelemetry({
|
|
1515
|
+
tunnelUrl: `${getBaseUrl(this.ctx.env)}telemetry`,
|
|
1516
|
+
sampleRate: telemetry.sample_rate,
|
|
1517
|
+
sdkType: this.platformUtils.sdkType,
|
|
1518
|
+
sdkVersion: _ParaCore.version,
|
|
1519
|
+
partnerId: this.partner.id,
|
|
1520
|
+
// Only true in DEV — adds localhost to the trace-propagation allow-list
|
|
1521
|
+
// so FE → local user-management requests carry traceparent. Never set in
|
|
1522
|
+
// sandbox/beta/prod, where localhost shouldn't appear in our request URLs.
|
|
1523
|
+
isDev: this.ctx.env === Environment.DEV,
|
|
1524
|
+
// Portal pages run the same ParaCore code path as the partner-app SDK, but
|
|
1525
|
+
// they're a different process boundary (popup/iframe) and a different surface
|
|
1526
|
+
// for ops to debug. Pass through the portal posture so initTelemetry can stamp
|
|
1527
|
+
// the right `service.name` and split SDK-side vs portal-side spans in the
|
|
1528
|
+
// backend. Uses the class-level isPortal() (same logic the rest of the SDK
|
|
1529
|
+
// gates portal-only paths on).
|
|
1530
|
+
isPortal: this.isPortal()
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1328
1533
|
return this.partner;
|
|
1329
1534
|
});
|
|
1330
1535
|
}
|
|
@@ -1350,15 +1555,30 @@ const _ParaCore = class _ParaCore {
|
|
|
1350
1555
|
if (!wallet) {
|
|
1351
1556
|
throw new Error("wallet not found");
|
|
1352
1557
|
}
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1558
|
+
return wrapWithSpan(
|
|
1559
|
+
"mpc.export",
|
|
1560
|
+
() => __async(this, null, function* () {
|
|
1561
|
+
if (wallet.scheme === "ED25519") {
|
|
1562
|
+
return yield this.platformUtils.getED25519PrivateKey(
|
|
1563
|
+
this.ctx,
|
|
1564
|
+
this.userId,
|
|
1565
|
+
wallet.id,
|
|
1566
|
+
wallet.signer,
|
|
1567
|
+
this.retrieveSessionCookie()
|
|
1568
|
+
);
|
|
1569
|
+
}
|
|
1570
|
+
if (wallet.scheme !== "DKLS") {
|
|
1571
|
+
throw new Error("invalid wallet scheme");
|
|
1572
|
+
}
|
|
1573
|
+
return yield this.platformUtils.getPrivateKey(
|
|
1574
|
+
this.ctx,
|
|
1575
|
+
this.userId,
|
|
1576
|
+
wallet.id,
|
|
1577
|
+
wallet.signer,
|
|
1578
|
+
this.retrieveSessionCookie()
|
|
1579
|
+
);
|
|
1580
|
+
}),
|
|
1581
|
+
{ "wallet.scheme": wallet.scheme, "wallet.id": wallet.id, "wallet.type": wallet.type }
|
|
1362
1582
|
);
|
|
1363
1583
|
});
|
|
1364
1584
|
}
|
|
@@ -1413,6 +1633,19 @@ const _ParaCore = class _ParaCore {
|
|
|
1413
1633
|
return yield __privateGet(this, _authService).signExternalWalletVerification(params);
|
|
1414
1634
|
});
|
|
1415
1635
|
}
|
|
1636
|
+
// Direct-to-wallet sign for an external-wallet user who's already authenticated.
|
|
1637
|
+
// The signExternalWalletVerification() path above dispatches a state-machine event
|
|
1638
|
+
// that's only handled from the `awaiting_wallet_signature` state — after login
|
|
1639
|
+
// the machine has moved past that, so the event is silently dropped and the
|
|
1640
|
+
// wallet never gets prompted. The re-auth flow (popup-driven SIWE for export-key
|
|
1641
|
+
// / transaction-review) needs the signature regardless of machine state, so it
|
|
1642
|
+
// routes here and reads the signature back synchronously.
|
|
1643
|
+
signExternalWalletMessageForReauth(params) {
|
|
1644
|
+
return __async(this, null, function* () {
|
|
1645
|
+
const _a = yield __privateGet(this, _externalWalletService).signMessage(params), { signature } = _a, rest = __objRest(_a, ["signature"]);
|
|
1646
|
+
return __spreadValues({ externalWallet: params.externalWallet, signedMessage: signature }, rest);
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1416
1649
|
verifyExternalWalletLink(opts) {
|
|
1417
1650
|
return __async(this, null, function* () {
|
|
1418
1651
|
const accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this, ["EXTERNAL_WALLET"]);
|
|
@@ -1489,6 +1722,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1489
1722
|
*/
|
|
1490
1723
|
verify2fa(_0) {
|
|
1491
1724
|
return __async(this, arguments, function* ({ auth, verificationCode }) {
|
|
1725
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1726
|
+
assertConfigAllowed(this.config, { kind: "2fa" });
|
|
1492
1727
|
const res = yield this.ctx.client.verify2FA(auth, verificationCode);
|
|
1493
1728
|
return {
|
|
1494
1729
|
initiatedAt: res.data.initiatedAt,
|
|
@@ -1504,6 +1739,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1504
1739
|
* */
|
|
1505
1740
|
setup2fa() {
|
|
1506
1741
|
return __async(this, null, function* () {
|
|
1742
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1743
|
+
assertConfigAllowed(this.config, { kind: "2fa" });
|
|
1507
1744
|
const userId = this.assertUserId();
|
|
1508
1745
|
const res = yield this.ctx.client.setup2FA(userId);
|
|
1509
1746
|
return res;
|
|
@@ -1516,6 +1753,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1516
1753
|
*/
|
|
1517
1754
|
enable2fa(_0) {
|
|
1518
1755
|
return __async(this, arguments, function* ({ verificationCode }) {
|
|
1756
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1757
|
+
assertConfigAllowed(this.config, { kind: "2fa" });
|
|
1519
1758
|
const userId = this.assertUserId();
|
|
1520
1759
|
yield this.ctx.client.enable2FA(userId, verificationCode);
|
|
1521
1760
|
});
|
|
@@ -1524,8 +1763,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1524
1763
|
* Resend a verification email for the current user.
|
|
1525
1764
|
*/
|
|
1526
1765
|
resendVerificationCode(_0) {
|
|
1527
|
-
return __async(this, arguments, function* ({ type: reason = "SIGNUP" }) {
|
|
1528
|
-
return yield __privateGet(this, _authService).resendVerificationCode({ type: reason });
|
|
1766
|
+
return __async(this, arguments, function* ({ type: reason = "SIGNUP", deliveryChannel }) {
|
|
1767
|
+
return yield __privateGet(this, _authService).resendVerificationCode({ type: reason, deliveryChannel });
|
|
1529
1768
|
});
|
|
1530
1769
|
}
|
|
1531
1770
|
/**
|
|
@@ -1700,6 +1939,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1700
1939
|
*/
|
|
1701
1940
|
getOAuthUrl(params) {
|
|
1702
1941
|
return __async(this, null, function* () {
|
|
1942
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1943
|
+
assertConfigAllowed(this.config, { kind: "oauth", method: params.method });
|
|
1703
1944
|
return yield __privateGet(this, _portalUrlService).getOAuthUrl(params);
|
|
1704
1945
|
});
|
|
1705
1946
|
}
|
|
@@ -1773,6 +2014,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1773
2014
|
}
|
|
1774
2015
|
verifyOAuth(params) {
|
|
1775
2016
|
return __async(this, null, function* () {
|
|
2017
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2018
|
+
assertConfigAllowed(this.config, { kind: "oauth", method: params.method });
|
|
1776
2019
|
return yield this.verifyOAuthProcess(__spreadProps(__spreadValues({}, params), { isLinkAccount: false }));
|
|
1777
2020
|
});
|
|
1778
2021
|
}
|
|
@@ -1944,8 +2187,6 @@ const _ParaCore = class _ParaCore {
|
|
|
1944
2187
|
});
|
|
1945
2188
|
}
|
|
1946
2189
|
/**
|
|
1947
|
-
* @deprecated Use the REST API (`POST /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
|
|
1948
|
-
*
|
|
1949
2190
|
* Creates a new pregenerated wallet.
|
|
1950
2191
|
*
|
|
1951
2192
|
* @param {Object} opts the options object.
|
|
@@ -1956,13 +2197,10 @@ const _ParaCore = class _ParaCore {
|
|
|
1956
2197
|
**/
|
|
1957
2198
|
createPregenWallet(params) {
|
|
1958
2199
|
return __async(this, null, function* () {
|
|
1959
|
-
warnPregenDeprecation("createPregenWallet");
|
|
1960
2200
|
return yield __privateGet(this, _pregenWalletService).createPregenWallet(params);
|
|
1961
2201
|
});
|
|
1962
2202
|
}
|
|
1963
2203
|
/**
|
|
1964
|
-
* @deprecated Use the REST API (`POST /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
|
|
1965
|
-
*
|
|
1966
2204
|
* Creates new pregenerated wallets for each desired type.
|
|
1967
2205
|
* If no types are provided, this method will create one for each of the non-optional types
|
|
1968
2206
|
* specified in the instance's `supportedWalletTypes` array that are not already present.
|
|
@@ -1974,13 +2212,10 @@ const _ParaCore = class _ParaCore {
|
|
|
1974
2212
|
**/
|
|
1975
2213
|
createPregenWalletPerType(params) {
|
|
1976
2214
|
return __async(this, null, function* () {
|
|
1977
|
-
warnPregenDeprecation("createPregenWalletPerType");
|
|
1978
2215
|
return yield __privateGet(this, _pregenWalletService).createPregenWalletPerType(params);
|
|
1979
2216
|
});
|
|
1980
2217
|
}
|
|
1981
2218
|
/**
|
|
1982
|
-
* @deprecated Use the REST API (`POST /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
|
|
1983
|
-
*
|
|
1984
2219
|
* Claims a pregenerated wallet.
|
|
1985
2220
|
* @param {Object} opts the options object.
|
|
1986
2221
|
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
@@ -1989,13 +2224,10 @@ const _ParaCore = class _ParaCore {
|
|
|
1989
2224
|
**/
|
|
1990
2225
|
claimPregenWallets() {
|
|
1991
2226
|
return __async(this, arguments, function* (params = {}) {
|
|
1992
|
-
warnPregenDeprecation("claimPregenWallets");
|
|
1993
2227
|
return yield __privateGet(this, _pregenWalletService).claimPregenWallets(params);
|
|
1994
2228
|
});
|
|
1995
2229
|
}
|
|
1996
2230
|
/**
|
|
1997
|
-
* @deprecated Use the REST API (`PATCH /v1/wallets/:id`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
|
|
1998
|
-
*
|
|
1999
2231
|
* Updates the identifier for a pregen wallet.
|
|
2000
2232
|
* @param {Object} opts the options object.
|
|
2001
2233
|
* @param {string} opts.walletId the pregen wallet ID
|
|
@@ -2004,13 +2236,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2004
2236
|
**/
|
|
2005
2237
|
updatePregenWalletIdentifier(params) {
|
|
2006
2238
|
return __async(this, null, function* () {
|
|
2007
|
-
warnPregenDeprecation("updatePregenWalletIdentifier");
|
|
2008
2239
|
return yield __privateGet(this, _pregenWalletService).updatePregenWalletIdentifier(params);
|
|
2009
2240
|
});
|
|
2010
2241
|
}
|
|
2011
2242
|
/**
|
|
2012
|
-
* @deprecated Use the REST API (`GET /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
|
|
2013
|
-
*
|
|
2014
2243
|
* Checks if a pregen Wallet exists for the given identifier with the current partner.
|
|
2015
2244
|
* @param {Object} opts the options object.
|
|
2016
2245
|
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
@@ -2019,13 +2248,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2019
2248
|
**/
|
|
2020
2249
|
hasPregenWallet(params) {
|
|
2021
2250
|
return __async(this, null, function* () {
|
|
2022
|
-
warnPregenDeprecation("hasPregenWallet");
|
|
2023
2251
|
return yield __privateGet(this, _pregenWalletService).hasPregenWallet(params);
|
|
2024
2252
|
});
|
|
2025
2253
|
}
|
|
2026
2254
|
/**
|
|
2027
|
-
* @deprecated Use the REST API (`GET /v1/wallets`) instead. See {@link https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen | migration guide}.
|
|
2028
|
-
*
|
|
2029
2255
|
* Get pregen wallets for the given identifier.
|
|
2030
2256
|
* @param {Object} opts the options object.
|
|
2031
2257
|
* @param {string} opts.pregenIdentifier - the identifier of the user claiming the wallet
|
|
@@ -2034,12 +2260,13 @@ const _ParaCore = class _ParaCore {
|
|
|
2034
2260
|
**/
|
|
2035
2261
|
getPregenWallets() {
|
|
2036
2262
|
return __async(this, arguments, function* (params = {}) {
|
|
2037
|
-
warnPregenDeprecation("getPregenWallets");
|
|
2038
2263
|
return yield __privateGet(this, _pregenWalletService).getPregenWallets(params);
|
|
2039
2264
|
});
|
|
2040
2265
|
}
|
|
2041
2266
|
createGuestWallets() {
|
|
2042
2267
|
return __async(this, null, function* () {
|
|
2268
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2269
|
+
assertConfigAllowed(this.config, { kind: "guest" });
|
|
2043
2270
|
return yield __privateGet(this, _pregenWalletService).createGuestWallets();
|
|
2044
2271
|
});
|
|
2045
2272
|
}
|
|
@@ -2079,6 +2306,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2079
2306
|
}
|
|
2080
2307
|
getTransactionReviewUrl(transactionId, timeoutMs) {
|
|
2081
2308
|
return __async(this, null, function* () {
|
|
2309
|
+
if (this.isExternalWalletAuth) {
|
|
2310
|
+
yield this.ctx.client.sessionAddPortalVerification();
|
|
2311
|
+
}
|
|
2082
2312
|
const authMethods = yield this.supportedUserAuthMethods();
|
|
2083
2313
|
const result = yield this.constructPortalUrl("txReview", {
|
|
2084
2314
|
pathId: transactionId,
|
|
@@ -2106,11 +2336,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2106
2336
|
});
|
|
2107
2337
|
}
|
|
2108
2338
|
/**
|
|
2109
|
-
*
|
|
2339
|
+
* Submits a testnet faucet funding transaction for the specified wallet.
|
|
2110
2340
|
* @param {RequestFaucetParams} params the options object.
|
|
2111
2341
|
* @param {string} params.walletId the id of the wallet to fund.
|
|
2112
2342
|
* @param {string} [params.chain] optional chain identifier to target a specific testnet.
|
|
2113
|
-
* @returns the faucet transaction details
|
|
2343
|
+
* @returns the submitted faucet transaction details. Wait for the returned transaction hash to confirm before spending.
|
|
2114
2344
|
*/
|
|
2115
2345
|
requestFaucet(params) {
|
|
2116
2346
|
return __async(this, null, function* () {
|
|
@@ -2139,14 +2369,17 @@ const _ParaCore = class _ParaCore {
|
|
|
2139
2369
|
onPoll,
|
|
2140
2370
|
onTransactionReviewUrl
|
|
2141
2371
|
}) {
|
|
2142
|
-
var _a;
|
|
2143
2372
|
__privateGet(this, _walletService).assertIsValidWalletId(walletId);
|
|
2144
2373
|
const wallet = this.wallets[walletId];
|
|
2145
2374
|
let signerId = this.userId;
|
|
2146
2375
|
if (wallet.partnerId && !wallet.userId) {
|
|
2147
2376
|
signerId = wallet.partnerId;
|
|
2148
2377
|
}
|
|
2149
|
-
let signRes = yield
|
|
2378
|
+
let signRes = yield wrapWithSpan(
|
|
2379
|
+
"mpc.sign",
|
|
2380
|
+
() => this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 }),
|
|
2381
|
+
{ "wallet.scheme": wallet.scheme, "wallet.id": walletId }
|
|
2382
|
+
);
|
|
2150
2383
|
let timeStart = Date.now();
|
|
2151
2384
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2152
2385
|
if (signRes.pendingTransactionId) {
|
|
@@ -2173,7 +2406,16 @@ const _ParaCore = class _ParaCore {
|
|
|
2173
2406
|
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2174
2407
|
let pendingTransaction;
|
|
2175
2408
|
try {
|
|
2176
|
-
pendingTransaction =
|
|
2409
|
+
pendingTransaction = yield wrapWithSpan(
|
|
2410
|
+
"tx.review.poll",
|
|
2411
|
+
(span) => __async(this, null, function* () {
|
|
2412
|
+
var _a;
|
|
2413
|
+
const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
|
|
2414
|
+
span.setAttribute("polling.status", (res == null ? void 0 : res.approvedAt) ? "approved" : "pending");
|
|
2415
|
+
return res;
|
|
2416
|
+
}),
|
|
2417
|
+
{ "pending_transaction.id": signRes.pendingTransactionId }
|
|
2418
|
+
);
|
|
2177
2419
|
} catch (e) {
|
|
2178
2420
|
const error = new TransactionReviewDenied();
|
|
2179
2421
|
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
@@ -2183,7 +2425,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2183
2425
|
onPoll == null ? void 0 : onPoll();
|
|
2184
2426
|
continue;
|
|
2185
2427
|
} else {
|
|
2186
|
-
signRes = yield
|
|
2428
|
+
signRes = yield wrapWithSpan(
|
|
2429
|
+
"mpc.sign",
|
|
2430
|
+
() => this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 }),
|
|
2431
|
+
{ "wallet.scheme": wallet.scheme, "wallet.id": walletId, "mpc.attempt": "post-review" }
|
|
2432
|
+
);
|
|
2187
2433
|
break;
|
|
2188
2434
|
}
|
|
2189
2435
|
}
|
|
@@ -2253,22 +2499,25 @@ const _ParaCore = class _ParaCore {
|
|
|
2253
2499
|
onPoll,
|
|
2254
2500
|
onTransactionReviewUrl
|
|
2255
2501
|
}) {
|
|
2256
|
-
var _a;
|
|
2257
2502
|
__privateGet(this, _walletService).assertIsValidWalletId(walletId);
|
|
2258
2503
|
const wallet = this.wallets[walletId];
|
|
2259
2504
|
let signerId = this.userId;
|
|
2260
2505
|
if (wallet.partnerId && !wallet.userId) {
|
|
2261
2506
|
signerId = wallet.partnerId;
|
|
2262
2507
|
}
|
|
2263
|
-
let signRes = yield
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2508
|
+
let signRes = yield wrapWithSpan(
|
|
2509
|
+
"mpc.sign",
|
|
2510
|
+
() => this.platformUtils.signTransaction(
|
|
2511
|
+
this.ctx,
|
|
2512
|
+
signerId,
|
|
2513
|
+
walletId,
|
|
2514
|
+
this.wallets[walletId].signer,
|
|
2515
|
+
rlpEncodedTxBase64,
|
|
2516
|
+
chainId,
|
|
2517
|
+
this.retrieveSessionCookie(),
|
|
2518
|
+
wallet.scheme === "DKLS"
|
|
2519
|
+
),
|
|
2520
|
+
{ "wallet.scheme": wallet.scheme, "wallet.id": walletId, "tx.kind": "transaction" }
|
|
2272
2521
|
);
|
|
2273
2522
|
let timeStart = Date.now();
|
|
2274
2523
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
@@ -2292,9 +2541,19 @@ const _ParaCore = class _ParaCore {
|
|
|
2292
2541
|
break;
|
|
2293
2542
|
}
|
|
2294
2543
|
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2544
|
+
const pendingTxId = signRes.pendingTransactionId;
|
|
2295
2545
|
let pendingTransaction;
|
|
2296
2546
|
try {
|
|
2297
|
-
pendingTransaction =
|
|
2547
|
+
pendingTransaction = yield wrapWithSpan(
|
|
2548
|
+
"tx.review.poll",
|
|
2549
|
+
(span) => __async(this, null, function* () {
|
|
2550
|
+
var _a;
|
|
2551
|
+
const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, pendingTxId)).data) == null ? void 0 : _a.pendingTransaction;
|
|
2552
|
+
span.setAttribute("polling.status", (res == null ? void 0 : res.approvedAt) ? "approved" : "pending");
|
|
2553
|
+
return res;
|
|
2554
|
+
}),
|
|
2555
|
+
{ "pending_transaction.id": pendingTxId }
|
|
2556
|
+
);
|
|
2298
2557
|
} catch (e) {
|
|
2299
2558
|
const error = new TransactionReviewDenied();
|
|
2300
2559
|
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
@@ -2304,15 +2563,19 @@ const _ParaCore = class _ParaCore {
|
|
|
2304
2563
|
onPoll == null ? void 0 : onPoll();
|
|
2305
2564
|
continue;
|
|
2306
2565
|
} else {
|
|
2307
|
-
signRes = yield
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2566
|
+
signRes = yield wrapWithSpan(
|
|
2567
|
+
"mpc.sign",
|
|
2568
|
+
() => this.platformUtils.signTransaction(
|
|
2569
|
+
this.ctx,
|
|
2570
|
+
signerId,
|
|
2571
|
+
walletId,
|
|
2572
|
+
this.wallets[walletId].signer,
|
|
2573
|
+
rlpEncodedTxBase64,
|
|
2574
|
+
chainId,
|
|
2575
|
+
this.retrieveSessionCookie(),
|
|
2576
|
+
wallet.scheme === "DKLS"
|
|
2577
|
+
),
|
|
2578
|
+
{ "wallet.scheme": wallet.scheme, "wallet.id": walletId, "tx.kind": "transaction", "mpc.attempt": "post-review" }
|
|
2316
2579
|
);
|
|
2317
2580
|
break;
|
|
2318
2581
|
}
|
|
@@ -2584,7 +2847,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2584
2847
|
useLocalFiles: this.ctx.useLocalFiles,
|
|
2585
2848
|
useDKLS: this.ctx.useDKLS,
|
|
2586
2849
|
cosmosPrefix: this.ctx.cosmosPrefix
|
|
2587
|
-
}
|
|
2850
|
+
},
|
|
2851
|
+
config: this.config
|
|
2588
2852
|
});
|
|
2589
2853
|
return `Para ${JSON.stringify(obj, null, 2)}`;
|
|
2590
2854
|
}
|
|
@@ -2619,16 +2883,26 @@ const _ParaCore = class _ParaCore {
|
|
|
2619
2883
|
}
|
|
2620
2884
|
signUpOrLogIn(params) {
|
|
2621
2885
|
return __async(this, null, function* () {
|
|
2886
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2887
|
+
assertConfigAllowed(this.config, {
|
|
2888
|
+
kind: extractAuthInfo(params.auth, { isRequired: true }).authType
|
|
2889
|
+
});
|
|
2622
2890
|
return yield __privateGet(this, _authService).signUpOrLogIn(params);
|
|
2623
2891
|
});
|
|
2624
2892
|
}
|
|
2625
2893
|
authenticateWithEmailOrPhone(params) {
|
|
2626
2894
|
return __async(this, null, function* () {
|
|
2895
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2896
|
+
assertConfigAllowed(this.config, {
|
|
2897
|
+
kind: extractAuthInfo(params.auth, { isRequired: true }).authType
|
|
2898
|
+
});
|
|
2627
2899
|
return yield __privateGet(this, _authService).authenticateWithEmailOrPhone(params);
|
|
2628
2900
|
});
|
|
2629
2901
|
}
|
|
2630
2902
|
authenticateWithOAuth(params) {
|
|
2631
2903
|
return __async(this, null, function* () {
|
|
2904
|
+
yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2905
|
+
assertConfigAllowed(this.config, { kind: "oauth", method: params.method });
|
|
2632
2906
|
return yield __privateGet(this, _authService).authenticateWithOAuth(params);
|
|
2633
2907
|
});
|
|
2634
2908
|
}
|
|
@@ -2764,16 +3038,17 @@ const _ParaCore = class _ParaCore {
|
|
|
2764
3038
|
}
|
|
2765
3039
|
sendLoginCode() {
|
|
2766
3040
|
return __async(this, null, function* () {
|
|
2767
|
-
const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
|
|
3041
|
+
const { userId, deliveryChannel, fallbackUsed, fallbackChannel, isSmsAllowed } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
|
|
2768
3042
|
yield this.setUserId(userId);
|
|
2769
|
-
return { userId };
|
|
3043
|
+
return { userId, deliveryChannel, fallbackUsed, fallbackChannel, isSmsAllowed };
|
|
2770
3044
|
});
|
|
2771
3045
|
}
|
|
2772
3046
|
exportPrivateKey() {
|
|
2773
3047
|
return __async(this, arguments, function* (args = {}) {
|
|
3048
|
+
var _a;
|
|
2774
3049
|
let walletId = args == null ? void 0 : args.walletId;
|
|
2775
3050
|
if (!(args == null ? void 0 : args.walletId)) {
|
|
2776
|
-
walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS"] });
|
|
3051
|
+
walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS", "ED25519"] });
|
|
2777
3052
|
}
|
|
2778
3053
|
const wallet = this.wallets[walletId];
|
|
2779
3054
|
if (this.externalWallets[walletId]) {
|
|
@@ -2782,28 +3057,38 @@ const _ParaCore = class _ParaCore {
|
|
|
2782
3057
|
if (!wallet || !wallet.signer) {
|
|
2783
3058
|
throw new Error("Wallet not found with id: " + walletId);
|
|
2784
3059
|
}
|
|
2785
|
-
if (wallet.scheme !== "DKLS") {
|
|
2786
|
-
throw new Error("Cannot export private key for a Solana wallet");
|
|
2787
|
-
}
|
|
2788
3060
|
if (wallet.isPregen && !!wallet.pregenIdentifier && wallet.pregenIdentifierType !== "GUEST_ID") {
|
|
2789
3061
|
throw new Error("Cannot export private key for a pregenerated wallet");
|
|
2790
3062
|
}
|
|
2791
3063
|
if (args.shouldOpenPopup) {
|
|
2792
3064
|
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: PopupType.EXPORT_PRIVATE_KEY });
|
|
2793
3065
|
}
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
3066
|
+
try {
|
|
3067
|
+
if (this.isExternalWalletAuth) {
|
|
3068
|
+
yield this.ctx.client.sessionAddPortalVerification();
|
|
3069
|
+
}
|
|
3070
|
+
const authMethods = yield this.supportedUserAuthMethods();
|
|
3071
|
+
const exportPrivateKeyResult = yield this.constructPortalUrl("exportPrivateKey", {
|
|
3072
|
+
pathId: walletId,
|
|
3073
|
+
useLegacyUrl: authMethods.has(AuthMethod.PASSKEY)
|
|
3074
|
+
});
|
|
3075
|
+
const exportPrivateKeyUrl = exportPrivateKeyResult.url;
|
|
3076
|
+
if (args.shouldOpenPopup) {
|
|
3077
|
+
this.popupWindow.location.href = exportPrivateKeyUrl;
|
|
3078
|
+
}
|
|
3079
|
+
return {
|
|
3080
|
+
url: exportPrivateKeyUrl,
|
|
3081
|
+
popupWindow: this.popupWindow
|
|
3082
|
+
};
|
|
3083
|
+
} catch (err) {
|
|
3084
|
+
if (args.shouldOpenPopup) {
|
|
3085
|
+
try {
|
|
3086
|
+
(_a = this.popupWindow) == null ? void 0 : _a.close();
|
|
3087
|
+
} catch (e) {
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
throw err;
|
|
2802
3091
|
}
|
|
2803
|
-
return {
|
|
2804
|
-
url: exportPrivateKeyUrl,
|
|
2805
|
-
popupWindow: this.popupWindow
|
|
2806
|
-
};
|
|
2807
3092
|
});
|
|
2808
3093
|
}
|
|
2809
3094
|
};
|
|
@@ -2816,7 +3101,54 @@ _pollingService = new WeakMap();
|
|
|
2816
3101
|
_portalUrlService = new WeakMap();
|
|
2817
3102
|
_sessionManagementService = new WeakMap();
|
|
2818
3103
|
_debugLogsEnabled = new WeakMap();
|
|
3104
|
+
_configChangeListeners = new WeakMap();
|
|
2819
3105
|
_ParaCore_instances = new WeakSet();
|
|
3106
|
+
notifyConfigChange_fn = function() {
|
|
3107
|
+
__privateGet(this, _configChangeListeners).forEach((cb) => cb());
|
|
3108
|
+
};
|
|
3109
|
+
_sdkConfigOverrides = new WeakMap();
|
|
3110
|
+
_configMemo = new WeakMap();
|
|
3111
|
+
/**
|
|
3112
|
+
* Drift telemetry. Currently fires only on `rpcUrl` (the only
|
|
3113
|
+
* remaining override-able field that's typically authoritative server-side
|
|
3114
|
+
* — `rpcUrl` SDK override is legitimate for local-dev, but if a consumer
|
|
3115
|
+
* silently overrides it in prod we want operators to know).
|
|
3116
|
+
*
|
|
3117
|
+
* Fires once per `(scope, key)` per session.
|
|
3118
|
+
*
|
|
3119
|
+
* Comparison baseline is the merge chain WITHOUT the SDK overrides layer
|
|
3120
|
+
* (i.e. the authoritative chain: `defaults ⊕ ecosystem ⊕ partner`). Today
|
|
3121
|
+
* with no ecosystem layer this resolves to the partner record values, but
|
|
3122
|
+
* computing it via the merge keeps the comparison correct when ecosystem
|
|
3123
|
+
* ships and an org overrides `rpcUrl` for its child partners.
|
|
3124
|
+
*
|
|
3125
|
+
* `appName` and `partnerLinks.*` are no longer overridable — they're 1:1
|
|
3126
|
+
* with the apikey/project and have no per-instance use case. Drift
|
|
3127
|
+
* telemetry for those was removed when they were excluded from
|
|
3128
|
+
* `SdkOverridableAppConfig`.
|
|
3129
|
+
*/
|
|
3130
|
+
warnPartnerConfigDrift_fn = function() {
|
|
3131
|
+
var _a;
|
|
3132
|
+
if (!this.partner || !__privateGet(this, _sdkConfigOverrides)) return;
|
|
3133
|
+
const baseline = __privateMethod(this, _ParaCore_instances, configWithoutSdkOverrides_fn).call(this);
|
|
3134
|
+
const sdkRpcUrl = __privateGet(this, _sdkConfigOverrides).rpcUrl;
|
|
3135
|
+
if (sdkRpcUrl && sdkRpcUrl !== baseline.rpcUrl) {
|
|
3136
|
+
warnOnce(
|
|
3137
|
+
"partnerConfigDrift",
|
|
3138
|
+
"rpcUrl",
|
|
3139
|
+
`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.`
|
|
3140
|
+
);
|
|
3141
|
+
}
|
|
3142
|
+
};
|
|
3143
|
+
/**
|
|
3144
|
+
* Resolved config WITHOUT the SDK override layer. Used by drift telemetry
|
|
3145
|
+
* to compare overrides against the authoritative chain. Slot for the
|
|
3146
|
+
* future ecosystem layer between `defaults` and `partner`.
|
|
3147
|
+
*/
|
|
3148
|
+
configWithoutSdkOverrides_fn = function() {
|
|
3149
|
+
const partnerLayer = this.partner ? partnerToAppConfigLayer(this.partner) : void 0;
|
|
3150
|
+
return mergePartnerAppConfig(DEFAULT_PARTNER_APP_CONFIG, partnerLayer);
|
|
3151
|
+
};
|
|
2820
3152
|
assertPartner_fn = function() {
|
|
2821
3153
|
return __async(this, null, function* () {
|
|
2822
3154
|
var _a, _b;
|
|
@@ -2881,6 +3213,26 @@ assertIsLinkingAccountOrStart_fn = function(type) {
|
|
|
2881
3213
|
});
|
|
2882
3214
|
};
|
|
2883
3215
|
waitForLoginProcess_fn = function() {
|
|
3216
|
+
return __async(this, arguments, function* ({
|
|
3217
|
+
isCanceled = () => false,
|
|
3218
|
+
onCancel,
|
|
3219
|
+
onPoll,
|
|
3220
|
+
skipSessionRefresh = false,
|
|
3221
|
+
isSwitchingWallets = false
|
|
3222
|
+
} = {}) {
|
|
3223
|
+
return wrapWithSpan("polling.waitForLoginProcess", (span) => __async(this, null, function* () {
|
|
3224
|
+
span.setAttribute("polling.is_switching_wallets", isSwitchingWallets);
|
|
3225
|
+
return __privateMethod(this, _ParaCore_instances, waitForLoginProcessImpl_fn).call(this, {
|
|
3226
|
+
isCanceled,
|
|
3227
|
+
onCancel,
|
|
3228
|
+
onPoll,
|
|
3229
|
+
skipSessionRefresh,
|
|
3230
|
+
isSwitchingWallets
|
|
3231
|
+
});
|
|
3232
|
+
}));
|
|
3233
|
+
});
|
|
3234
|
+
};
|
|
3235
|
+
waitForLoginProcessImpl_fn = function() {
|
|
2884
3236
|
return __async(this, arguments, function* ({
|
|
2885
3237
|
isCanceled = () => false,
|
|
2886
3238
|
onCancel,
|
|
@@ -3014,7 +3366,7 @@ waitForLoginProcess_fn = function() {
|
|
|
3014
3366
|
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
3015
3367
|
this.devLog("[waitForLoginProcess] Setup after login complete");
|
|
3016
3368
|
this.devLog("[waitForLoginProcess] Claiming pregen wallets");
|
|
3017
|
-
yield
|
|
3369
|
+
yield this.claimPregenWallets();
|
|
3018
3370
|
this.devLog("[waitForLoginProcess] Pregen wallets claimed");
|
|
3019
3371
|
const resp = {
|
|
3020
3372
|
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
@@ -3075,6 +3427,7 @@ logout_fn = function() {
|
|
|
3075
3427
|
__privateGet(this, _authService).userId = void 0;
|
|
3076
3428
|
__privateGet(this, _sessionManagementService).sessionCookie = void 0;
|
|
3077
3429
|
this.isEnclaveUser = false;
|
|
3430
|
+
setCurrentUserId(void 0);
|
|
3078
3431
|
if (isSessionActive) {
|
|
3079
3432
|
dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
|
|
3080
3433
|
if (!skipStateReset) {
|