@getpara/core-sdk 2.0.0-alpha.39 → 2.0.0-alpha.41

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.
@@ -99,7 +99,7 @@ var import_recovery = require("./shares/recovery.js");
99
99
  var import_utils2 = require("./utils/index.js");
100
100
  var import_errors = require("./errors.js");
101
101
  var constants = __toESM(require("./constants.js"));
102
- var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLoginState_fn, prepareSignUpState_fn;
102
+ var _authInfo, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLoginState_fn, prepareSignUpState_fn;
103
103
  if (typeof global !== "undefined") {
104
104
  global.Buffer = global.Buffer || import_buffer.Buffer;
105
105
  } else if (typeof window !== "undefined") {
@@ -123,7 +123,6 @@ const _ParaCore = class _ParaCore {
123
123
  __privateAdd(this, _authInfo);
124
124
  this.isNativePasskey = false;
125
125
  this.isReady = false;
126
- __privateAdd(this, _partner);
127
126
  this.accountLinkInProgress = void 0;
128
127
  this.isAwaitingAccountCreation = false;
129
128
  this.isAwaitingLogin = false;
@@ -465,11 +464,19 @@ const _ParaCore = class _ParaCore {
465
464
  }
466
465
  get partnerId() {
467
466
  var _a;
468
- return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id;
467
+ return (_a = this.partner) == null ? void 0 : _a.id;
468
+ }
469
+ get partnerName() {
470
+ var _a;
471
+ return (_a = this.partner) == null ? void 0 : _a.displayName;
472
+ }
473
+ get partnerLogo() {
474
+ var _a;
475
+ return (_a = this.partner) == null ? void 0 : _a.logoUrl;
469
476
  }
470
477
  get currentWalletIdsArray() {
471
478
  var _a, _b;
472
- return ((_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : Object.keys(this.currentWalletIds).map((type) => ({ type }))).reduce(
479
+ return ((_b = (_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : Object.keys(this.currentWalletIds).map((type) => ({ type }))).reduce(
473
480
  (acc, { type }) => {
474
481
  var _a2;
475
482
  return [
@@ -509,23 +516,23 @@ const _ParaCore = class _ParaCore {
509
516
  }
510
517
  get isNoWalletConfig() {
511
518
  var _a;
512
- return !!((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) && __privateGet(this, _partner).supportedWalletTypes.length === 0;
519
+ return !!((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) && this.partner.supportedWalletTypes.length === 0;
513
520
  }
514
521
  get supportedWalletTypes() {
515
522
  var _a, _b;
516
- return (_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : [];
523
+ return (_b = (_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : [];
517
524
  }
518
525
  get cosmosPrefix() {
519
526
  var _a;
520
- return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix;
527
+ return (_a = this.partner) == null ? void 0 : _a.cosmosPrefix;
521
528
  }
522
529
  get supportedAccountLinks() {
523
530
  var _a, _b;
524
- return (_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedAccountLinks) != null ? _b : [...import_user_management_client.LINKED_ACCOUNT_TYPES];
531
+ return (_b = (_a = this.partner) == null ? void 0 : _a.supportedAccountLinks) != null ? _b : [...import_user_management_client.LINKED_ACCOUNT_TYPES];
525
532
  }
526
533
  get isWalletTypeEnabled() {
527
534
  var _a;
528
- return (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) || []).reduce((acc, { type }) => {
535
+ return (((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) || []).reduce((acc, { type }) => {
529
536
  return __spreadProps(__spreadValues({}, acc), { [type]: true });
530
537
  }, {});
531
538
  }
@@ -574,7 +581,7 @@ const _ParaCore = class _ParaCore {
574
581
  }
575
582
  isWalletSupported(wallet) {
576
583
  var _a, _b;
577
- return !((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) || (0, import_utils2.isWalletSupported)((_b = __privateGet(this, _partner).supportedWalletTypes.map(({ type }) => type)) != null ? _b : [], wallet);
584
+ return !((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) || (0, import_utils2.isWalletSupported)((_b = this.partner.supportedWalletTypes.map(({ type }) => type)) != null ? _b : [], wallet);
578
585
  }
579
586
  isWalletOwned(wallet) {
580
587
  return this.isWalletSupported(wallet) && !(wallet == null ? void 0 : wallet.pregenIdentifier) && !(wallet == null ? void 0 : wallet.pregenIdentifierType) && !!this.userId && (wallet == null ? void 0 : wallet.userId) === this.userId;
@@ -605,7 +612,7 @@ const _ParaCore = class _ParaCore {
605
612
  } else if (!isOwned && !isUnclaimed) {
606
613
  error = `wallet with id ${wallet == null ? void 0 : wallet.id} is not owned by the current user`;
607
614
  } else if (!this.isWalletSupported(wallet)) {
608
- error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${(((_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes) || []).map(({ type }) => type).join(", ")}`;
615
+ error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${(((_b = this.partner) == null ? void 0 : _b.supportedWalletTypes) || []).map(({ type }) => type).join(", ")}`;
609
616
  } else if (types && (!(0, import_utils2.getEquivalentTypes)(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
610
617
  var _a2, _b2;
611
618
  return (_b2 = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b2.includes(walletId);
@@ -636,7 +643,7 @@ const _ParaCore = class _ParaCore {
636
643
  if (this.externalWallets[walletId]) {
637
644
  const wallet2 = this.externalWallets[walletId];
638
645
  return options.truncate ? (0, import_utils2.truncateAddress)(wallet2.address, wallet2.type, {
639
- prefix: (_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix,
646
+ prefix: (_a = this.partner) == null ? void 0 : _a.cosmosPrefix,
640
647
  targetLength: options.targetLength
641
648
  }) : wallet2.address;
642
649
  }
@@ -648,7 +655,7 @@ const _ParaCore = class _ParaCore {
648
655
  let prefix;
649
656
  switch (wallet.type) {
650
657
  case "COSMOS":
651
- prefix = (_d = (_c = options.cosmosPrefix) != null ? _c : (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix) != null ? _d : "cosmos";
658
+ prefix = (_d = (_c = options.cosmosPrefix) != null ? _c : (_b = this.partner) == null ? void 0 : _b.cosmosPrefix) != null ? _d : "cosmos";
652
659
  str = (0, import_utils2.getCosmosAddress)(wallet.publicKey, prefix);
653
660
  break;
654
661
  default:
@@ -683,8 +690,8 @@ const _ParaCore = class _ParaCore {
683
690
  return __async(this, arguments, function* (type, opts = {}) {
684
691
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
685
692
  const [isCreate, isLogin, isOnRamp] = [
686
- ["createAuth", "createPassword"].includes(type),
687
- ["loginAuth", "loginPassword"].includes(type),
693
+ ["createAuth", "createPassword", "createPIN"].includes(type),
694
+ ["loginAuth", "loginPassword", "loginPIN"].includes(type),
688
695
  type === "onRamp"
689
696
  ];
690
697
  if (isCreate || isLogin) {
@@ -705,6 +712,10 @@ const _ParaCore = class _ParaCore {
705
712
  path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
706
713
  break;
707
714
  }
715
+ case "createPIN": {
716
+ path = `/web/users/${this.userId}/pin/${opts.pathId}`;
717
+ break;
718
+ }
708
719
  case "createAuth": {
709
720
  path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
710
721
  break;
@@ -717,6 +728,10 @@ const _ParaCore = class _ParaCore {
717
728
  path = "/web/biometrics/login";
718
729
  break;
719
730
  }
731
+ case "loginPIN": {
732
+ path = "/web/pin/login";
733
+ break;
734
+ }
720
735
  case "txReview": {
721
736
  path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
722
737
  break;
@@ -791,7 +806,7 @@ const _ParaCore = class _ParaCore {
791
806
  yield this.ready();
792
807
  }
793
808
  const session = yield this.ctx.client.touchSession(regenerate);
794
- if (!__privateGet(this, _partner) || ((_a = __privateGet(this, _partner)) == null ? void 0 : _a.id) !== session.partnerId || !(0, import_utils2.supportedWalletTypesEq)(((_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes) || [], session.supportedWalletTypes) || (((_c = __privateGet(this, _partner)) == null ? void 0 : _c.cosmosPrefix) || "cosmos") !== session.cosmosPrefix) {
809
+ if (!this.partner || ((_a = this.partner) == null ? void 0 : _a.id) !== session.partnerId || !(0, import_utils2.supportedWalletTypesEq)(((_b = this.partner) == null ? void 0 : _b.supportedWalletTypes) || [], session.supportedWalletTypes) || (((_c = this.partner) == null ? void 0 : _c.cosmosPrefix) || "cosmos") !== session.cosmosPrefix) {
795
810
  yield __privateMethod(this, _ParaCore_instances, getPartner_fn).call(this, session.partnerId);
796
811
  }
797
812
  return session;
@@ -1405,12 +1420,17 @@ const _ParaCore = class _ParaCore {
1405
1420
  "cosmosPublicKeyHex",
1406
1421
  "cosmosSigner"
1407
1422
  ]);
1423
+ var _a;
1408
1424
  const serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
1409
1425
  externalWallet,
1410
1426
  signedMessage,
1411
1427
  cosmosPublicKeyHex,
1412
1428
  cosmosSigner
1413
1429
  });
1430
+ if (serverAuthState.stage === "login" && ((_a = serverAuthState.loginAuthMethods) == null ? void 0 : _a.includes(import_user_management_client.AuthMethod.PIN))) {
1431
+ const { sessionLookupId } = yield this.touchSession();
1432
+ return __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
1433
+ }
1414
1434
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
1415
1435
  });
1416
1436
  }
@@ -1522,6 +1542,7 @@ const _ParaCore = class _ParaCore {
1522
1542
  let type, linkedAccountId;
1523
1543
  switch (reason) {
1524
1544
  case "SIGNUP":
1545
+ case "LOGIN":
1525
1546
  {
1526
1547
  const authInfo = this.assertIsAuthSet(["email", "phone"]);
1527
1548
  type = authInfo.authType.toUpperCase();
@@ -1592,10 +1613,13 @@ const _ParaCore = class _ParaCore {
1592
1613
  return __privateGet(this, _ParaCore_instances, guestWalletIdsArray_get).length > 0 && Object.values(this.wallets).every(
1593
1614
  ({ userId, partnerId }) => {
1594
1615
  var _a;
1595
- return partnerId === ((_a = __privateGet(this, _partner)) == null ? void 0 : _a.id) && (!userId || userId !== this.userId);
1616
+ return partnerId === ((_a = this.partner) == null ? void 0 : _a.id) && (!userId || userId !== this.userId);
1596
1617
  }
1597
1618
  );
1598
1619
  }
1620
+ /**
1621
+ * Get the auth methods available to an existing user
1622
+ */
1599
1623
  supportedAuthMethods(auth) {
1600
1624
  return __async(this, null, function* () {
1601
1625
  const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
@@ -2845,6 +2869,7 @@ const _ParaCore = class _ParaCore {
2845
2869
  **/
2846
2870
  logout() {
2847
2871
  return __async(this, arguments, function* ({ clearPregenWallets = false } = {}) {
2872
+ const shouldDispatchLogoutEvent = yield this.isSessionActive();
2848
2873
  yield this.ctx.client.logout();
2849
2874
  yield this.clearStorage();
2850
2875
  if (!clearPregenWallets) {
@@ -2864,7 +2889,9 @@ const _ParaCore = class _ParaCore {
2864
2889
  this.accountLinkInProgress = void 0;
2865
2890
  this.userId = void 0;
2866
2891
  this.sessionCookie = void 0;
2867
- (0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGOUT_EVENT, null);
2892
+ if (shouldDispatchLogoutEvent) {
2893
+ (0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGOUT_EVENT, null);
2894
+ }
2868
2895
  });
2869
2896
  }
2870
2897
  get toStringAdditions() {
@@ -2894,9 +2921,9 @@ const _ParaCore = class _ParaCore {
2894
2921
  {}
2895
2922
  );
2896
2923
  const obj = __spreadProps(__spreadValues({
2897
- partnerId: (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id,
2898
- supportedWalletTypes: (_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes,
2899
- cosmosPrefix: (_c = __privateGet(this, _partner)) == null ? void 0 : _c.cosmosPrefix,
2924
+ partnerId: (_a = this.partner) == null ? void 0 : _a.id,
2925
+ supportedWalletTypes: (_b = this.partner) == null ? void 0 : _b.supportedWalletTypes,
2926
+ cosmosPrefix: (_c = this.partner) == null ? void 0 : _c.cosmosPrefix,
2900
2927
  authInfo: __privateGet(this, _authInfo),
2901
2928
  isGuestMode: this.isGuestMode,
2902
2929
  userId: this.userId,
@@ -2953,6 +2980,14 @@ const _ParaCore = class _ParaCore {
2953
2980
  }));
2954
2981
  urlType = "createPassword";
2955
2982
  break;
2983
+ case "PIN":
2984
+ ({
2985
+ data: { id: credentialId }
2986
+ } = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
2987
+ status: import_user_management_client.PasswordStatus.PENDING
2988
+ }));
2989
+ urlType = "createPIN";
2990
+ break;
2956
2991
  }
2957
2992
  const url = this.isNativePasskey && urlType === "createAuth" ? void 0 : yield this.constructPortalUrl(urlType, {
2958
2993
  isForNewDevice,
@@ -2964,7 +2999,7 @@ const _ParaCore = class _ParaCore {
2964
2999
  });
2965
3000
  }
2966
3001
  /**
2967
- * Returns a Para Portal URL for logging in with a WebAuth passkey or a password.
3002
+ * Returns a Para Portal URL for logging in with a WebAuth passkey, password or PIN.
2968
3003
  * @param {Object} opts the options object
2969
3004
  * @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
2970
3005
  * @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
@@ -2990,6 +3025,9 @@ const _ParaCore = class _ParaCore {
2990
3025
  case "PASSWORD":
2991
3026
  urlType = "loginPassword";
2992
3027
  break;
3028
+ case "PIN":
3029
+ urlType = "loginPIN";
3030
+ break;
2993
3031
  default:
2994
3032
  throw new Error(`invalid authentication method: '${authMethod}'`);
2995
3033
  }
@@ -3033,9 +3071,12 @@ const _ParaCore = class _ParaCore {
3033
3071
  ]);
3034
3072
  this.assertIsAuthSet(["email", "phone"]);
3035
3073
  const userId = this.assertUserId({ allowGuestMode: true });
3036
- const serverAuthState = yield this.ctx.client.verifyNewAccount(userId, {
3074
+ const serverAuthState = yield this.ctx.client.verifyAccount(userId, {
3037
3075
  verificationCode
3038
3076
  });
3077
+ if (serverAuthState.stage === "login") {
3078
+ throw new Error("Account already exists.");
3079
+ }
3039
3080
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
3040
3081
  });
3041
3082
  }
@@ -3154,31 +3195,36 @@ const _ParaCore = class _ParaCore {
3154
3195
  return accounts;
3155
3196
  });
3156
3197
  }
3198
+ sendLoginCode() {
3199
+ return __async(this, null, function* () {
3200
+ const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
3201
+ this.setUserId(userId);
3202
+ });
3203
+ }
3157
3204
  };
3158
3205
  _authInfo = new WeakMap();
3159
- _partner = new WeakMap();
3160
3206
  _ParaCore_instances = new WeakSet();
3161
3207
  assertPartner_fn = function() {
3162
3208
  return __async(this, null, function* () {
3163
3209
  var _a, _b;
3164
- if (!__privateGet(this, _partner)) {
3210
+ if (!this.partner) {
3165
3211
  yield this.touchSession();
3166
3212
  }
3167
- if (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== __privateGet(this, _partner).cosmosPrefix) {
3168
- this.ctx.cosmosPrefix = (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix;
3213
+ if (((_a = this.partner) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== this.partner.cosmosPrefix) {
3214
+ this.ctx.cosmosPrefix = (_b = this.partner) == null ? void 0 : _b.cosmosPrefix;
3169
3215
  }
3170
- return __privateGet(this, _partner);
3216
+ return this.partner;
3171
3217
  });
3172
3218
  };
3173
3219
  guestWalletIds_get = function() {
3174
3220
  var _a, _b, _c;
3175
- if (!((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes)) {
3221
+ if (!((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes)) {
3176
3222
  return {};
3177
3223
  }
3178
3224
  const guestId = (_c = (_b = this.pregenIds) == null ? void 0 : _b.GUEST_ID) == null ? void 0 : _c[0];
3179
3225
  return !!guestId ? Object.entries(this.wallets).reduce((acc, [id, wallet]) => {
3180
3226
  if (wallet.isPregen && !wallet.userId && wallet.pregenIdentifierType === "GUEST_ID" && wallet.pregenIdentifier === guestId) {
3181
- return __spreadValues(__spreadValues({}, acc), (0, import_utils2.getEquivalentTypes)(wallet.type).filter((type) => __privateGet(this, _partner).supportedWalletTypes.some((entry) => entry.type === type)).reduce((acc2, eqType) => {
3227
+ return __spreadValues(__spreadValues({}, acc), (0, import_utils2.getEquivalentTypes)(wallet.type).filter((type) => this.partner.supportedWalletTypes.some((entry) => entry.type === type)).reduce((acc2, eqType) => {
3182
3228
  var _a2;
3183
3229
  return __spreadProps(__spreadValues({}, acc2), { [eqType]: [.../* @__PURE__ */ new Set([...(_a2 = acc2[eqType]) != null ? _a2 : [], id])] });
3184
3230
  }, {}));
@@ -3239,8 +3285,8 @@ getPartner_fn = function(partnerId) {
3239
3285
  return void 0;
3240
3286
  }
3241
3287
  const res = yield this.ctx.client.getPartner(partnerId);
3242
- __privateSet(this, _partner, res.data.partner);
3243
- return __privateGet(this, _partner);
3288
+ this.partner = res.data.partner;
3289
+ return this.partner;
3244
3290
  });
3245
3291
  };
3246
3292
  assertIsLinkingAccount_fn = function(types) {
@@ -3338,7 +3384,8 @@ createPregenWallet_fn = function(opts) {
3338
3384
  _isCreateGuestWalletsPending = new WeakMap();
3339
3385
  prepareAuthState_fn = function(_0) {
3340
3386
  return __async(this, arguments, function* (serverAuthState, opts = {}) {
3341
- if (!opts.sessionLookupId && serverAuthState.stage === "login") {
3387
+ var _a, _b;
3388
+ if (!opts.sessionLookupId && serverAuthState.stage === "login" && (!serverAuthState.externalWallet || !(((_a = serverAuthState.externalWallet) == null ? void 0 : _a.withFullParaAuth) && ((_b = serverAuthState.loginAuthMethods) == null ? void 0 : _b.includes(import_user_management_client.AuthMethod.PIN))))) {
3342
3389
  opts.sessionLookupId = yield this.prepareLogin();
3343
3390
  }
3344
3391
  const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
@@ -3387,9 +3434,9 @@ prepareLoginState_fn = function(_0, _1) {
3387
3434
  portalTheme,
3388
3435
  sessionLookupId
3389
3436
  }) {
3390
- const _a = loginState, { loginAuthMethods } = _a, authState = __objRest(_a, ["loginAuthMethods"]);
3391
- const isPasskeySupported = yield this.isPasskeySupported(), isPasskeyPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY) && !this.isNativePasskey, isPasswordPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD);
3392
- return __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
3437
+ const _a = loginState, { loginAuthMethods, hasPasswordWithoutPIN } = _a, authState = __objRest(_a, ["loginAuthMethods", "hasPasswordWithoutPIN"]);
3438
+ const isPasskeySupported = yield this.isPasskeySupported(), isPasskeyPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY) && !this.isNativePasskey, isPasswordPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) && hasPasswordWithoutPIN, isPINPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PIN);
3439
+ return __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
3393
3440
  isPasskeySupported
3394
3441
  }), isPasskeyPossible ? {
3395
3442
  passkeyUrl: yield this.getLoginUrl({ sessionId: sessionLookupId, shorten, portalTheme }),
@@ -3409,6 +3456,13 @@ prepareLoginState_fn = function(_0, _1) {
3409
3456
  portalTheme,
3410
3457
  params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
3411
3458
  })
3459
+ } : {}), isPINPossible ? {
3460
+ pinUrl: yield this.constructPortalUrl("loginPIN", {
3461
+ sessionId: sessionLookupId,
3462
+ shorten,
3463
+ portalTheme,
3464
+ params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
3465
+ })
3412
3466
  } : {});
3413
3467
  });
3414
3468
  };
@@ -3416,13 +3470,14 @@ prepareSignUpState_fn = function(_0, _1) {
3416
3470
  return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
3417
3471
  const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
3418
3472
  const isPasskeySupported = yield this.isPasskeySupported();
3419
- const [isPasskey, isPassword] = [
3473
+ const [isPasskey, isPassword, isPIN] = [
3420
3474
  signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY),
3421
- signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) || !isPasskeySupported
3475
+ signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) || !isPasskeySupported,
3476
+ signupAuthMethods.includes(import_user_management_client.AuthMethod.PIN)
3422
3477
  ];
3423
- if (!isPasskey && !isPassword) {
3478
+ if (!isPasskey && !isPassword && !isPIN) {
3424
3479
  throw new Error(
3425
- "No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys or passwords in your Developer Portal settings."
3480
+ "No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys, passwords or PINs in your Developer Portal settings."
3426
3481
  );
3427
3482
  }
3428
3483
  const signupState = __spreadProps(__spreadValues({}, authState), { isPasskeySupported });
@@ -3443,6 +3498,15 @@ prepareSignUpState_fn = function(_0, _1) {
3443
3498
  signupState.passwordUrl = passwordUrl;
3444
3499
  signupState.passwordId = passwordId;
3445
3500
  }
3501
+ if (isPIN) {
3502
+ const { url: pinUrl, credentialId: pinId } = yield this.getNewCredentialAndUrl({
3503
+ authMethod: "PIN",
3504
+ portalTheme,
3505
+ shorten
3506
+ });
3507
+ signupState.pinUrl = pinUrl;
3508
+ signupState.pinId = pinId;
3509
+ }
3446
3510
  return signupState;
3447
3511
  });
3448
3512
  };
@@ -40,7 +40,7 @@ __export(constants_exports, {
40
40
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
41
41
  });
42
42
  module.exports = __toCommonJS(constants_exports);
43
- const PARA_CORE_VERSION = "2.0.0-alpha.39";
43
+ const PARA_CORE_VERSION = "2.0.0-alpha.41";
44
44
  const PREFIX = "@CAPSULE/";
45
45
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
46
46
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -81,7 +81,8 @@ const PARA_INTERNAL_METHODS = [
81
81
  "verifyTelegramLink",
82
82
  "verifyExternalWalletLink",
83
83
  "accountLinkInProgress",
84
- "prepareLogin"
84
+ "prepareLogin",
85
+ "sendLoginCode"
85
86
  ];
86
87
  // Annotate the CommonJS export names for ESM import in node:
87
88
  0 && (module.exports = {
@@ -8,7 +8,7 @@ import {
8
8
  __spreadProps,
9
9
  __spreadValues
10
10
  } from "./chunk-7B52C2XE.js";
11
- var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLoginState_fn, prepareSignUpState_fn;
11
+ var _authInfo, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLoginState_fn, prepareSignUpState_fn;
12
12
  import { Buffer as NodeBuffer } from "buffer";
13
13
  if (typeof global !== "undefined") {
14
14
  global.Buffer = global.Buffer || NodeBuffer;
@@ -88,7 +88,6 @@ const _ParaCore = class _ParaCore {
88
88
  __privateAdd(this, _authInfo);
89
89
  this.isNativePasskey = false;
90
90
  this.isReady = false;
91
- __privateAdd(this, _partner);
92
91
  this.accountLinkInProgress = void 0;
93
92
  this.isAwaitingAccountCreation = false;
94
93
  this.isAwaitingLogin = false;
@@ -430,11 +429,19 @@ const _ParaCore = class _ParaCore {
430
429
  }
431
430
  get partnerId() {
432
431
  var _a;
433
- return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id;
432
+ return (_a = this.partner) == null ? void 0 : _a.id;
433
+ }
434
+ get partnerName() {
435
+ var _a;
436
+ return (_a = this.partner) == null ? void 0 : _a.displayName;
437
+ }
438
+ get partnerLogo() {
439
+ var _a;
440
+ return (_a = this.partner) == null ? void 0 : _a.logoUrl;
434
441
  }
435
442
  get currentWalletIdsArray() {
436
443
  var _a, _b;
437
- return ((_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : Object.keys(this.currentWalletIds).map((type) => ({ type }))).reduce(
444
+ return ((_b = (_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : Object.keys(this.currentWalletIds).map((type) => ({ type }))).reduce(
438
445
  (acc, { type }) => {
439
446
  var _a2;
440
447
  return [
@@ -474,23 +481,23 @@ const _ParaCore = class _ParaCore {
474
481
  }
475
482
  get isNoWalletConfig() {
476
483
  var _a;
477
- return !!((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) && __privateGet(this, _partner).supportedWalletTypes.length === 0;
484
+ return !!((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) && this.partner.supportedWalletTypes.length === 0;
478
485
  }
479
486
  get supportedWalletTypes() {
480
487
  var _a, _b;
481
- return (_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : [];
488
+ return (_b = (_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : [];
482
489
  }
483
490
  get cosmosPrefix() {
484
491
  var _a;
485
- return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix;
492
+ return (_a = this.partner) == null ? void 0 : _a.cosmosPrefix;
486
493
  }
487
494
  get supportedAccountLinks() {
488
495
  var _a, _b;
489
- return (_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedAccountLinks) != null ? _b : [...LINKED_ACCOUNT_TYPES];
496
+ return (_b = (_a = this.partner) == null ? void 0 : _a.supportedAccountLinks) != null ? _b : [...LINKED_ACCOUNT_TYPES];
490
497
  }
491
498
  get isWalletTypeEnabled() {
492
499
  var _a;
493
- return (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) || []).reduce((acc, { type }) => {
500
+ return (((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) || []).reduce((acc, { type }) => {
494
501
  return __spreadProps(__spreadValues({}, acc), { [type]: true });
495
502
  }, {});
496
503
  }
@@ -539,7 +546,7 @@ const _ParaCore = class _ParaCore {
539
546
  }
540
547
  isWalletSupported(wallet) {
541
548
  var _a, _b;
542
- return !((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) || isWalletSupported((_b = __privateGet(this, _partner).supportedWalletTypes.map(({ type }) => type)) != null ? _b : [], wallet);
549
+ return !((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) || isWalletSupported((_b = this.partner.supportedWalletTypes.map(({ type }) => type)) != null ? _b : [], wallet);
543
550
  }
544
551
  isWalletOwned(wallet) {
545
552
  return this.isWalletSupported(wallet) && !(wallet == null ? void 0 : wallet.pregenIdentifier) && !(wallet == null ? void 0 : wallet.pregenIdentifierType) && !!this.userId && (wallet == null ? void 0 : wallet.userId) === this.userId;
@@ -570,7 +577,7 @@ const _ParaCore = class _ParaCore {
570
577
  } else if (!isOwned && !isUnclaimed) {
571
578
  error = `wallet with id ${wallet == null ? void 0 : wallet.id} is not owned by the current user`;
572
579
  } else if (!this.isWalletSupported(wallet)) {
573
- error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${(((_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes) || []).map(({ type }) => type).join(", ")}`;
580
+ error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${(((_b = this.partner) == null ? void 0 : _b.supportedWalletTypes) || []).map(({ type }) => type).join(", ")}`;
574
581
  } else if (types && (!getEquivalentTypes(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
575
582
  var _a2, _b2;
576
583
  return (_b2 = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b2.includes(walletId);
@@ -601,7 +608,7 @@ const _ParaCore = class _ParaCore {
601
608
  if (this.externalWallets[walletId]) {
602
609
  const wallet2 = this.externalWallets[walletId];
603
610
  return options.truncate ? truncateAddress(wallet2.address, wallet2.type, {
604
- prefix: (_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix,
611
+ prefix: (_a = this.partner) == null ? void 0 : _a.cosmosPrefix,
605
612
  targetLength: options.targetLength
606
613
  }) : wallet2.address;
607
614
  }
@@ -613,7 +620,7 @@ const _ParaCore = class _ParaCore {
613
620
  let prefix;
614
621
  switch (wallet.type) {
615
622
  case "COSMOS":
616
- prefix = (_d = (_c = options.cosmosPrefix) != null ? _c : (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix) != null ? _d : "cosmos";
623
+ prefix = (_d = (_c = options.cosmosPrefix) != null ? _c : (_b = this.partner) == null ? void 0 : _b.cosmosPrefix) != null ? _d : "cosmos";
617
624
  str = getCosmosAddress(wallet.publicKey, prefix);
618
625
  break;
619
626
  default:
@@ -648,8 +655,8 @@ const _ParaCore = class _ParaCore {
648
655
  return __async(this, arguments, function* (type, opts = {}) {
649
656
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
650
657
  const [isCreate, isLogin, isOnRamp] = [
651
- ["createAuth", "createPassword"].includes(type),
652
- ["loginAuth", "loginPassword"].includes(type),
658
+ ["createAuth", "createPassword", "createPIN"].includes(type),
659
+ ["loginAuth", "loginPassword", "loginPIN"].includes(type),
653
660
  type === "onRamp"
654
661
  ];
655
662
  if (isCreate || isLogin) {
@@ -670,6 +677,10 @@ const _ParaCore = class _ParaCore {
670
677
  path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
671
678
  break;
672
679
  }
680
+ case "createPIN": {
681
+ path = `/web/users/${this.userId}/pin/${opts.pathId}`;
682
+ break;
683
+ }
673
684
  case "createAuth": {
674
685
  path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
675
686
  break;
@@ -682,6 +693,10 @@ const _ParaCore = class _ParaCore {
682
693
  path = "/web/biometrics/login";
683
694
  break;
684
695
  }
696
+ case "loginPIN": {
697
+ path = "/web/pin/login";
698
+ break;
699
+ }
685
700
  case "txReview": {
686
701
  path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
687
702
  break;
@@ -756,7 +771,7 @@ const _ParaCore = class _ParaCore {
756
771
  yield this.ready();
757
772
  }
758
773
  const session = yield this.ctx.client.touchSession(regenerate);
759
- if (!__privateGet(this, _partner) || ((_a = __privateGet(this, _partner)) == null ? void 0 : _a.id) !== session.partnerId || !supportedWalletTypesEq(((_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes) || [], session.supportedWalletTypes) || (((_c = __privateGet(this, _partner)) == null ? void 0 : _c.cosmosPrefix) || "cosmos") !== session.cosmosPrefix) {
774
+ if (!this.partner || ((_a = this.partner) == null ? void 0 : _a.id) !== session.partnerId || !supportedWalletTypesEq(((_b = this.partner) == null ? void 0 : _b.supportedWalletTypes) || [], session.supportedWalletTypes) || (((_c = this.partner) == null ? void 0 : _c.cosmosPrefix) || "cosmos") !== session.cosmosPrefix) {
760
775
  yield __privateMethod(this, _ParaCore_instances, getPartner_fn).call(this, session.partnerId);
761
776
  }
762
777
  return session;
@@ -1370,12 +1385,17 @@ const _ParaCore = class _ParaCore {
1370
1385
  "cosmosPublicKeyHex",
1371
1386
  "cosmosSigner"
1372
1387
  ]);
1388
+ var _a;
1373
1389
  const serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
1374
1390
  externalWallet,
1375
1391
  signedMessage,
1376
1392
  cosmosPublicKeyHex,
1377
1393
  cosmosSigner
1378
1394
  });
1395
+ if (serverAuthState.stage === "login" && ((_a = serverAuthState.loginAuthMethods) == null ? void 0 : _a.includes(AuthMethod.PIN))) {
1396
+ const { sessionLookupId } = yield this.touchSession();
1397
+ return __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
1398
+ }
1379
1399
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
1380
1400
  });
1381
1401
  }
@@ -1487,6 +1507,7 @@ const _ParaCore = class _ParaCore {
1487
1507
  let type, linkedAccountId;
1488
1508
  switch (reason) {
1489
1509
  case "SIGNUP":
1510
+ case "LOGIN":
1490
1511
  {
1491
1512
  const authInfo = this.assertIsAuthSet(["email", "phone"]);
1492
1513
  type = authInfo.authType.toUpperCase();
@@ -1557,10 +1578,13 @@ const _ParaCore = class _ParaCore {
1557
1578
  return __privateGet(this, _ParaCore_instances, guestWalletIdsArray_get).length > 0 && Object.values(this.wallets).every(
1558
1579
  ({ userId, partnerId }) => {
1559
1580
  var _a;
1560
- return partnerId === ((_a = __privateGet(this, _partner)) == null ? void 0 : _a.id) && (!userId || userId !== this.userId);
1581
+ return partnerId === ((_a = this.partner) == null ? void 0 : _a.id) && (!userId || userId !== this.userId);
1561
1582
  }
1562
1583
  );
1563
1584
  }
1585
+ /**
1586
+ * Get the auth methods available to an existing user
1587
+ */
1564
1588
  supportedAuthMethods(auth) {
1565
1589
  return __async(this, null, function* () {
1566
1590
  const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
@@ -2810,6 +2834,7 @@ const _ParaCore = class _ParaCore {
2810
2834
  **/
2811
2835
  logout() {
2812
2836
  return __async(this, arguments, function* ({ clearPregenWallets = false } = {}) {
2837
+ const shouldDispatchLogoutEvent = yield this.isSessionActive();
2813
2838
  yield this.ctx.client.logout();
2814
2839
  yield this.clearStorage();
2815
2840
  if (!clearPregenWallets) {
@@ -2829,7 +2854,9 @@ const _ParaCore = class _ParaCore {
2829
2854
  this.accountLinkInProgress = void 0;
2830
2855
  this.userId = void 0;
2831
2856
  this.sessionCookie = void 0;
2832
- dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
2857
+ if (shouldDispatchLogoutEvent) {
2858
+ dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
2859
+ }
2833
2860
  });
2834
2861
  }
2835
2862
  get toStringAdditions() {
@@ -2859,9 +2886,9 @@ const _ParaCore = class _ParaCore {
2859
2886
  {}
2860
2887
  );
2861
2888
  const obj = __spreadProps(__spreadValues({
2862
- partnerId: (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id,
2863
- supportedWalletTypes: (_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes,
2864
- cosmosPrefix: (_c = __privateGet(this, _partner)) == null ? void 0 : _c.cosmosPrefix,
2889
+ partnerId: (_a = this.partner) == null ? void 0 : _a.id,
2890
+ supportedWalletTypes: (_b = this.partner) == null ? void 0 : _b.supportedWalletTypes,
2891
+ cosmosPrefix: (_c = this.partner) == null ? void 0 : _c.cosmosPrefix,
2865
2892
  authInfo: __privateGet(this, _authInfo),
2866
2893
  isGuestMode: this.isGuestMode,
2867
2894
  userId: this.userId,
@@ -2918,6 +2945,14 @@ const _ParaCore = class _ParaCore {
2918
2945
  }));
2919
2946
  urlType = "createPassword";
2920
2947
  break;
2948
+ case "PIN":
2949
+ ({
2950
+ data: { id: credentialId }
2951
+ } = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
2952
+ status: PasswordStatus.PENDING
2953
+ }));
2954
+ urlType = "createPIN";
2955
+ break;
2921
2956
  }
2922
2957
  const url = this.isNativePasskey && urlType === "createAuth" ? void 0 : yield this.constructPortalUrl(urlType, {
2923
2958
  isForNewDevice,
@@ -2929,7 +2964,7 @@ const _ParaCore = class _ParaCore {
2929
2964
  });
2930
2965
  }
2931
2966
  /**
2932
- * Returns a Para Portal URL for logging in with a WebAuth passkey or a password.
2967
+ * Returns a Para Portal URL for logging in with a WebAuth passkey, password or PIN.
2933
2968
  * @param {Object} opts the options object
2934
2969
  * @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
2935
2970
  * @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
@@ -2955,6 +2990,9 @@ const _ParaCore = class _ParaCore {
2955
2990
  case "PASSWORD":
2956
2991
  urlType = "loginPassword";
2957
2992
  break;
2993
+ case "PIN":
2994
+ urlType = "loginPIN";
2995
+ break;
2958
2996
  default:
2959
2997
  throw new Error(`invalid authentication method: '${authMethod}'`);
2960
2998
  }
@@ -2998,9 +3036,12 @@ const _ParaCore = class _ParaCore {
2998
3036
  ]);
2999
3037
  this.assertIsAuthSet(["email", "phone"]);
3000
3038
  const userId = this.assertUserId({ allowGuestMode: true });
3001
- const serverAuthState = yield this.ctx.client.verifyNewAccount(userId, {
3039
+ const serverAuthState = yield this.ctx.client.verifyAccount(userId, {
3002
3040
  verificationCode
3003
3041
  });
3042
+ if (serverAuthState.stage === "login") {
3043
+ throw new Error("Account already exists.");
3044
+ }
3004
3045
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
3005
3046
  });
3006
3047
  }
@@ -3119,31 +3160,36 @@ const _ParaCore = class _ParaCore {
3119
3160
  return accounts;
3120
3161
  });
3121
3162
  }
3163
+ sendLoginCode() {
3164
+ return __async(this, null, function* () {
3165
+ const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
3166
+ this.setUserId(userId);
3167
+ });
3168
+ }
3122
3169
  };
3123
3170
  _authInfo = new WeakMap();
3124
- _partner = new WeakMap();
3125
3171
  _ParaCore_instances = new WeakSet();
3126
3172
  assertPartner_fn = function() {
3127
3173
  return __async(this, null, function* () {
3128
3174
  var _a, _b;
3129
- if (!__privateGet(this, _partner)) {
3175
+ if (!this.partner) {
3130
3176
  yield this.touchSession();
3131
3177
  }
3132
- if (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== __privateGet(this, _partner).cosmosPrefix) {
3133
- this.ctx.cosmosPrefix = (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix;
3178
+ if (((_a = this.partner) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== this.partner.cosmosPrefix) {
3179
+ this.ctx.cosmosPrefix = (_b = this.partner) == null ? void 0 : _b.cosmosPrefix;
3134
3180
  }
3135
- return __privateGet(this, _partner);
3181
+ return this.partner;
3136
3182
  });
3137
3183
  };
3138
3184
  guestWalletIds_get = function() {
3139
3185
  var _a, _b, _c;
3140
- if (!((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes)) {
3186
+ if (!((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes)) {
3141
3187
  return {};
3142
3188
  }
3143
3189
  const guestId = (_c = (_b = this.pregenIds) == null ? void 0 : _b.GUEST_ID) == null ? void 0 : _c[0];
3144
3190
  return !!guestId ? Object.entries(this.wallets).reduce((acc, [id, wallet]) => {
3145
3191
  if (wallet.isPregen && !wallet.userId && wallet.pregenIdentifierType === "GUEST_ID" && wallet.pregenIdentifier === guestId) {
3146
- return __spreadValues(__spreadValues({}, acc), getEquivalentTypes(wallet.type).filter((type) => __privateGet(this, _partner).supportedWalletTypes.some((entry) => entry.type === type)).reduce((acc2, eqType) => {
3192
+ return __spreadValues(__spreadValues({}, acc), getEquivalentTypes(wallet.type).filter((type) => this.partner.supportedWalletTypes.some((entry) => entry.type === type)).reduce((acc2, eqType) => {
3147
3193
  var _a2;
3148
3194
  return __spreadProps(__spreadValues({}, acc2), { [eqType]: [.../* @__PURE__ */ new Set([...(_a2 = acc2[eqType]) != null ? _a2 : [], id])] });
3149
3195
  }, {}));
@@ -3204,8 +3250,8 @@ getPartner_fn = function(partnerId) {
3204
3250
  return void 0;
3205
3251
  }
3206
3252
  const res = yield this.ctx.client.getPartner(partnerId);
3207
- __privateSet(this, _partner, res.data.partner);
3208
- return __privateGet(this, _partner);
3253
+ this.partner = res.data.partner;
3254
+ return this.partner;
3209
3255
  });
3210
3256
  };
3211
3257
  assertIsLinkingAccount_fn = function(types) {
@@ -3303,7 +3349,8 @@ createPregenWallet_fn = function(opts) {
3303
3349
  _isCreateGuestWalletsPending = new WeakMap();
3304
3350
  prepareAuthState_fn = function(_0) {
3305
3351
  return __async(this, arguments, function* (serverAuthState, opts = {}) {
3306
- if (!opts.sessionLookupId && serverAuthState.stage === "login") {
3352
+ var _a, _b;
3353
+ if (!opts.sessionLookupId && serverAuthState.stage === "login" && (!serverAuthState.externalWallet || !(((_a = serverAuthState.externalWallet) == null ? void 0 : _a.withFullParaAuth) && ((_b = serverAuthState.loginAuthMethods) == null ? void 0 : _b.includes(AuthMethod.PIN))))) {
3307
3354
  opts.sessionLookupId = yield this.prepareLogin();
3308
3355
  }
3309
3356
  const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
@@ -3352,9 +3399,9 @@ prepareLoginState_fn = function(_0, _1) {
3352
3399
  portalTheme,
3353
3400
  sessionLookupId
3354
3401
  }) {
3355
- const _a = loginState, { loginAuthMethods } = _a, authState = __objRest(_a, ["loginAuthMethods"]);
3356
- const isPasskeySupported = yield this.isPasskeySupported(), isPasskeyPossible = loginAuthMethods.includes(AuthMethod.PASSKEY) && !this.isNativePasskey, isPasswordPossible = loginAuthMethods.includes(AuthMethod.PASSWORD);
3357
- return __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
3402
+ const _a = loginState, { loginAuthMethods, hasPasswordWithoutPIN } = _a, authState = __objRest(_a, ["loginAuthMethods", "hasPasswordWithoutPIN"]);
3403
+ const isPasskeySupported = yield this.isPasskeySupported(), isPasskeyPossible = loginAuthMethods.includes(AuthMethod.PASSKEY) && !this.isNativePasskey, isPasswordPossible = loginAuthMethods.includes(AuthMethod.PASSWORD) && hasPasswordWithoutPIN, isPINPossible = loginAuthMethods.includes(AuthMethod.PIN);
3404
+ return __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
3358
3405
  isPasskeySupported
3359
3406
  }), isPasskeyPossible ? {
3360
3407
  passkeyUrl: yield this.getLoginUrl({ sessionId: sessionLookupId, shorten, portalTheme }),
@@ -3374,6 +3421,13 @@ prepareLoginState_fn = function(_0, _1) {
3374
3421
  portalTheme,
3375
3422
  params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
3376
3423
  })
3424
+ } : {}), isPINPossible ? {
3425
+ pinUrl: yield this.constructPortalUrl("loginPIN", {
3426
+ sessionId: sessionLookupId,
3427
+ shorten,
3428
+ portalTheme,
3429
+ params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
3430
+ })
3377
3431
  } : {});
3378
3432
  });
3379
3433
  };
@@ -3381,13 +3435,14 @@ prepareSignUpState_fn = function(_0, _1) {
3381
3435
  return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
3382
3436
  const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
3383
3437
  const isPasskeySupported = yield this.isPasskeySupported();
3384
- const [isPasskey, isPassword] = [
3438
+ const [isPasskey, isPassword, isPIN] = [
3385
3439
  signupAuthMethods.includes(AuthMethod.PASSKEY),
3386
- signupAuthMethods.includes(AuthMethod.PASSWORD) || !isPasskeySupported
3440
+ signupAuthMethods.includes(AuthMethod.PASSWORD) || !isPasskeySupported,
3441
+ signupAuthMethods.includes(AuthMethod.PIN)
3387
3442
  ];
3388
- if (!isPasskey && !isPassword) {
3443
+ if (!isPasskey && !isPassword && !isPIN) {
3389
3444
  throw new Error(
3390
- "No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys or passwords in your Developer Portal settings."
3445
+ "No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys, passwords or PINs in your Developer Portal settings."
3391
3446
  );
3392
3447
  }
3393
3448
  const signupState = __spreadProps(__spreadValues({}, authState), { isPasskeySupported });
@@ -3408,6 +3463,15 @@ prepareSignUpState_fn = function(_0, _1) {
3408
3463
  signupState.passwordUrl = passwordUrl;
3409
3464
  signupState.passwordId = passwordId;
3410
3465
  }
3466
+ if (isPIN) {
3467
+ const { url: pinUrl, credentialId: pinId } = yield this.getNewCredentialAndUrl({
3468
+ authMethod: "PIN",
3469
+ portalTheme,
3470
+ shorten
3471
+ });
3472
+ signupState.pinUrl = pinUrl;
3473
+ signupState.pinId = pinId;
3474
+ }
3411
3475
  return signupState;
3412
3476
  });
3413
3477
  };
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.39";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.41";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
5
5
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -59,7 +59,8 @@ const PARA_INTERNAL_METHODS = [
59
59
  "verifyTelegramLink",
60
60
  "verifyExternalWalletLink",
61
61
  "accountLinkInProgress",
62
- "prepareLogin"
62
+ "prepareLogin",
63
+ "sendLoginCode"
63
64
  ];
64
65
  export {
65
66
  PARA_CORE_METHODS,
@@ -1,4 +1,4 @@
1
- import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks, OnRampPurchase } from '@getpara/user-management-client';
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 } from '@getpara/user-management-client';
2
2
  import type { pki as pkiType } from 'node-forge';
3
3
  import { Ctx, Environment, Theme, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse } from './types/index.js';
4
4
  import { PlatformUtils } from './PlatformUtils.js';
@@ -16,6 +16,7 @@ export declare abstract class ParaCore implements CoreInterface {
16
16
  get telegramUserId(): AuthIdentifier<'telegram'> | undefined;
17
17
  get externalWalletWithParaAuth(): Wallet | undefined;
18
18
  get externalWalletConnectionType(): ExternalWalletConnectionType;
19
+ protected partner?: PartnerEntity;
19
20
  userId?: string;
20
21
  accountLinkInProgress: AccountLinkInProgress | undefined;
21
22
  private sessionCookie?;
@@ -31,6 +32,8 @@ export declare abstract class ParaCore implements CoreInterface {
31
32
  get isExternalWalletAuth(): boolean;
32
33
  get isExternalWalletWithVerification(): boolean;
33
34
  get partnerId(): string | undefined;
35
+ protected get partnerName(): string | undefined;
36
+ protected get partnerLogo(): string | undefined;
34
37
  /**
35
38
  * The IDs of the currently active wallets, for each supported wallet type. Any signer integrations will default to the first viable wallet ID in this dictionary.
36
39
  */
@@ -408,6 +411,9 @@ export declare abstract class ParaCore implements CoreInterface {
408
411
  **/
409
412
  isFullyLoggedIn(): CoreMethodResponse<'isFullyLoggedIn'>;
410
413
  get isGuestMode(): boolean;
414
+ /**
415
+ * Get the auth methods available to an existing user
416
+ */
411
417
  protected supportedAuthMethods(auth: Auth<PrimaryAuthType | 'userId'>): Promise<Set<AuthMethod>>;
412
418
  /**
413
419
  * Get hints associated with the users stored biometrics.
@@ -682,7 +688,7 @@ export declare abstract class ParaCore implements CoreInterface {
682
688
  url?: string;
683
689
  }>;
684
690
  /**
685
- * Returns a Para Portal URL for logging in with a WebAuth passkey or a password.
691
+ * Returns a Para Portal URL for logging in with a WebAuth passkey, password or PIN.
686
692
  * @param {Object} opts the options object
687
693
  * @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
688
694
  * @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
@@ -700,4 +706,5 @@ export declare abstract class ParaCore implements CoreInterface {
700
706
  accountLinkInProgress?: AccountLinkInProgress;
701
707
  } & Partial<Pick<VerifyLinkParams, 'verificationCode' | 'telegramAuthResponse'> & VerifyExternalWalletParams>): Promise<LinkedAccounts>;
702
708
  protected verifyEmailOrPhoneLink({ verificationCode, }: InternalMethodParams<'verifyEmailOrPhoneLink'>): InternalMethodResponse<'verifyEmailOrPhoneLink'>;
709
+ protected sendLoginCode(): Promise<void>;
703
710
  }
@@ -4,7 +4,7 @@ import { ParaCore } from '../ParaCore.js';
4
4
  import { FullSignatureRes, Wallet } from './wallet.js';
5
5
  import { AccountLinkInProgress } from './auth.js';
6
6
  export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress"];
7
- export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin"];
7
+ export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode"];
8
8
  export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
9
9
  export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
10
10
  params: infer P;
@@ -148,11 +148,11 @@ export type CoreMethods = Record<CoreMethodName, {
148
148
  };
149
149
  verifyExternalWallet: {
150
150
  params: AuthStateBaseParams & VerifyExternalWalletParams;
151
- response: AuthStateSignup;
151
+ response: AuthStateSignup | AuthStateLogin;
152
152
  };
153
153
  resendVerificationCode: {
154
154
  params: {
155
- type?: 'SIGNUP' | 'LINK_ACCOUNT';
155
+ type?: 'SIGNUP' | 'LINK_ACCOUNT' | 'LOGIN';
156
156
  } | undefined;
157
157
  response: void;
158
158
  };
@@ -526,6 +526,10 @@ export type InternalMethods = {
526
526
  params: void;
527
527
  response: string;
528
528
  };
529
+ sendLoginCode: {
530
+ params: void;
531
+ response: void;
532
+ };
529
533
  };
530
534
  export type CoreInterface = {
531
535
  [key in keyof CoreMethods]: Partial<CoreMethod<key>>;
@@ -14,7 +14,7 @@ export type VerifyExternalWalletV1 = {
14
14
  cosmosPublicKeyHex?: string;
15
15
  cosmosSigner?: string;
16
16
  };
17
- export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin';
17
+ export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN';
18
18
  export type PortalUrlOptions = {
19
19
  params?: Record<string, string | undefined | null>;
20
20
  isForNewDevice?: boolean;
@@ -28,7 +28,7 @@ export type PortalUrlOptions = {
28
28
  };
29
29
  export type WithAuthMethod = {
30
30
  /**
31
- * Which authorization method to use for the URL, either `'passkey'` or `'passwprd'`.
31
+ * Which authorization method to use for the URL, either `'passkey'` or `'password'`.
32
32
  */
33
33
  authMethod?: Uppercase<AuthMethod>;
34
34
  };
@@ -137,6 +137,10 @@ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & Wi
137
137
  * A Para Portal URL for logging in via a password.
138
138
  */
139
139
  passwordUrl?: string;
140
+ /**
141
+ * A Para Portal URL for logging in via a PIN.
142
+ */
143
+ pinUrl?: string;
140
144
  };
141
145
  export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
142
146
  /**
@@ -147,6 +151,10 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
147
151
  * A Para Portal URL for creating a new user password.
148
152
  */
149
153
  passwordUrl?: string;
154
+ /**
155
+ * A Para Portal URL for creating a new user PIN.
156
+ */
157
+ pinUrl?: string;
150
158
  /**
151
159
  * The Para system ID for the newly generated passkey.
152
160
  */
@@ -155,6 +163,10 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
155
163
  * The Para system ID for the newly generated password.
156
164
  */
157
165
  passwordId?: string;
166
+ /**
167
+ * The Para system ID for the newly generated PIN.
168
+ */
169
+ pinId?: string;
158
170
  };
159
171
  export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
160
172
  export type AuthStateSignupOrLogin = AuthStateSignup | AuthStateLogin;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.39",
3
+ "version": "2.0.0-alpha.41",
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.39",
8
+ "@getpara/user-management-client": "2.0.0-alpha.41",
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": "51cb61b1dd8c0b89ab7e779eb1d08e893883396b",
30
+ "gitHead": "1d153152b648828e13bed611ad479d48247642d1",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {