@getpara/core-sdk 2.0.0-alpha.66 → 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.
@@ -708,6 +708,9 @@ const _ParaCore = class _ParaCore {
708
708
  }
709
709
  return true;
710
710
  }
711
+ truncateAddress(...args) {
712
+ return (0, import_utils2.truncateAddress)(args[0], args[1], __spreadValues({ prefix: this.cosmosPrefix }, args[2] || {}));
713
+ }
711
714
  /**
712
715
  * Returns the formatted address for the desired wallet ID, depending on your app settings.
713
716
  * @param {string} walletId the ID of the wallet address to display.
@@ -766,7 +769,7 @@ const _ParaCore = class _ParaCore {
766
769
  }
767
770
  constructPortalUrl(_0) {
768
771
  return __async(this, arguments, function* (type, opts = {}) {
769
- 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;
770
773
  const [
771
774
  isCreate,
772
775
  isLogin,
@@ -780,7 +783,7 @@ const _ParaCore = class _ParaCore {
780
783
  isExportPrivateKey
781
784
  ] = [
782
785
  ["createAuth", "createPassword", "createPIN"].includes(type),
783
- ["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets"].includes(type),
786
+ ["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets", "loginExternalWallet"].includes(type),
784
787
  type === "onRamp",
785
788
  type === "oAuth",
786
789
  type === "oAuthCallback",
@@ -875,6 +878,14 @@ const _ParaCore = class _ParaCore {
875
878
  path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
876
879
  break;
877
880
  }
881
+ case "loginExternalWallet": {
882
+ path = "/auth/external-wallet";
883
+ break;
884
+ }
885
+ case "connectExternalWallet": {
886
+ path = "/auth/connect-external-wallet";
887
+ break;
888
+ }
878
889
  default: {
879
890
  throw new Error(`invalid URL type ${type}`);
880
891
  }
@@ -893,25 +904,27 @@ const _ParaCore = class _ParaCore {
893
904
  encryptionKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair),
894
905
  sessionId
895
906
  };
896
- const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
907
+ const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
897
908
  apiKey: this.ctx.apiKey,
898
909
  origin: typeof window !== "undefined" ? window.location.origin : void 0,
899
- partnerId: partner == null ? void 0 : partner.id,
900
- portalFont: ((_b = opts.portalTheme) == null ? void 0 : _b.font) || ((_c = this.portalTheme) == null ? void 0 : _c.font) || (partner == null ? void 0 : partner.font),
901
- portalBorderRadius: ((_d = opts.portalTheme) == null ? void 0 : _d.borderRadius) || ((_e = this.portalTheme) == null ? void 0 : _e.borderRadius),
902
- portalThemeMode: ((_f = opts.portalTheme) == null ? void 0 : _f.mode) || ((_g = this.portalTheme) == null ? void 0 : _g.mode) || (partner == null ? void 0 : partner.themeMode),
903
- portalAccentColor: ((_h = opts.portalTheme) == null ? void 0 : _h.accentColor) || ((_i = this.portalTheme) == null ? void 0 : _i.accentColor) || (partner == null ? void 0 : partner.accentColor),
904
- portalForegroundColor: ((_j = opts.portalTheme) == null ? void 0 : _j.foregroundColor) || ((_k = this.portalTheme) == null ? void 0 : _k.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor),
905
- portalBackgroundColor: ((_l = opts.portalTheme) == null ? void 0 : _l.backgroundColor) || ((_m = this.portalTheme) == null ? void 0 : _m.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor,
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,
906
918
  portalPrimaryButtonColor: this.portalPrimaryButtonColor,
907
919
  portalTextColor: this.portalTextColor,
908
920
  portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
909
921
  isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
910
- }, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
922
+ }), this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
911
923
  authInfo: JSON.stringify(this.authInfo)
912
924
  }, (0, import_user_management_client.isPhone)(this.authInfo.auth) ? (0, import_utils2.splitPhoneNumber)(this.authInfo.auth.phone) : this.authInfo.auth), {
913
925
  pfpUrl: this.authInfo.pfpUrl,
914
- displayName: this.authInfo.displayName
926
+ displayName: this.authInfo.displayName,
927
+ userId: this.userId
915
928
  }) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential || isExportPrivateKey ? __spreadProps(__spreadValues({
916
929
  sessionId: thisDevice.sessionId,
917
930
  encryptionKey: thisDevice.encryptionKey
@@ -925,7 +938,10 @@ const _ParaCore = class _ParaCore {
925
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() }), {
926
939
  addNewCredentialPasskeyId: opts.addNewCredentialPasskeyId,
927
940
  addNewCredentialPasswordId: opts.addNewCredentialPasswordId
928
- }) : {});
941
+ }) : {}), isLogin && {
942
+ // Prior versions won't have this param which will skip the upgrade prompt
943
+ isBasicLoginUpgradeVersion: "true"
944
+ });
929
945
  const url = (0, import_utils2.constructUrl)({ base, path, params });
930
946
  if (opts.shorten) {
931
947
  return (0, import_utils2.shortenUrl)(this.ctx, url);
@@ -1461,15 +1477,27 @@ Need help? Visit: https://docs.getpara.com or contact support
1461
1477
  ...[...this.currentWalletIdsArray, ...__privateGet(this, _ParaCore_instances, guestWalletIdsArray_get)].map(([address, type]) => [address, type, false]).map(([id, type]) => {
1462
1478
  const wallet = this.findWallet(id, type);
1463
1479
  if (!wallet) return null;
1480
+ const name = wallet.name;
1481
+ const address = this.getDisplayAddress(id, { addressType: type });
1482
+ const addressShort = this.getDisplayAddress(id, { addressType: type, truncate: true });
1464
1483
  return {
1465
1484
  id: wallet.id,
1466
1485
  partner: wallet.partner,
1467
1486
  type,
1468
- address: this.getDisplayAddress(id, { addressType: type }),
1469
- name: wallet.name
1487
+ address,
1488
+ name,
1489
+ addressShort,
1490
+ displayName: name != null ? name : addressShort,
1491
+ ensName: wallet.ensName,
1492
+ ensAvatar: wallet.ensAvatar
1470
1493
  };
1471
1494
  }).filter((obj) => obj !== null),
1472
- ...Object.values((_a = this.externalWallets) != null ? _a : {})
1495
+ ...Object.values((_a = this.externalWallets) != null ? _a : {}).map((wallet) => {
1496
+ return __spreadProps(__spreadValues({}, wallet), {
1497
+ addressShort: (0, import_utils2.truncateAddress)(wallet.address, wallet.type, { prefix: this.cosmosPrefix }),
1498
+ displayName: wallet.externalProviderId
1499
+ });
1500
+ })
1473
1501
  ];
1474
1502
  }
1475
1503
  /**
@@ -1605,9 +1633,13 @@ Need help? Visit: https://docs.getpara.com or contact support
1605
1633
  loginExternalWallet(_a) {
1606
1634
  return __async(this, null, function* () {
1607
1635
  var _b = _a, {
1608
- externalWallet
1636
+ externalWallet,
1637
+ chainId,
1638
+ uri
1609
1639
  } = _b, urlOptions = __objRest(_b, [
1610
- "externalWallet"
1640
+ "externalWallet",
1641
+ "chainId",
1642
+ "uri"
1611
1643
  ]);
1612
1644
  const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
1613
1645
  if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
@@ -1626,38 +1658,47 @@ Need help? Visit: https://docs.getpara.com or contact support
1626
1658
  );
1627
1659
  }
1628
1660
  this.requireApiKey();
1629
- const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
1661
+ const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet, chainId, uri });
1630
1662
  if (!externalWallet.withFullParaAuth && externalWallet.withVerification) {
1631
1663
  yield this.touchSession(true);
1632
1664
  }
1665
+ if (externalWallet.withFullParaAuth) {
1666
+ yield this.ctx.client.sessionAddPortalVerification();
1667
+ }
1633
1668
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
1634
1669
  });
1635
1670
  }
1636
- verifyExternalWallet(_c) {
1671
+ verifyExternalWallet(params) {
1637
1672
  return __async(this, null, function* () {
1638
- var _d = _c, {
1639
- externalWallet,
1640
- signedMessage,
1641
- cosmosPublicKeyHex,
1642
- cosmosSigner
1643
- } = _d, urlOptions = __objRest(_d, [
1644
- "externalWallet",
1645
- "signedMessage",
1646
- "cosmosPublicKeyHex",
1647
- "cosmosSigner"
1648
- ]);
1649
- var _a;
1650
- const serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
1651
- externalWallet,
1652
- signedMessage,
1653
- cosmosPublicKeyHex,
1654
- cosmosSigner
1655
- });
1656
- if (serverAuthState.stage === "login" && ((_a = serverAuthState.loginAuthMethods) == null ? void 0 : _a.includes(import_user_management_client.AuthMethod.PIN))) {
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))) {
1657
1692
  const { sessionLookupId } = yield this.touchSession();
1658
- 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 }));
1659
1694
  }
1660
- return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
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;
1661
1702
  });
1662
1703
  }
1663
1704
  verifyExternalWalletLink(opts) {
@@ -1680,13 +1721,13 @@ Need help? Visit: https://docs.getpara.com or contact support
1680
1721
  * @param authResponse - the response JSON object received from the Telegram widget.
1681
1722
  * @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
1682
1723
  */
1683
- verifyTelegramProcess(_e) {
1724
+ verifyTelegramProcess(_c) {
1684
1725
  return __async(this, null, function* () {
1685
- var _f = _e, {
1726
+ var _d = _c, {
1686
1727
  serverAuthState: optsServerAuthState,
1687
1728
  telegramAuthResponse,
1688
1729
  isLinkAccount
1689
- } = _f, urlOptions = __objRest(_f, [
1730
+ } = _d, urlOptions = __objRest(_d, [
1690
1731
  "serverAuthState",
1691
1732
  "telegramAuthResponse",
1692
1733
  "isLinkAccount"
@@ -1856,8 +1897,12 @@ Need help? Visit: https://docs.getpara.com or contact support
1856
1897
  const requiredWalletTypes = supportedWalletTypes.filter(({ optional }) => !optional);
1857
1898
  for (const { type } of requiredWalletTypes) {
1858
1899
  const hasWalletForType = this.currentWalletIdsArray.some(([walletId, walletType]) => {
1859
- const wallet = this.wallets[walletId];
1860
- return wallet && walletType === type;
1900
+ try {
1901
+ const wallet = this.wallets[walletId];
1902
+ return wallet && walletType === type && typeof wallet.address === "string";
1903
+ } catch (e) {
1904
+ return false;
1905
+ }
1861
1906
  });
1862
1907
  if (!hasWalletForType) {
1863
1908
  return false;
@@ -2018,16 +2063,16 @@ Need help? Visit: https://docs.getpara.com or contact support
2018
2063
  * If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
2019
2064
  * @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
2020
2065
  */
2021
- verifyFarcasterProcess(_g) {
2066
+ verifyFarcasterProcess(_e) {
2022
2067
  return __async(this, null, function* () {
2023
- var _h = _g, {
2068
+ var _f = _e, {
2024
2069
  isCanceled = () => false,
2025
2070
  onConnectUri,
2026
2071
  onCancel,
2027
2072
  onPoll,
2028
2073
  isLinkAccount,
2029
2074
  serverAuthState: optsServerAuthState
2030
- } = _h, urlOptions = __objRest(_h, [
2075
+ } = _f, urlOptions = __objRest(_f, [
2031
2076
  "isCanceled",
2032
2077
  "onConnectUri",
2033
2078
  "onCancel",
@@ -2113,9 +2158,9 @@ Need help? Visit: https://docs.getpara.com or contact support
2113
2158
  * @param {Window} [opts.popupWindow] the popup window being used for login.
2114
2159
  * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
2115
2160
  */
2116
- verifyOAuthProcess(_i) {
2161
+ verifyOAuthProcess(_g) {
2117
2162
  return __async(this, null, function* () {
2118
- var _j = _i, {
2163
+ var _h = _g, {
2119
2164
  method,
2120
2165
  appScheme,
2121
2166
  isCanceled = () => false,
@@ -2124,7 +2169,7 @@ Need help? Visit: https://docs.getpara.com or contact support
2124
2169
  onOAuthUrl,
2125
2170
  onOAuthPopup,
2126
2171
  isLinkAccount
2127
- } = _j, urlOptions = __objRest(_j, [
2172
+ } = _h, urlOptions = __objRest(_h, [
2128
2173
  "method",
2129
2174
  "appScheme",
2130
2175
  "isCanceled",
@@ -3242,49 +3287,55 @@ Need help? Visit: https://docs.getpara.com or contact support
3242
3287
  } = {}) {
3243
3288
  const userAuthMethods = yield this.supportedUserAuthMethods();
3244
3289
  const isEnclaveUser = userAuthMethods.has(import_user_management_client.AuthMethod.BASIC_LOGIN);
3245
- if (isEnclaveUser) {
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) {
3246
3295
  isForNewDevice = true;
3247
3296
  }
3248
3297
  const authMethods = optsAuthMethod ? [optsAuthMethod] : isForNewDevice ? ["PASSKEY", "PIN", "PASSWORD"] : ["PASSKEY"];
3249
3298
  this.assertIsAuthSet();
3250
- const canAddPasswordOrPIN = !userAuthMethods.has(import_user_management_client.AuthMethod.PASSWORD) && !userAuthMethods.has(import_user_management_client.AuthMethod.PIN);
3251
- let passkeyId, passwordId, urlType;
3252
- if (authMethods.includes("PASSKEY") && (yield this.isPasskeySupported())) {
3253
- ({
3254
- data: { id: passkeyId }
3255
- } = yield this.ctx.client.addSessionPublicKey(this.userId, {
3256
- status: import_user_management_client.AuthMethodStatus.PENDING,
3257
- type: import_user_management_client.PublicKeyType.WEB
3258
- }));
3259
- urlType = "createAuth";
3260
- }
3261
- if (authMethods.includes("PASSWORD")) {
3262
- if (!canAddPasswordOrPIN) {
3263
- if (optsAuthMethod === "PASSWORD") throw new Error("A user cannot have more than one password or PIN.");
3264
- } 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())) {
3265
3303
  ({
3266
- data: { id: passwordId }
3267
- } = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
3268
- 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
3269
3308
  }));
3270
- urlType = "createPassword";
3309
+ urlType = "createAuth";
3271
3310
  }
3272
- }
3273
- if (authMethods.includes("PIN")) {
3274
- if (!canAddPasswordOrPIN) {
3275
- if (optsAuthMethod === "PIN") throw new Error("A user cannot have more than one password or PIN.");
3276
- } else {
3277
- ({
3278
- data: { id: passwordId }
3279
- } = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
3280
- status: import_user_management_client.AuthMethodStatus.PENDING
3281
- }));
3282
- urlType = "createPIN";
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 };
3283
3338
  }
3284
- }
3285
- const credentialId = passkeyId != null ? passkeyId : passwordId;
3286
- if (this.isNativePasskey && authMethods.includes("PASSKEY")) {
3287
- return { credentialId };
3288
3339
  }
3289
3340
  const { sessionId } = yield this.touchSession();
3290
3341
  const url = (isForNewDevice || urlType) && (yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
@@ -3340,7 +3391,7 @@ Need help? Visit: https://docs.getpara.com or contact support
3340
3391
  urlType = "loginPIN";
3341
3392
  break;
3342
3393
  case "BASIC_LOGIN":
3343
- urlType = "loginOTP";
3394
+ urlType = this.authInfo.authType === "externalWallet" ? "loginExternalWallet" : "loginOTP";
3344
3395
  break;
3345
3396
  default:
3346
3397
  throw new Error(`invalid authentication method: '${authMethod}'`);
@@ -3362,9 +3413,9 @@ Need help? Visit: https://docs.getpara.com or contact support
3362
3413
  return sessionLookupId;
3363
3414
  });
3364
3415
  }
3365
- signUpOrLogIn(_k) {
3416
+ signUpOrLogIn(_i) {
3366
3417
  return __async(this, null, function* () {
3367
- var _l = _k, { auth } = _l, urlOptions = __objRest(_l, ["auth"]);
3418
+ var _j = _i, { auth } = _j, urlOptions = __objRest(_j, ["auth"]);
3368
3419
  let serverAuthState;
3369
3420
  try {
3370
3421
  serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
@@ -3386,11 +3437,11 @@ Need help? Visit: https://docs.getpara.com or contact support
3386
3437
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadValues({}, urlOptions));
3387
3438
  });
3388
3439
  }
3389
- verifyNewAccount(_m) {
3440
+ verifyNewAccount(_k) {
3390
3441
  return __async(this, null, function* () {
3391
- var _n = _m, {
3442
+ var _l = _k, {
3392
3443
  verificationCode
3393
- } = _n, urlOptions = __objRest(_n, [
3444
+ } = _l, urlOptions = __objRest(_l, [
3394
3445
  "verificationCode"
3395
3446
  ]);
3396
3447
  this.assertIsAuthSet(["email", "phone"]);
@@ -3488,10 +3539,10 @@ Need help? Visit: https://docs.getpara.com or contact support
3488
3539
  });
3489
3540
  }
3490
3541
  verifyLink() {
3491
- return __async(this, arguments, function* (_o = {}) {
3492
- var _p = _o, {
3542
+ return __async(this, arguments, function* (_m = {}) {
3543
+ var _n = _m, {
3493
3544
  accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
3494
- } = _p, opts = __objRest(_p, [
3545
+ } = _n, opts = __objRest(_n, [
3495
3546
  "accountLinkInProgress"
3496
3547
  ]);
3497
3548
  try {
@@ -3992,6 +4043,7 @@ prepareVerificationState_fn = function(_0, _1) {
3992
4043
  portalTheme,
3993
4044
  sessionLookupId
3994
4045
  }) {
4046
+ var _a;
3995
4047
  let isSLOPossible = false;
3996
4048
  if (verifyState.nextStage === "login") {
3997
4049
  isSLOPossible = verifyState.loginAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
@@ -3999,7 +4051,8 @@ prepareVerificationState_fn = function(_0, _1) {
3999
4051
  isSLOPossible = verifyState.signupAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
4000
4052
  }
4001
4053
  this.isEnclaveUser = isSLOPossible;
4002
- return __spreadValues(__spreadValues({}, verifyState), isSLOPossible ? {
4054
+ const isExternalWalletFullAuth = (_a = verifyState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
4055
+ return __spreadValues(__spreadValues({}, verifyState), isSLOPossible || isExternalWalletFullAuth ? {
4003
4056
  loginUrl: yield this.getLoginUrl({
4004
4057
  authMethod: import_user_management_client.AuthMethod.BASIC_LOGIN,
4005
4058
  sessionId: sessionLookupId,
@@ -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.66";
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`;
@@ -674,6 +674,9 @@ const _ParaCore = class _ParaCore {
674
674
  }
675
675
  return true;
676
676
  }
677
+ truncateAddress(...args) {
678
+ return truncateAddress(args[0], args[1], __spreadValues({ prefix: this.cosmosPrefix }, args[2] || {}));
679
+ }
677
680
  /**
678
681
  * Returns the formatted address for the desired wallet ID, depending on your app settings.
679
682
  * @param {string} walletId the ID of the wallet address to display.
@@ -732,7 +735,7 @@ const _ParaCore = class _ParaCore {
732
735
  }
733
736
  constructPortalUrl(_0) {
734
737
  return __async(this, arguments, function* (type, opts = {}) {
735
- 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;
736
739
  const [
737
740
  isCreate,
738
741
  isLogin,
@@ -746,7 +749,7 @@ const _ParaCore = class _ParaCore {
746
749
  isExportPrivateKey
747
750
  ] = [
748
751
  ["createAuth", "createPassword", "createPIN"].includes(type),
749
- ["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets"].includes(type),
752
+ ["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets", "loginExternalWallet"].includes(type),
750
753
  type === "onRamp",
751
754
  type === "oAuth",
752
755
  type === "oAuthCallback",
@@ -841,6 +844,14 @@ const _ParaCore = class _ParaCore {
841
844
  path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
842
845
  break;
843
846
  }
847
+ case "loginExternalWallet": {
848
+ path = "/auth/external-wallet";
849
+ break;
850
+ }
851
+ case "connectExternalWallet": {
852
+ path = "/auth/connect-external-wallet";
853
+ break;
854
+ }
844
855
  default: {
845
856
  throw new Error(`invalid URL type ${type}`);
846
857
  }
@@ -859,25 +870,27 @@ const _ParaCore = class _ParaCore {
859
870
  encryptionKey: getPublicKeyHex(this.loginEncryptionKeyPair),
860
871
  sessionId
861
872
  };
862
- const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
873
+ const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
863
874
  apiKey: this.ctx.apiKey,
864
875
  origin: typeof window !== "undefined" ? window.location.origin : void 0,
865
- partnerId: partner == null ? void 0 : partner.id,
866
- portalFont: ((_b = opts.portalTheme) == null ? void 0 : _b.font) || ((_c = this.portalTheme) == null ? void 0 : _c.font) || (partner == null ? void 0 : partner.font),
867
- portalBorderRadius: ((_d = opts.portalTheme) == null ? void 0 : _d.borderRadius) || ((_e = this.portalTheme) == null ? void 0 : _e.borderRadius),
868
- portalThemeMode: ((_f = opts.portalTheme) == null ? void 0 : _f.mode) || ((_g = this.portalTheme) == null ? void 0 : _g.mode) || (partner == null ? void 0 : partner.themeMode),
869
- portalAccentColor: ((_h = opts.portalTheme) == null ? void 0 : _h.accentColor) || ((_i = this.portalTheme) == null ? void 0 : _i.accentColor) || (partner == null ? void 0 : partner.accentColor),
870
- portalForegroundColor: ((_j = opts.portalTheme) == null ? void 0 : _j.foregroundColor) || ((_k = this.portalTheme) == null ? void 0 : _k.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor),
871
- portalBackgroundColor: ((_l = opts.portalTheme) == null ? void 0 : _l.backgroundColor) || ((_m = this.portalTheme) == null ? void 0 : _m.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor,
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,
872
884
  portalPrimaryButtonColor: this.portalPrimaryButtonColor,
873
885
  portalTextColor: this.portalTextColor,
874
886
  portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
875
887
  isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
876
- }, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
888
+ }), this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
877
889
  authInfo: JSON.stringify(this.authInfo)
878
890
  }, isPhone(this.authInfo.auth) ? splitPhoneNumber(this.authInfo.auth.phone) : this.authInfo.auth), {
879
891
  pfpUrl: this.authInfo.pfpUrl,
880
- displayName: this.authInfo.displayName
892
+ displayName: this.authInfo.displayName,
893
+ userId: this.userId
881
894
  }) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential || isExportPrivateKey ? __spreadProps(__spreadValues({
882
895
  sessionId: thisDevice.sessionId,
883
896
  encryptionKey: thisDevice.encryptionKey
@@ -891,7 +904,10 @@ const _ParaCore = class _ParaCore {
891
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() }), {
892
905
  addNewCredentialPasskeyId: opts.addNewCredentialPasskeyId,
893
906
  addNewCredentialPasswordId: opts.addNewCredentialPasswordId
894
- }) : {});
907
+ }) : {}), isLogin && {
908
+ // Prior versions won't have this param which will skip the upgrade prompt
909
+ isBasicLoginUpgradeVersion: "true"
910
+ });
895
911
  const url = constructUrl({ base, path, params });
896
912
  if (opts.shorten) {
897
913
  return shortenUrl(this.ctx, url);
@@ -1427,15 +1443,27 @@ Need help? Visit: https://docs.getpara.com or contact support
1427
1443
  ...[...this.currentWalletIdsArray, ...__privateGet(this, _ParaCore_instances, guestWalletIdsArray_get)].map(([address, type]) => [address, type, false]).map(([id, type]) => {
1428
1444
  const wallet = this.findWallet(id, type);
1429
1445
  if (!wallet) return null;
1446
+ const name = wallet.name;
1447
+ const address = this.getDisplayAddress(id, { addressType: type });
1448
+ const addressShort = this.getDisplayAddress(id, { addressType: type, truncate: true });
1430
1449
  return {
1431
1450
  id: wallet.id,
1432
1451
  partner: wallet.partner,
1433
1452
  type,
1434
- address: this.getDisplayAddress(id, { addressType: type }),
1435
- name: wallet.name
1453
+ address,
1454
+ name,
1455
+ addressShort,
1456
+ displayName: name != null ? name : addressShort,
1457
+ ensName: wallet.ensName,
1458
+ ensAvatar: wallet.ensAvatar
1436
1459
  };
1437
1460
  }).filter((obj) => obj !== null),
1438
- ...Object.values((_a = this.externalWallets) != null ? _a : {})
1461
+ ...Object.values((_a = this.externalWallets) != null ? _a : {}).map((wallet) => {
1462
+ return __spreadProps(__spreadValues({}, wallet), {
1463
+ addressShort: truncateAddress(wallet.address, wallet.type, { prefix: this.cosmosPrefix }),
1464
+ displayName: wallet.externalProviderId
1465
+ });
1466
+ })
1439
1467
  ];
1440
1468
  }
1441
1469
  /**
@@ -1571,9 +1599,13 @@ Need help? Visit: https://docs.getpara.com or contact support
1571
1599
  loginExternalWallet(_a) {
1572
1600
  return __async(this, null, function* () {
1573
1601
  var _b = _a, {
1574
- externalWallet
1602
+ externalWallet,
1603
+ chainId,
1604
+ uri
1575
1605
  } = _b, urlOptions = __objRest(_b, [
1576
- "externalWallet"
1606
+ "externalWallet",
1607
+ "chainId",
1608
+ "uri"
1577
1609
  ]);
1578
1610
  const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
1579
1611
  if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
@@ -1592,38 +1624,47 @@ Need help? Visit: https://docs.getpara.com or contact support
1592
1624
  );
1593
1625
  }
1594
1626
  this.requireApiKey();
1595
- const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
1627
+ const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet, chainId, uri });
1596
1628
  if (!externalWallet.withFullParaAuth && externalWallet.withVerification) {
1597
1629
  yield this.touchSession(true);
1598
1630
  }
1631
+ if (externalWallet.withFullParaAuth) {
1632
+ yield this.ctx.client.sessionAddPortalVerification();
1633
+ }
1599
1634
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
1600
1635
  });
1601
1636
  }
1602
- verifyExternalWallet(_c) {
1637
+ verifyExternalWallet(params) {
1603
1638
  return __async(this, null, function* () {
1604
- var _d = _c, {
1605
- externalWallet,
1606
- signedMessage,
1607
- cosmosPublicKeyHex,
1608
- cosmosSigner
1609
- } = _d, urlOptions = __objRest(_d, [
1610
- "externalWallet",
1611
- "signedMessage",
1612
- "cosmosPublicKeyHex",
1613
- "cosmosSigner"
1614
- ]);
1615
- var _a;
1616
- const serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
1617
- externalWallet,
1618
- signedMessage,
1619
- cosmosPublicKeyHex,
1620
- cosmosSigner
1621
- });
1622
- if (serverAuthState.stage === "login" && ((_a = serverAuthState.loginAuthMethods) == null ? void 0 : _a.includes(AuthMethod.PIN))) {
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))) {
1623
1658
  const { sessionLookupId } = yield this.touchSession();
1624
- 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 }));
1625
1660
  }
1626
- return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
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;
1627
1668
  });
1628
1669
  }
1629
1670
  verifyExternalWalletLink(opts) {
@@ -1646,13 +1687,13 @@ Need help? Visit: https://docs.getpara.com or contact support
1646
1687
  * @param authResponse - the response JSON object received from the Telegram widget.
1647
1688
  * @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
1648
1689
  */
1649
- verifyTelegramProcess(_e) {
1690
+ verifyTelegramProcess(_c) {
1650
1691
  return __async(this, null, function* () {
1651
- var _f = _e, {
1692
+ var _d = _c, {
1652
1693
  serverAuthState: optsServerAuthState,
1653
1694
  telegramAuthResponse,
1654
1695
  isLinkAccount
1655
- } = _f, urlOptions = __objRest(_f, [
1696
+ } = _d, urlOptions = __objRest(_d, [
1656
1697
  "serverAuthState",
1657
1698
  "telegramAuthResponse",
1658
1699
  "isLinkAccount"
@@ -1822,8 +1863,12 @@ Need help? Visit: https://docs.getpara.com or contact support
1822
1863
  const requiredWalletTypes = supportedWalletTypes.filter(({ optional }) => !optional);
1823
1864
  for (const { type } of requiredWalletTypes) {
1824
1865
  const hasWalletForType = this.currentWalletIdsArray.some(([walletId, walletType]) => {
1825
- const wallet = this.wallets[walletId];
1826
- return wallet && walletType === type;
1866
+ try {
1867
+ const wallet = this.wallets[walletId];
1868
+ return wallet && walletType === type && typeof wallet.address === "string";
1869
+ } catch (e) {
1870
+ return false;
1871
+ }
1827
1872
  });
1828
1873
  if (!hasWalletForType) {
1829
1874
  return false;
@@ -1984,16 +2029,16 @@ Need help? Visit: https://docs.getpara.com or contact support
1984
2029
  * If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
1985
2030
  * @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
1986
2031
  */
1987
- verifyFarcasterProcess(_g) {
2032
+ verifyFarcasterProcess(_e) {
1988
2033
  return __async(this, null, function* () {
1989
- var _h = _g, {
2034
+ var _f = _e, {
1990
2035
  isCanceled = () => false,
1991
2036
  onConnectUri,
1992
2037
  onCancel,
1993
2038
  onPoll,
1994
2039
  isLinkAccount,
1995
2040
  serverAuthState: optsServerAuthState
1996
- } = _h, urlOptions = __objRest(_h, [
2041
+ } = _f, urlOptions = __objRest(_f, [
1997
2042
  "isCanceled",
1998
2043
  "onConnectUri",
1999
2044
  "onCancel",
@@ -2079,9 +2124,9 @@ Need help? Visit: https://docs.getpara.com or contact support
2079
2124
  * @param {Window} [opts.popupWindow] the popup window being used for login.
2080
2125
  * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
2081
2126
  */
2082
- verifyOAuthProcess(_i) {
2127
+ verifyOAuthProcess(_g) {
2083
2128
  return __async(this, null, function* () {
2084
- var _j = _i, {
2129
+ var _h = _g, {
2085
2130
  method,
2086
2131
  appScheme,
2087
2132
  isCanceled = () => false,
@@ -2090,7 +2135,7 @@ Need help? Visit: https://docs.getpara.com or contact support
2090
2135
  onOAuthUrl,
2091
2136
  onOAuthPopup,
2092
2137
  isLinkAccount
2093
- } = _j, urlOptions = __objRest(_j, [
2138
+ } = _h, urlOptions = __objRest(_h, [
2094
2139
  "method",
2095
2140
  "appScheme",
2096
2141
  "isCanceled",
@@ -3208,49 +3253,55 @@ Need help? Visit: https://docs.getpara.com or contact support
3208
3253
  } = {}) {
3209
3254
  const userAuthMethods = yield this.supportedUserAuthMethods();
3210
3255
  const isEnclaveUser = userAuthMethods.has(AuthMethod.BASIC_LOGIN);
3211
- if (isEnclaveUser) {
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) {
3212
3261
  isForNewDevice = true;
3213
3262
  }
3214
3263
  const authMethods = optsAuthMethod ? [optsAuthMethod] : isForNewDevice ? ["PASSKEY", "PIN", "PASSWORD"] : ["PASSKEY"];
3215
3264
  this.assertIsAuthSet();
3216
- const canAddPasswordOrPIN = !userAuthMethods.has(AuthMethod.PASSWORD) && !userAuthMethods.has(AuthMethod.PIN);
3217
- let passkeyId, passwordId, urlType;
3218
- if (authMethods.includes("PASSKEY") && (yield this.isPasskeySupported())) {
3219
- ({
3220
- data: { id: passkeyId }
3221
- } = yield this.ctx.client.addSessionPublicKey(this.userId, {
3222
- status: AuthMethodStatus.PENDING,
3223
- type: PublicKeyType.WEB
3224
- }));
3225
- urlType = "createAuth";
3226
- }
3227
- if (authMethods.includes("PASSWORD")) {
3228
- if (!canAddPasswordOrPIN) {
3229
- if (optsAuthMethod === "PASSWORD") throw new Error("A user cannot have more than one password or PIN.");
3230
- } 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())) {
3231
3269
  ({
3232
- data: { id: passwordId }
3233
- } = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
3234
- status: AuthMethodStatus.PENDING
3270
+ data: { id: passkeyId }
3271
+ } = yield this.ctx.client.addSessionPublicKey(this.userId, {
3272
+ status: AuthMethodStatus.PENDING,
3273
+ type: PublicKeyType.WEB
3235
3274
  }));
3236
- urlType = "createPassword";
3275
+ urlType = "createAuth";
3237
3276
  }
3238
- }
3239
- if (authMethods.includes("PIN")) {
3240
- if (!canAddPasswordOrPIN) {
3241
- if (optsAuthMethod === "PIN") throw new Error("A user cannot have more than one password or PIN.");
3242
- } else {
3243
- ({
3244
- data: { id: passwordId }
3245
- } = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
3246
- status: AuthMethodStatus.PENDING
3247
- }));
3248
- urlType = "createPIN";
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 };
3249
3304
  }
3250
- }
3251
- const credentialId = passkeyId != null ? passkeyId : passwordId;
3252
- if (this.isNativePasskey && authMethods.includes("PASSKEY")) {
3253
- return { credentialId };
3254
3305
  }
3255
3306
  const { sessionId } = yield this.touchSession();
3256
3307
  const url = (isForNewDevice || urlType) && (yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
@@ -3306,7 +3357,7 @@ Need help? Visit: https://docs.getpara.com or contact support
3306
3357
  urlType = "loginPIN";
3307
3358
  break;
3308
3359
  case "BASIC_LOGIN":
3309
- urlType = "loginOTP";
3360
+ urlType = this.authInfo.authType === "externalWallet" ? "loginExternalWallet" : "loginOTP";
3310
3361
  break;
3311
3362
  default:
3312
3363
  throw new Error(`invalid authentication method: '${authMethod}'`);
@@ -3328,9 +3379,9 @@ Need help? Visit: https://docs.getpara.com or contact support
3328
3379
  return sessionLookupId;
3329
3380
  });
3330
3381
  }
3331
- signUpOrLogIn(_k) {
3382
+ signUpOrLogIn(_i) {
3332
3383
  return __async(this, null, function* () {
3333
- var _l = _k, { auth } = _l, urlOptions = __objRest(_l, ["auth"]);
3384
+ var _j = _i, { auth } = _j, urlOptions = __objRest(_j, ["auth"]);
3334
3385
  let serverAuthState;
3335
3386
  try {
3336
3387
  serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
@@ -3352,11 +3403,11 @@ Need help? Visit: https://docs.getpara.com or contact support
3352
3403
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadValues({}, urlOptions));
3353
3404
  });
3354
3405
  }
3355
- verifyNewAccount(_m) {
3406
+ verifyNewAccount(_k) {
3356
3407
  return __async(this, null, function* () {
3357
- var _n = _m, {
3408
+ var _l = _k, {
3358
3409
  verificationCode
3359
- } = _n, urlOptions = __objRest(_n, [
3410
+ } = _l, urlOptions = __objRest(_l, [
3360
3411
  "verificationCode"
3361
3412
  ]);
3362
3413
  this.assertIsAuthSet(["email", "phone"]);
@@ -3454,10 +3505,10 @@ Need help? Visit: https://docs.getpara.com or contact support
3454
3505
  });
3455
3506
  }
3456
3507
  verifyLink() {
3457
- return __async(this, arguments, function* (_o = {}) {
3458
- var _p = _o, {
3508
+ return __async(this, arguments, function* (_m = {}) {
3509
+ var _n = _m, {
3459
3510
  accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
3460
- } = _p, opts = __objRest(_p, [
3511
+ } = _n, opts = __objRest(_n, [
3461
3512
  "accountLinkInProgress"
3462
3513
  ]);
3463
3514
  try {
@@ -3958,6 +4009,7 @@ prepareVerificationState_fn = function(_0, _1) {
3958
4009
  portalTheme,
3959
4010
  sessionLookupId
3960
4011
  }) {
4012
+ var _a;
3961
4013
  let isSLOPossible = false;
3962
4014
  if (verifyState.nextStage === "login") {
3963
4015
  isSLOPossible = verifyState.loginAuthMethods.includes(AuthMethod.BASIC_LOGIN);
@@ -3965,7 +4017,8 @@ prepareVerificationState_fn = function(_0, _1) {
3965
4017
  isSLOPossible = verifyState.signupAuthMethods.includes(AuthMethod.BASIC_LOGIN);
3966
4018
  }
3967
4019
  this.isEnclaveUser = isSLOPossible;
3968
- return __spreadValues(__spreadValues({}, verifyState), isSLOPossible ? {
4020
+ const isExternalWalletFullAuth = (_a = verifyState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
4021
+ return __spreadValues(__spreadValues({}, verifyState), isSLOPossible || isExternalWalletFullAuth ? {
3969
4022
  loginUrl: yield this.getLoginUrl({
3970
4023
  authMethod: AuthMethod.BASIC_LOGIN,
3971
4024
  sessionId: sessionLookupId,
@@ -1,5 +1,5 @@
1
1
  import "./chunk-W5CT3TVS.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.66";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.68";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const PARA_PREFIX = "@PARA/";
5
5
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -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';
@@ -172,6 +172,7 @@ export declare abstract class ParaCore implements CoreInterface {
172
172
  private isPregenWalletUnclaimed;
173
173
  private isPregenWalletClaimable;
174
174
  private isWalletUsable;
175
+ private truncateAddress;
175
176
  /**
176
177
  * Returns the formatted address for the desired wallet ID, depending on your app settings.
177
178
  * @param {string} walletId the ID of the wallet address to display.
@@ -390,8 +391,13 @@ export declare abstract class ParaCore implements CoreInterface {
390
391
  * @param {TWalletType} opts.type type of external wallet to use for identification.
391
392
  * @param {string} opts.provider the name of the provider for the external wallet.
392
393
  */
393
- loginExternalWallet({ externalWallet, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
394
- verifyExternalWallet({ externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner, ...urlOptions }: CoreMethodParams<'verifyExternalWallet'>): CoreMethodResponse<'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'>;
395
401
  protected verifyExternalWalletLink(opts: InternalMethodParams<'verifyExternalWalletLink'>): InternalMethodResponse<'verifyExternalWalletLink'>;
396
402
  protected verifyTelegramProcess(opts: CoreMethodParams<'verifyTelegram'> & {
397
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 & VerifyExternalWalletParams;
153
- response: AuthStateSignup | AuthStateLogin;
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?: Exclude<TAuthMethod, 'BASIC_LOGIN'>;
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?: Exclude<TAuthMethod, 'BASIC_LOGIN'>;
103
+ authMethod?: TAuthMethod;
104
104
  };
105
105
  export type OAuthUrlParams = {
106
106
  /**
@@ -26,7 +26,10 @@ export interface Wallet extends Omit<IWalletEntity, 'createdAt' | 'updatedAt' |
26
26
  ensName?: string | null;
27
27
  ensAvatar?: string | null;
28
28
  }
29
- export type AvailableWallet = Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'>;
29
+ export type AvailableWallet = Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'ensName' | 'ensAvatar' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'> & {
30
+ addressShort?: string;
31
+ displayName?: string;
32
+ };
30
33
  /** @deprecated */
31
34
  export declare enum PregenIdentifierType {
32
35
  EMAIL = "EMAIL",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.66",
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.66",
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": "07c8b7b68aa36dec6071e3b3b3a66de2870312c8",
30
+ "gitHead": "98955203281606201609bb4674f5984acb63d3bf",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {