@getpara/core-sdk 2.0.0-alpha.67 → 2.0.0-alpha.68
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 +126 -92
- package/dist/cjs/constants.js +1 -1
- package/dist/esm/ParaCore.js +126 -92
- package/dist/esm/constants.js +1 -1
- package/dist/types/ParaCore.d.ts +8 -3
- package/dist/types/types/coreApi.d.ts +16 -4
- package/dist/types/types/methods.d.ts +3 -3
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -769,7 +769,7 @@ const _ParaCore = class _ParaCore {
|
|
|
769
769
|
}
|
|
770
770
|
constructPortalUrl(_0) {
|
|
771
771
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
772
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
772
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
773
773
|
const [
|
|
774
774
|
isCreate,
|
|
775
775
|
isLogin,
|
|
@@ -783,7 +783,7 @@ const _ParaCore = class _ParaCore {
|
|
|
783
783
|
isExportPrivateKey
|
|
784
784
|
] = [
|
|
785
785
|
["createAuth", "createPassword", "createPIN"].includes(type),
|
|
786
|
-
["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets"].includes(type),
|
|
786
|
+
["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets", "loginExternalWallet"].includes(type),
|
|
787
787
|
type === "onRamp",
|
|
788
788
|
type === "oAuth",
|
|
789
789
|
type === "oAuthCallback",
|
|
@@ -878,6 +878,14 @@ const _ParaCore = class _ParaCore {
|
|
|
878
878
|
path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
|
|
879
879
|
break;
|
|
880
880
|
}
|
|
881
|
+
case "loginExternalWallet": {
|
|
882
|
+
path = "/auth/external-wallet";
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
case "connectExternalWallet": {
|
|
886
|
+
path = "/auth/connect-external-wallet";
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
881
889
|
default: {
|
|
882
890
|
throw new Error(`invalid URL type ${type}`);
|
|
883
891
|
}
|
|
@@ -896,25 +904,27 @@ const _ParaCore = class _ParaCore {
|
|
|
896
904
|
encryptionKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair),
|
|
897
905
|
sessionId
|
|
898
906
|
};
|
|
899
|
-
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
907
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
900
908
|
apiKey: this.ctx.apiKey,
|
|
901
909
|
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
902
|
-
partnerId: partner == null ? void 0 : partner.id
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
910
|
+
partnerId: partner == null ? void 0 : partner.id
|
|
911
|
+
}, typeof window !== "undefined" && ((_b = window.location) == null ? void 0 : _b.origin) ? { origin: window.location.origin } : {}), {
|
|
912
|
+
portalFont: ((_c = opts.portalTheme) == null ? void 0 : _c.font) || ((_d = this.portalTheme) == null ? void 0 : _d.font) || (partner == null ? void 0 : partner.font),
|
|
913
|
+
portalBorderRadius: ((_e = opts.portalTheme) == null ? void 0 : _e.borderRadius) || ((_f = this.portalTheme) == null ? void 0 : _f.borderRadius),
|
|
914
|
+
portalThemeMode: ((_g = opts.portalTheme) == null ? void 0 : _g.mode) || ((_h = this.portalTheme) == null ? void 0 : _h.mode) || (partner == null ? void 0 : partner.themeMode),
|
|
915
|
+
portalAccentColor: ((_i = opts.portalTheme) == null ? void 0 : _i.accentColor) || ((_j = this.portalTheme) == null ? void 0 : _j.accentColor) || (partner == null ? void 0 : partner.accentColor),
|
|
916
|
+
portalForegroundColor: ((_k = opts.portalTheme) == null ? void 0 : _k.foregroundColor) || ((_l = this.portalTheme) == null ? void 0 : _l.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor),
|
|
917
|
+
portalBackgroundColor: ((_m = opts.portalTheme) == null ? void 0 : _m.backgroundColor) || ((_n = this.portalTheme) == null ? void 0 : _n.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor,
|
|
909
918
|
portalPrimaryButtonColor: this.portalPrimaryButtonColor,
|
|
910
919
|
portalTextColor: this.portalTextColor,
|
|
911
920
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
912
921
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
913
|
-
}, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
|
|
922
|
+
}), this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
|
|
914
923
|
authInfo: JSON.stringify(this.authInfo)
|
|
915
924
|
}, (0, import_user_management_client.isPhone)(this.authInfo.auth) ? (0, import_utils2.splitPhoneNumber)(this.authInfo.auth.phone) : this.authInfo.auth), {
|
|
916
925
|
pfpUrl: this.authInfo.pfpUrl,
|
|
917
|
-
displayName: this.authInfo.displayName
|
|
926
|
+
displayName: this.authInfo.displayName,
|
|
927
|
+
userId: this.userId
|
|
918
928
|
}) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential || isExportPrivateKey ? __spreadProps(__spreadValues({
|
|
919
929
|
sessionId: thisDevice.sessionId,
|
|
920
930
|
encryptionKey: thisDevice.encryptionKey
|
|
@@ -928,7 +938,10 @@ const _ParaCore = class _ParaCore {
|
|
|
928
938
|
} : {}), isTelegramLogin ? { isEmbed: "true" } : {}), isSwitchWallets ? __spreadValues(__spreadValues({}, this.currentWalletIds ? { currentWalletIds: JSON.stringify(this.currentWalletIds) } : {}), this.userId ? { userId: this.userId } : {}) : {}), opts.params || {}), isAddNewCredential ? __spreadProps(__spreadValues({}, opts.addNewCredentialType && { addNewCredentialType: opts.addNewCredentialType.toString() }), {
|
|
929
939
|
addNewCredentialPasskeyId: opts.addNewCredentialPasskeyId,
|
|
930
940
|
addNewCredentialPasswordId: opts.addNewCredentialPasswordId
|
|
931
|
-
}) : {})
|
|
941
|
+
}) : {}), isLogin && {
|
|
942
|
+
// Prior versions won't have this param which will skip the upgrade prompt
|
|
943
|
+
isBasicLoginUpgradeVersion: "true"
|
|
944
|
+
});
|
|
932
945
|
const url = (0, import_utils2.constructUrl)({ base, path, params });
|
|
933
946
|
if (opts.shorten) {
|
|
934
947
|
return (0, import_utils2.shortenUrl)(this.ctx, url);
|
|
@@ -1620,9 +1633,13 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1620
1633
|
loginExternalWallet(_a) {
|
|
1621
1634
|
return __async(this, null, function* () {
|
|
1622
1635
|
var _b = _a, {
|
|
1623
|
-
externalWallet
|
|
1636
|
+
externalWallet,
|
|
1637
|
+
chainId,
|
|
1638
|
+
uri
|
|
1624
1639
|
} = _b, urlOptions = __objRest(_b, [
|
|
1625
|
-
"externalWallet"
|
|
1640
|
+
"externalWallet",
|
|
1641
|
+
"chainId",
|
|
1642
|
+
"uri"
|
|
1626
1643
|
]);
|
|
1627
1644
|
const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
|
|
1628
1645
|
if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
|
|
@@ -1641,38 +1658,47 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1641
1658
|
);
|
|
1642
1659
|
}
|
|
1643
1660
|
this.requireApiKey();
|
|
1644
|
-
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
|
|
1661
|
+
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet, chainId, uri });
|
|
1645
1662
|
if (!externalWallet.withFullParaAuth && externalWallet.withVerification) {
|
|
1646
1663
|
yield this.touchSession(true);
|
|
1647
1664
|
}
|
|
1665
|
+
if (externalWallet.withFullParaAuth) {
|
|
1666
|
+
yield this.ctx.client.sessionAddPortalVerification();
|
|
1667
|
+
}
|
|
1648
1668
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1649
1669
|
});
|
|
1650
1670
|
}
|
|
1651
|
-
verifyExternalWallet(
|
|
1671
|
+
verifyExternalWallet(params) {
|
|
1652
1672
|
return __async(this, null, function* () {
|
|
1653
|
-
var
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
"cosmosPublicKeyHex",
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
}
|
|
1671
|
-
if (serverAuthState.stage === "login" && ((
|
|
1673
|
+
var _c;
|
|
1674
|
+
let serverAuthState;
|
|
1675
|
+
let urlOptions;
|
|
1676
|
+
if ("serverAuthState" in params && params.serverAuthState !== void 0) {
|
|
1677
|
+
const _a = params, { serverAuthState: optsServerAuthState } = _a, rest = __objRest(_a, ["serverAuthState"]);
|
|
1678
|
+
serverAuthState = optsServerAuthState;
|
|
1679
|
+
urlOptions = rest;
|
|
1680
|
+
} else if ("externalWallet" in params) {
|
|
1681
|
+
const _b = params, { externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner } = _b, rest = __objRest(_b, ["externalWallet", "signedMessage", "cosmosPublicKeyHex", "cosmosSigner"]);
|
|
1682
|
+
const _serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
|
|
1683
|
+
externalWallet,
|
|
1684
|
+
signedMessage,
|
|
1685
|
+
cosmosPublicKeyHex,
|
|
1686
|
+
cosmosSigner
|
|
1687
|
+
});
|
|
1688
|
+
serverAuthState = _serverAuthState;
|
|
1689
|
+
urlOptions = rest;
|
|
1690
|
+
}
|
|
1691
|
+
if (serverAuthState.stage === "login" && ((_c = serverAuthState.loginAuthMethods) == null ? void 0 : _c.includes(import_user_management_client.AuthMethod.PIN))) {
|
|
1672
1692
|
const { sessionLookupId } = yield this.touchSession();
|
|
1673
|
-
return __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1693
|
+
return yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1674
1694
|
}
|
|
1675
|
-
|
|
1695
|
+
let state;
|
|
1696
|
+
try {
|
|
1697
|
+
state = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1698
|
+
} catch (err) {
|
|
1699
|
+
console.error("Error prepping state:", err);
|
|
1700
|
+
}
|
|
1701
|
+
return state;
|
|
1676
1702
|
});
|
|
1677
1703
|
}
|
|
1678
1704
|
verifyExternalWalletLink(opts) {
|
|
@@ -1695,13 +1721,13 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1695
1721
|
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
1696
1722
|
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
1697
1723
|
*/
|
|
1698
|
-
verifyTelegramProcess(
|
|
1724
|
+
verifyTelegramProcess(_c) {
|
|
1699
1725
|
return __async(this, null, function* () {
|
|
1700
|
-
var
|
|
1726
|
+
var _d = _c, {
|
|
1701
1727
|
serverAuthState: optsServerAuthState,
|
|
1702
1728
|
telegramAuthResponse,
|
|
1703
1729
|
isLinkAccount
|
|
1704
|
-
} =
|
|
1730
|
+
} = _d, urlOptions = __objRest(_d, [
|
|
1705
1731
|
"serverAuthState",
|
|
1706
1732
|
"telegramAuthResponse",
|
|
1707
1733
|
"isLinkAccount"
|
|
@@ -2037,16 +2063,16 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2037
2063
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
2038
2064
|
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
2039
2065
|
*/
|
|
2040
|
-
verifyFarcasterProcess(
|
|
2066
|
+
verifyFarcasterProcess(_e) {
|
|
2041
2067
|
return __async(this, null, function* () {
|
|
2042
|
-
var
|
|
2068
|
+
var _f = _e, {
|
|
2043
2069
|
isCanceled = () => false,
|
|
2044
2070
|
onConnectUri,
|
|
2045
2071
|
onCancel,
|
|
2046
2072
|
onPoll,
|
|
2047
2073
|
isLinkAccount,
|
|
2048
2074
|
serverAuthState: optsServerAuthState
|
|
2049
|
-
} =
|
|
2075
|
+
} = _f, urlOptions = __objRest(_f, [
|
|
2050
2076
|
"isCanceled",
|
|
2051
2077
|
"onConnectUri",
|
|
2052
2078
|
"onCancel",
|
|
@@ -2132,9 +2158,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2132
2158
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
2133
2159
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
2134
2160
|
*/
|
|
2135
|
-
verifyOAuthProcess(
|
|
2161
|
+
verifyOAuthProcess(_g) {
|
|
2136
2162
|
return __async(this, null, function* () {
|
|
2137
|
-
var
|
|
2163
|
+
var _h = _g, {
|
|
2138
2164
|
method,
|
|
2139
2165
|
appScheme,
|
|
2140
2166
|
isCanceled = () => false,
|
|
@@ -2143,7 +2169,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2143
2169
|
onOAuthUrl,
|
|
2144
2170
|
onOAuthPopup,
|
|
2145
2171
|
isLinkAccount
|
|
2146
|
-
} =
|
|
2172
|
+
} = _h, urlOptions = __objRest(_h, [
|
|
2147
2173
|
"method",
|
|
2148
2174
|
"appScheme",
|
|
2149
2175
|
"isCanceled",
|
|
@@ -3261,49 +3287,55 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3261
3287
|
} = {}) {
|
|
3262
3288
|
const userAuthMethods = yield this.supportedUserAuthMethods();
|
|
3263
3289
|
const isEnclaveUser = userAuthMethods.has(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
3264
|
-
|
|
3290
|
+
const isAddingBasicLogin = optsAuthMethod === "BASIC_LOGIN";
|
|
3291
|
+
if (isEnclaveUser && isAddingBasicLogin) {
|
|
3292
|
+
throw new Error("That user is already using basic login");
|
|
3293
|
+
}
|
|
3294
|
+
if (isEnclaveUser || isAddingBasicLogin) {
|
|
3265
3295
|
isForNewDevice = true;
|
|
3266
3296
|
}
|
|
3267
3297
|
const authMethods = optsAuthMethod ? [optsAuthMethod] : isForNewDevice ? ["PASSKEY", "PIN", "PASSWORD"] : ["PASSKEY"];
|
|
3268
3298
|
this.assertIsAuthSet();
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
({
|
|
3273
|
-
data: { id: passkeyId }
|
|
3274
|
-
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
3275
|
-
status: import_user_management_client.AuthMethodStatus.PENDING,
|
|
3276
|
-
type: import_user_management_client.PublicKeyType.WEB
|
|
3277
|
-
}));
|
|
3278
|
-
urlType = "createAuth";
|
|
3279
|
-
}
|
|
3280
|
-
if (authMethods.includes("PASSWORD")) {
|
|
3281
|
-
if (!canAddPasswordOrPIN) {
|
|
3282
|
-
if (optsAuthMethod === "PASSWORD") throw new Error("A user cannot have more than one password or PIN.");
|
|
3283
|
-
} else {
|
|
3299
|
+
let passkeyId, passwordId, urlType, credentialId;
|
|
3300
|
+
if (!isAddingBasicLogin) {
|
|
3301
|
+
const canAddPasswordOrPIN = !userAuthMethods.has(import_user_management_client.AuthMethod.PASSWORD) && !userAuthMethods.has(import_user_management_client.AuthMethod.PIN);
|
|
3302
|
+
if (authMethods.includes("PASSKEY") && (yield this.isPasskeySupported())) {
|
|
3284
3303
|
({
|
|
3285
|
-
data: { id:
|
|
3286
|
-
} = yield this.ctx.client.
|
|
3287
|
-
status: import_user_management_client.AuthMethodStatus.PENDING
|
|
3304
|
+
data: { id: passkeyId }
|
|
3305
|
+
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
3306
|
+
status: import_user_management_client.AuthMethodStatus.PENDING,
|
|
3307
|
+
type: import_user_management_client.PublicKeyType.WEB
|
|
3288
3308
|
}));
|
|
3289
|
-
urlType = "
|
|
3309
|
+
urlType = "createAuth";
|
|
3290
3310
|
}
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3311
|
+
if (authMethods.includes("PASSWORD")) {
|
|
3312
|
+
if (!canAddPasswordOrPIN) {
|
|
3313
|
+
if (optsAuthMethod === "PASSWORD") throw new Error("A user cannot have more than one password or PIN.");
|
|
3314
|
+
} else {
|
|
3315
|
+
({
|
|
3316
|
+
data: { id: passwordId }
|
|
3317
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
3318
|
+
status: import_user_management_client.AuthMethodStatus.PENDING
|
|
3319
|
+
}));
|
|
3320
|
+
urlType = "createPassword";
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
if (authMethods.includes("PIN")) {
|
|
3324
|
+
if (!canAddPasswordOrPIN) {
|
|
3325
|
+
if (optsAuthMethod === "PIN") throw new Error("A user cannot have more than one password or PIN.");
|
|
3326
|
+
} else {
|
|
3327
|
+
({
|
|
3328
|
+
data: { id: passwordId }
|
|
3329
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
3330
|
+
status: import_user_management_client.AuthMethodStatus.PENDING
|
|
3331
|
+
}));
|
|
3332
|
+
urlType = "createPIN";
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
credentialId = passkeyId != null ? passkeyId : passwordId;
|
|
3336
|
+
if (this.isNativePasskey && authMethods.includes("PASSKEY")) {
|
|
3337
|
+
return { credentialId };
|
|
3302
3338
|
}
|
|
3303
|
-
}
|
|
3304
|
-
const credentialId = passkeyId != null ? passkeyId : passwordId;
|
|
3305
|
-
if (this.isNativePasskey && authMethods.includes("PASSKEY")) {
|
|
3306
|
-
return { credentialId };
|
|
3307
3339
|
}
|
|
3308
3340
|
const { sessionId } = yield this.touchSession();
|
|
3309
3341
|
const url = (isForNewDevice || urlType) && (yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
|
|
@@ -3359,7 +3391,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3359
3391
|
urlType = "loginPIN";
|
|
3360
3392
|
break;
|
|
3361
3393
|
case "BASIC_LOGIN":
|
|
3362
|
-
urlType = "loginOTP";
|
|
3394
|
+
urlType = this.authInfo.authType === "externalWallet" ? "loginExternalWallet" : "loginOTP";
|
|
3363
3395
|
break;
|
|
3364
3396
|
default:
|
|
3365
3397
|
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
@@ -3381,9 +3413,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3381
3413
|
return sessionLookupId;
|
|
3382
3414
|
});
|
|
3383
3415
|
}
|
|
3384
|
-
signUpOrLogIn(
|
|
3416
|
+
signUpOrLogIn(_i) {
|
|
3385
3417
|
return __async(this, null, function* () {
|
|
3386
|
-
var
|
|
3418
|
+
var _j = _i, { auth } = _j, urlOptions = __objRest(_j, ["auth"]);
|
|
3387
3419
|
let serverAuthState;
|
|
3388
3420
|
try {
|
|
3389
3421
|
serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
@@ -3405,11 +3437,11 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3405
3437
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadValues({}, urlOptions));
|
|
3406
3438
|
});
|
|
3407
3439
|
}
|
|
3408
|
-
verifyNewAccount(
|
|
3440
|
+
verifyNewAccount(_k) {
|
|
3409
3441
|
return __async(this, null, function* () {
|
|
3410
|
-
var
|
|
3442
|
+
var _l = _k, {
|
|
3411
3443
|
verificationCode
|
|
3412
|
-
} =
|
|
3444
|
+
} = _l, urlOptions = __objRest(_l, [
|
|
3413
3445
|
"verificationCode"
|
|
3414
3446
|
]);
|
|
3415
3447
|
this.assertIsAuthSet(["email", "phone"]);
|
|
@@ -3507,10 +3539,10 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3507
3539
|
});
|
|
3508
3540
|
}
|
|
3509
3541
|
verifyLink() {
|
|
3510
|
-
return __async(this, arguments, function* (
|
|
3511
|
-
var
|
|
3542
|
+
return __async(this, arguments, function* (_m = {}) {
|
|
3543
|
+
var _n = _m, {
|
|
3512
3544
|
accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
|
|
3513
|
-
} =
|
|
3545
|
+
} = _n, opts = __objRest(_n, [
|
|
3514
3546
|
"accountLinkInProgress"
|
|
3515
3547
|
]);
|
|
3516
3548
|
try {
|
|
@@ -4011,6 +4043,7 @@ prepareVerificationState_fn = function(_0, _1) {
|
|
|
4011
4043
|
portalTheme,
|
|
4012
4044
|
sessionLookupId
|
|
4013
4045
|
}) {
|
|
4046
|
+
var _a;
|
|
4014
4047
|
let isSLOPossible = false;
|
|
4015
4048
|
if (verifyState.nextStage === "login") {
|
|
4016
4049
|
isSLOPossible = verifyState.loginAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
@@ -4018,7 +4051,8 @@ prepareVerificationState_fn = function(_0, _1) {
|
|
|
4018
4051
|
isSLOPossible = verifyState.signupAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
4019
4052
|
}
|
|
4020
4053
|
this.isEnclaveUser = isSLOPossible;
|
|
4021
|
-
|
|
4054
|
+
const isExternalWalletFullAuth = (_a = verifyState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
|
|
4055
|
+
return __spreadValues(__spreadValues({}, verifyState), isSLOPossible || isExternalWalletFullAuth ? {
|
|
4022
4056
|
loginUrl: yield this.getLoginUrl({
|
|
4023
4057
|
authMethod: import_user_management_client.AuthMethod.BASIC_LOGIN,
|
|
4024
4058
|
sessionId: sessionLookupId,
|
package/dist/cjs/constants.js
CHANGED
|
@@ -43,7 +43,7 @@ __export(constants_exports, {
|
|
|
43
43
|
SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
|
|
44
44
|
});
|
|
45
45
|
module.exports = __toCommonJS(constants_exports);
|
|
46
|
-
const PARA_CORE_VERSION = "2.0.0-alpha.
|
|
46
|
+
const PARA_CORE_VERSION = "2.0.0-alpha.68";
|
|
47
47
|
const PREFIX = "@CAPSULE/";
|
|
48
48
|
const PARA_PREFIX = "@PARA/";
|
|
49
49
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -735,7 +735,7 @@ const _ParaCore = class _ParaCore {
|
|
|
735
735
|
}
|
|
736
736
|
constructPortalUrl(_0) {
|
|
737
737
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
738
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
738
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
739
739
|
const [
|
|
740
740
|
isCreate,
|
|
741
741
|
isLogin,
|
|
@@ -749,7 +749,7 @@ const _ParaCore = class _ParaCore {
|
|
|
749
749
|
isExportPrivateKey
|
|
750
750
|
] = [
|
|
751
751
|
["createAuth", "createPassword", "createPIN"].includes(type),
|
|
752
|
-
["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets"].includes(type),
|
|
752
|
+
["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets", "loginExternalWallet"].includes(type),
|
|
753
753
|
type === "onRamp",
|
|
754
754
|
type === "oAuth",
|
|
755
755
|
type === "oAuthCallback",
|
|
@@ -844,6 +844,14 @@ const _ParaCore = class _ParaCore {
|
|
|
844
844
|
path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
|
|
845
845
|
break;
|
|
846
846
|
}
|
|
847
|
+
case "loginExternalWallet": {
|
|
848
|
+
path = "/auth/external-wallet";
|
|
849
|
+
break;
|
|
850
|
+
}
|
|
851
|
+
case "connectExternalWallet": {
|
|
852
|
+
path = "/auth/connect-external-wallet";
|
|
853
|
+
break;
|
|
854
|
+
}
|
|
847
855
|
default: {
|
|
848
856
|
throw new Error(`invalid URL type ${type}`);
|
|
849
857
|
}
|
|
@@ -862,25 +870,27 @@ const _ParaCore = class _ParaCore {
|
|
|
862
870
|
encryptionKey: getPublicKeyHex(this.loginEncryptionKeyPair),
|
|
863
871
|
sessionId
|
|
864
872
|
};
|
|
865
|
-
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
873
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
866
874
|
apiKey: this.ctx.apiKey,
|
|
867
875
|
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
868
|
-
partnerId: partner == null ? void 0 : partner.id
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
876
|
+
partnerId: partner == null ? void 0 : partner.id
|
|
877
|
+
}, typeof window !== "undefined" && ((_b = window.location) == null ? void 0 : _b.origin) ? { origin: window.location.origin } : {}), {
|
|
878
|
+
portalFont: ((_c = opts.portalTheme) == null ? void 0 : _c.font) || ((_d = this.portalTheme) == null ? void 0 : _d.font) || (partner == null ? void 0 : partner.font),
|
|
879
|
+
portalBorderRadius: ((_e = opts.portalTheme) == null ? void 0 : _e.borderRadius) || ((_f = this.portalTheme) == null ? void 0 : _f.borderRadius),
|
|
880
|
+
portalThemeMode: ((_g = opts.portalTheme) == null ? void 0 : _g.mode) || ((_h = this.portalTheme) == null ? void 0 : _h.mode) || (partner == null ? void 0 : partner.themeMode),
|
|
881
|
+
portalAccentColor: ((_i = opts.portalTheme) == null ? void 0 : _i.accentColor) || ((_j = this.portalTheme) == null ? void 0 : _j.accentColor) || (partner == null ? void 0 : partner.accentColor),
|
|
882
|
+
portalForegroundColor: ((_k = opts.portalTheme) == null ? void 0 : _k.foregroundColor) || ((_l = this.portalTheme) == null ? void 0 : _l.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor),
|
|
883
|
+
portalBackgroundColor: ((_m = opts.portalTheme) == null ? void 0 : _m.backgroundColor) || ((_n = this.portalTheme) == null ? void 0 : _n.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor,
|
|
875
884
|
portalPrimaryButtonColor: this.portalPrimaryButtonColor,
|
|
876
885
|
portalTextColor: this.portalTextColor,
|
|
877
886
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
878
887
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
879
|
-
}, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
|
|
888
|
+
}), this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
|
|
880
889
|
authInfo: JSON.stringify(this.authInfo)
|
|
881
890
|
}, isPhone(this.authInfo.auth) ? splitPhoneNumber(this.authInfo.auth.phone) : this.authInfo.auth), {
|
|
882
891
|
pfpUrl: this.authInfo.pfpUrl,
|
|
883
|
-
displayName: this.authInfo.displayName
|
|
892
|
+
displayName: this.authInfo.displayName,
|
|
893
|
+
userId: this.userId
|
|
884
894
|
}) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential || isExportPrivateKey ? __spreadProps(__spreadValues({
|
|
885
895
|
sessionId: thisDevice.sessionId,
|
|
886
896
|
encryptionKey: thisDevice.encryptionKey
|
|
@@ -894,7 +904,10 @@ const _ParaCore = class _ParaCore {
|
|
|
894
904
|
} : {}), isTelegramLogin ? { isEmbed: "true" } : {}), isSwitchWallets ? __spreadValues(__spreadValues({}, this.currentWalletIds ? { currentWalletIds: JSON.stringify(this.currentWalletIds) } : {}), this.userId ? { userId: this.userId } : {}) : {}), opts.params || {}), isAddNewCredential ? __spreadProps(__spreadValues({}, opts.addNewCredentialType && { addNewCredentialType: opts.addNewCredentialType.toString() }), {
|
|
895
905
|
addNewCredentialPasskeyId: opts.addNewCredentialPasskeyId,
|
|
896
906
|
addNewCredentialPasswordId: opts.addNewCredentialPasswordId
|
|
897
|
-
}) : {})
|
|
907
|
+
}) : {}), isLogin && {
|
|
908
|
+
// Prior versions won't have this param which will skip the upgrade prompt
|
|
909
|
+
isBasicLoginUpgradeVersion: "true"
|
|
910
|
+
});
|
|
898
911
|
const url = constructUrl({ base, path, params });
|
|
899
912
|
if (opts.shorten) {
|
|
900
913
|
return shortenUrl(this.ctx, url);
|
|
@@ -1586,9 +1599,13 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1586
1599
|
loginExternalWallet(_a) {
|
|
1587
1600
|
return __async(this, null, function* () {
|
|
1588
1601
|
var _b = _a, {
|
|
1589
|
-
externalWallet
|
|
1602
|
+
externalWallet,
|
|
1603
|
+
chainId,
|
|
1604
|
+
uri
|
|
1590
1605
|
} = _b, urlOptions = __objRest(_b, [
|
|
1591
|
-
"externalWallet"
|
|
1606
|
+
"externalWallet",
|
|
1607
|
+
"chainId",
|
|
1608
|
+
"uri"
|
|
1592
1609
|
]);
|
|
1593
1610
|
const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
|
|
1594
1611
|
if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
|
|
@@ -1607,38 +1624,47 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1607
1624
|
);
|
|
1608
1625
|
}
|
|
1609
1626
|
this.requireApiKey();
|
|
1610
|
-
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
|
|
1627
|
+
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet, chainId, uri });
|
|
1611
1628
|
if (!externalWallet.withFullParaAuth && externalWallet.withVerification) {
|
|
1612
1629
|
yield this.touchSession(true);
|
|
1613
1630
|
}
|
|
1631
|
+
if (externalWallet.withFullParaAuth) {
|
|
1632
|
+
yield this.ctx.client.sessionAddPortalVerification();
|
|
1633
|
+
}
|
|
1614
1634
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1615
1635
|
});
|
|
1616
1636
|
}
|
|
1617
|
-
verifyExternalWallet(
|
|
1637
|
+
verifyExternalWallet(params) {
|
|
1618
1638
|
return __async(this, null, function* () {
|
|
1619
|
-
var
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
"cosmosPublicKeyHex",
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
}
|
|
1637
|
-
if (serverAuthState.stage === "login" && ((
|
|
1639
|
+
var _c;
|
|
1640
|
+
let serverAuthState;
|
|
1641
|
+
let urlOptions;
|
|
1642
|
+
if ("serverAuthState" in params && params.serverAuthState !== void 0) {
|
|
1643
|
+
const _a = params, { serverAuthState: optsServerAuthState } = _a, rest = __objRest(_a, ["serverAuthState"]);
|
|
1644
|
+
serverAuthState = optsServerAuthState;
|
|
1645
|
+
urlOptions = rest;
|
|
1646
|
+
} else if ("externalWallet" in params) {
|
|
1647
|
+
const _b = params, { externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner } = _b, rest = __objRest(_b, ["externalWallet", "signedMessage", "cosmosPublicKeyHex", "cosmosSigner"]);
|
|
1648
|
+
const _serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
|
|
1649
|
+
externalWallet,
|
|
1650
|
+
signedMessage,
|
|
1651
|
+
cosmosPublicKeyHex,
|
|
1652
|
+
cosmosSigner
|
|
1653
|
+
});
|
|
1654
|
+
serverAuthState = _serverAuthState;
|
|
1655
|
+
urlOptions = rest;
|
|
1656
|
+
}
|
|
1657
|
+
if (serverAuthState.stage === "login" && ((_c = serverAuthState.loginAuthMethods) == null ? void 0 : _c.includes(AuthMethod.PIN))) {
|
|
1638
1658
|
const { sessionLookupId } = yield this.touchSession();
|
|
1639
|
-
return __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1659
|
+
return yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1640
1660
|
}
|
|
1641
|
-
|
|
1661
|
+
let state;
|
|
1662
|
+
try {
|
|
1663
|
+
state = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1664
|
+
} catch (err) {
|
|
1665
|
+
console.error("Error prepping state:", err);
|
|
1666
|
+
}
|
|
1667
|
+
return state;
|
|
1642
1668
|
});
|
|
1643
1669
|
}
|
|
1644
1670
|
verifyExternalWalletLink(opts) {
|
|
@@ -1661,13 +1687,13 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1661
1687
|
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
1662
1688
|
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
1663
1689
|
*/
|
|
1664
|
-
verifyTelegramProcess(
|
|
1690
|
+
verifyTelegramProcess(_c) {
|
|
1665
1691
|
return __async(this, null, function* () {
|
|
1666
|
-
var
|
|
1692
|
+
var _d = _c, {
|
|
1667
1693
|
serverAuthState: optsServerAuthState,
|
|
1668
1694
|
telegramAuthResponse,
|
|
1669
1695
|
isLinkAccount
|
|
1670
|
-
} =
|
|
1696
|
+
} = _d, urlOptions = __objRest(_d, [
|
|
1671
1697
|
"serverAuthState",
|
|
1672
1698
|
"telegramAuthResponse",
|
|
1673
1699
|
"isLinkAccount"
|
|
@@ -2003,16 +2029,16 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2003
2029
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
2004
2030
|
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
2005
2031
|
*/
|
|
2006
|
-
verifyFarcasterProcess(
|
|
2032
|
+
verifyFarcasterProcess(_e) {
|
|
2007
2033
|
return __async(this, null, function* () {
|
|
2008
|
-
var
|
|
2034
|
+
var _f = _e, {
|
|
2009
2035
|
isCanceled = () => false,
|
|
2010
2036
|
onConnectUri,
|
|
2011
2037
|
onCancel,
|
|
2012
2038
|
onPoll,
|
|
2013
2039
|
isLinkAccount,
|
|
2014
2040
|
serverAuthState: optsServerAuthState
|
|
2015
|
-
} =
|
|
2041
|
+
} = _f, urlOptions = __objRest(_f, [
|
|
2016
2042
|
"isCanceled",
|
|
2017
2043
|
"onConnectUri",
|
|
2018
2044
|
"onCancel",
|
|
@@ -2098,9 +2124,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2098
2124
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
2099
2125
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
2100
2126
|
*/
|
|
2101
|
-
verifyOAuthProcess(
|
|
2127
|
+
verifyOAuthProcess(_g) {
|
|
2102
2128
|
return __async(this, null, function* () {
|
|
2103
|
-
var
|
|
2129
|
+
var _h = _g, {
|
|
2104
2130
|
method,
|
|
2105
2131
|
appScheme,
|
|
2106
2132
|
isCanceled = () => false,
|
|
@@ -2109,7 +2135,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2109
2135
|
onOAuthUrl,
|
|
2110
2136
|
onOAuthPopup,
|
|
2111
2137
|
isLinkAccount
|
|
2112
|
-
} =
|
|
2138
|
+
} = _h, urlOptions = __objRest(_h, [
|
|
2113
2139
|
"method",
|
|
2114
2140
|
"appScheme",
|
|
2115
2141
|
"isCanceled",
|
|
@@ -3227,49 +3253,55 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3227
3253
|
} = {}) {
|
|
3228
3254
|
const userAuthMethods = yield this.supportedUserAuthMethods();
|
|
3229
3255
|
const isEnclaveUser = userAuthMethods.has(AuthMethod.BASIC_LOGIN);
|
|
3230
|
-
|
|
3256
|
+
const isAddingBasicLogin = optsAuthMethod === "BASIC_LOGIN";
|
|
3257
|
+
if (isEnclaveUser && isAddingBasicLogin) {
|
|
3258
|
+
throw new Error("That user is already using basic login");
|
|
3259
|
+
}
|
|
3260
|
+
if (isEnclaveUser || isAddingBasicLogin) {
|
|
3231
3261
|
isForNewDevice = true;
|
|
3232
3262
|
}
|
|
3233
3263
|
const authMethods = optsAuthMethod ? [optsAuthMethod] : isForNewDevice ? ["PASSKEY", "PIN", "PASSWORD"] : ["PASSKEY"];
|
|
3234
3264
|
this.assertIsAuthSet();
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
({
|
|
3239
|
-
data: { id: passkeyId }
|
|
3240
|
-
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
3241
|
-
status: AuthMethodStatus.PENDING,
|
|
3242
|
-
type: PublicKeyType.WEB
|
|
3243
|
-
}));
|
|
3244
|
-
urlType = "createAuth";
|
|
3245
|
-
}
|
|
3246
|
-
if (authMethods.includes("PASSWORD")) {
|
|
3247
|
-
if (!canAddPasswordOrPIN) {
|
|
3248
|
-
if (optsAuthMethod === "PASSWORD") throw new Error("A user cannot have more than one password or PIN.");
|
|
3249
|
-
} else {
|
|
3265
|
+
let passkeyId, passwordId, urlType, credentialId;
|
|
3266
|
+
if (!isAddingBasicLogin) {
|
|
3267
|
+
const canAddPasswordOrPIN = !userAuthMethods.has(AuthMethod.PASSWORD) && !userAuthMethods.has(AuthMethod.PIN);
|
|
3268
|
+
if (authMethods.includes("PASSKEY") && (yield this.isPasskeySupported())) {
|
|
3250
3269
|
({
|
|
3251
|
-
data: { id:
|
|
3252
|
-
} = yield this.ctx.client.
|
|
3253
|
-
status: AuthMethodStatus.PENDING
|
|
3270
|
+
data: { id: passkeyId }
|
|
3271
|
+
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
3272
|
+
status: AuthMethodStatus.PENDING,
|
|
3273
|
+
type: PublicKeyType.WEB
|
|
3254
3274
|
}));
|
|
3255
|
-
urlType = "
|
|
3275
|
+
urlType = "createAuth";
|
|
3256
3276
|
}
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3277
|
+
if (authMethods.includes("PASSWORD")) {
|
|
3278
|
+
if (!canAddPasswordOrPIN) {
|
|
3279
|
+
if (optsAuthMethod === "PASSWORD") throw new Error("A user cannot have more than one password or PIN.");
|
|
3280
|
+
} else {
|
|
3281
|
+
({
|
|
3282
|
+
data: { id: passwordId }
|
|
3283
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
3284
|
+
status: AuthMethodStatus.PENDING
|
|
3285
|
+
}));
|
|
3286
|
+
urlType = "createPassword";
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
if (authMethods.includes("PIN")) {
|
|
3290
|
+
if (!canAddPasswordOrPIN) {
|
|
3291
|
+
if (optsAuthMethod === "PIN") throw new Error("A user cannot have more than one password or PIN.");
|
|
3292
|
+
} else {
|
|
3293
|
+
({
|
|
3294
|
+
data: { id: passwordId }
|
|
3295
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
3296
|
+
status: AuthMethodStatus.PENDING
|
|
3297
|
+
}));
|
|
3298
|
+
urlType = "createPIN";
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
credentialId = passkeyId != null ? passkeyId : passwordId;
|
|
3302
|
+
if (this.isNativePasskey && authMethods.includes("PASSKEY")) {
|
|
3303
|
+
return { credentialId };
|
|
3268
3304
|
}
|
|
3269
|
-
}
|
|
3270
|
-
const credentialId = passkeyId != null ? passkeyId : passwordId;
|
|
3271
|
-
if (this.isNativePasskey && authMethods.includes("PASSKEY")) {
|
|
3272
|
-
return { credentialId };
|
|
3273
3305
|
}
|
|
3274
3306
|
const { sessionId } = yield this.touchSession();
|
|
3275
3307
|
const url = (isForNewDevice || urlType) && (yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
|
|
@@ -3325,7 +3357,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3325
3357
|
urlType = "loginPIN";
|
|
3326
3358
|
break;
|
|
3327
3359
|
case "BASIC_LOGIN":
|
|
3328
|
-
urlType = "loginOTP";
|
|
3360
|
+
urlType = this.authInfo.authType === "externalWallet" ? "loginExternalWallet" : "loginOTP";
|
|
3329
3361
|
break;
|
|
3330
3362
|
default:
|
|
3331
3363
|
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
@@ -3347,9 +3379,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3347
3379
|
return sessionLookupId;
|
|
3348
3380
|
});
|
|
3349
3381
|
}
|
|
3350
|
-
signUpOrLogIn(
|
|
3382
|
+
signUpOrLogIn(_i) {
|
|
3351
3383
|
return __async(this, null, function* () {
|
|
3352
|
-
var
|
|
3384
|
+
var _j = _i, { auth } = _j, urlOptions = __objRest(_j, ["auth"]);
|
|
3353
3385
|
let serverAuthState;
|
|
3354
3386
|
try {
|
|
3355
3387
|
serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
@@ -3371,11 +3403,11 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3371
3403
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadValues({}, urlOptions));
|
|
3372
3404
|
});
|
|
3373
3405
|
}
|
|
3374
|
-
verifyNewAccount(
|
|
3406
|
+
verifyNewAccount(_k) {
|
|
3375
3407
|
return __async(this, null, function* () {
|
|
3376
|
-
var
|
|
3408
|
+
var _l = _k, {
|
|
3377
3409
|
verificationCode
|
|
3378
|
-
} =
|
|
3410
|
+
} = _l, urlOptions = __objRest(_l, [
|
|
3379
3411
|
"verificationCode"
|
|
3380
3412
|
]);
|
|
3381
3413
|
this.assertIsAuthSet(["email", "phone"]);
|
|
@@ -3473,10 +3505,10 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3473
3505
|
});
|
|
3474
3506
|
}
|
|
3475
3507
|
verifyLink() {
|
|
3476
|
-
return __async(this, arguments, function* (
|
|
3477
|
-
var
|
|
3508
|
+
return __async(this, arguments, function* (_m = {}) {
|
|
3509
|
+
var _n = _m, {
|
|
3478
3510
|
accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
|
|
3479
|
-
} =
|
|
3511
|
+
} = _n, opts = __objRest(_n, [
|
|
3480
3512
|
"accountLinkInProgress"
|
|
3481
3513
|
]);
|
|
3482
3514
|
try {
|
|
@@ -3977,6 +4009,7 @@ prepareVerificationState_fn = function(_0, _1) {
|
|
|
3977
4009
|
portalTheme,
|
|
3978
4010
|
sessionLookupId
|
|
3979
4011
|
}) {
|
|
4012
|
+
var _a;
|
|
3980
4013
|
let isSLOPossible = false;
|
|
3981
4014
|
if (verifyState.nextStage === "login") {
|
|
3982
4015
|
isSLOPossible = verifyState.loginAuthMethods.includes(AuthMethod.BASIC_LOGIN);
|
|
@@ -3984,7 +4017,8 @@ prepareVerificationState_fn = function(_0, _1) {
|
|
|
3984
4017
|
isSLOPossible = verifyState.signupAuthMethods.includes(AuthMethod.BASIC_LOGIN);
|
|
3985
4018
|
}
|
|
3986
4019
|
this.isEnclaveUser = isSLOPossible;
|
|
3987
|
-
|
|
4020
|
+
const isExternalWalletFullAuth = (_a = verifyState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
|
|
4021
|
+
return __spreadValues(__spreadValues({}, verifyState), isSLOPossible || isExternalWalletFullAuth ? {
|
|
3988
4022
|
loginUrl: yield this.getLoginUrl({
|
|
3989
4023
|
authMethod: AuthMethod.BASIC_LOGIN,
|
|
3990
4024
|
sessionId: sessionLookupId,
|
package/dist/esm/constants.js
CHANGED
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks, OnRampPurchase, BalancesConfig, Theme } from '@getpara/user-management-client';
|
|
1
|
+
import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, ServerAuthStateLogin, ServerAuthStateSignup, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks, OnRampPurchase, BalancesConfig, Theme, ServerAuthStateDone } from '@getpara/user-management-client';
|
|
2
2
|
import type { pki as pkiType } from 'node-forge';
|
|
3
3
|
import { Ctx, Environment, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse, AvailableWallet } from './types/index.js';
|
|
4
4
|
import { PlatformUtils } from './PlatformUtils.js';
|
|
@@ -391,8 +391,13 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
391
391
|
* @param {TWalletType} opts.type type of external wallet to use for identification.
|
|
392
392
|
* @param {string} opts.provider the name of the provider for the external wallet.
|
|
393
393
|
*/
|
|
394
|
-
loginExternalWallet({ externalWallet, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
|
|
395
|
-
verifyExternalWallet(
|
|
394
|
+
loginExternalWallet({ externalWallet, chainId, uri, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
|
|
395
|
+
verifyExternalWallet(params: {
|
|
396
|
+
serverAuthState: ServerAuthStateSignup | ServerAuthStateLogin | ServerAuthStateDone;
|
|
397
|
+
} & Omit<CoreMethodParams<'verifyExternalWallet'>, keyof VerifyExternalWalletParams>): CoreMethodResponse<'verifyExternalWallet'>;
|
|
398
|
+
verifyExternalWallet(params: VerifyExternalWalletParams & {
|
|
399
|
+
serverAuthState?: undefined;
|
|
400
|
+
} & Omit<CoreMethodParams<'verifyExternalWallet'>, 'serverAuthState'>): CoreMethodResponse<'verifyExternalWallet'>;
|
|
396
401
|
protected verifyExternalWalletLink(opts: InternalMethodParams<'verifyExternalWalletLink'>): InternalMethodResponse<'verifyExternalWalletLink'>;
|
|
397
402
|
protected verifyTelegramProcess(opts: CoreMethodParams<'verifyTelegram'> & {
|
|
398
403
|
isLinkAccount: false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse, TLinkedAccountType, LinkedAccounts, AuthMethod } from '@getpara/user-management-client';
|
|
2
|
-
import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams, CoreAuthInfo, GetWalletBalanceParams, GetWalletBalanceResponse, FarcasterParams, TelegramParams, OAuthParams, NewCredentialUrlParams } from './methods.js';
|
|
1
|
+
import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse, TLinkedAccountType, LinkedAccounts, AuthMethod, ServerAuthStateSignup, ServerAuthStateLogin, ServerAuthStateDone } from '@getpara/user-management-client';
|
|
2
|
+
import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams, CoreAuthInfo, GetWalletBalanceParams, GetWalletBalanceResponse, FarcasterParams, TelegramParams, OAuthParams, NewCredentialUrlParams, AuthStateDone } from './methods.js';
|
|
3
3
|
import { ParaCore } from '../ParaCore.js';
|
|
4
4
|
import { FullSignatureRes, Wallet } from './wallet.js';
|
|
5
5
|
import { AccountLinkInProgress } from './auth.js';
|
|
@@ -145,12 +145,24 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
145
145
|
* The external wallet information to use for login.
|
|
146
146
|
*/
|
|
147
147
|
externalWallet: ExternalWalletInfo | ExternalWalletInfo[];
|
|
148
|
+
/**
|
|
149
|
+
* The chain ID used to generate the SIWE message.
|
|
150
|
+
*/
|
|
151
|
+
chainId?: string;
|
|
152
|
+
/**
|
|
153
|
+
* The URI used to generate the SIWE message.
|
|
154
|
+
*/
|
|
155
|
+
uri?: string;
|
|
148
156
|
};
|
|
149
157
|
response: AuthStateVerifyOrLogin;
|
|
150
158
|
};
|
|
151
159
|
verifyExternalWallet: {
|
|
152
|
-
params: AuthStateBaseParams &
|
|
153
|
-
|
|
160
|
+
params: (AuthStateBaseParams & {
|
|
161
|
+
serverAuthState: ServerAuthStateSignup | ServerAuthStateLogin | ServerAuthStateDone;
|
|
162
|
+
}) | (AuthStateBaseParams & VerifyExternalWalletParams & {
|
|
163
|
+
serverAuthState?: undefined;
|
|
164
|
+
});
|
|
165
|
+
response: AuthStateSignup | AuthStateLogin | AuthStateDone;
|
|
154
166
|
};
|
|
155
167
|
resendVerificationCode: {
|
|
156
168
|
params: {
|
|
@@ -12,7 +12,7 @@ export type VerifyExternalWalletV1 = {
|
|
|
12
12
|
cosmosPublicKeyHex?: string;
|
|
13
13
|
cosmosSigner?: string;
|
|
14
14
|
};
|
|
15
|
-
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster' | 'switchWallets' | 'addNewCredential' | 'exportPrivateKey';
|
|
15
|
+
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster' | 'switchWallets' | 'addNewCredential' | 'exportPrivateKey' | 'loginExternalWallet' | 'connectExternalWallet';
|
|
16
16
|
export type PortalUrlOptions = {
|
|
17
17
|
params?: Record<string, string | undefined | null>;
|
|
18
18
|
isForNewDevice?: boolean;
|
|
@@ -26,7 +26,7 @@ export type PortalUrlOptions = {
|
|
|
26
26
|
oAuthMethod?: OAuthUrlParams['method'];
|
|
27
27
|
appScheme?: string;
|
|
28
28
|
encryptionKey?: string;
|
|
29
|
-
addNewCredentialType?:
|
|
29
|
+
addNewCredentialType?: TAuthMethod;
|
|
30
30
|
addNewCredentialPasswordId?: string;
|
|
31
31
|
addNewCredentialPasskeyId?: string;
|
|
32
32
|
};
|
|
@@ -100,7 +100,7 @@ export type NewCredentialUrlParams = WithCustomTheme & WithShorten & {
|
|
|
100
100
|
/**
|
|
101
101
|
* The authentication method to add.
|
|
102
102
|
*/
|
|
103
|
-
authMethod?:
|
|
103
|
+
authMethod?: TAuthMethod;
|
|
104
104
|
};
|
|
105
105
|
export type OAuthUrlParams = {
|
|
106
106
|
/**
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.68",
|
|
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.0.0-alpha.
|
|
8
|
+
"@getpara/user-management-client": "2.0.0-alpha.68",
|
|
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": "98955203281606201609bb4674f5984acb63d3bf",
|
|
31
31
|
"main": "dist/cjs/index.js",
|
|
32
32
|
"module": "dist/esm/index.js",
|
|
33
33
|
"scripts": {
|