@getpara/core-sdk 2.9.0 → 2.11.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 +43 -28
- package/dist/cjs/constants.js +4 -1
- package/dist/cjs/external/userManagementClient.js +5 -5
- package/dist/cjs/shares/enclave.js +3 -0
- package/dist/esm/ParaCore.js +43 -28
- package/dist/esm/constants.js +3 -1
- package/dist/esm/external/userManagementClient.js +5 -5
- package/dist/esm/shares/enclave.js +3 -0
- package/dist/types/ParaCore.d.ts +1 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/external/userManagementClient.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -234,6 +234,7 @@ const _ParaCore = class _ParaCore {
|
|
|
234
234
|
this.updateSessionCookieFromStorage();
|
|
235
235
|
this.updateLoginEncryptionKeyPairFromStorage();
|
|
236
236
|
this.updateEnclaveJwtFromStorage();
|
|
237
|
+
this.updateIsEnclaveUserFromStorage();
|
|
237
238
|
};
|
|
238
239
|
this.updateAuthInfoFromStorage = () => {
|
|
239
240
|
var _a;
|
|
@@ -257,6 +258,12 @@ const _ParaCore = class _ParaCore {
|
|
|
257
258
|
this.enclaveJwt = this.localStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_JWT) || this.sessionStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_JWT) || void 0;
|
|
258
259
|
this.enclaveRefreshJwt = this.localStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT) || this.sessionStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT) || void 0;
|
|
259
260
|
};
|
|
261
|
+
this.updateIsEnclaveUserFromStorage = () => {
|
|
262
|
+
const stored = this.localStorageGetItem(constants.LOCAL_STORAGE_IS_ENCLAVE_USER);
|
|
263
|
+
if (stored != null) {
|
|
264
|
+
this.isEnclaveUser = JSON.parse(stored);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
260
267
|
this.updateUserIdFromStorage = () => {
|
|
261
268
|
this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || void 0;
|
|
262
269
|
};
|
|
@@ -1111,6 +1118,10 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1111
1118
|
if (loginEncryptionKey && loginEncryptionKey !== "undefined") {
|
|
1112
1119
|
this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
|
|
1113
1120
|
}
|
|
1121
|
+
const storedIsEnclaveUser = yield this.localStorageGetItem(constants.LOCAL_STORAGE_IS_ENCLAVE_USER);
|
|
1122
|
+
if (storedIsEnclaveUser != null) {
|
|
1123
|
+
this.isEnclaveUser = JSON.parse(storedIsEnclaveUser);
|
|
1124
|
+
}
|
|
1114
1125
|
import_utils2.setupListeners.bind(this)();
|
|
1115
1126
|
yield this.touchSession();
|
|
1116
1127
|
});
|
|
@@ -2052,8 +2063,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2052
2063
|
const pregenWallets = yield this.getPregenWallets();
|
|
2053
2064
|
let recoverySecret, walletIds = {};
|
|
2054
2065
|
if (pregenWallets.length > 0) {
|
|
2066
|
+
let shares = [];
|
|
2055
2067
|
try {
|
|
2056
|
-
|
|
2068
|
+
shares = yield this.ctx.enclaveClient.getPregenShares({
|
|
2057
2069
|
userId: this.userId,
|
|
2058
2070
|
walletIds: pregenWallets.map((w) => w.id),
|
|
2059
2071
|
partnerId: pregenWallets[0].partnerId
|
|
@@ -2078,13 +2090,15 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2078
2090
|
} catch (err) {
|
|
2079
2091
|
console.warn("[waitForWalletCreation] Failed to fetch pregen shares:", err);
|
|
2080
2092
|
}
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2093
|
+
if (shares.length > 0) {
|
|
2094
|
+
recoverySecret = yield this.claimPregenWallets();
|
|
2095
|
+
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
2096
|
+
var _a;
|
|
2097
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
2098
|
+
[type]: [(_a = pregenWallets.find((w) => !!import_utils2.WalletSchemeTypeMap[w.scheme][type])) == null ? void 0 : _a.id]
|
|
2099
|
+
});
|
|
2100
|
+
}, {});
|
|
2101
|
+
}
|
|
2088
2102
|
}
|
|
2089
2103
|
const created = yield this.createWalletPerType();
|
|
2090
2104
|
recoverySecret = recoverySecret != null ? recoverySecret : created.recoverySecret;
|
|
@@ -3263,6 +3277,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3263
3277
|
this.accountLinkInProgress = void 0;
|
|
3264
3278
|
this.userId = void 0;
|
|
3265
3279
|
this.sessionCookie = void 0;
|
|
3280
|
+
this.isEnclaveUser = false;
|
|
3266
3281
|
if (shouldDispatchLogoutEvent) {
|
|
3267
3282
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGOUT_EVENT, null);
|
|
3268
3283
|
}
|
|
@@ -3789,14 +3804,26 @@ getOAuthUrl_fn = function(_0) {
|
|
|
3789
3804
|
if (!accountLinkInProgress && !this.isPortal()) {
|
|
3790
3805
|
return yield this.constructPortalUrl("oAuth", { sessionId: sessionLookupId, oAuthMethod: method, appScheme });
|
|
3791
3806
|
}
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3807
|
+
const [portalSessionLookupId, callback] = yield Promise.all([
|
|
3808
|
+
this.isPortal() ? this.touchSession(true).then((s) => s.sessionLookupId) : Promise.resolve(void 0),
|
|
3809
|
+
!accountLinkInProgress ? this.constructPortalUrl("oAuthCallback", __spreadValues({
|
|
3810
|
+
sessionId: sessionLookupId,
|
|
3811
|
+
oAuthMethod: method,
|
|
3812
|
+
appScheme,
|
|
3813
|
+
thisDevice: {
|
|
3814
|
+
sessionId: sessionLookupId,
|
|
3815
|
+
encryptionKey
|
|
3816
|
+
}
|
|
3817
|
+
}, this.isPortal() && {
|
|
3818
|
+
params: portalCallbackParams,
|
|
3819
|
+
// Build callback for legacy portal if needed
|
|
3820
|
+
useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
|
|
3821
|
+
})) : Promise.resolve(false)
|
|
3822
|
+
]);
|
|
3796
3823
|
return (0, import_utils2.constructUrl)({
|
|
3797
3824
|
base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
|
|
3798
3825
|
path: `/auth/${method.toLowerCase()}`,
|
|
3799
|
-
params:
|
|
3826
|
+
params: __spreadValues(__spreadValues({
|
|
3800
3827
|
apiKey: this.ctx.apiKey,
|
|
3801
3828
|
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
3802
3829
|
sessionLookupId,
|
|
@@ -3804,21 +3831,7 @@ getOAuthUrl_fn = function(_0) {
|
|
|
3804
3831
|
appScheme
|
|
3805
3832
|
}, accountLinkInProgress ? {
|
|
3806
3833
|
linkedAccountId: this.accountLinkInProgress.id
|
|
3807
|
-
} : {}), {
|
|
3808
|
-
callback: !accountLinkInProgress && (yield this.constructPortalUrl("oAuthCallback", __spreadValues({
|
|
3809
|
-
sessionId: sessionLookupId,
|
|
3810
|
-
oAuthMethod: method,
|
|
3811
|
-
appScheme,
|
|
3812
|
-
thisDevice: {
|
|
3813
|
-
sessionId: sessionLookupId,
|
|
3814
|
-
encryptionKey
|
|
3815
|
-
}
|
|
3816
|
-
}, this.isPortal() && {
|
|
3817
|
-
params: portalCallbackParams,
|
|
3818
|
-
// Build callback for legacy portal if needed
|
|
3819
|
-
useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
|
|
3820
|
-
})))
|
|
3821
|
-
})
|
|
3834
|
+
} : {}), callback && { callback })
|
|
3822
3835
|
});
|
|
3823
3836
|
});
|
|
3824
3837
|
};
|
|
@@ -4090,6 +4103,7 @@ prepareDoneState_fn = function(doneState) {
|
|
|
4090
4103
|
return __async(this, null, function* () {
|
|
4091
4104
|
let isSLOPossible = doneState.authMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
4092
4105
|
this.isEnclaveUser = isSLOPossible;
|
|
4106
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_IS_ENCLAVE_USER, JSON.stringify(isSLOPossible));
|
|
4093
4107
|
return doneState;
|
|
4094
4108
|
});
|
|
4095
4109
|
};
|
|
@@ -4107,6 +4121,7 @@ prepareVerificationState_fn = function(_0, _1) {
|
|
|
4107
4121
|
isSLOPossible = verifyState.signupAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
4108
4122
|
}
|
|
4109
4123
|
this.isEnclaveUser = isSLOPossible;
|
|
4124
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_IS_ENCLAVE_USER, JSON.stringify(isSLOPossible));
|
|
4110
4125
|
const isExternalWalletFullAuth = (_a = verifyState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
|
|
4111
4126
|
return __spreadValues(__spreadValues({}, verifyState), isSLOPossible || isExternalWalletFullAuth ? {
|
|
4112
4127
|
loginUrl: yield this.getLoginUrl({
|
package/dist/cjs/constants.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(constants_exports, {
|
|
|
29
29
|
LOCAL_STORAGE_EXTERNAL_WALLETS: () => LOCAL_STORAGE_EXTERNAL_WALLETS,
|
|
30
30
|
LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID: () => LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID,
|
|
31
31
|
LOCAL_STORAGE_FARCASTER_USERNAME: () => LOCAL_STORAGE_FARCASTER_USERNAME,
|
|
32
|
+
LOCAL_STORAGE_IS_ENCLAVE_USER: () => LOCAL_STORAGE_IS_ENCLAVE_USER,
|
|
32
33
|
LOCAL_STORAGE_PHONE: () => LOCAL_STORAGE_PHONE,
|
|
33
34
|
LOCAL_STORAGE_SESSION_COOKIE: () => LOCAL_STORAGE_SESSION_COOKIE,
|
|
34
35
|
LOCAL_STORAGE_TELEGRAM_USER_ID: () => LOCAL_STORAGE_TELEGRAM_USER_ID,
|
|
@@ -43,7 +44,7 @@ __export(constants_exports, {
|
|
|
43
44
|
SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(constants_exports);
|
|
46
|
-
const PARA_CORE_VERSION = "2.
|
|
47
|
+
const PARA_CORE_VERSION = "2.11.0";
|
|
47
48
|
const PREFIX = "@CAPSULE/";
|
|
48
49
|
const PARA_PREFIX = "@PARA/";
|
|
49
50
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -61,6 +62,7 @@ const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
|
|
|
61
62
|
const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
62
63
|
const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
|
|
63
64
|
const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
|
|
65
|
+
const LOCAL_STORAGE_IS_ENCLAVE_USER = `${PREFIX}isEnclaveUser`;
|
|
64
66
|
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
65
67
|
const POLLING_INTERVAL_MS = 1e3;
|
|
66
68
|
const SHORT_POLLING_INTERVAL_MS = 750;
|
|
@@ -81,6 +83,7 @@ const ACCOUNT_LINK_CONFLICT = "Account already linked";
|
|
|
81
83
|
LOCAL_STORAGE_EXTERNAL_WALLETS,
|
|
82
84
|
LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID,
|
|
83
85
|
LOCAL_STORAGE_FARCASTER_USERNAME,
|
|
86
|
+
LOCAL_STORAGE_IS_ENCLAVE_USER,
|
|
84
87
|
LOCAL_STORAGE_PHONE,
|
|
85
88
|
LOCAL_STORAGE_SESSION_COOKIE,
|
|
86
89
|
LOCAL_STORAGE_TELEGRAM_USER_ID,
|
|
@@ -49,16 +49,16 @@ function getBaseOAuthUrl(env) {
|
|
|
49
49
|
throw new Error(`unsupported env: ${env}`);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function getBaseUrl(env) {
|
|
52
|
+
function getBaseUrl(env, scheme = "http") {
|
|
53
53
|
switch (env) {
|
|
54
54
|
case import_types.Environment.DEV:
|
|
55
|
-
return
|
|
55
|
+
return `${scheme}://localhost:8080/`;
|
|
56
56
|
case import_types.Environment.SANDBOX:
|
|
57
|
-
return
|
|
57
|
+
return `${scheme}s://api.sandbox.getpara.com/`;
|
|
58
58
|
case import_types.Environment.BETA:
|
|
59
|
-
return
|
|
59
|
+
return `${scheme}s://api.beta.getpara.com/`;
|
|
60
60
|
case import_types.Environment.PROD:
|
|
61
|
-
return
|
|
61
|
+
return `${scheme}s://api.getpara.com/`;
|
|
62
62
|
default:
|
|
63
63
|
throw new Error(`unsupported env: ${env}`);
|
|
64
64
|
}
|
|
@@ -287,6 +287,9 @@ ${exportedAsBase64}
|
|
|
287
287
|
const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
|
|
288
288
|
const encryptedPayloadStr = JSON.stringify(encryptedPayload);
|
|
289
289
|
const response = yield this.userManagementClient.getPregenShares(encryptedPayloadStr);
|
|
290
|
+
if (!response.payload) {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
290
293
|
const encryptedResponse = JSON.parse(response.payload);
|
|
291
294
|
const decryptedData = yield this.decryptForFrontend(encryptedResponse);
|
|
292
295
|
return decryptedData.shares;
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -200,6 +200,7 @@ const _ParaCore = class _ParaCore {
|
|
|
200
200
|
this.updateSessionCookieFromStorage();
|
|
201
201
|
this.updateLoginEncryptionKeyPairFromStorage();
|
|
202
202
|
this.updateEnclaveJwtFromStorage();
|
|
203
|
+
this.updateIsEnclaveUserFromStorage();
|
|
203
204
|
};
|
|
204
205
|
this.updateAuthInfoFromStorage = () => {
|
|
205
206
|
var _a;
|
|
@@ -223,6 +224,12 @@ const _ParaCore = class _ParaCore {
|
|
|
223
224
|
this.enclaveJwt = this.localStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_JWT) || this.sessionStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_JWT) || void 0;
|
|
224
225
|
this.enclaveRefreshJwt = this.localStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT) || this.sessionStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT) || void 0;
|
|
225
226
|
};
|
|
227
|
+
this.updateIsEnclaveUserFromStorage = () => {
|
|
228
|
+
const stored = this.localStorageGetItem(constants.LOCAL_STORAGE_IS_ENCLAVE_USER);
|
|
229
|
+
if (stored != null) {
|
|
230
|
+
this.isEnclaveUser = JSON.parse(stored);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
226
233
|
this.updateUserIdFromStorage = () => {
|
|
227
234
|
this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || void 0;
|
|
228
235
|
};
|
|
@@ -1077,6 +1084,10 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1077
1084
|
if (loginEncryptionKey && loginEncryptionKey !== "undefined") {
|
|
1078
1085
|
this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
|
|
1079
1086
|
}
|
|
1087
|
+
const storedIsEnclaveUser = yield this.localStorageGetItem(constants.LOCAL_STORAGE_IS_ENCLAVE_USER);
|
|
1088
|
+
if (storedIsEnclaveUser != null) {
|
|
1089
|
+
this.isEnclaveUser = JSON.parse(storedIsEnclaveUser);
|
|
1090
|
+
}
|
|
1080
1091
|
setupListeners.bind(this)();
|
|
1081
1092
|
yield this.touchSession();
|
|
1082
1093
|
});
|
|
@@ -2018,8 +2029,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2018
2029
|
const pregenWallets = yield this.getPregenWallets();
|
|
2019
2030
|
let recoverySecret, walletIds = {};
|
|
2020
2031
|
if (pregenWallets.length > 0) {
|
|
2032
|
+
let shares = [];
|
|
2021
2033
|
try {
|
|
2022
|
-
|
|
2034
|
+
shares = yield this.ctx.enclaveClient.getPregenShares({
|
|
2023
2035
|
userId: this.userId,
|
|
2024
2036
|
walletIds: pregenWallets.map((w) => w.id),
|
|
2025
2037
|
partnerId: pregenWallets[0].partnerId
|
|
@@ -2044,13 +2056,15 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2044
2056
|
} catch (err) {
|
|
2045
2057
|
console.warn("[waitForWalletCreation] Failed to fetch pregen shares:", err);
|
|
2046
2058
|
}
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2059
|
+
if (shares.length > 0) {
|
|
2060
|
+
recoverySecret = yield this.claimPregenWallets();
|
|
2061
|
+
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
2062
|
+
var _a;
|
|
2063
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
2064
|
+
[type]: [(_a = pregenWallets.find((w) => !!WalletSchemeTypeMap[w.scheme][type])) == null ? void 0 : _a.id]
|
|
2065
|
+
});
|
|
2066
|
+
}, {});
|
|
2067
|
+
}
|
|
2054
2068
|
}
|
|
2055
2069
|
const created = yield this.createWalletPerType();
|
|
2056
2070
|
recoverySecret = recoverySecret != null ? recoverySecret : created.recoverySecret;
|
|
@@ -3229,6 +3243,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3229
3243
|
this.accountLinkInProgress = void 0;
|
|
3230
3244
|
this.userId = void 0;
|
|
3231
3245
|
this.sessionCookie = void 0;
|
|
3246
|
+
this.isEnclaveUser = false;
|
|
3232
3247
|
if (shouldDispatchLogoutEvent) {
|
|
3233
3248
|
dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
|
|
3234
3249
|
}
|
|
@@ -3755,14 +3770,26 @@ getOAuthUrl_fn = function(_0) {
|
|
|
3755
3770
|
if (!accountLinkInProgress && !this.isPortal()) {
|
|
3756
3771
|
return yield this.constructPortalUrl("oAuth", { sessionId: sessionLookupId, oAuthMethod: method, appScheme });
|
|
3757
3772
|
}
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3773
|
+
const [portalSessionLookupId, callback] = yield Promise.all([
|
|
3774
|
+
this.isPortal() ? this.touchSession(true).then((s) => s.sessionLookupId) : Promise.resolve(void 0),
|
|
3775
|
+
!accountLinkInProgress ? this.constructPortalUrl("oAuthCallback", __spreadValues({
|
|
3776
|
+
sessionId: sessionLookupId,
|
|
3777
|
+
oAuthMethod: method,
|
|
3778
|
+
appScheme,
|
|
3779
|
+
thisDevice: {
|
|
3780
|
+
sessionId: sessionLookupId,
|
|
3781
|
+
encryptionKey
|
|
3782
|
+
}
|
|
3783
|
+
}, this.isPortal() && {
|
|
3784
|
+
params: portalCallbackParams,
|
|
3785
|
+
// Build callback for legacy portal if needed
|
|
3786
|
+
useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
|
|
3787
|
+
})) : Promise.resolve(false)
|
|
3788
|
+
]);
|
|
3762
3789
|
return constructUrl({
|
|
3763
3790
|
base: getBaseOAuthUrl(this.ctx.env),
|
|
3764
3791
|
path: `/auth/${method.toLowerCase()}`,
|
|
3765
|
-
params:
|
|
3792
|
+
params: __spreadValues(__spreadValues({
|
|
3766
3793
|
apiKey: this.ctx.apiKey,
|
|
3767
3794
|
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
3768
3795
|
sessionLookupId,
|
|
@@ -3770,21 +3797,7 @@ getOAuthUrl_fn = function(_0) {
|
|
|
3770
3797
|
appScheme
|
|
3771
3798
|
}, accountLinkInProgress ? {
|
|
3772
3799
|
linkedAccountId: this.accountLinkInProgress.id
|
|
3773
|
-
} : {}), {
|
|
3774
|
-
callback: !accountLinkInProgress && (yield this.constructPortalUrl("oAuthCallback", __spreadValues({
|
|
3775
|
-
sessionId: sessionLookupId,
|
|
3776
|
-
oAuthMethod: method,
|
|
3777
|
-
appScheme,
|
|
3778
|
-
thisDevice: {
|
|
3779
|
-
sessionId: sessionLookupId,
|
|
3780
|
-
encryptionKey
|
|
3781
|
-
}
|
|
3782
|
-
}, this.isPortal() && {
|
|
3783
|
-
params: portalCallbackParams,
|
|
3784
|
-
// Build callback for legacy portal if needed
|
|
3785
|
-
useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
|
|
3786
|
-
})))
|
|
3787
|
-
})
|
|
3800
|
+
} : {}), callback && { callback })
|
|
3788
3801
|
});
|
|
3789
3802
|
});
|
|
3790
3803
|
};
|
|
@@ -4056,6 +4069,7 @@ prepareDoneState_fn = function(doneState) {
|
|
|
4056
4069
|
return __async(this, null, function* () {
|
|
4057
4070
|
let isSLOPossible = doneState.authMethods.includes(AuthMethod.BASIC_LOGIN);
|
|
4058
4071
|
this.isEnclaveUser = isSLOPossible;
|
|
4072
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_IS_ENCLAVE_USER, JSON.stringify(isSLOPossible));
|
|
4059
4073
|
return doneState;
|
|
4060
4074
|
});
|
|
4061
4075
|
};
|
|
@@ -4073,6 +4087,7 @@ prepareVerificationState_fn = function(_0, _1) {
|
|
|
4073
4087
|
isSLOPossible = verifyState.signupAuthMethods.includes(AuthMethod.BASIC_LOGIN);
|
|
4074
4088
|
}
|
|
4075
4089
|
this.isEnclaveUser = isSLOPossible;
|
|
4090
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_IS_ENCLAVE_USER, JSON.stringify(isSLOPossible));
|
|
4076
4091
|
const isExternalWalletFullAuth = (_a = verifyState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
|
|
4077
4092
|
return __spreadValues(__spreadValues({}, verifyState), isSLOPossible || isExternalWalletFullAuth ? {
|
|
4078
4093
|
loginUrl: yield this.getLoginUrl({
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./chunk-7B52C2XE.js";
|
|
2
|
-
const PARA_CORE_VERSION = "2.
|
|
2
|
+
const PARA_CORE_VERSION = "2.11.0";
|
|
3
3
|
const PREFIX = "@CAPSULE/";
|
|
4
4
|
const PARA_PREFIX = "@PARA/";
|
|
5
5
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -17,6 +17,7 @@ const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
|
|
|
17
17
|
const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
18
18
|
const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
|
|
19
19
|
const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
|
|
20
|
+
const LOCAL_STORAGE_IS_ENCLAVE_USER = `${PREFIX}isEnclaveUser`;
|
|
20
21
|
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
21
22
|
const POLLING_INTERVAL_MS = 1e3;
|
|
22
23
|
const SHORT_POLLING_INTERVAL_MS = 750;
|
|
@@ -36,6 +37,7 @@ export {
|
|
|
36
37
|
LOCAL_STORAGE_EXTERNAL_WALLETS,
|
|
37
38
|
LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID,
|
|
38
39
|
LOCAL_STORAGE_FARCASTER_USERNAME,
|
|
40
|
+
LOCAL_STORAGE_IS_ENCLAVE_USER,
|
|
39
41
|
LOCAL_STORAGE_PHONE,
|
|
40
42
|
LOCAL_STORAGE_SESSION_COOKIE,
|
|
41
43
|
LOCAL_STORAGE_TELEGRAM_USER_ID,
|
|
@@ -15,16 +15,16 @@ function getBaseOAuthUrl(env) {
|
|
|
15
15
|
throw new Error(`unsupported env: ${env}`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
function getBaseUrl(env) {
|
|
18
|
+
function getBaseUrl(env, scheme = "http") {
|
|
19
19
|
switch (env) {
|
|
20
20
|
case Environment.DEV:
|
|
21
|
-
return
|
|
21
|
+
return `${scheme}://localhost:8080/`;
|
|
22
22
|
case Environment.SANDBOX:
|
|
23
|
-
return
|
|
23
|
+
return `${scheme}s://api.sandbox.getpara.com/`;
|
|
24
24
|
case Environment.BETA:
|
|
25
|
-
return
|
|
25
|
+
return `${scheme}s://api.beta.getpara.com/`;
|
|
26
26
|
case Environment.PROD:
|
|
27
|
-
return
|
|
27
|
+
return `${scheme}s://api.getpara.com/`;
|
|
28
28
|
default:
|
|
29
29
|
throw new Error(`unsupported env: ${env}`);
|
|
30
30
|
}
|
|
@@ -248,6 +248,9 @@ ${exportedAsBase64}
|
|
|
248
248
|
const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
|
|
249
249
|
const encryptedPayloadStr = JSON.stringify(encryptedPayload);
|
|
250
250
|
const response = yield this.userManagementClient.getPregenShares(encryptedPayloadStr);
|
|
251
|
+
if (!response.payload) {
|
|
252
|
+
return [];
|
|
253
|
+
}
|
|
251
254
|
const encryptedResponse = JSON.parse(response.payload);
|
|
252
255
|
const decryptedData = yield this.decryptForFrontend(encryptedResponse);
|
|
253
256
|
return decryptedData.shares;
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -214,6 +214,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
214
214
|
private initializeFromStorage;
|
|
215
215
|
private updateAuthInfoFromStorage;
|
|
216
216
|
private updateEnclaveJwtFromStorage;
|
|
217
|
+
private updateIsEnclaveUserFromStorage;
|
|
217
218
|
private updateUserIdFromStorage;
|
|
218
219
|
private updateWalletsFromStorage;
|
|
219
220
|
private updateWalletIdsFromStorage;
|
|
@@ -16,6 +16,7 @@ export declare const LOCAL_STORAGE_CURRENT_WALLET_IDS = "@CAPSULE/currentWalletI
|
|
|
16
16
|
export declare const LOCAL_STORAGE_SESSION_COOKIE = "@CAPSULE/sessionCookie";
|
|
17
17
|
export declare const LOCAL_STORAGE_ENCLAVE_JWT = "@CAPSULE/enclaveJwt";
|
|
18
18
|
export declare const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = "@CAPSULE/enclaveRefreshJwt";
|
|
19
|
+
export declare const LOCAL_STORAGE_IS_ENCLAVE_USER = "@CAPSULE/isEnclaveUser";
|
|
19
20
|
export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = "@CAPSULE/loginEncryptionKeyPair";
|
|
20
21
|
export declare const POLLING_INTERVAL_MS = 1000;
|
|
21
22
|
export declare const SHORT_POLLING_INTERVAL_MS = 750;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Client from '@getpara/user-management-client';
|
|
2
2
|
import { Environment } from '../types/index.js';
|
|
3
3
|
export declare function getBaseOAuthUrl(env: Environment): string;
|
|
4
|
-
export declare function getBaseUrl(env: Environment): string;
|
|
4
|
+
export declare function getBaseUrl(env: Environment, scheme?: 'http' | 'ws'): string;
|
|
5
5
|
export declare function getBaseMPCNetworkUrl(env: Environment, useWebsocket?: boolean): string;
|
|
6
6
|
export declare function initClient({ env, version, apiKey, partnerId, useFetchAdapter, retrieveSessionCookie, persistSessionCookie, }: {
|
|
7
7
|
env: Environment;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@celo/utils": "^8.0.2",
|
|
6
6
|
"@cosmjs/encoding": "^0.32.4",
|
|
7
7
|
"@ethereumjs/util": "^9.1.0",
|
|
8
|
-
"@getpara/user-management-client": "2.
|
|
8
|
+
"@getpara/user-management-client": "2.11.0",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
10
|
"base64url": "^3.0.1",
|
|
11
11
|
"libphonenumber-js": "^1.11.7",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist",
|
|
28
28
|
"package.json"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "1cce45857320460cca03c4a9d0a59db169b222d6",
|
|
31
31
|
"main": "dist/cjs/index.js",
|
|
32
32
|
"module": "dist/esm/index.js",
|
|
33
33
|
"scripts": {
|