@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/cjs/constants.js
CHANGED
|
@@ -46,7 +46,7 @@ __export(constants_exports, {
|
|
|
46
46
|
TRANSACTION_REVIEW_TIMEOUT_MS: () => TRANSACTION_REVIEW_TIMEOUT_MS
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(constants_exports);
|
|
49
|
-
const PARA_CORE_VERSION = "3.0.0
|
|
49
|
+
const PARA_CORE_VERSION = "3.0.0";
|
|
50
50
|
const PREFIX = "@CAPSULE/";
|
|
51
51
|
const PARA_PREFIX = "@PARA/";
|
|
52
52
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -71,6 +71,7 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
71
71
|
var import_base64url = __toESM(require("base64url"));
|
|
72
72
|
var import_node_forge = __toESM(require("node-forge"));
|
|
73
73
|
var import_utils = require("../utils/index.js");
|
|
74
|
+
var import_tracer = require("../telemetry/tracer.js");
|
|
74
75
|
const rsa = import_node_forge.default.pki.rsa;
|
|
75
76
|
const RSA_ENCRYPTION_SCHEME = "RSA-OAEP";
|
|
76
77
|
const CONSTANT_IV = "794241bc819a125a7b78ea313decc0bc";
|
|
@@ -160,8 +161,10 @@ function getAsymmetricKeyPair(ctx, seedValue) {
|
|
|
160
161
|
if (!ctx.disableWorkers) {
|
|
161
162
|
options.workLoad = 100;
|
|
162
163
|
options.workers = seedValue ? 1 : -1;
|
|
163
|
-
const
|
|
164
|
-
|
|
164
|
+
const workerBlob = yield (0, import_tracer.wrapWithSpan)("worker.load_prime", () => __async(this, null, function* () {
|
|
165
|
+
const workerRes = yield fetch(`${(0, import_utils.getPortalBaseURL)(ctx)}/static/js/prime.worker.min.js`);
|
|
166
|
+
return new Blob([yield workerRes.text()], { type: "application/javascript" });
|
|
167
|
+
}));
|
|
165
168
|
options.workerScript = URL.createObjectURL(workerBlob);
|
|
166
169
|
}
|
|
167
170
|
return new Promise(
|
package/dist/cjs/errors.js
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var errors_exports = {};
|
|
19
19
|
__export(errors_exports, {
|
|
20
|
+
PartnerConfigError: () => PartnerConfigError,
|
|
20
21
|
TransactionReviewDenied: () => TransactionReviewDenied,
|
|
21
22
|
TransactionReviewError: () => TransactionReviewError,
|
|
22
23
|
TransactionReviewTimeout: () => TransactionReviewTimeout
|
|
@@ -43,8 +44,17 @@ class TransactionReviewTimeout extends Error {
|
|
|
43
44
|
this.pendingTransactionId = pendingTransactionId;
|
|
44
45
|
}
|
|
45
46
|
}
|
|
47
|
+
class PartnerConfigError extends Error {
|
|
48
|
+
constructor(code, message, detail) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.name = "PartnerConfigError";
|
|
51
|
+
this.code = code;
|
|
52
|
+
this.detail = detail;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
46
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
47
56
|
0 && (module.exports = {
|
|
57
|
+
PartnerConfigError,
|
|
48
58
|
TransactionReviewDenied,
|
|
49
59
|
TransactionReviewError,
|
|
50
60
|
TransactionReviewTimeout
|
|
@@ -35,10 +35,24 @@ __export(userManagementClient_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(userManagementClient_exports);
|
|
36
36
|
var import_user_management_client = __toESM(require("@getpara/user-management-client"));
|
|
37
37
|
var import_types = require("../types/index.js");
|
|
38
|
+
function getDevApiBaseUrlOverride(scheme = "http") {
|
|
39
|
+
const override = typeof globalThis !== "undefined" ? globalThis.__PARA_API_BASE_URL_OVERRIDE__ : void 0;
|
|
40
|
+
if (!override || typeof override !== "string") {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
const url = new URL(override);
|
|
44
|
+
if (scheme === "ws") {
|
|
45
|
+
url.protocol = url.protocol === "https:" || url.protocol === "wss:" ? "wss:" : "ws:";
|
|
46
|
+
} else {
|
|
47
|
+
url.protocol = url.protocol === "wss:" || url.protocol === "https:" ? "https:" : "http:";
|
|
48
|
+
}
|
|
49
|
+
return url.toString();
|
|
50
|
+
}
|
|
38
51
|
function getBaseOAuthUrl(env) {
|
|
52
|
+
var _a;
|
|
39
53
|
switch (env) {
|
|
40
54
|
case import_types.Environment.DEV:
|
|
41
|
-
return "http://localhost:8080/";
|
|
55
|
+
return (_a = getDevApiBaseUrlOverride()) != null ? _a : "http://localhost:8080/";
|
|
42
56
|
case import_types.Environment.SANDBOX:
|
|
43
57
|
return "https://api.sandbox.usecapsule.com/";
|
|
44
58
|
case import_types.Environment.BETA:
|
|
@@ -50,9 +64,10 @@ function getBaseOAuthUrl(env) {
|
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
function getBaseUrl(env, scheme = "http") {
|
|
67
|
+
var _a;
|
|
53
68
|
switch (env) {
|
|
54
69
|
case import_types.Environment.DEV:
|
|
55
|
-
return `${scheme}://localhost:8080/`;
|
|
70
|
+
return (_a = getDevApiBaseUrlOverride(scheme)) != null ? _a : `${scheme}://localhost:8080/`;
|
|
56
71
|
case import_types.Environment.SANDBOX:
|
|
57
72
|
return `${scheme}s://api.sandbox.getpara.com/`;
|
|
58
73
|
case import_types.Environment.BETA:
|
|
@@ -85,7 +100,8 @@ function initClient({
|
|
|
85
100
|
partnerId,
|
|
86
101
|
useFetchAdapter = false,
|
|
87
102
|
retrieveSessionCookie,
|
|
88
|
-
persistSessionCookie
|
|
103
|
+
persistSessionCookie,
|
|
104
|
+
staticTraceContext
|
|
89
105
|
}) {
|
|
90
106
|
return new import_user_management_client.default({
|
|
91
107
|
userManagementHost: getBaseUrl(env),
|
|
@@ -94,7 +110,8 @@ function initClient({
|
|
|
94
110
|
partnerId,
|
|
95
111
|
opts: { useFetchAdapter },
|
|
96
112
|
retrieveSessionCookie,
|
|
97
|
-
persistSessionCookie
|
|
113
|
+
persistSessionCookie,
|
|
114
|
+
staticTraceContext
|
|
98
115
|
});
|
|
99
116
|
}
|
|
100
117
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/index.js
CHANGED
|
@@ -29,9 +29,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var src_exports = {};
|
|
30
30
|
__export(src_exports, {
|
|
31
31
|
AccountLinkError: () => import_types.AccountLinkError,
|
|
32
|
+
AuthLayout: () => import_user_management_client.AuthLayout,
|
|
32
33
|
AuthMethod: () => import_user_management_client.AuthMethod,
|
|
33
34
|
AuthMethodStatus: () => import_user_management_client.AuthMethodStatus,
|
|
34
35
|
COSMOS_WALLETS: () => import_user_management_client.COSMOS_WALLETS,
|
|
36
|
+
DeliveryChannel: () => import_user_management_client.DeliveryChannel,
|
|
37
|
+
ENCODED_CONFIG_VERSION: () => import_configEncoding.ENCODED_CONFIG_VERSION,
|
|
35
38
|
EVM_WALLETS: () => import_user_management_client.EVM_WALLETS,
|
|
36
39
|
EXTERNAL_WALLET_TYPES: () => import_user_management_client.EXTERNAL_WALLET_TYPES,
|
|
37
40
|
EmailTheme: () => import_user_management_client.EmailTheme,
|
|
@@ -55,6 +58,7 @@ __export(src_exports, {
|
|
|
55
58
|
RecoveryStatus: () => import_user_management_client.RecoveryStatus,
|
|
56
59
|
SOLANA_WALLETS: () => import_user_management_client.SOLANA_WALLETS,
|
|
57
60
|
STORAGE_PREFIX: () => import_constants.PREFIX,
|
|
61
|
+
SpanStatusCode: () => import_tracer.SpanStatusCode,
|
|
58
62
|
ThemeMode: () => import_user_management_client.ThemeMode,
|
|
59
63
|
WALLET_SCHEMES: () => import_user_management_client.WALLET_SCHEMES,
|
|
60
64
|
WALLET_TYPES: () => import_user_management_client.WALLET_TYPES,
|
|
@@ -69,36 +73,61 @@ __export(src_exports, {
|
|
|
69
73
|
default: () => src_default,
|
|
70
74
|
dispatchEvent: () => import_utils.dispatchEvent,
|
|
71
75
|
distributeNewShare: () => import_shareDistribution.distributeNewShare,
|
|
76
|
+
encodeConfigParams: () => import_configEncoding.encodeConfigParams,
|
|
72
77
|
encodePrivateKeyToPemHex: () => import_utils2.encodePrivateKeyToPemHex,
|
|
73
78
|
encryptPrivateKey: () => import_utils2.encryptPrivateKey,
|
|
74
79
|
encryptPrivateKeyWithPassword: () => import_utils2.encryptPrivateKeyWithPassword,
|
|
75
80
|
encryptWithDerivedPublicKey: () => import_utils2.encryptWithDerivedPublicKey,
|
|
81
|
+
endModalSession: () => import_modalSession.endModalSession,
|
|
76
82
|
entityToWallet: () => import_utils.entityToWallet,
|
|
83
|
+
extractTraceContextFromUrl: () => import_tracer.extractTraceContextFromUrl,
|
|
84
|
+
flushTelemetry: () => import_init.flushTelemetry,
|
|
77
85
|
formatAssetQuantity: () => import_user_management_client.formatAssetQuantity,
|
|
78
86
|
formatCurrency: () => import_user_management_client.formatCurrency,
|
|
79
87
|
getAsymmetricKeyPair: () => import_utils2.getAsymmetricKeyPair,
|
|
80
88
|
getBaseUrl: () => import_userManagementClient.getBaseUrl,
|
|
89
|
+
getDefaultParentContext: () => import_tracer.getDefaultParentContext,
|
|
81
90
|
getDerivedPrivateKeyAndDecrypt: () => import_utils2.getDerivedPrivateKeyAndDecrypt,
|
|
91
|
+
getModalSessionContext: () => import_modalSession.getModalSessionContext,
|
|
82
92
|
getNetworkPrefix: () => import_onRamps.getNetworkPrefix,
|
|
83
93
|
getOnRampAssets: () => import_onRamps.getOnRampAssets,
|
|
84
94
|
getOnRampNetworks: () => import_onRamps.getOnRampNetworks,
|
|
95
|
+
getOrCreateSessionId: () => import_session.getOrCreateSessionId,
|
|
96
|
+
getParaConnectBaseUrl: () => import_url.getParaConnectBaseUrl,
|
|
85
97
|
getPortalBaseURL: () => import_url.getPortalBaseURL,
|
|
86
98
|
getPortalDomain: () => import_utils.getPortalDomain,
|
|
87
99
|
getPublicKeyFromSignature: () => import_utils2.getPublicKeyFromSignature,
|
|
88
100
|
getPublicKeyHex: () => import_utils2.getPublicKeyHex,
|
|
89
101
|
getSHA256HashHex: () => import_utils2.getSHA256HashHex,
|
|
102
|
+
getTracer: () => import_tracer.getTracer,
|
|
103
|
+
getUrlTraceCarrier: () => import_tracer.getUrlTraceCarrier,
|
|
104
|
+
getUxState: () => import_uxState.getUxState,
|
|
90
105
|
hashPasswordWithSalt: () => import_utils2.hashPasswordWithSalt,
|
|
91
106
|
initClient: () => import_userManagementClient.initClient,
|
|
107
|
+
initTelemetry: () => import_init.initTelemetry,
|
|
108
|
+
isCompressionStreamSupported: () => import_configEncoding.isCompressionStreamSupported,
|
|
92
109
|
isPortal: () => import_utils.isPortal,
|
|
110
|
+
isTelemetryInitialized: () => import_init.isTelemetryInitialized,
|
|
93
111
|
isWalletSupported: () => import_wallet.isWalletSupported,
|
|
94
112
|
mpcComputationClient: () => mpcComputationClient,
|
|
95
113
|
offParaEvent: () => import_utils.offParaEvent,
|
|
96
114
|
onParaEvent: () => import_utils.onParaEvent,
|
|
115
|
+
onTelemetryReady: () => import_init.onTelemetryReady,
|
|
97
116
|
paraVersion: () => paraVersion,
|
|
98
117
|
publicKeyFromHex: () => import_utils2.publicKeyFromHex,
|
|
118
|
+
recordActionOnSpan: () => import_uxAction.recordActionOnSpan,
|
|
119
|
+
setCurrentUserId: () => import_uxStateSpanProcessor.setCurrentUserId,
|
|
120
|
+
setCurrentView: () => import_uxState.setCurrentView,
|
|
121
|
+
setDefaultParentContext: () => import_tracer.setDefaultParentContext,
|
|
122
|
+
setLastInteraction: () => import_uxState.setLastInteraction,
|
|
99
123
|
shortenUrl: () => import_utils.shortenUrl,
|
|
124
|
+
startModalSession: () => import_modalSession.startModalSession,
|
|
100
125
|
toAssetInfoArray: () => import_onRamps.toAssetInfoArray,
|
|
101
|
-
transmissionUtilsRetrieve: () => import_transmissionUtils.retrieve
|
|
126
|
+
transmissionUtilsRetrieve: () => import_transmissionUtils.retrieve,
|
|
127
|
+
tryDecodeConfig: () => import_configEncoding.tryDecodeConfig,
|
|
128
|
+
warnOnce: () => import_utils.warnOnce,
|
|
129
|
+
wrapWithSpan: () => import_tracer.wrapWithSpan,
|
|
130
|
+
wrapWithSpanInContext: () => import_tracer.wrapWithSpanInContext
|
|
102
131
|
});
|
|
103
132
|
module.exports = __toCommonJS(src_exports);
|
|
104
133
|
var import_ParaCore = require("./ParaCore.js");
|
|
@@ -124,15 +153,26 @@ __reExport(src_exports, require("./utils/config.js"), module.exports);
|
|
|
124
153
|
var import_wallet = require("./utils/wallet.js");
|
|
125
154
|
var import_onRamps = require("./utils/onRamps.js");
|
|
126
155
|
var import_url = require("./utils/url.js");
|
|
156
|
+
var import_configEncoding = require("./utils/configEncoding.js");
|
|
127
157
|
var import_transmissionUtils = require("./transmission/transmissionUtils.js");
|
|
158
|
+
var import_tracer = require("./telemetry/tracer.js");
|
|
159
|
+
var import_session = require("./telemetry/session.js");
|
|
160
|
+
var import_init = require("./telemetry/init.js");
|
|
161
|
+
var import_uxState = require("./telemetry/uxState.js");
|
|
162
|
+
var import_uxStateSpanProcessor = require("./telemetry/uxStateSpanProcessor.js");
|
|
163
|
+
var import_uxAction = require("./telemetry/uxAction.js");
|
|
164
|
+
var import_modalSession = require("./telemetry/modalSession.js");
|
|
128
165
|
const paraVersion = import_ParaCore.ParaCore.version;
|
|
129
166
|
var src_default = import_ParaCore.ParaCore;
|
|
130
167
|
// Annotate the CommonJS export names for ESM import in node:
|
|
131
168
|
0 && (module.exports = {
|
|
132
169
|
AccountLinkError,
|
|
170
|
+
AuthLayout,
|
|
133
171
|
AuthMethod,
|
|
134
172
|
AuthMethodStatus,
|
|
135
173
|
COSMOS_WALLETS,
|
|
174
|
+
DeliveryChannel,
|
|
175
|
+
ENCODED_CONFIG_VERSION,
|
|
136
176
|
EVM_WALLETS,
|
|
137
177
|
EXTERNAL_WALLET_TYPES,
|
|
138
178
|
EmailTheme,
|
|
@@ -156,6 +196,7 @@ var src_default = import_ParaCore.ParaCore;
|
|
|
156
196
|
RecoveryStatus,
|
|
157
197
|
SOLANA_WALLETS,
|
|
158
198
|
STORAGE_PREFIX,
|
|
199
|
+
SpanStatusCode,
|
|
159
200
|
ThemeMode,
|
|
160
201
|
WALLET_SCHEMES,
|
|
161
202
|
WALLET_TYPES,
|
|
@@ -169,36 +210,61 @@ var src_default = import_ParaCore.ParaCore;
|
|
|
169
210
|
decryptWithPrivateKey,
|
|
170
211
|
dispatchEvent,
|
|
171
212
|
distributeNewShare,
|
|
213
|
+
encodeConfigParams,
|
|
172
214
|
encodePrivateKeyToPemHex,
|
|
173
215
|
encryptPrivateKey,
|
|
174
216
|
encryptPrivateKeyWithPassword,
|
|
175
217
|
encryptWithDerivedPublicKey,
|
|
218
|
+
endModalSession,
|
|
176
219
|
entityToWallet,
|
|
220
|
+
extractTraceContextFromUrl,
|
|
221
|
+
flushTelemetry,
|
|
177
222
|
formatAssetQuantity,
|
|
178
223
|
formatCurrency,
|
|
179
224
|
getAsymmetricKeyPair,
|
|
180
225
|
getBaseUrl,
|
|
226
|
+
getDefaultParentContext,
|
|
181
227
|
getDerivedPrivateKeyAndDecrypt,
|
|
228
|
+
getModalSessionContext,
|
|
182
229
|
getNetworkPrefix,
|
|
183
230
|
getOnRampAssets,
|
|
184
231
|
getOnRampNetworks,
|
|
232
|
+
getOrCreateSessionId,
|
|
233
|
+
getParaConnectBaseUrl,
|
|
185
234
|
getPortalBaseURL,
|
|
186
235
|
getPortalDomain,
|
|
187
236
|
getPublicKeyFromSignature,
|
|
188
237
|
getPublicKeyHex,
|
|
189
238
|
getSHA256HashHex,
|
|
239
|
+
getTracer,
|
|
240
|
+
getUrlTraceCarrier,
|
|
241
|
+
getUxState,
|
|
190
242
|
hashPasswordWithSalt,
|
|
191
243
|
initClient,
|
|
244
|
+
initTelemetry,
|
|
245
|
+
isCompressionStreamSupported,
|
|
192
246
|
isPortal,
|
|
247
|
+
isTelemetryInitialized,
|
|
193
248
|
isWalletSupported,
|
|
194
249
|
mpcComputationClient,
|
|
195
250
|
offParaEvent,
|
|
196
251
|
onParaEvent,
|
|
252
|
+
onTelemetryReady,
|
|
197
253
|
paraVersion,
|
|
198
254
|
publicKeyFromHex,
|
|
255
|
+
recordActionOnSpan,
|
|
256
|
+
setCurrentUserId,
|
|
257
|
+
setCurrentView,
|
|
258
|
+
setDefaultParentContext,
|
|
259
|
+
setLastInteraction,
|
|
199
260
|
shortenUrl,
|
|
261
|
+
startModalSession,
|
|
200
262
|
toAssetInfoArray,
|
|
201
263
|
transmissionUtilsRetrieve,
|
|
264
|
+
tryDecodeConfig,
|
|
265
|
+
warnOnce,
|
|
266
|
+
wrapWithSpan,
|
|
267
|
+
wrapWithSpanInContext,
|
|
202
268
|
...require("./types/smartAccounts.js"),
|
|
203
269
|
...require("./types/coreApi.js"),
|
|
204
270
|
...require("./types/events.js"),
|
|
@@ -91,6 +91,8 @@ var constants = __toESM(require("../constants.js"));
|
|
|
91
91
|
var import_LoginFlowService = require("./LoginFlowService.js");
|
|
92
92
|
var import_VerificationFlowService = require("./VerificationFlowService.js");
|
|
93
93
|
var import_SignupFlowService = require("./SignupFlowService.js");
|
|
94
|
+
var import_tracer = require("../telemetry/tracer.js");
|
|
95
|
+
var import_uxStateSpanProcessor = require("../telemetry/uxStateSpanProcessor.js");
|
|
94
96
|
var import_stateListener = require("../utils/stateListener.js");
|
|
95
97
|
var _stateManager, _loginFlowService, _signupFlowService, _verificationFlowService, _externalWalletService, _pregenWalletService, _sessionManagementService, _portalUrlService, _paraCoreInterface, _authInfo, _isEnclaveUser;
|
|
96
98
|
class AuthService {
|
|
@@ -142,12 +144,14 @@ class AuthService {
|
|
|
142
144
|
}));
|
|
143
145
|
};
|
|
144
146
|
this.prepareLogin = () => __async(this, null, function* () {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
return (0, import_tracer.wrapWithSpan)("auth.prepare_login", () => __async(this, null, function* () {
|
|
148
|
+
yield __privateGet(this, _paraCoreInterface).logout({ skipStateReset: true });
|
|
149
|
+
const { sessionLookupId } = yield __privateGet(this, _sessionManagementService).touchSession(true);
|
|
150
|
+
if (!__privateGet(this, _paraCoreInterface).loginEncryptionKeyPair) {
|
|
151
|
+
yield __privateGet(this, _paraCoreInterface).setLoginEncryptionKeyPair();
|
|
152
|
+
}
|
|
153
|
+
return sessionLookupId;
|
|
154
|
+
}));
|
|
151
155
|
});
|
|
152
156
|
this.setAuth = (_0, ..._1) => __async(this, [_0, ..._1], function* (auth, { extras = {}, userId } = {}) {
|
|
153
157
|
const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client.extractAuthInfo)(auth, { isRequired: true })), extras || {});
|
|
@@ -168,6 +172,7 @@ class AuthService {
|
|
|
168
172
|
});
|
|
169
173
|
this.setUserId = (userId) => __async(this, null, function* () {
|
|
170
174
|
this.userId = userId;
|
|
175
|
+
(0, import_uxStateSpanProcessor.setCurrentUserId)(userId);
|
|
171
176
|
yield __privateGet(this, _paraCoreInterface).localStorageSetItem(constants.LOCAL_STORAGE_USER_ID, userId);
|
|
172
177
|
});
|
|
173
178
|
this.assertIsAuthSet = (allowed) => {
|
|
@@ -243,9 +248,14 @@ class AuthService {
|
|
|
243
248
|
});
|
|
244
249
|
});
|
|
245
250
|
this.performSignUpOrLogIn = (params) => __async(this, null, function* () {
|
|
251
|
+
var _b;
|
|
246
252
|
const _a = params, { auth } = _a, urlOptions = __objRest(_a, ["auth"]);
|
|
247
253
|
try {
|
|
248
|
-
const serverAuthState = yield
|
|
254
|
+
const serverAuthState = yield (0, import_tracer.wrapWithSpan)(
|
|
255
|
+
"auth.send_otp",
|
|
256
|
+
() => __privateGet(this, _paraCoreInterface).ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), __privateGet(this, _paraCoreInterface).getVerificationEmailProps())),
|
|
257
|
+
{ "auth.method": (_b = auth.authType) != null ? _b : "unknown" }
|
|
258
|
+
);
|
|
249
259
|
return { authState: serverAuthState, opts: urlOptions };
|
|
250
260
|
} catch (error) {
|
|
251
261
|
if (error.message.includes("max beta users reached")) {
|
|
@@ -526,51 +536,59 @@ class AuthService {
|
|
|
526
536
|
break;
|
|
527
537
|
}
|
|
528
538
|
}
|
|
529
|
-
yield (0,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
539
|
+
yield (0, import_tracer.wrapWithSpan)(
|
|
540
|
+
"oauth.redirect_wait",
|
|
541
|
+
() => (0, import_stateListener.waitForAuthStateChange)({
|
|
542
|
+
stateManager: __privateGet(this, _stateManager),
|
|
543
|
+
resolvePhases: [
|
|
544
|
+
// awaiting_session_start will be hit for non-SLO logins & all SLO logins/sign ups
|
|
545
|
+
{ phase: "awaiting_session_start", onPhase: () => void 0 }
|
|
546
|
+
],
|
|
547
|
+
rejectPhases: [
|
|
548
|
+
{
|
|
549
|
+
phase: "unauthenticated",
|
|
550
|
+
onPhase: () => new Error("OAuth canceled")
|
|
551
|
+
}
|
|
552
|
+
]
|
|
553
|
+
}),
|
|
554
|
+
{ "auth.method": params.method }
|
|
555
|
+
);
|
|
542
556
|
__privateGet(this, _stateManager).send({
|
|
543
557
|
type: "WAIT_FOR_SESSION",
|
|
544
558
|
data: __spreadProps(__spreadValues({}, params.sessionPollingCallbacks), { autoCreateWallets: true })
|
|
545
559
|
});
|
|
546
|
-
const resp = yield (0,
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
560
|
+
const resp = yield (0, import_tracer.wrapWithSpan)(
|
|
561
|
+
"oauth.session_wait",
|
|
562
|
+
() => (0, import_stateListener.waitForAuthStateChange)({
|
|
563
|
+
stateManager: __privateGet(this, _stateManager),
|
|
564
|
+
resolvePhases: [
|
|
565
|
+
{
|
|
566
|
+
phase: "authenticated",
|
|
567
|
+
onPhase: (state) => {
|
|
568
|
+
const createdWallets = state.newWalletsResult;
|
|
569
|
+
if (createdWallets) {
|
|
570
|
+
return {
|
|
571
|
+
hasCreatedWallets: true,
|
|
572
|
+
recoverySecret: state.newWalletsResult.recoverySecret
|
|
573
|
+
};
|
|
574
|
+
}
|
|
554
575
|
return {
|
|
555
|
-
hasCreatedWallets:
|
|
556
|
-
recoverySecret:
|
|
576
|
+
hasCreatedWallets: false,
|
|
577
|
+
recoverySecret: void 0
|
|
557
578
|
};
|
|
558
579
|
}
|
|
559
|
-
return {
|
|
560
|
-
hasCreatedWallets: false,
|
|
561
|
-
recoverySecret: void 0
|
|
562
|
-
};
|
|
563
580
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
581
|
+
],
|
|
582
|
+
rejectPhases: [
|
|
583
|
+
{
|
|
584
|
+
phase: "unauthenticated",
|
|
585
|
+
onPhase: () => new Error("Session waiting canceled")
|
|
586
|
+
}
|
|
587
|
+
],
|
|
588
|
+
waitForCoreAuthenticated: true
|
|
589
|
+
}),
|
|
590
|
+
{ "auth.method": params.method }
|
|
591
|
+
);
|
|
574
592
|
return __spreadValues({ authInfo: this.authInfo }, resp);
|
|
575
593
|
});
|
|
576
594
|
this.performVerifyTelegram = (params) => __async(this, null, function* () {
|
|
@@ -687,7 +705,7 @@ class AuthService {
|
|
|
687
705
|
const { url } = yield this.getNewCredentialAndUrl({ isForNewDevice: true, authMethod });
|
|
688
706
|
return url;
|
|
689
707
|
});
|
|
690
|
-
this.resendVerificationCode = (_0) => __async(this, [_0], function* ({ type: reason = "SIGNUP" }) {
|
|
708
|
+
this.resendVerificationCode = (_0) => __async(this, [_0], function* ({ type: reason = "SIGNUP", deliveryChannel }) {
|
|
691
709
|
let type, linkedAccountId;
|
|
692
710
|
switch (reason) {
|
|
693
711
|
case "SIGNUP":
|
|
@@ -709,10 +727,11 @@ class AuthService {
|
|
|
709
727
|
if (type !== "EMAIL" && type !== "PHONE") {
|
|
710
728
|
throw new Error("invalid auth type for verification code");
|
|
711
729
|
}
|
|
712
|
-
yield __privateGet(this, _paraCoreInterface).ctx.client.resendVerificationCode(__spreadValues({
|
|
730
|
+
return yield __privateGet(this, _paraCoreInterface).ctx.client.resendVerificationCode(__spreadValues({
|
|
713
731
|
userId,
|
|
714
732
|
type,
|
|
715
|
-
linkedAccountId
|
|
733
|
+
linkedAccountId,
|
|
734
|
+
deliveryChannel
|
|
716
735
|
}, __privateGet(this, _paraCoreInterface).getVerificationEmailProps()));
|
|
717
736
|
});
|
|
718
737
|
__privateSet(this, _paraCoreInterface, paraCore.getAuthServiceInterface());
|
|
@@ -75,6 +75,7 @@ var import_utils = require("../cryptography/utils.js");
|
|
|
75
75
|
var import_events = require("../types/events.js");
|
|
76
76
|
var import_utils2 = require("../utils/index.js");
|
|
77
77
|
var import_stateListener = require("../utils/stateListener.js");
|
|
78
|
+
var import_tracer = require("../telemetry/tracer.js");
|
|
78
79
|
class LoginFlowService extends import_BaseAuthFlowService.BaseAuthFlowService {
|
|
79
80
|
constructor() {
|
|
80
81
|
super(...arguments);
|
|
@@ -136,35 +137,37 @@ class LoginFlowService extends import_BaseAuthFlowService.BaseAuthFlowService {
|
|
|
136
137
|
return result;
|
|
137
138
|
});
|
|
138
139
|
this.waitForLogin = (params) => __async(this, null, function* () {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
140
|
+
return (0, import_tracer.wrapWithSpan)("auth.login_wait", () => __async(this, null, function* () {
|
|
141
|
+
this.stateManager.send({
|
|
142
|
+
type: "WAIT_FOR_SESSION",
|
|
143
|
+
data: __spreadValues({}, params)
|
|
144
|
+
});
|
|
145
|
+
return yield (0, import_stateListener.waitForAuthStateChange)({
|
|
146
|
+
stateManager: this.stateManager,
|
|
147
|
+
resolvePhases: [
|
|
148
|
+
{
|
|
149
|
+
phase: "authenticated",
|
|
150
|
+
onPhase: () => {
|
|
151
|
+
const needsWallet = this.stateManager.getSnapshot().needsWallet;
|
|
152
|
+
(0, import_utils2.dispatchEvent)(import_events.ParaEvent.LOGIN_EVENT, true);
|
|
153
|
+
return {
|
|
154
|
+
partnerId: this.paraCoreInterface.partnerId,
|
|
155
|
+
needsWallet: needsWallet || Object.values(this.services.walletService.wallets).length === 0
|
|
156
|
+
};
|
|
157
|
+
}
|
|
155
158
|
}
|
|
159
|
+
],
|
|
160
|
+
rejectPhases: [
|
|
161
|
+
{
|
|
162
|
+
phase: "unauthenticated",
|
|
163
|
+
onPhase: () => new Error("canceled")
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
onReject: () => {
|
|
167
|
+
(0, import_utils2.dispatchEvent)(import_events.ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
156
168
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
{
|
|
160
|
-
phase: "unauthenticated",
|
|
161
|
-
onPhase: () => new Error("canceled")
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
onReject: () => {
|
|
165
|
-
(0, import_utils2.dispatchEvent)(import_events.ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
166
|
-
}
|
|
167
|
-
});
|
|
169
|
+
});
|
|
170
|
+
}));
|
|
168
171
|
});
|
|
169
172
|
}
|
|
170
173
|
}
|