@getpara/core-sdk 2.24.0 → 3.0.0-alpha.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 +28 -9
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/services/AuthService.js +2 -2
- package/dist/cjs/services/ExternalWalletService.js +0 -3
- package/dist/cjs/services/LoginFlowService.js +24 -13
- package/dist/cjs/services/PollingService.js +3 -3
- package/dist/cjs/services/PortalUrlService.js +50 -43
- package/dist/cjs/services/SessionManagementService.js +3 -3
- package/dist/cjs/services/SignupFlowService.js +18 -3
- package/dist/cjs/services/VerificationFlowService.js +9 -4
- package/dist/cjs/services/WalletService.js +8 -1
- package/dist/cjs/state/CoreStateManager.js +37 -17
- package/dist/cjs/state/machines/authStateMachine.js +12 -0
- package/dist/cjs/types/coreApi.js +1 -0
- package/dist/esm/ParaCore.js +28 -9
- package/dist/esm/constants.js +1 -1
- package/dist/esm/services/AuthService.js +2 -2
- package/dist/esm/services/ExternalWalletService.js +0 -3
- package/dist/esm/services/LoginFlowService.js +24 -13
- package/dist/esm/services/PollingService.js +3 -3
- package/dist/esm/services/PortalUrlService.js +50 -43
- package/dist/esm/services/SessionManagementService.js +3 -3
- package/dist/esm/services/SignupFlowService.js +18 -3
- package/dist/esm/services/VerificationFlowService.js +9 -4
- package/dist/esm/services/WalletService.js +8 -1
- package/dist/esm/state/CoreStateManager.js +37 -17
- package/dist/esm/state/machines/authStateMachine.js +12 -0
- package/dist/esm/types/coreApi.js +1 -0
- package/dist/types/ParaCore.d.ts +17 -7
- package/dist/types/services/WalletService.d.ts +2 -1
- package/dist/types/services/types/AuthServiceTypes.d.ts +4 -1
- package/dist/types/services/types/PortalUrlServiceTypes.d.ts +9 -5
- package/dist/types/services/types/WalletServiceTypes.d.ts +12 -0
- package/dist/types/state/machines/authStateMachine.d.ts +112 -1
- package/dist/types/state/machines/coreStateMachine.d.ts +682 -16
- package/dist/types/state/types/auth.d.ts +4 -1
- package/dist/types/state/types/core.d.ts +11 -1
- package/dist/types/types/authState.d.ts +25 -0
- package/dist/types/types/config.d.ts +3 -2
- package/dist/types/types/coreApi.d.ts +9 -3
- package/dist/types/types/serviceInterfaces.d.ts +3 -3
- package/dist/types/types/util.d.ts +14 -1
- package/package.json +3 -3
|
@@ -115,7 +115,7 @@ const _CoreStateManager = class _CoreStateManager {
|
|
|
115
115
|
* Extracts all data needed by UI consumers from authStateResult.
|
|
116
116
|
*/
|
|
117
117
|
computeAuthStateInfo(authContext, walletContext) {
|
|
118
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
118
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
|
|
119
119
|
const defaultAuthStateInfo = {
|
|
120
120
|
userId: null,
|
|
121
121
|
isPasskeySupported: false,
|
|
@@ -124,11 +124,15 @@ const _CoreStateManager = class _CoreStateManager {
|
|
|
124
124
|
hasPassword: false,
|
|
125
125
|
hasPin: false,
|
|
126
126
|
passkeyUrl: null,
|
|
127
|
+
passkeyFullUrl: null,
|
|
127
128
|
passkeyKnownDeviceUrl: null,
|
|
128
129
|
passwordUrl: null,
|
|
129
130
|
pinUrl: null,
|
|
131
|
+
passwordFullUrl: null,
|
|
132
|
+
pinFullUrl: null,
|
|
130
133
|
passkeyId: null,
|
|
131
134
|
verificationUrl: null,
|
|
135
|
+
verificationFullUrl: null,
|
|
132
136
|
externalWalletVerification: null,
|
|
133
137
|
recoverySecret: null,
|
|
134
138
|
isNewUser: false
|
|
@@ -158,10 +162,14 @@ const _CoreStateManager = class _CoreStateManager {
|
|
|
158
162
|
let hasPin = false;
|
|
159
163
|
let isPasskeySupported = false;
|
|
160
164
|
let passkeyUrl = null;
|
|
165
|
+
let passkeyFullUrl = null;
|
|
161
166
|
let passkeyKnownDeviceUrl = null;
|
|
162
167
|
let passwordUrl = null;
|
|
163
168
|
let pinUrl = null;
|
|
169
|
+
let passwordFullUrl = null;
|
|
170
|
+
let pinFullUrl = null;
|
|
164
171
|
let verificationUrl = null;
|
|
172
|
+
let verificationFullUrl = null;
|
|
165
173
|
let passkeyHints = null;
|
|
166
174
|
let passkeyId = null;
|
|
167
175
|
if (stage === "login") {
|
|
@@ -172,24 +180,31 @@ const _CoreStateManager = class _CoreStateManager {
|
|
|
172
180
|
hasPin = authMethods.includes("PIN");
|
|
173
181
|
isPasskeySupported = (_k = loginState.isPasskeySupported) != null ? _k : false;
|
|
174
182
|
passkeyUrl = (_l = loginState.passkeyUrl) != null ? _l : null;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
183
|
+
passkeyFullUrl = (_m = loginState.passkeyFullUrl) != null ? _m : null;
|
|
184
|
+
passkeyKnownDeviceUrl = (_n = loginState.passkeyKnownDeviceUrl) != null ? _n : null;
|
|
185
|
+
passwordUrl = (_o = loginState.passwordUrl) != null ? _o : null;
|
|
186
|
+
pinUrl = (_p = loginState.pinUrl) != null ? _p : null;
|
|
187
|
+
passwordFullUrl = (_q = loginState.passwordFullUrl) != null ? _q : null;
|
|
188
|
+
pinFullUrl = (_r = loginState.pinFullUrl) != null ? _r : null;
|
|
189
|
+
passkeyHints = (_s = loginState.biometricHints) != null ? _s : null;
|
|
179
190
|
} else if (stage === "signup") {
|
|
180
191
|
const signupState = authStateResult;
|
|
181
|
-
const authMethods = (
|
|
192
|
+
const authMethods = (_t = signupState.signupAuthMethods) != null ? _t : [];
|
|
182
193
|
hasPasskey = authMethods.includes("PASSKEY");
|
|
183
194
|
hasPassword = authMethods.includes("PASSWORD");
|
|
184
195
|
hasPin = authMethods.includes("PIN");
|
|
185
|
-
isPasskeySupported = (
|
|
186
|
-
passkeyUrl = (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
isPasskeySupported = (_u = signupState.isPasskeySupported) != null ? _u : false;
|
|
197
|
+
passkeyUrl = (_v = signupState.passkeyUrl) != null ? _v : null;
|
|
198
|
+
passkeyFullUrl = (_w = signupState.passkeyFullUrl) != null ? _w : null;
|
|
199
|
+
passwordUrl = (_x = signupState.passwordUrl) != null ? _x : null;
|
|
200
|
+
pinUrl = (_y = signupState.pinUrl) != null ? _y : null;
|
|
201
|
+
passwordFullUrl = (_z = signupState.passwordFullUrl) != null ? _z : null;
|
|
202
|
+
pinFullUrl = (_A = signupState.pinFullUrl) != null ? _A : null;
|
|
203
|
+
passkeyId = (_B = signupState.passkeyId) != null ? _B : null;
|
|
190
204
|
} else if (stage === "verify") {
|
|
191
205
|
const verifyState = authStateResult;
|
|
192
|
-
verificationUrl = (
|
|
206
|
+
verificationUrl = (_C = verifyState.loginUrl) != null ? _C : null;
|
|
207
|
+
verificationFullUrl = (_D = verifyState.loginFullUrl) != null ? _D : null;
|
|
193
208
|
}
|
|
194
209
|
return {
|
|
195
210
|
userId,
|
|
@@ -199,15 +214,19 @@ const _CoreStateManager = class _CoreStateManager {
|
|
|
199
214
|
hasPassword,
|
|
200
215
|
hasPin,
|
|
201
216
|
passkeyUrl,
|
|
217
|
+
passkeyFullUrl,
|
|
202
218
|
passkeyKnownDeviceUrl,
|
|
203
219
|
passwordUrl,
|
|
204
220
|
pinUrl,
|
|
221
|
+
passwordFullUrl,
|
|
222
|
+
pinFullUrl,
|
|
205
223
|
passkeyId,
|
|
206
224
|
verificationUrl,
|
|
225
|
+
verificationFullUrl,
|
|
207
226
|
externalWalletVerification: externalWalletVerification ? {
|
|
208
|
-
signatureVerificationMessage: (
|
|
209
|
-
walletAddress: (
|
|
210
|
-
walletType: (
|
|
227
|
+
signatureVerificationMessage: (_E = externalWalletVerification.signatureVerificationMessage) != null ? _E : "",
|
|
228
|
+
walletAddress: (_G = (_F = externalWalletVerification.externalWallet) == null ? void 0 : _F.address) != null ? _G : "",
|
|
229
|
+
walletType: (_I = (_H = externalWalletVerification.externalWallet) == null ? void 0 : _H.type) != null ? _I : ""
|
|
211
230
|
} : null,
|
|
212
231
|
recoverySecret,
|
|
213
232
|
isNewUser
|
|
@@ -237,6 +256,7 @@ const _CoreStateManager = class _CoreStateManager {
|
|
|
237
256
|
newWalletsResult: (walletMachineState == null ? void 0 : walletMachineState.context.newWalletsResult) || null,
|
|
238
257
|
externalWalletSignVerification: (authMachineState == null ? void 0 : authMachineState.context.externalWalletSignVerification) || null,
|
|
239
258
|
isNewUser: (authMachineState == null ? void 0 : authMachineState.context.isNewUser) || false,
|
|
259
|
+
selectedOAuthMethod: (authMachineState == null ? void 0 : authMachineState.context.selectedOAuthMethod) || null,
|
|
240
260
|
// Wallet process
|
|
241
261
|
guestWallets: (walletMachineState == null ? void 0 : walletMachineState.context.guestWallets) || null
|
|
242
262
|
};
|
|
@@ -264,11 +284,11 @@ const _CoreStateManager = class _CoreStateManager {
|
|
|
264
284
|
}
|
|
265
285
|
statesEqual(state1, state2) {
|
|
266
286
|
var _a, _b;
|
|
267
|
-
return state1.phase === state2.phase && state1.authStatePhase === state2.authStatePhase && state1.walletStatePhase === state2.walletStatePhase && state1.isLoading === state2.isLoading && state1.isReady === state2.isReady && state1.isNewUser === state2.isNewUser && state1.needsWallet === state2.needsWallet && ((_a = state1.error) == null ? void 0 : _a.message) === ((_b = state2.error) == null ? void 0 : _b.message) && state1.authStateResult === state2.authStateResult && state1.newWalletsResult === state2.newWalletsResult && state1.guestWallets === state2.guestWallets && state1.externalWalletSignVerification === state2.externalWalletSignVerification && this.authStateInfoEqual(state1.authStateInfo, state2.authStateInfo);
|
|
287
|
+
return state1.phase === state2.phase && state1.authStatePhase === state2.authStatePhase && state1.walletStatePhase === state2.walletStatePhase && state1.isLoading === state2.isLoading && state1.isReady === state2.isReady && state1.isNewUser === state2.isNewUser && state1.needsWallet === state2.needsWallet && ((_a = state1.error) == null ? void 0 : _a.message) === ((_b = state2.error) == null ? void 0 : _b.message) && state1.authStateResult === state2.authStateResult && state1.newWalletsResult === state2.newWalletsResult && state1.guestWallets === state2.guestWallets && state1.externalWalletSignVerification === state2.externalWalletSignVerification && state1.selectedOAuthMethod === state2.selectedOAuthMethod && this.authStateInfoEqual(state1.authStateInfo, state2.authStateInfo);
|
|
268
288
|
}
|
|
269
289
|
authStateInfoEqual(a, b) {
|
|
270
290
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
271
|
-
return a.userId === b.userId && a.isPasskeySupported === b.isPasskeySupported && a.hasPasskey === b.hasPasskey && a.hasPassword === b.hasPassword && a.hasPin === b.hasPin && a.passkeyUrl === b.passkeyUrl && a.passkeyKnownDeviceUrl === b.passkeyKnownDeviceUrl && a.passwordUrl === b.passwordUrl && a.pinUrl === b.pinUrl && a.passkeyId === b.passkeyId && a.verificationUrl === b.verificationUrl && a.recoverySecret === b.recoverySecret && a.isNewUser === b.isNewUser && ((_a = a.externalWalletVerification) == null ? void 0 : _a.signatureVerificationMessage) === ((_b = b.externalWalletVerification) == null ? void 0 : _b.signatureVerificationMessage) && ((_c = a.externalWalletVerification) == null ? void 0 : _c.walletAddress) === ((_d = b.externalWalletVerification) == null ? void 0 : _d.walletAddress) && ((_e = a.externalWalletVerification) == null ? void 0 : _e.walletType) === ((_f = b.externalWalletVerification) == null ? void 0 : _f.walletType) && ((_g = a.passkeyHints) == null ? void 0 : _g.length) === ((_h = b.passkeyHints) == null ? void 0 : _h.length) && ((_i = a.passkeyHints) != null ? _i : []).every(
|
|
291
|
+
return a.userId === b.userId && a.isPasskeySupported === b.isPasskeySupported && a.hasPasskey === b.hasPasskey && a.hasPassword === b.hasPassword && a.hasPin === b.hasPin && a.passkeyUrl === b.passkeyUrl && a.passkeyFullUrl === b.passkeyFullUrl && a.passkeyKnownDeviceUrl === b.passkeyKnownDeviceUrl && a.passwordUrl === b.passwordUrl && a.passwordFullUrl === b.passwordFullUrl && a.pinUrl === b.pinUrl && a.pinFullUrl === b.pinFullUrl && a.passkeyId === b.passkeyId && a.verificationUrl === b.verificationUrl && a.verificationFullUrl === b.verificationFullUrl && a.recoverySecret === b.recoverySecret && a.isNewUser === b.isNewUser && ((_a = a.externalWalletVerification) == null ? void 0 : _a.signatureVerificationMessage) === ((_b = b.externalWalletVerification) == null ? void 0 : _b.signatureVerificationMessage) && ((_c = a.externalWalletVerification) == null ? void 0 : _c.walletAddress) === ((_d = b.externalWalletVerification) == null ? void 0 : _d.walletAddress) && ((_e = a.externalWalletVerification) == null ? void 0 : _e.walletType) === ((_f = b.externalWalletVerification) == null ? void 0 : _f.walletType) && ((_g = a.passkeyHints) == null ? void 0 : _g.length) === ((_h = b.passkeyHints) == null ? void 0 : _h.length) && ((_i = a.passkeyHints) != null ? _i : []).every(
|
|
272
292
|
(hint, i) => hint.useragent === b.passkeyHints[i].useragent && hint.aaguid === b.passkeyHints[i].aaguid
|
|
273
293
|
);
|
|
274
294
|
}
|
|
@@ -158,6 +158,7 @@ function createAuthStateMachine(paraCoreInterface) {
|
|
|
158
158
|
shouldAutoCreateWallets: false,
|
|
159
159
|
skipSessionRefreshOnSetup: false,
|
|
160
160
|
isLegacy: false,
|
|
161
|
+
selectedOAuthMethod: null,
|
|
161
162
|
retryAttempts: {},
|
|
162
163
|
externalWalletInfo: void 0,
|
|
163
164
|
externalWalletSignVerification: void 0
|
|
@@ -219,8 +220,12 @@ function createAuthStateMachine(paraCoreInterface) {
|
|
|
219
220
|
shouldAutoCreateWallets: false,
|
|
220
221
|
skipSessionRefreshOnSetup: false,
|
|
221
222
|
isLegacy: false,
|
|
223
|
+
selectedOAuthMethod: null,
|
|
222
224
|
retryAttempts: {}
|
|
223
225
|
}),
|
|
226
|
+
on: {
|
|
227
|
+
LOGOUT: { target: ".unauthenticated", actions: ["resetState"] }
|
|
228
|
+
},
|
|
224
229
|
states: {
|
|
225
230
|
checking_state: {
|
|
226
231
|
invoke: {
|
|
@@ -256,6 +261,7 @@ function createAuthStateMachine(paraCoreInterface) {
|
|
|
256
261
|
}
|
|
257
262
|
},
|
|
258
263
|
unauthenticated: {
|
|
264
|
+
entry: [(0, import_xstate.assign)({ selectedOAuthMethod: null })],
|
|
259
265
|
on: __spreadProps(__spreadValues({}, import_authStateMachine_helpers.AUTH_RESTART_TRANSITIONS), {
|
|
260
266
|
INITIALIZE_GUEST_MODE: "guest_mode",
|
|
261
267
|
SESSION_IMPORTED: "authenticated"
|
|
@@ -379,6 +385,12 @@ function createAuthStateMachine(paraCoreInterface) {
|
|
|
379
385
|
};
|
|
380
386
|
}
|
|
381
387
|
return null;
|
|
388
|
+
},
|
|
389
|
+
selectedOAuthMethod: ({ event }) => {
|
|
390
|
+
if (event.type === "AUTHENTICATE_OAUTH") {
|
|
391
|
+
return event.data.method;
|
|
392
|
+
}
|
|
393
|
+
return null;
|
|
382
394
|
}
|
|
383
395
|
}),
|
|
384
396
|
"setIsLegacy"
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -499,6 +499,7 @@ const _ParaCore = class _ParaCore {
|
|
|
499
499
|
authPhase: state.authStatePhase,
|
|
500
500
|
walletPhase: state.walletStatePhase,
|
|
501
501
|
authStateInfo: state.authStateInfo,
|
|
502
|
+
selectedOAuthMethod: state.selectedOAuthMethod,
|
|
502
503
|
error: state.error,
|
|
503
504
|
isReady: state.isReady
|
|
504
505
|
};
|
|
@@ -552,10 +553,11 @@ const _ParaCore = class _ParaCore {
|
|
|
552
553
|
authPhase: state.authStatePhase,
|
|
553
554
|
walletPhase: state.walletStatePhase,
|
|
554
555
|
authStateInfo: state.authStateInfo,
|
|
556
|
+
selectedOAuthMethod: state.selectedOAuthMethod,
|
|
555
557
|
error: state.error,
|
|
556
558
|
isReady: state.isReady
|
|
557
559
|
};
|
|
558
|
-
if (!lastSnapshot || lastSnapshot.corePhase !== currentSnapshot.corePhase || lastSnapshot.authPhase !== currentSnapshot.authPhase || lastSnapshot.walletPhase !== currentSnapshot.walletPhase || lastSnapshot.error !== currentSnapshot.error || lastSnapshot.isReady !== currentSnapshot.isReady) {
|
|
560
|
+
if (!lastSnapshot || lastSnapshot.corePhase !== currentSnapshot.corePhase || lastSnapshot.authPhase !== currentSnapshot.authPhase || lastSnapshot.walletPhase !== currentSnapshot.walletPhase || lastSnapshot.selectedOAuthMethod !== currentSnapshot.selectedOAuthMethod || lastSnapshot.error !== currentSnapshot.error || lastSnapshot.isReady !== currentSnapshot.isReady) {
|
|
559
561
|
lastSnapshot = currentSnapshot;
|
|
560
562
|
callback(currentSnapshot);
|
|
561
563
|
}
|
|
@@ -1806,10 +1808,10 @@ const _ParaCore = class _ParaCore {
|
|
|
1806
1808
|
getSwitchWalletsUrl() {
|
|
1807
1809
|
return __async(this, null, function* () {
|
|
1808
1810
|
const authMethods = yield this.supportedUserAuthMethods();
|
|
1809
|
-
const
|
|
1811
|
+
const result = yield this.constructPortalUrl("switchWallets", {
|
|
1810
1812
|
useLegacyUrl: authMethods.has(AuthMethod.PASSKEY)
|
|
1811
1813
|
});
|
|
1812
|
-
return url;
|
|
1814
|
+
return result.url;
|
|
1813
1815
|
});
|
|
1814
1816
|
}
|
|
1815
1817
|
/**
|
|
@@ -2078,22 +2080,24 @@ const _ParaCore = class _ParaCore {
|
|
|
2078
2080
|
getTransactionReviewUrl(transactionId, timeoutMs) {
|
|
2079
2081
|
return __async(this, null, function* () {
|
|
2080
2082
|
const authMethods = yield this.supportedUserAuthMethods();
|
|
2081
|
-
|
|
2083
|
+
const result = yield this.constructPortalUrl("txReview", {
|
|
2082
2084
|
pathId: transactionId,
|
|
2083
2085
|
useLegacyUrl: authMethods.has(AuthMethod.PASSKEY),
|
|
2084
2086
|
params: {
|
|
2085
2087
|
timeoutMs: timeoutMs == null ? void 0 : timeoutMs.toString()
|
|
2086
2088
|
}
|
|
2087
2089
|
});
|
|
2090
|
+
return result.url;
|
|
2088
2091
|
});
|
|
2089
2092
|
}
|
|
2090
2093
|
getOnRampTransactionUrl(_0) {
|
|
2091
2094
|
return __async(this, arguments, function* ({
|
|
2092
2095
|
purchaseId
|
|
2093
2096
|
}) {
|
|
2094
|
-
|
|
2097
|
+
const result = yield this.constructPortalUrl("onRamp", {
|
|
2095
2098
|
pathId: purchaseId
|
|
2096
2099
|
});
|
|
2100
|
+
return result.url;
|
|
2097
2101
|
});
|
|
2098
2102
|
}
|
|
2099
2103
|
getWalletBalance(params) {
|
|
@@ -2101,6 +2105,18 @@ const _ParaCore = class _ParaCore {
|
|
|
2101
2105
|
return yield __privateGet(this, _walletService).getWalletBalance(params);
|
|
2102
2106
|
});
|
|
2103
2107
|
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Requests testnet funds from the faucet for the specified wallet.
|
|
2110
|
+
* @param {RequestFaucetParams} params the options object.
|
|
2111
|
+
* @param {string} params.walletId the id of the wallet to fund.
|
|
2112
|
+
* @param {string} [params.chain] optional chain identifier to target a specific testnet.
|
|
2113
|
+
* @returns the faucet transaction details, including the transaction hash and amount sent.
|
|
2114
|
+
*/
|
|
2115
|
+
requestFaucet(params) {
|
|
2116
|
+
return __async(this, null, function* () {
|
|
2117
|
+
return yield __privateGet(this, _walletService).requestFaucet(params);
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2104
2120
|
/**
|
|
2105
2121
|
* Signs a message using one of the current wallets.
|
|
2106
2122
|
*
|
|
@@ -2587,12 +2603,13 @@ const _ParaCore = class _ParaCore {
|
|
|
2587
2603
|
* @param {Object} opts the options object
|
|
2588
2604
|
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
2589
2605
|
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
2590
|
-
* @param {
|
|
2606
|
+
* @param {PortalTheme} opts.portalTheme the Para Portal theme to apply to the password creation URL, if other than the default theme
|
|
2591
2607
|
* @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
|
|
2592
2608
|
*/
|
|
2593
2609
|
getLoginUrl(params) {
|
|
2594
2610
|
return __async(this, null, function* () {
|
|
2595
|
-
|
|
2611
|
+
const result = yield __privateGet(this, _portalUrlService).getLoginUrl(params);
|
|
2612
|
+
return result.url;
|
|
2596
2613
|
});
|
|
2597
2614
|
}
|
|
2598
2615
|
prepareLogin() {
|
|
@@ -2748,7 +2765,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2748
2765
|
sendLoginCode() {
|
|
2749
2766
|
return __async(this, null, function* () {
|
|
2750
2767
|
const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
|
|
2751
|
-
this.setUserId(userId);
|
|
2768
|
+
yield this.setUserId(userId);
|
|
2769
|
+
return { userId };
|
|
2752
2770
|
});
|
|
2753
2771
|
}
|
|
2754
2772
|
exportPrivateKey() {
|
|
@@ -2774,10 +2792,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2774
2792
|
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: PopupType.EXPORT_PRIVATE_KEY });
|
|
2775
2793
|
}
|
|
2776
2794
|
const authMethods = yield this.supportedUserAuthMethods();
|
|
2777
|
-
const
|
|
2795
|
+
const exportPrivateKeyResult = yield this.constructPortalUrl("exportPrivateKey", {
|
|
2778
2796
|
pathId: walletId,
|
|
2779
2797
|
useLegacyUrl: authMethods.has(AuthMethod.PASSKEY)
|
|
2780
2798
|
});
|
|
2799
|
+
const exportPrivateKeyUrl = exportPrivateKeyResult.url;
|
|
2781
2800
|
if (args.shouldOpenPopup) {
|
|
2782
2801
|
this.popupWindow.location.href = exportPrivateKeyUrl;
|
|
2783
2802
|
}
|
package/dist/esm/constants.js
CHANGED
|
@@ -599,7 +599,7 @@ class AuthService {
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
const { sessionId } = yield __privateGet(this, _sessionManagementService).touchSession();
|
|
602
|
-
const
|
|
602
|
+
const result = (isForNewDevice || urlType) && (yield __privateGet(this, _portalUrlService).constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
|
|
603
603
|
isForNewDevice,
|
|
604
604
|
pathId: credentialId,
|
|
605
605
|
portalTheme,
|
|
@@ -609,7 +609,7 @@ class AuthService {
|
|
|
609
609
|
addNewCredentialPasskeyId: passkeyId,
|
|
610
610
|
addNewCredentialPasswordId: passwordId
|
|
611
611
|
}));
|
|
612
|
-
return __spreadValues({ credentialId },
|
|
612
|
+
return __spreadValues({ credentialId }, result ? { url: result.url, fullUrl: result.fullUrl } : {});
|
|
613
613
|
});
|
|
614
614
|
this.addCredential = (_0) => __async(this, [_0], function* ({ authMethod }) {
|
|
615
615
|
if (authMethod === "PASSKEY" && !(yield __privateGet(this, _paraCoreInterface).isPasskeySupported())) {
|
|
@@ -102,9 +102,6 @@ class ExternalWalletService {
|
|
|
102
102
|
for (const type of types) {
|
|
103
103
|
const providerInterface = this.externalWalletProviderInterfaces[type];
|
|
104
104
|
if (!providerInterface) {
|
|
105
|
-
console.warn(
|
|
106
|
-
`External wallet provider interface for type ${type} is not initialized. Para connector will not be connected.`
|
|
107
|
-
);
|
|
108
105
|
continue;
|
|
109
106
|
}
|
|
110
107
|
try {
|
|
@@ -25,16 +25,19 @@ class LoginFlowService extends BaseAuthFlowService {
|
|
|
25
25
|
const isPasskeyPossible = loginAuthMethods.includes(AuthMethod.PASSKEY) && !this.paraCoreInterface.isNativePasskey;
|
|
26
26
|
const isPasswordPossible = loginAuthMethods.includes(AuthMethod.PASSWORD) && hasPasswordWithoutPIN;
|
|
27
27
|
const isPINPossible = loginAuthMethods.includes(AuthMethod.PIN);
|
|
28
|
-
|
|
28
|
+
const result = __spreadProps(__spreadValues({}, authState), {
|
|
29
29
|
isPasskeySupported,
|
|
30
30
|
loginAuthMethods
|
|
31
|
-
})
|
|
32
|
-
|
|
31
|
+
});
|
|
32
|
+
if (isPasskeyPossible) {
|
|
33
|
+
const passkeyResult = yield this.services.portalUrlService.getLoginUrl({
|
|
33
34
|
sessionId: sessionLookupId,
|
|
34
35
|
shorten,
|
|
35
36
|
portalTheme
|
|
36
|
-
})
|
|
37
|
-
|
|
37
|
+
});
|
|
38
|
+
result.passkeyUrl = passkeyResult.url;
|
|
39
|
+
result.passkeyFullUrl = passkeyResult.fullUrl;
|
|
40
|
+
const knownDeviceResult = yield this.services.portalUrlService.constructPortalUrl("loginAuth", {
|
|
38
41
|
sessionId: sessionLookupId,
|
|
39
42
|
newDevice: {
|
|
40
43
|
sessionId: sessionLookupId,
|
|
@@ -42,22 +45,30 @@ class LoginFlowService extends BaseAuthFlowService {
|
|
|
42
45
|
},
|
|
43
46
|
shorten,
|
|
44
47
|
portalTheme
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
});
|
|
49
|
+
result.passkeyKnownDeviceUrl = knownDeviceResult.url;
|
|
50
|
+
}
|
|
51
|
+
if (isPasswordPossible) {
|
|
52
|
+
const passwordResult = yield this.services.portalUrlService.constructPortalUrl("loginPassword", {
|
|
48
53
|
sessionId: sessionLookupId,
|
|
49
54
|
shorten,
|
|
50
55
|
portalTheme,
|
|
51
56
|
params: { isEmbedded: `${!serverAuthState.isWalletSelectionNeeded}` }
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
});
|
|
58
|
+
result.passwordUrl = passwordResult.url;
|
|
59
|
+
result.passwordFullUrl = passwordResult.fullUrl;
|
|
60
|
+
}
|
|
61
|
+
if (isPINPossible) {
|
|
62
|
+
const pinResult = yield this.services.portalUrlService.constructPortalUrl("loginPIN", {
|
|
55
63
|
sessionId: sessionLookupId,
|
|
56
64
|
shorten,
|
|
57
65
|
portalTheme,
|
|
58
66
|
params: { isEmbedded: `${!serverAuthState.isWalletSelectionNeeded}` }
|
|
59
|
-
})
|
|
60
|
-
|
|
67
|
+
});
|
|
68
|
+
result.pinUrl = pinResult.url;
|
|
69
|
+
result.pinFullUrl = pinResult.fullUrl;
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
61
72
|
});
|
|
62
73
|
this.waitForLogin = (params) => __async(this, null, function* () {
|
|
63
74
|
this.stateManager.send({
|
|
@@ -185,15 +185,15 @@ class PollingService {
|
|
|
185
185
|
yield __privateGet(this, _openOAuthPopup).call(this);
|
|
186
186
|
}
|
|
187
187
|
yield __privateGet(this, _authService).prepareLogin();
|
|
188
|
-
const
|
|
188
|
+
const oAuthResult = yield __privateGet(this, _portalUrlService).constructPortalUrl(config.portalUrlType, {
|
|
189
189
|
portalTheme,
|
|
190
190
|
shorten: useShortUrls,
|
|
191
191
|
appScheme
|
|
192
192
|
});
|
|
193
193
|
if (onOAuthUrl) {
|
|
194
|
-
onOAuthUrl(
|
|
194
|
+
onOAuthUrl(oAuthResult.url, oAuthResult.fullUrl);
|
|
195
195
|
} else if (!!__privateGet(this, _paraCoreInterface).popupWindow) {
|
|
196
|
-
__privateGet(this, _paraCoreInterface).popupWindow.location.href =
|
|
196
|
+
__privateGet(this, _paraCoreInterface).popupWindow.location.href = oAuthResult.url;
|
|
197
197
|
onOAuthPopup(__privateGet(this, _paraCoreInterface).popupWindow);
|
|
198
198
|
}
|
|
199
199
|
return new Promise((resolve, reject) => {
|
|
@@ -53,7 +53,7 @@ class PortalUrlService {
|
|
|
53
53
|
return __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || (yield this.getPartnerURL()) || getPortalBaseURL(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
|
|
54
54
|
});
|
|
55
55
|
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;
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
57
57
|
const [
|
|
58
58
|
isCreate,
|
|
59
59
|
isLogin,
|
|
@@ -98,82 +98,83 @@ class PortalUrlService {
|
|
|
98
98
|
}
|
|
99
99
|
const shouldUseLegacyPortalUrl = opts.useLegacyUrl || !!opts.addNewCredentialPasskeyId || type === "loginAuth";
|
|
100
100
|
const base = type === "onRamp" || isTelegramLogin ? __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || getPortalBaseURL(__privateGet(this, _paraCoreInterface).ctx, isTelegramLogin, false, shouldUseLegacyPortalUrl) : yield this.getPortalURL(shouldUseLegacyPortalUrl);
|
|
101
|
+
const userId = __privateGet(this, _authService).userId;
|
|
101
102
|
let path;
|
|
102
103
|
switch (type) {
|
|
104
|
+
case "createAuth": {
|
|
105
|
+
path = `/v2/create/${userId}/passkey/${opts.pathId}`;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
103
108
|
case "createPassword": {
|
|
104
|
-
path = `/
|
|
109
|
+
path = `/v2/create/${userId}/password/${opts.pathId}`;
|
|
105
110
|
break;
|
|
106
111
|
}
|
|
107
112
|
case "createPIN": {
|
|
108
|
-
path = `/
|
|
113
|
+
path = `/v2/create/${userId}/pin/${opts.pathId}`;
|
|
109
114
|
break;
|
|
110
115
|
}
|
|
111
|
-
case "
|
|
112
|
-
path =
|
|
116
|
+
case "loginAuth": {
|
|
117
|
+
path = "/v2/login/passkey";
|
|
113
118
|
break;
|
|
114
119
|
}
|
|
115
120
|
case "loginPassword": {
|
|
116
|
-
path = "/
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case "loginAuth": {
|
|
120
|
-
path = "/web/biometrics/login";
|
|
121
|
+
path = "/v2/login/password";
|
|
121
122
|
break;
|
|
122
123
|
}
|
|
123
124
|
case "loginPIN": {
|
|
124
|
-
path = "/
|
|
125
|
+
path = "/v2/login/pin";
|
|
125
126
|
break;
|
|
126
127
|
}
|
|
127
|
-
case "
|
|
128
|
-
path =
|
|
128
|
+
case "loginOTP": {
|
|
129
|
+
path = "/v2/login/otp";
|
|
129
130
|
break;
|
|
130
131
|
}
|
|
131
|
-
case "
|
|
132
|
-
path =
|
|
132
|
+
case "telegramLogin": {
|
|
133
|
+
path = "/v2/login/telegram";
|
|
133
134
|
break;
|
|
134
135
|
}
|
|
135
136
|
case "telegramLoginVerify": {
|
|
136
|
-
path =
|
|
137
|
+
path = "/v2/login/telegram/verify";
|
|
137
138
|
break;
|
|
138
139
|
}
|
|
139
|
-
case "
|
|
140
|
-
path =
|
|
140
|
+
case "loginFarcaster": {
|
|
141
|
+
path = "/v2/login/farcaster";
|
|
141
142
|
break;
|
|
142
143
|
}
|
|
143
144
|
case "oAuth": {
|
|
144
|
-
path = `/
|
|
145
|
+
path = `/v2/login/${opts.oAuthMethod.toLowerCase()}`;
|
|
145
146
|
break;
|
|
146
147
|
}
|
|
147
148
|
case "oAuthCallback": {
|
|
148
|
-
path = `/
|
|
149
|
+
path = `/v2/login/${opts.oAuthMethod.toLowerCase()}/callback`;
|
|
149
150
|
break;
|
|
150
151
|
}
|
|
151
|
-
case "
|
|
152
|
-
path = "/
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
case "loginFarcaster": {
|
|
156
|
-
path = "/auth/farcaster";
|
|
152
|
+
case "loginExternalWallet": {
|
|
153
|
+
path = "/v2/login/external-wallet";
|
|
157
154
|
break;
|
|
158
155
|
}
|
|
159
|
-
case "
|
|
160
|
-
path = `/
|
|
156
|
+
case "txReview": {
|
|
157
|
+
path = `/v2/wallet/${userId}/transaction/${opts.pathId}`;
|
|
161
158
|
break;
|
|
162
159
|
}
|
|
163
|
-
case "
|
|
164
|
-
path =
|
|
160
|
+
case "onRamp": {
|
|
161
|
+
path = `/v2/wallet/${userId}/on-ramp/${opts.pathId}`;
|
|
165
162
|
break;
|
|
166
163
|
}
|
|
167
164
|
case "exportPrivateKey": {
|
|
168
|
-
path = `/
|
|
165
|
+
path = `/v2/wallet/${userId}/export-key/${opts.pathId}`;
|
|
169
166
|
break;
|
|
170
167
|
}
|
|
171
|
-
case "
|
|
172
|
-
path = "/
|
|
168
|
+
case "switchWallets": {
|
|
169
|
+
path = "/v2/wallet/switch";
|
|
173
170
|
break;
|
|
174
171
|
}
|
|
175
172
|
case "connectExternalWallet": {
|
|
176
|
-
path = "/
|
|
173
|
+
path = "/v2/wallet/connect-external";
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case "addNewCredential": {
|
|
177
|
+
path = "/v2/account/add-credential";
|
|
177
178
|
break;
|
|
178
179
|
}
|
|
179
180
|
default: {
|
|
@@ -196,15 +197,19 @@ class PortalUrlService {
|
|
|
196
197
|
};
|
|
197
198
|
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
198
199
|
apiKey: __privateGet(this, _paraCoreInterface).ctx.apiKey,
|
|
199
|
-
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
200
200
|
partnerId: partner == null ? void 0 : partner.id
|
|
201
201
|
}, typeof window !== "undefined" && ((_b = window.location) == null ? void 0 : _b.origin) ? { origin: window.location.origin } : {}), {
|
|
202
202
|
portalFont: ((_c = opts.portalTheme) == null ? void 0 : _c.font) || ((_d = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _d.font) || (partner == null ? void 0 : partner.font),
|
|
203
203
|
portalBorderRadius: ((_e = opts.portalTheme) == null ? void 0 : _e.borderRadius) || ((_f = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _f.borderRadius),
|
|
204
204
|
portalThemeMode: ((_g = opts.portalTheme) == null ? void 0 : _g.mode) || ((_h = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _h.mode) || (partner == null ? void 0 : partner.themeMode),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
portalForegroundMixRatio: (_l = (_k = (_i = opts.portalTheme) == null ? void 0 : _i.foregroundMixRatio) != null ? _k : (_j = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _j.foregroundMixRatio) == null ? void 0 : _l.toString(),
|
|
206
|
+
portalCssOverrides: (() => {
|
|
207
|
+
var _a2, _b2, _c2;
|
|
208
|
+
const overrides = (_c2 = (_a2 = opts.portalTheme) == null ? void 0 : _a2.cssOverrides) != null ? _c2 : (_b2 = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _b2.cssOverrides;
|
|
209
|
+
return overrides ? JSON.stringify(overrides) : void 0;
|
|
210
|
+
})(),
|
|
211
|
+
portalForegroundColor: ((_m = opts.portalTheme) == null ? void 0 : _m.accentColor) || ((_n = opts.portalTheme) == null ? void 0 : _n.foregroundColor) || ((_o = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _o.accentColor) || ((_p = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _p.foregroundColor) || (partner == null ? void 0 : partner.accentColor) || (partner == null ? void 0 : partner.foregroundColor),
|
|
212
|
+
portalBackgroundColor: ((_q = opts.portalTheme) == null ? void 0 : _q.backgroundColor) || ((_r = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _r.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || __privateGet(this, _paraCoreInterface).portalBackgroundColor,
|
|
208
213
|
portalPrimaryButtonColor: __privateGet(this, _paraCoreInterface).portalPrimaryButtonColor,
|
|
209
214
|
portalTextColor: __privateGet(this, _paraCoreInterface).portalTextColor,
|
|
210
215
|
portalPrimaryButtonTextColor: __privateGet(this, _paraCoreInterface).portalPrimaryButtonTextColor,
|
|
@@ -234,11 +239,12 @@ class PortalUrlService {
|
|
|
234
239
|
}), isExportPrivateKey || isTxReview ? {
|
|
235
240
|
sessionId: thisDevice.sessionId
|
|
236
241
|
} : {});
|
|
237
|
-
const
|
|
242
|
+
const fullUrl = constructUrl({ base, path, params });
|
|
238
243
|
if (opts.shorten) {
|
|
239
|
-
|
|
244
|
+
const shortUrl = yield shortenUrl(__privateGet(this, _paraCoreInterface).ctx, fullUrl, shouldUseLegacyPortalUrl);
|
|
245
|
+
return { url: shortUrl, fullUrl };
|
|
240
246
|
}
|
|
241
|
-
return url;
|
|
247
|
+
return { url: fullUrl, fullUrl };
|
|
242
248
|
});
|
|
243
249
|
this.getLoginUrl = (_0) => __async(this, [_0], function* ({ authMethod = "PASSKEY", shorten = false, portalTheme, sessionId }) {
|
|
244
250
|
if (!sessionId) {
|
|
@@ -278,7 +284,8 @@ class PortalUrlService {
|
|
|
278
284
|
}) {
|
|
279
285
|
const sessionLookupId = _sessionLookupId != null ? _sessionLookupId : yield __privateGet(this, _authService).prepareLogin();
|
|
280
286
|
if (!accountLinkInProgress && !__privateGet(this, _paraCoreInterface).isPortal()) {
|
|
281
|
-
|
|
287
|
+
const result = yield this.constructPortalUrl("oAuth", { sessionId: sessionLookupId, oAuthMethod: method, appScheme });
|
|
288
|
+
return result.url;
|
|
282
289
|
}
|
|
283
290
|
const [portalSessionLookupId, callback] = yield Promise.all([
|
|
284
291
|
__privateGet(this, _paraCoreInterface).isPortal() ? __privateGet(this, _sessionManagementService).touchSession(true).then((s) => s.sessionLookupId) : Promise.resolve(void 0),
|
|
@@ -294,7 +301,7 @@ class PortalUrlService {
|
|
|
294
301
|
params: portalCallbackParams,
|
|
295
302
|
// Build callback for legacy portal if needed
|
|
296
303
|
useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
|
|
297
|
-
})) : Promise.resolve(false)
|
|
304
|
+
})).then((r) => r.url) : Promise.resolve(false)
|
|
298
305
|
]);
|
|
299
306
|
return constructUrl({
|
|
300
307
|
base: getBaseOAuthUrl(__privateGet(this, _paraCoreInterface).ctx.env),
|
|
@@ -180,13 +180,13 @@ class SessionManagementService {
|
|
|
180
180
|
if (!__privateGet(this, _paraCoreInterface).loginEncryptionKeyPair) {
|
|
181
181
|
yield __privateGet(this, _paraCoreInterface).setLoginEncryptionKeyPair();
|
|
182
182
|
}
|
|
183
|
-
const
|
|
183
|
+
const result = yield __privateGet(this, _portalUrlService).getLoginUrl({
|
|
184
184
|
sessionId
|
|
185
185
|
});
|
|
186
186
|
if (shouldOpenPopup) {
|
|
187
|
-
yield __privateGet(this, _paraCoreInterface).platformUtils.openPopup(
|
|
187
|
+
yield __privateGet(this, _paraCoreInterface).platformUtils.openPopup(result.url);
|
|
188
188
|
}
|
|
189
|
-
return
|
|
189
|
+
return result.url;
|
|
190
190
|
});
|
|
191
191
|
this.keepSessionAlive = () => __async(this, null, function* () {
|
|
192
192
|
try {
|