@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
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
__spreadProps,
|
|
7
7
|
__spreadValues
|
|
8
8
|
} from "../chunk-7B52C2XE.js";
|
|
9
|
-
var _authService, _pregenWalletService, _walletService, _portalUrlService, _sessionManagementService, _paraCoreInterface, _activePollingOperations, _pollingCancelFlags, _openOAuthPopup;
|
|
9
|
+
var _authService, _pregenWalletService, _walletService, _portalUrlService, _sessionManagementService, _paraCoreInterface, _activePollingOperations, _pollingCancelFlags, _openOAuthPopup, _waitForOAuthEventImpl;
|
|
10
10
|
import { PopupType } from "../types/popup.js";
|
|
11
11
|
import { isServerAuthState } from "../utils/types.js";
|
|
12
|
+
import { wrapWithSpan } from "../telemetry/tracer.js";
|
|
12
13
|
import { POLLING_INTERVAL_MS, POLLING_TIMEOUT_MS } from "../constants.js";
|
|
13
14
|
class PollingService {
|
|
14
15
|
constructor(paraCore) {
|
|
@@ -72,85 +73,104 @@ class PollingService {
|
|
|
72
73
|
isCanceled,
|
|
73
74
|
id = "genericPolling"
|
|
74
75
|
} = config;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
cleanup();
|
|
104
|
-
onCancel == null ? void 0 : onCancel();
|
|
105
|
-
return { type: "ERROR", error: "TIMEOUT" };
|
|
106
|
-
}
|
|
76
|
+
return wrapWithSpan(
|
|
77
|
+
`polling.${id}`,
|
|
78
|
+
(span) => __async(this, null, function* () {
|
|
79
|
+
const pollingId = `${id}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
80
|
+
__privateGet(this, _activePollingOperations).add(pollingId);
|
|
81
|
+
const cancelFlag = { canceled: false };
|
|
82
|
+
__privateGet(this, _pollingCancelFlags).set(pollingId, cancelFlag);
|
|
83
|
+
const cleanup = () => {
|
|
84
|
+
__privateGet(this, _activePollingOperations).delete(pollingId);
|
|
85
|
+
__privateGet(this, _pollingCancelFlags).delete(pollingId);
|
|
86
|
+
};
|
|
87
|
+
const isOperationCanceled = () => {
|
|
88
|
+
return cancelFlag.canceled || (isCanceled == null ? void 0 : isCanceled());
|
|
89
|
+
};
|
|
90
|
+
let pollCount = 0;
|
|
91
|
+
let consecutiveErrors = 0;
|
|
92
|
+
let hasInitialized = false;
|
|
93
|
+
const startTime = Date.now();
|
|
94
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
95
|
+
const finalize = (result) => {
|
|
96
|
+
span.setAttribute("polling.poll_count", pollCount);
|
|
97
|
+
span.setAttribute("polling.duration_ms", Date.now() - startTime);
|
|
98
|
+
span.setAttribute("polling.result", result.type);
|
|
99
|
+
if (result.type === "ERROR") {
|
|
100
|
+
span.setAttribute("polling.error", result.error);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
107
104
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
cleanup();
|
|
112
|
-
return { type: "COMPLETE", data };
|
|
105
|
+
if (!hasInitialized && init) {
|
|
106
|
+
yield init();
|
|
107
|
+
hasInitialized = true;
|
|
113
108
|
}
|
|
114
|
-
pollCount
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
109
|
+
while (pollCount < maxPolls) {
|
|
110
|
+
if (isOperationCanceled()) {
|
|
111
|
+
cleanup();
|
|
112
|
+
onCancel == null ? void 0 : onCancel();
|
|
113
|
+
return finalize({ type: "CANCEL" });
|
|
114
|
+
}
|
|
115
|
+
if (Date.now() - startTime > timeoutMs) {
|
|
116
|
+
cleanup();
|
|
117
|
+
onCancel == null ? void 0 : onCancel();
|
|
118
|
+
return finalize({ type: "ERROR", error: "TIMEOUT" });
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const { finished, data } = yield checkCondition();
|
|
122
|
+
consecutiveErrors = 0;
|
|
123
|
+
if (finished) {
|
|
124
|
+
cleanup();
|
|
125
|
+
return finalize({ type: "COMPLETE", data });
|
|
126
|
+
}
|
|
127
|
+
pollCount++;
|
|
128
|
+
__privateGet(this, _paraCoreInterface).devLog(`[${id}] Poll iteration`, {
|
|
129
|
+
pollCount,
|
|
130
|
+
elapsedMs: Date.now() - startTime
|
|
131
|
+
});
|
|
132
|
+
onPoll == null ? void 0 : onPoll();
|
|
133
|
+
if (pollCount < maxPolls) {
|
|
134
|
+
yield sleep(intervalMs);
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
consecutiveErrors++;
|
|
138
|
+
if (consecutiveErrors >= 3) {
|
|
139
|
+
console.warn(`[${id}] ${consecutiveErrors} consecutive polling errors`, error);
|
|
140
|
+
}
|
|
141
|
+
pollCount++;
|
|
142
|
+
onPoll == null ? void 0 : onPoll();
|
|
143
|
+
if (pollCount < maxPolls) {
|
|
144
|
+
yield sleep(intervalMs);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
122
147
|
}
|
|
148
|
+
cleanup();
|
|
149
|
+
onCancel == null ? void 0 : onCancel();
|
|
150
|
+
return finalize({ type: "ERROR", error: "MAX_POLLS_EXCEEDED" });
|
|
123
151
|
} catch (error) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
pollCount++;
|
|
129
|
-
onPoll == null ? void 0 : onPoll();
|
|
130
|
-
if (pollCount < maxPolls) {
|
|
131
|
-
yield sleep(intervalMs);
|
|
132
|
-
}
|
|
152
|
+
console.error("Polling initialization error:", error);
|
|
153
|
+
cleanup();
|
|
154
|
+
onCancel == null ? void 0 : onCancel();
|
|
155
|
+
return finalize({ type: "ERROR", error: "INITIALIZATION_FAILED" });
|
|
133
156
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return { type: "ERROR", error: "MAX_POLLS_EXCEEDED" };
|
|
138
|
-
} catch (error) {
|
|
139
|
-
console.error("Polling initialization error:", error);
|
|
140
|
-
cleanup();
|
|
141
|
-
onCancel == null ? void 0 : onCancel();
|
|
142
|
-
return { type: "ERROR", error: "INITIALIZATION_FAILED" };
|
|
143
|
-
}
|
|
157
|
+
}),
|
|
158
|
+
{ "polling.id": id, "polling.interval_ms": intervalMs, "polling.timeout_ms": timeoutMs }
|
|
159
|
+
);
|
|
144
160
|
});
|
|
145
|
-
this.waitForOAuthEvent = (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
161
|
+
this.waitForOAuthEvent = (params) => __async(this, null, function* () {
|
|
162
|
+
return (
|
|
163
|
+
// Wrap the whole OAuth wait — popup/url setup → event-listener resolution — so
|
|
164
|
+
// the trace shows the user's OAuth round-trip as a single bar with method tagged
|
|
165
|
+
// (Telegram vs Farcaster) and the resolution cause (success/failure/cancel/timeout)
|
|
166
|
+
// attached. Without this, the trace fragments into orphan HTTP spans for the
|
|
167
|
+
// portal URL fetch and nothing tying them to the wait phase.
|
|
168
|
+
wrapWithSpan(`polling.waitForOAuthEvent.${params.method}`, (span) => __privateGet(this, _waitForOAuthEventImpl).call(this, params, span), {
|
|
169
|
+
"polling.method": params.method
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
__privateAdd(this, _waitForOAuthEventImpl, (_0, _1) => __async(this, [_0, _1], function* ({ method, onOAuthPopup, onOAuthUrl, portalTheme, useShortUrls, isCanceled, appScheme }, parentSpan) {
|
|
154
174
|
const oAuthConfigs = {
|
|
155
175
|
TELEGRAM: {
|
|
156
176
|
name: "Telegram",
|
|
@@ -216,12 +236,14 @@ class PollingService {
|
|
|
216
236
|
const successHandler = (eventData) => {
|
|
217
237
|
if (settled) return;
|
|
218
238
|
settled = true;
|
|
239
|
+
parentSpan.setAttribute("polling.result", "success");
|
|
219
240
|
cleanupAll();
|
|
220
241
|
resolve({ authState: eventData.payload, opts: { portalTheme, useShortUrls } });
|
|
221
242
|
};
|
|
222
243
|
const errorHandler = () => {
|
|
223
244
|
if (settled) return;
|
|
224
245
|
settled = true;
|
|
246
|
+
parentSpan.setAttribute("polling.result", "failed");
|
|
225
247
|
cleanupAll();
|
|
226
248
|
reject(`${config.name} authentication failed`);
|
|
227
249
|
};
|
|
@@ -239,6 +261,7 @@ class PollingService {
|
|
|
239
261
|
if (isOperationCanceled()) {
|
|
240
262
|
if (settled) return;
|
|
241
263
|
settled = true;
|
|
264
|
+
parentSpan.setAttribute("polling.result", "canceled");
|
|
242
265
|
cleanupAll();
|
|
243
266
|
reject(`${config.name} authentication canceled`);
|
|
244
267
|
}
|
|
@@ -246,11 +269,12 @@ class PollingService {
|
|
|
246
269
|
timeoutId = setTimeout(() => {
|
|
247
270
|
if (settled) return;
|
|
248
271
|
settled = true;
|
|
272
|
+
parentSpan.setAttribute("polling.result", "timeout");
|
|
249
273
|
cleanupAll();
|
|
250
274
|
reject(`${config.name} authentication timed out`);
|
|
251
275
|
}, POLLING_TIMEOUT_MS);
|
|
252
276
|
});
|
|
253
|
-
});
|
|
277
|
+
}));
|
|
254
278
|
this.waitForTelegramEvent = (params) => __async(this, null, function* () {
|
|
255
279
|
return yield this.waitForOAuthEvent(__spreadProps(__spreadValues({}, params), { method: "TELEGRAM" }));
|
|
256
280
|
});
|
|
@@ -384,6 +408,7 @@ _paraCoreInterface = new WeakMap();
|
|
|
384
408
|
_activePollingOperations = new WeakMap();
|
|
385
409
|
_pollingCancelFlags = new WeakMap();
|
|
386
410
|
_openOAuthPopup = new WeakMap();
|
|
411
|
+
_waitForOAuthEventImpl = new WeakMap();
|
|
387
412
|
export {
|
|
388
413
|
PollingService
|
|
389
414
|
};
|
|
@@ -6,12 +6,64 @@ import {
|
|
|
6
6
|
__spreadProps,
|
|
7
7
|
__spreadValues
|
|
8
8
|
} from "../chunk-7B52C2XE.js";
|
|
9
|
-
var _authService, _pregenWalletService, _sessionManagementService, _walletService, _paraCoreInterface;
|
|
9
|
+
var _authService, _pregenWalletService, _sessionManagementService, _walletService, _paraCoreInterface, _getOAuthUrlImpl;
|
|
10
10
|
import { isPhone } from "@getpara/user-management-client";
|
|
11
11
|
import { constructUrl, getPortalBaseURL, shortenUrl } from "../utils/url.js";
|
|
12
|
+
import { encodeConfigParams, ENCODED_CONFIG_VERSION } from "../utils/configEncoding.js";
|
|
12
13
|
import { getPublicKeyHex } from "../cryptography/utils.js";
|
|
13
14
|
import { splitPhoneNumber } from "../utils/phone.js";
|
|
14
15
|
import { getBaseOAuthUrl } from "../external/userManagementClient.js";
|
|
16
|
+
import { wrapWithSpan } from "../telemetry/tracer.js";
|
|
17
|
+
import { getModalSessionContext } from "../telemetry/modalSession.js";
|
|
18
|
+
import { context, propagation } from "@opentelemetry/api";
|
|
19
|
+
const ENCODE_THRESHOLD = 2500;
|
|
20
|
+
const SHORTEN_THRESHOLD = 3e3;
|
|
21
|
+
const CONFIG_PARAM_KEYS_FOR_BLOB = /* @__PURE__ */ new Set([
|
|
22
|
+
"portalBackgroundColor",
|
|
23
|
+
"portalForegroundColor",
|
|
24
|
+
"portalFont",
|
|
25
|
+
"portalBorderRadius",
|
|
26
|
+
"portalThemeMode",
|
|
27
|
+
"portalForegroundMixRatio",
|
|
28
|
+
"portalCssOverrides",
|
|
29
|
+
"appName",
|
|
30
|
+
"homepageUrl"
|
|
31
|
+
]);
|
|
32
|
+
function buildThemeBlobFromParams(params) {
|
|
33
|
+
const hasAny = params.portalBackgroundColor || params.portalForegroundColor || params.portalFont || params.portalCssOverrides || params.portalThemeMode || params.portalBorderRadius || params.portalForegroundMixRatio;
|
|
34
|
+
if (!hasAny) return void 0;
|
|
35
|
+
let cssOverrides;
|
|
36
|
+
if (params.portalCssOverrides) {
|
|
37
|
+
try {
|
|
38
|
+
cssOverrides = JSON.parse(params.portalCssOverrides);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
cssOverrides = void 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
backgroundColor: params.portalBackgroundColor || void 0,
|
|
45
|
+
foregroundColor: params.portalForegroundColor || void 0,
|
|
46
|
+
mode: params.portalThemeMode || void 0,
|
|
47
|
+
font: params.portalFont || void 0,
|
|
48
|
+
borderRadius: params.portalBorderRadius || void 0,
|
|
49
|
+
foregroundMixRatio: params.portalForegroundMixRatio ? parseFloat(params.portalForegroundMixRatio) : void 0,
|
|
50
|
+
cssOverrides
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function buildAppBlobFromParams(params) {
|
|
54
|
+
if (!params.appName && !params.homepageUrl) return void 0;
|
|
55
|
+
return {
|
|
56
|
+
appName: params.appName || void 0,
|
|
57
|
+
homepageUrl: params.homepageUrl || void 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function withoutConfigParams(params) {
|
|
61
|
+
const out = {};
|
|
62
|
+
for (const [k, v] of Object.entries(params)) {
|
|
63
|
+
if (!CONFIG_PARAM_KEYS_FOR_BLOB.has(k)) out[k] = v;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
15
67
|
class PortalUrlService {
|
|
16
68
|
constructor(paraCore) {
|
|
17
69
|
__privateAdd(this, _authService);
|
|
@@ -53,7 +105,7 @@ class PortalUrlService {
|
|
|
53
105
|
return __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || (yield this.getPartnerURL()) || getPortalBaseURL(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
|
|
54
106
|
});
|
|
55
107
|
this.constructPortalUrl = (_0, ..._1) => __async(this, [_0, ..._1], function* (type, opts = {}) {
|
|
56
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
108
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
57
109
|
const [
|
|
58
110
|
isCreate,
|
|
59
111
|
isLogin,
|
|
@@ -195,24 +247,40 @@ class PortalUrlService {
|
|
|
195
247
|
encryptionKey: getPublicKeyHex(__privateGet(this, _paraCoreInterface).loginEncryptionKeyPair),
|
|
196
248
|
sessionId
|
|
197
249
|
};
|
|
198
|
-
const
|
|
250
|
+
const traceCarrier = {};
|
|
251
|
+
propagation.inject((_b = getModalSessionContext()) != null ? _b : context.active(), traceCarrier);
|
|
252
|
+
const cfgTheme = __privateGet(this, _paraCoreInterface).config.themeConfig;
|
|
253
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, traceCarrier), {
|
|
199
254
|
apiKey: __privateGet(this, _paraCoreInterface).ctx.apiKey,
|
|
200
255
|
partnerId: partner == null ? void 0 : partner.id
|
|
201
|
-
}, typeof window !== "undefined" && ((
|
|
202
|
-
portalFont: ((
|
|
203
|
-
portalBorderRadius: ((
|
|
204
|
-
portalThemeMode: ((
|
|
205
|
-
portalForegroundMixRatio: (
|
|
256
|
+
}), typeof window !== "undefined" && ((_c = window.location) == null ? void 0 : _c.origin) ? { origin: window.location.origin } : {}), {
|
|
257
|
+
portalFont: ((_d = opts.portalTheme) == null ? void 0 : _d.font) || (cfgTheme == null ? void 0 : cfgTheme.font) || ((_e = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _e.font) || (partner == null ? void 0 : partner.font),
|
|
258
|
+
portalBorderRadius: ((_f = opts.portalTheme) == null ? void 0 : _f.borderRadius) || (cfgTheme == null ? void 0 : cfgTheme.borderRadius) || ((_g = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _g.borderRadius),
|
|
259
|
+
portalThemeMode: ((_h = opts.portalTheme) == null ? void 0 : _h.mode) || (cfgTheme == null ? void 0 : cfgTheme.mode) || ((_i = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _i.mode) || (partner == null ? void 0 : partner.themeMode),
|
|
260
|
+
portalForegroundMixRatio: (_n = (_m = (_k = (_j = opts.portalTheme) == null ? void 0 : _j.foregroundMixRatio) != null ? _k : cfgTheme == null ? void 0 : cfgTheme.foregroundMixRatio) != null ? _m : (_l = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _l.foregroundMixRatio) == null ? void 0 : _n.toString(),
|
|
206
261
|
portalCssOverrides: (() => {
|
|
207
|
-
var _a2, _b2, _c2;
|
|
208
|
-
const overrides = (
|
|
262
|
+
var _a2, _b2, _c2, _d2;
|
|
263
|
+
const overrides = (_d2 = (_b2 = (_a2 = opts.portalTheme) == null ? void 0 : _a2.cssOverrides) != null ? _b2 : cfgTheme == null ? void 0 : cfgTheme.cssOverrides) != null ? _d2 : (_c2 = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _c2.cssOverrides;
|
|
209
264
|
return overrides ? JSON.stringify(overrides) : void 0;
|
|
210
265
|
})(),
|
|
211
|
-
portalForegroundColor: ((
|
|
212
|
-
portalBackgroundColor: ((
|
|
266
|
+
portalForegroundColor: ((_o = opts.portalTheme) == null ? void 0 : _o.accentColor) || ((_p = opts.portalTheme) == null ? void 0 : _p.foregroundColor) || (cfgTheme == null ? void 0 : cfgTheme.accentColor) || (cfgTheme == null ? void 0 : cfgTheme.foregroundColor) || ((_q = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _q.accentColor) || ((_r = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _r.foregroundColor) || (partner == null ? void 0 : partner.accentColor) || (partner == null ? void 0 : partner.foregroundColor),
|
|
267
|
+
portalBackgroundColor: ((_s = opts.portalTheme) == null ? void 0 : _s.backgroundColor) || (cfgTheme == null ? void 0 : cfgTheme.backgroundColor) || ((_t = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _t.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || __privateGet(this, _paraCoreInterface).portalBackgroundColor,
|
|
213
268
|
portalPrimaryButtonColor: __privateGet(this, _paraCoreInterface).portalPrimaryButtonColor,
|
|
214
269
|
portalTextColor: __privateGet(this, _paraCoreInterface).portalTextColor,
|
|
215
270
|
portalPrimaryButtonTextColor: __privateGet(this, _paraCoreInterface).portalPrimaryButtonTextColor,
|
|
271
|
+
// SDK-overridable branding threaded into the popup. `appName` is the
|
|
272
|
+
// load-bearing field for the V2 render sites that previously read
|
|
273
|
+
// `partner.displayName`; `homepageUrl` lights up the URL param
|
|
274
|
+
// ModalLayoutV2 already consumed.
|
|
275
|
+
appName: __privateGet(this, _paraCoreInterface).config.appName,
|
|
276
|
+
homepageUrl: (_u = __privateGet(this, _paraCoreInterface).config.partnerLinks) == null ? void 0 : _u.homepageUrl,
|
|
277
|
+
// The `authOAuthMethods` / `authDisableEmail` / `authDisablePhone` URL
|
|
278
|
+
// params were deleted here. Portal audit confirmed there is no
|
|
279
|
+
// auth-method-selection UI in V2 (every route lands on an already-chosen
|
|
280
|
+
// flow), so the params had no consumer. SDK-side gating in
|
|
281
|
+
// partnerConfigGating.ts is the sole enforcement point. If the portal
|
|
282
|
+
// ever grows method-selection UI, re-add via the `c` encoded blob (bump
|
|
283
|
+
// schema version) rather than as individual params.
|
|
216
284
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
217
285
|
}), __privateGet(this, _authService).authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey || isTxReview) ? __spreadProps(__spreadValues({
|
|
218
286
|
authInfo: JSON.stringify(__privateGet(this, _authService).authInfo)
|
|
@@ -239,12 +307,31 @@ class PortalUrlService {
|
|
|
239
307
|
}), isExportPrivateKey || isTxReview ? {
|
|
240
308
|
sessionId: thisDevice.sessionId
|
|
241
309
|
} : {});
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
|
|
310
|
+
const plainUrl = constructUrl({ base, path, params });
|
|
311
|
+
if (plainUrl.length <= ENCODE_THRESHOLD) {
|
|
312
|
+
if (opts.shorten) {
|
|
313
|
+
const shortUrl = yield shortenUrl(__privateGet(this, _paraCoreInterface).ctx, plainUrl, shouldUseLegacyPortalUrl);
|
|
314
|
+
return { url: shortUrl, fullUrl: plainUrl };
|
|
315
|
+
}
|
|
316
|
+
return { url: plainUrl, fullUrl: plainUrl };
|
|
246
317
|
}
|
|
247
|
-
|
|
318
|
+
const themeBlob = buildThemeBlobFromParams(params);
|
|
319
|
+
const appBlob = buildAppBlobFromParams(params);
|
|
320
|
+
let candidateUrl = plainUrl;
|
|
321
|
+
if (themeBlob || appBlob) {
|
|
322
|
+
const c = yield encodeConfigParams(__spreadValues(__spreadValues({
|
|
323
|
+
v: ENCODED_CONFIG_VERSION
|
|
324
|
+
}, themeBlob && { theme: themeBlob }), appBlob && { app: appBlob }));
|
|
325
|
+
if (c) {
|
|
326
|
+
const encodedParams = __spreadProps(__spreadValues({}, withoutConfigParams(params)), { c });
|
|
327
|
+
candidateUrl = constructUrl({ base, path, params: encodedParams });
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (opts.shorten || candidateUrl.length > SHORTEN_THRESHOLD) {
|
|
331
|
+
const shortUrl = yield shortenUrl(__privateGet(this, _paraCoreInterface).ctx, candidateUrl, shouldUseLegacyPortalUrl);
|
|
332
|
+
return { url: shortUrl, fullUrl: candidateUrl };
|
|
333
|
+
}
|
|
334
|
+
return { url: candidateUrl, fullUrl: candidateUrl };
|
|
248
335
|
});
|
|
249
336
|
this.getLoginUrl = (_0) => __async(this, [_0], function* ({ authMethod = "PASSKEY", shorten = false, portalTheme, sessionId }) {
|
|
250
337
|
if (!sessionId) {
|
|
@@ -274,7 +361,12 @@ class PortalUrlService {
|
|
|
274
361
|
portalTheme
|
|
275
362
|
});
|
|
276
363
|
});
|
|
277
|
-
this.getOAuthUrl = (
|
|
364
|
+
this.getOAuthUrl = (params) => __async(this, null, function* () {
|
|
365
|
+
return wrapWithSpan("auth.get_oauth_url", () => __privateGet(this, _getOAuthUrlImpl).call(this, params), {
|
|
366
|
+
"oauth.method": params.method
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
__privateAdd(this, _getOAuthUrlImpl, (_0) => __async(this, [_0], function* ({
|
|
278
370
|
method,
|
|
279
371
|
appScheme,
|
|
280
372
|
accountLinkInProgress,
|
|
@@ -316,7 +408,7 @@ class PortalUrlService {
|
|
|
316
408
|
linkedAccountId: __privateGet(this, _paraCoreInterface).accountLinkInProgress.id
|
|
317
409
|
} : {}), callback && { callback })
|
|
318
410
|
});
|
|
319
|
-
});
|
|
411
|
+
}));
|
|
320
412
|
__privateSet(this, _paraCoreInterface, paraCore.getPortalUrlServiceInterface());
|
|
321
413
|
}
|
|
322
414
|
}
|
|
@@ -325,6 +417,7 @@ _pregenWalletService = new WeakMap();
|
|
|
325
417
|
_sessionManagementService = new WeakMap();
|
|
326
418
|
_walletService = new WeakMap();
|
|
327
419
|
_paraCoreInterface = new WeakMap();
|
|
420
|
+
_getOAuthUrlImpl = new WeakMap();
|
|
328
421
|
export {
|
|
329
422
|
PortalUrlService
|
|
330
423
|
};
|