@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
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -557,6 +557,7 @@ const _ParaCore = class _ParaCore {
|
|
|
557
557
|
authPhase: state.authStatePhase,
|
|
558
558
|
walletPhase: state.walletStatePhase,
|
|
559
559
|
authStateInfo: state.authStateInfo,
|
|
560
|
+
selectedOAuthMethod: state.selectedOAuthMethod,
|
|
560
561
|
error: state.error,
|
|
561
562
|
isReady: state.isReady
|
|
562
563
|
};
|
|
@@ -610,10 +611,11 @@ const _ParaCore = class _ParaCore {
|
|
|
610
611
|
authPhase: state.authStatePhase,
|
|
611
612
|
walletPhase: state.walletStatePhase,
|
|
612
613
|
authStateInfo: state.authStateInfo,
|
|
614
|
+
selectedOAuthMethod: state.selectedOAuthMethod,
|
|
613
615
|
error: state.error,
|
|
614
616
|
isReady: state.isReady
|
|
615
617
|
};
|
|
616
|
-
if (!lastSnapshot || lastSnapshot.corePhase !== currentSnapshot.corePhase || lastSnapshot.authPhase !== currentSnapshot.authPhase || lastSnapshot.walletPhase !== currentSnapshot.walletPhase || lastSnapshot.error !== currentSnapshot.error || lastSnapshot.isReady !== currentSnapshot.isReady) {
|
|
618
|
+
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) {
|
|
617
619
|
lastSnapshot = currentSnapshot;
|
|
618
620
|
callback(currentSnapshot);
|
|
619
621
|
}
|
|
@@ -1864,10 +1866,10 @@ const _ParaCore = class _ParaCore {
|
|
|
1864
1866
|
getSwitchWalletsUrl() {
|
|
1865
1867
|
return __async(this, null, function* () {
|
|
1866
1868
|
const authMethods = yield this.supportedUserAuthMethods();
|
|
1867
|
-
const
|
|
1869
|
+
const result = yield this.constructPortalUrl("switchWallets", {
|
|
1868
1870
|
useLegacyUrl: authMethods.has(import_user_management_client.AuthMethod.PASSKEY)
|
|
1869
1871
|
});
|
|
1870
|
-
return url;
|
|
1872
|
+
return result.url;
|
|
1871
1873
|
});
|
|
1872
1874
|
}
|
|
1873
1875
|
/**
|
|
@@ -2136,22 +2138,24 @@ const _ParaCore = class _ParaCore {
|
|
|
2136
2138
|
getTransactionReviewUrl(transactionId, timeoutMs) {
|
|
2137
2139
|
return __async(this, null, function* () {
|
|
2138
2140
|
const authMethods = yield this.supportedUserAuthMethods();
|
|
2139
|
-
|
|
2141
|
+
const result = yield this.constructPortalUrl("txReview", {
|
|
2140
2142
|
pathId: transactionId,
|
|
2141
2143
|
useLegacyUrl: authMethods.has(import_user_management_client.AuthMethod.PASSKEY),
|
|
2142
2144
|
params: {
|
|
2143
2145
|
timeoutMs: timeoutMs == null ? void 0 : timeoutMs.toString()
|
|
2144
2146
|
}
|
|
2145
2147
|
});
|
|
2148
|
+
return result.url;
|
|
2146
2149
|
});
|
|
2147
2150
|
}
|
|
2148
2151
|
getOnRampTransactionUrl(_0) {
|
|
2149
2152
|
return __async(this, arguments, function* ({
|
|
2150
2153
|
purchaseId
|
|
2151
2154
|
}) {
|
|
2152
|
-
|
|
2155
|
+
const result = yield this.constructPortalUrl("onRamp", {
|
|
2153
2156
|
pathId: purchaseId
|
|
2154
2157
|
});
|
|
2158
|
+
return result.url;
|
|
2155
2159
|
});
|
|
2156
2160
|
}
|
|
2157
2161
|
getWalletBalance(params) {
|
|
@@ -2159,6 +2163,18 @@ const _ParaCore = class _ParaCore {
|
|
|
2159
2163
|
return yield __privateGet(this, _walletService).getWalletBalance(params);
|
|
2160
2164
|
});
|
|
2161
2165
|
}
|
|
2166
|
+
/**
|
|
2167
|
+
* Requests testnet funds from the faucet for the specified wallet.
|
|
2168
|
+
* @param {RequestFaucetParams} params the options object.
|
|
2169
|
+
* @param {string} params.walletId the id of the wallet to fund.
|
|
2170
|
+
* @param {string} [params.chain] optional chain identifier to target a specific testnet.
|
|
2171
|
+
* @returns the faucet transaction details, including the transaction hash and amount sent.
|
|
2172
|
+
*/
|
|
2173
|
+
requestFaucet(params) {
|
|
2174
|
+
return __async(this, null, function* () {
|
|
2175
|
+
return yield __privateGet(this, _walletService).requestFaucet(params);
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2162
2178
|
/**
|
|
2163
2179
|
* Signs a message using one of the current wallets.
|
|
2164
2180
|
*
|
|
@@ -2645,12 +2661,13 @@ const _ParaCore = class _ParaCore {
|
|
|
2645
2661
|
* @param {Object} opts the options object
|
|
2646
2662
|
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
2647
2663
|
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
2648
|
-
* @param {
|
|
2664
|
+
* @param {PortalTheme} opts.portalTheme the Para Portal theme to apply to the password creation URL, if other than the default theme
|
|
2649
2665
|
* @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
|
|
2650
2666
|
*/
|
|
2651
2667
|
getLoginUrl(params) {
|
|
2652
2668
|
return __async(this, null, function* () {
|
|
2653
|
-
|
|
2669
|
+
const result = yield __privateGet(this, _portalUrlService).getLoginUrl(params);
|
|
2670
|
+
return result.url;
|
|
2654
2671
|
});
|
|
2655
2672
|
}
|
|
2656
2673
|
prepareLogin() {
|
|
@@ -2806,7 +2823,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2806
2823
|
sendLoginCode() {
|
|
2807
2824
|
return __async(this, null, function* () {
|
|
2808
2825
|
const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
|
|
2809
|
-
this.setUserId(userId);
|
|
2826
|
+
yield this.setUserId(userId);
|
|
2827
|
+
return { userId };
|
|
2810
2828
|
});
|
|
2811
2829
|
}
|
|
2812
2830
|
exportPrivateKey() {
|
|
@@ -2832,10 +2850,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2832
2850
|
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.EXPORT_PRIVATE_KEY });
|
|
2833
2851
|
}
|
|
2834
2852
|
const authMethods = yield this.supportedUserAuthMethods();
|
|
2835
|
-
const
|
|
2853
|
+
const exportPrivateKeyResult = yield this.constructPortalUrl("exportPrivateKey", {
|
|
2836
2854
|
pathId: walletId,
|
|
2837
2855
|
useLegacyUrl: authMethods.has(import_user_management_client.AuthMethod.PASSKEY)
|
|
2838
2856
|
});
|
|
2857
|
+
const exportPrivateKeyUrl = exportPrivateKeyResult.url;
|
|
2839
2858
|
if (args.shouldOpenPopup) {
|
|
2840
2859
|
this.popupWindow.location.href = exportPrivateKeyUrl;
|
|
2841
2860
|
}
|
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 = "
|
|
49
|
+
const PARA_CORE_VERSION = "3.0.0-alpha.0";
|
|
50
50
|
const PREFIX = "@CAPSULE/";
|
|
51
51
|
const PARA_PREFIX = "@PARA/";
|
|
52
52
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -668,7 +668,7 @@ class AuthService {
|
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
const { sessionId } = yield __privateGet(this, _sessionManagementService).touchSession();
|
|
671
|
-
const
|
|
671
|
+
const result = (isForNewDevice || urlType) && (yield __privateGet(this, _portalUrlService).constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
|
|
672
672
|
isForNewDevice,
|
|
673
673
|
pathId: credentialId,
|
|
674
674
|
portalTheme,
|
|
@@ -678,7 +678,7 @@ class AuthService {
|
|
|
678
678
|
addNewCredentialPasskeyId: passkeyId,
|
|
679
679
|
addNewCredentialPasswordId: passwordId
|
|
680
680
|
}));
|
|
681
|
-
return __spreadValues({ credentialId },
|
|
681
|
+
return __spreadValues({ credentialId }, result ? { url: result.url, fullUrl: result.fullUrl } : {});
|
|
682
682
|
});
|
|
683
683
|
this.addCredential = (_0) => __async(this, [_0], function* ({ authMethod }) {
|
|
684
684
|
if (authMethod === "PASSKEY" && !(yield __privateGet(this, _paraCoreInterface).isPasskeySupported())) {
|
|
@@ -160,9 +160,6 @@ class ExternalWalletService {
|
|
|
160
160
|
for (const type of types) {
|
|
161
161
|
const providerInterface = this.externalWalletProviderInterfaces[type];
|
|
162
162
|
if (!providerInterface) {
|
|
163
|
-
console.warn(
|
|
164
|
-
`External wallet provider interface for type ${type} is not initialized. Para connector will not be connected.`
|
|
165
|
-
);
|
|
166
163
|
continue;
|
|
167
164
|
}
|
|
168
165
|
try {
|
|
@@ -90,16 +90,19 @@ class LoginFlowService extends import_BaseAuthFlowService.BaseAuthFlowService {
|
|
|
90
90
|
const isPasskeyPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY) && !this.paraCoreInterface.isNativePasskey;
|
|
91
91
|
const isPasswordPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) && hasPasswordWithoutPIN;
|
|
92
92
|
const isPINPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PIN);
|
|
93
|
-
|
|
93
|
+
const result = __spreadProps(__spreadValues({}, authState), {
|
|
94
94
|
isPasskeySupported,
|
|
95
95
|
loginAuthMethods
|
|
96
|
-
})
|
|
97
|
-
|
|
96
|
+
});
|
|
97
|
+
if (isPasskeyPossible) {
|
|
98
|
+
const passkeyResult = yield this.services.portalUrlService.getLoginUrl({
|
|
98
99
|
sessionId: sessionLookupId,
|
|
99
100
|
shorten,
|
|
100
101
|
portalTheme
|
|
101
|
-
})
|
|
102
|
-
|
|
102
|
+
});
|
|
103
|
+
result.passkeyUrl = passkeyResult.url;
|
|
104
|
+
result.passkeyFullUrl = passkeyResult.fullUrl;
|
|
105
|
+
const knownDeviceResult = yield this.services.portalUrlService.constructPortalUrl("loginAuth", {
|
|
103
106
|
sessionId: sessionLookupId,
|
|
104
107
|
newDevice: {
|
|
105
108
|
sessionId: sessionLookupId,
|
|
@@ -107,22 +110,30 @@ class LoginFlowService extends import_BaseAuthFlowService.BaseAuthFlowService {
|
|
|
107
110
|
},
|
|
108
111
|
shorten,
|
|
109
112
|
portalTheme
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
});
|
|
114
|
+
result.passkeyKnownDeviceUrl = knownDeviceResult.url;
|
|
115
|
+
}
|
|
116
|
+
if (isPasswordPossible) {
|
|
117
|
+
const passwordResult = yield this.services.portalUrlService.constructPortalUrl("loginPassword", {
|
|
113
118
|
sessionId: sessionLookupId,
|
|
114
119
|
shorten,
|
|
115
120
|
portalTheme,
|
|
116
121
|
params: { isEmbedded: `${!serverAuthState.isWalletSelectionNeeded}` }
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
});
|
|
123
|
+
result.passwordUrl = passwordResult.url;
|
|
124
|
+
result.passwordFullUrl = passwordResult.fullUrl;
|
|
125
|
+
}
|
|
126
|
+
if (isPINPossible) {
|
|
127
|
+
const pinResult = yield this.services.portalUrlService.constructPortalUrl("loginPIN", {
|
|
120
128
|
sessionId: sessionLookupId,
|
|
121
129
|
shorten,
|
|
122
130
|
portalTheme,
|
|
123
131
|
params: { isEmbedded: `${!serverAuthState.isWalletSelectionNeeded}` }
|
|
124
|
-
})
|
|
125
|
-
|
|
132
|
+
});
|
|
133
|
+
result.pinUrl = pinResult.url;
|
|
134
|
+
result.pinFullUrl = pinResult.fullUrl;
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
126
137
|
});
|
|
127
138
|
this.waitForLogin = (params) => __async(this, null, function* () {
|
|
128
139
|
this.stateManager.send({
|
|
@@ -243,15 +243,15 @@ class PollingService {
|
|
|
243
243
|
yield __privateGet(this, _openOAuthPopup).call(this);
|
|
244
244
|
}
|
|
245
245
|
yield __privateGet(this, _authService).prepareLogin();
|
|
246
|
-
const
|
|
246
|
+
const oAuthResult = yield __privateGet(this, _portalUrlService).constructPortalUrl(config.portalUrlType, {
|
|
247
247
|
portalTheme,
|
|
248
248
|
shorten: useShortUrls,
|
|
249
249
|
appScheme
|
|
250
250
|
});
|
|
251
251
|
if (onOAuthUrl) {
|
|
252
|
-
onOAuthUrl(
|
|
252
|
+
onOAuthUrl(oAuthResult.url, oAuthResult.fullUrl);
|
|
253
253
|
} else if (!!__privateGet(this, _paraCoreInterface).popupWindow) {
|
|
254
|
-
__privateGet(this, _paraCoreInterface).popupWindow.location.href =
|
|
254
|
+
__privateGet(this, _paraCoreInterface).popupWindow.location.href = oAuthResult.url;
|
|
255
255
|
onOAuthPopup(__privateGet(this, _paraCoreInterface).popupWindow);
|
|
256
256
|
}
|
|
257
257
|
return new Promise((resolve, reject) => {
|
|
@@ -111,7 +111,7 @@ class PortalUrlService {
|
|
|
111
111
|
return __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || (yield this.getPartnerURL()) || (0, import_url.getPortalBaseURL)(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
|
|
112
112
|
});
|
|
113
113
|
this.constructPortalUrl = (_0, ..._1) => __async(this, [_0, ..._1], function* (type, opts = {}) {
|
|
114
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
115
115
|
const [
|
|
116
116
|
isCreate,
|
|
117
117
|
isLogin,
|
|
@@ -156,82 +156,83 @@ class PortalUrlService {
|
|
|
156
156
|
}
|
|
157
157
|
const shouldUseLegacyPortalUrl = opts.useLegacyUrl || !!opts.addNewCredentialPasskeyId || type === "loginAuth";
|
|
158
158
|
const base = type === "onRamp" || isTelegramLogin ? __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || (0, import_url.getPortalBaseURL)(__privateGet(this, _paraCoreInterface).ctx, isTelegramLogin, false, shouldUseLegacyPortalUrl) : yield this.getPortalURL(shouldUseLegacyPortalUrl);
|
|
159
|
+
const userId = __privateGet(this, _authService).userId;
|
|
159
160
|
let path;
|
|
160
161
|
switch (type) {
|
|
162
|
+
case "createAuth": {
|
|
163
|
+
path = `/v2/create/${userId}/passkey/${opts.pathId}`;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
161
166
|
case "createPassword": {
|
|
162
|
-
path = `/
|
|
167
|
+
path = `/v2/create/${userId}/password/${opts.pathId}`;
|
|
163
168
|
break;
|
|
164
169
|
}
|
|
165
170
|
case "createPIN": {
|
|
166
|
-
path = `/
|
|
171
|
+
path = `/v2/create/${userId}/pin/${opts.pathId}`;
|
|
167
172
|
break;
|
|
168
173
|
}
|
|
169
|
-
case "
|
|
170
|
-
path =
|
|
174
|
+
case "loginAuth": {
|
|
175
|
+
path = "/v2/login/passkey";
|
|
171
176
|
break;
|
|
172
177
|
}
|
|
173
178
|
case "loginPassword": {
|
|
174
|
-
path = "/
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
case "loginAuth": {
|
|
178
|
-
path = "/web/biometrics/login";
|
|
179
|
+
path = "/v2/login/password";
|
|
179
180
|
break;
|
|
180
181
|
}
|
|
181
182
|
case "loginPIN": {
|
|
182
|
-
path = "/
|
|
183
|
+
path = "/v2/login/pin";
|
|
183
184
|
break;
|
|
184
185
|
}
|
|
185
|
-
case "
|
|
186
|
-
path =
|
|
186
|
+
case "loginOTP": {
|
|
187
|
+
path = "/v2/login/otp";
|
|
187
188
|
break;
|
|
188
189
|
}
|
|
189
|
-
case "
|
|
190
|
-
path =
|
|
190
|
+
case "telegramLogin": {
|
|
191
|
+
path = "/v2/login/telegram";
|
|
191
192
|
break;
|
|
192
193
|
}
|
|
193
194
|
case "telegramLoginVerify": {
|
|
194
|
-
path =
|
|
195
|
+
path = "/v2/login/telegram/verify";
|
|
195
196
|
break;
|
|
196
197
|
}
|
|
197
|
-
case "
|
|
198
|
-
path =
|
|
198
|
+
case "loginFarcaster": {
|
|
199
|
+
path = "/v2/login/farcaster";
|
|
199
200
|
break;
|
|
200
201
|
}
|
|
201
202
|
case "oAuth": {
|
|
202
|
-
path = `/
|
|
203
|
+
path = `/v2/login/${opts.oAuthMethod.toLowerCase()}`;
|
|
203
204
|
break;
|
|
204
205
|
}
|
|
205
206
|
case "oAuthCallback": {
|
|
206
|
-
path = `/
|
|
207
|
+
path = `/v2/login/${opts.oAuthMethod.toLowerCase()}/callback`;
|
|
207
208
|
break;
|
|
208
209
|
}
|
|
209
|
-
case "
|
|
210
|
-
path = "/
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
case "loginFarcaster": {
|
|
214
|
-
path = "/auth/farcaster";
|
|
210
|
+
case "loginExternalWallet": {
|
|
211
|
+
path = "/v2/login/external-wallet";
|
|
215
212
|
break;
|
|
216
213
|
}
|
|
217
|
-
case "
|
|
218
|
-
path = `/
|
|
214
|
+
case "txReview": {
|
|
215
|
+
path = `/v2/wallet/${userId}/transaction/${opts.pathId}`;
|
|
219
216
|
break;
|
|
220
217
|
}
|
|
221
|
-
case "
|
|
222
|
-
path =
|
|
218
|
+
case "onRamp": {
|
|
219
|
+
path = `/v2/wallet/${userId}/on-ramp/${opts.pathId}`;
|
|
223
220
|
break;
|
|
224
221
|
}
|
|
225
222
|
case "exportPrivateKey": {
|
|
226
|
-
path = `/
|
|
223
|
+
path = `/v2/wallet/${userId}/export-key/${opts.pathId}`;
|
|
227
224
|
break;
|
|
228
225
|
}
|
|
229
|
-
case "
|
|
230
|
-
path = "/
|
|
226
|
+
case "switchWallets": {
|
|
227
|
+
path = "/v2/wallet/switch";
|
|
231
228
|
break;
|
|
232
229
|
}
|
|
233
230
|
case "connectExternalWallet": {
|
|
234
|
-
path = "/
|
|
231
|
+
path = "/v2/wallet/connect-external";
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case "addNewCredential": {
|
|
235
|
+
path = "/v2/account/add-credential";
|
|
235
236
|
break;
|
|
236
237
|
}
|
|
237
238
|
default: {
|
|
@@ -254,15 +255,19 @@ class PortalUrlService {
|
|
|
254
255
|
};
|
|
255
256
|
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
256
257
|
apiKey: __privateGet(this, _paraCoreInterface).ctx.apiKey,
|
|
257
|
-
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
258
258
|
partnerId: partner == null ? void 0 : partner.id
|
|
259
259
|
}, typeof window !== "undefined" && ((_b = window.location) == null ? void 0 : _b.origin) ? { origin: window.location.origin } : {}), {
|
|
260
260
|
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),
|
|
261
261
|
portalBorderRadius: ((_e = opts.portalTheme) == null ? void 0 : _e.borderRadius) || ((_f = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _f.borderRadius),
|
|
262
262
|
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),
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
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(),
|
|
264
|
+
portalCssOverrides: (() => {
|
|
265
|
+
var _a2, _b2, _c2;
|
|
266
|
+
const overrides = (_c2 = (_a2 = opts.portalTheme) == null ? void 0 : _a2.cssOverrides) != null ? _c2 : (_b2 = __privateGet(this, _paraCoreInterface).portalTheme) == null ? void 0 : _b2.cssOverrides;
|
|
267
|
+
return overrides ? JSON.stringify(overrides) : void 0;
|
|
268
|
+
})(),
|
|
269
|
+
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),
|
|
270
|
+
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,
|
|
266
271
|
portalPrimaryButtonColor: __privateGet(this, _paraCoreInterface).portalPrimaryButtonColor,
|
|
267
272
|
portalTextColor: __privateGet(this, _paraCoreInterface).portalTextColor,
|
|
268
273
|
portalPrimaryButtonTextColor: __privateGet(this, _paraCoreInterface).portalPrimaryButtonTextColor,
|
|
@@ -292,11 +297,12 @@ class PortalUrlService {
|
|
|
292
297
|
}), isExportPrivateKey || isTxReview ? {
|
|
293
298
|
sessionId: thisDevice.sessionId
|
|
294
299
|
} : {});
|
|
295
|
-
const
|
|
300
|
+
const fullUrl = (0, import_url.constructUrl)({ base, path, params });
|
|
296
301
|
if (opts.shorten) {
|
|
297
|
-
|
|
302
|
+
const shortUrl = yield (0, import_url.shortenUrl)(__privateGet(this, _paraCoreInterface).ctx, fullUrl, shouldUseLegacyPortalUrl);
|
|
303
|
+
return { url: shortUrl, fullUrl };
|
|
298
304
|
}
|
|
299
|
-
return url;
|
|
305
|
+
return { url: fullUrl, fullUrl };
|
|
300
306
|
});
|
|
301
307
|
this.getLoginUrl = (_0) => __async(this, [_0], function* ({ authMethod = "PASSKEY", shorten = false, portalTheme, sessionId }) {
|
|
302
308
|
if (!sessionId) {
|
|
@@ -336,7 +342,8 @@ class PortalUrlService {
|
|
|
336
342
|
}) {
|
|
337
343
|
const sessionLookupId = _sessionLookupId != null ? _sessionLookupId : yield __privateGet(this, _authService).prepareLogin();
|
|
338
344
|
if (!accountLinkInProgress && !__privateGet(this, _paraCoreInterface).isPortal()) {
|
|
339
|
-
|
|
345
|
+
const result = yield this.constructPortalUrl("oAuth", { sessionId: sessionLookupId, oAuthMethod: method, appScheme });
|
|
346
|
+
return result.url;
|
|
340
347
|
}
|
|
341
348
|
const [portalSessionLookupId, callback] = yield Promise.all([
|
|
342
349
|
__privateGet(this, _paraCoreInterface).isPortal() ? __privateGet(this, _sessionManagementService).touchSession(true).then((s) => s.sessionLookupId) : Promise.resolve(void 0),
|
|
@@ -352,7 +359,7 @@ class PortalUrlService {
|
|
|
352
359
|
params: portalCallbackParams,
|
|
353
360
|
// Build callback for legacy portal if needed
|
|
354
361
|
useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
|
|
355
|
-
})) : Promise.resolve(false)
|
|
362
|
+
})).then((r) => r.url) : Promise.resolve(false)
|
|
356
363
|
]);
|
|
357
364
|
return (0, import_url.constructUrl)({
|
|
358
365
|
base: (0, import_userManagementClient.getBaseOAuthUrl)(__privateGet(this, _paraCoreInterface).ctx.env),
|
|
@@ -223,13 +223,13 @@ class SessionManagementService {
|
|
|
223
223
|
if (!__privateGet(this, _paraCoreInterface).loginEncryptionKeyPair) {
|
|
224
224
|
yield __privateGet(this, _paraCoreInterface).setLoginEncryptionKeyPair();
|
|
225
225
|
}
|
|
226
|
-
const
|
|
226
|
+
const result = yield __privateGet(this, _portalUrlService).getLoginUrl({
|
|
227
227
|
sessionId
|
|
228
228
|
});
|
|
229
229
|
if (shouldOpenPopup) {
|
|
230
|
-
yield __privateGet(this, _paraCoreInterface).platformUtils.openPopup(
|
|
230
|
+
yield __privateGet(this, _paraCoreInterface).platformUtils.openPopup(result.url);
|
|
231
231
|
}
|
|
232
|
-
return
|
|
232
|
+
return result.url;
|
|
233
233
|
});
|
|
234
234
|
this.keepSessionAlive = () => __async(this, null, function* () {
|
|
235
235
|
try {
|
|
@@ -96,29 +96,44 @@ class SignupFlowService extends import_BaseAuthFlowService.BaseAuthFlowService {
|
|
|
96
96
|
signupAuthMethods
|
|
97
97
|
});
|
|
98
98
|
if (isPasskey) {
|
|
99
|
-
const {
|
|
99
|
+
const {
|
|
100
|
+
url: passkeyUrl,
|
|
101
|
+
fullUrl: passkeyFullUrl,
|
|
102
|
+
credentialId: passkeyId
|
|
103
|
+
} = yield this.services.authService.getNewCredentialAndUrl({
|
|
100
104
|
authMethod: "PASSKEY",
|
|
101
105
|
shorten
|
|
102
106
|
});
|
|
103
107
|
if (passkeyUrl) signupState.passkeyUrl = passkeyUrl;
|
|
108
|
+
if (passkeyFullUrl) signupState.passkeyFullUrl = passkeyFullUrl;
|
|
104
109
|
signupState.passkeyId = passkeyId;
|
|
105
110
|
}
|
|
106
111
|
if (isPassword) {
|
|
107
|
-
const {
|
|
112
|
+
const {
|
|
113
|
+
url: passwordUrl,
|
|
114
|
+
fullUrl: passwordFullUrl,
|
|
115
|
+
credentialId: passwordId
|
|
116
|
+
} = yield this.services.authService.getNewCredentialAndUrl({
|
|
108
117
|
authMethod: "PASSWORD",
|
|
109
118
|
portalTheme,
|
|
110
119
|
shorten
|
|
111
120
|
});
|
|
112
121
|
signupState.passwordUrl = passwordUrl;
|
|
122
|
+
if (passwordFullUrl) signupState.passwordFullUrl = passwordFullUrl;
|
|
113
123
|
signupState.passwordId = passwordId;
|
|
114
124
|
}
|
|
115
125
|
if (isPIN) {
|
|
116
|
-
const {
|
|
126
|
+
const {
|
|
127
|
+
url: pinUrl,
|
|
128
|
+
fullUrl: pinFullUrl,
|
|
129
|
+
credentialId: pinId
|
|
130
|
+
} = yield this.services.authService.getNewCredentialAndUrl({
|
|
117
131
|
authMethod: "PIN",
|
|
118
132
|
portalTheme,
|
|
119
133
|
shorten
|
|
120
134
|
});
|
|
121
135
|
signupState.pinUrl = pinUrl;
|
|
136
|
+
if (pinFullUrl) signupState.pinFullUrl = pinFullUrl;
|
|
122
137
|
signupState.pinId = pinId;
|
|
123
138
|
}
|
|
124
139
|
return signupState;
|
|
@@ -86,14 +86,19 @@ class VerificationFlowService extends import_BaseAuthFlowService.BaseAuthFlowSer
|
|
|
86
86
|
this.services.authService.isEnclaveUser = isSLOPossible;
|
|
87
87
|
yield this.paraCoreInterface.localStorageSetItem(import_constants.LOCAL_STORAGE_IS_ENCLAVE_USER, JSON.stringify(isSLOPossible));
|
|
88
88
|
const isExternalWalletFullAuth = (_a = serverAuthState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
let loginUrl;
|
|
90
|
+
let loginFullUrl;
|
|
91
|
+
if (isSLOPossible || isExternalWalletFullAuth) {
|
|
92
|
+
const result = yield this.services.portalUrlService.getLoginUrl({
|
|
91
93
|
authMethod: import_user_management_client.AuthMethod.BASIC_LOGIN,
|
|
92
94
|
sessionId: sessionLookupId,
|
|
93
95
|
shorten,
|
|
94
96
|
portalTheme
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
+
});
|
|
98
|
+
loginUrl = result.url;
|
|
99
|
+
loginFullUrl = result.fullUrl;
|
|
100
|
+
}
|
|
101
|
+
return __spreadValues(__spreadValues({}, serverAuthState), loginUrl ? { loginUrl, loginFullUrl } : {});
|
|
97
102
|
});
|
|
98
103
|
this.performVerifyNewAccount = (params) => __async(this, null, function* () {
|
|
99
104
|
this.services.authService.assertIsAuthSet(["email", "phone"]);
|
|
@@ -183,6 +183,8 @@ class WalletService {
|
|
|
183
183
|
yield this.setCurrentWalletIds(updatedWalletIds, options);
|
|
184
184
|
});
|
|
185
185
|
this.setCurrentWalletIds = (_0, ..._1) => __async(this, [_0, ..._1], function* (currentWalletIds, { needsWallet = false, sessionLookupId, newDeviceSessionLookupId } = {}) {
|
|
186
|
+
var _a;
|
|
187
|
+
const hasChanged = JSON.stringify((_a = this.currentWalletIds) != null ? _a : {}) !== JSON.stringify(currentWalletIds != null ? currentWalletIds : {});
|
|
186
188
|
this.currentWalletIds = currentWalletIds;
|
|
187
189
|
yield __privateGet(this, _paraCoreInterface).localStorageSetItem(
|
|
188
190
|
import_constants.LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
@@ -197,7 +199,9 @@ class WalletService {
|
|
|
197
199
|
newDeviceSessionLookupId
|
|
198
200
|
);
|
|
199
201
|
}
|
|
200
|
-
(
|
|
202
|
+
if (hasChanged) {
|
|
203
|
+
(0, import_utils.dispatchEvent)(import_events.ParaEvent.WALLETS_CHANGE_EVENT, null);
|
|
204
|
+
}
|
|
201
205
|
});
|
|
202
206
|
this.createWallet = (..._0) => __async(this, [..._0], function* ({ type: _type, skipDistribute = false } = {}) {
|
|
203
207
|
var _a, _b;
|
|
@@ -449,6 +453,9 @@ class WalletService {
|
|
|
449
453
|
this.getWalletBalance = (_0) => __async(this, [_0], function* ({ walletId, rpcUrl }) {
|
|
450
454
|
return (yield __privateGet(this, _paraCoreInterface).ctx.client.getWalletBalance({ walletId, rpcUrl })).balance;
|
|
451
455
|
});
|
|
456
|
+
this.requestFaucet = (_0) => __async(this, [_0], function* ({ walletId, chain }) {
|
|
457
|
+
return yield __privateGet(this, _paraCoreInterface).ctx.client.requestFaucet({ walletId, chain });
|
|
458
|
+
});
|
|
452
459
|
__privateAdd(this, _encodeWalletBase64, (wallet) => {
|
|
453
460
|
const walletJson = JSON.stringify(wallet);
|
|
454
461
|
const base64Wallet = Buffer.from(walletJson).toString("base64");
|