@getpara/core-sdk 2.0.0-alpha.57 → 2.0.0-alpha.59

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.
@@ -627,6 +627,12 @@ const _ParaCore = class _ParaCore {
627
627
  if (typeof window === "undefined") return false;
628
628
  return !!((_a = window.location) == null ? void 0 : _a.host) && (0, import_utils2.getPortalBaseURL)(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host);
629
629
  }
630
+ isRecoveryPortal(envOverride) {
631
+ var _a, _b;
632
+ if (typeof window === "undefined") return false;
633
+ const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("getpara", "usecapsule");
634
+ return !!normalizedUrl && (0, import_utils2.getPortalBaseURL)(envOverride ? { env: envOverride } : this.ctx).includes(normalizedUrl);
635
+ }
630
636
  isParaConnect() {
631
637
  var _a;
632
638
  if (typeof window === "undefined") return false;
@@ -922,7 +928,7 @@ const _ParaCore = class _ParaCore {
922
928
  throw error;
923
929
  }
924
930
  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) {
925
- if (!session.partnerId) {
931
+ if (!session.partnerId && !this.isRecoveryPortal()) {
926
932
  this.displayModalError(
927
933
  `Invalid API Key. Please ensure you have a valid API key for the current environment: ${(_d = this.ctx.env) == null ? void 0 : _d.toUpperCase()}.`
928
934
  );
@@ -2771,6 +2777,7 @@ Need help? Visit: https://docs.getpara.com or contact support
2771
2777
  onCancel,
2772
2778
  onPoll
2773
2779
  }) {
2780
+ var _a;
2774
2781
  this.assertIsValidWalletId(walletId);
2775
2782
  const wallet = this.wallets[walletId];
2776
2783
  let signerId = this.userId;
@@ -2794,18 +2801,19 @@ Need help? Visit: https://docs.getpara.com or contact support
2794
2801
  break;
2795
2802
  }
2796
2803
  yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2804
+ let pendingTransaction;
2797
2805
  try {
2798
- yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
2806
+ pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2799
2807
  } catch (err) {
2800
2808
  const error = new import_errors.TransactionReviewDenied();
2801
2809
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
2802
2810
  throw error;
2803
2811
  }
2804
- signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2805
- if (signRes.pendingTransactionId) {
2812
+ if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
2806
2813
  onPoll == null ? void 0 : onPoll();
2807
2814
  continue;
2808
2815
  } else {
2816
+ signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2809
2817
  break;
2810
2818
  }
2811
2819
  }
@@ -2874,6 +2882,7 @@ Need help? Visit: https://docs.getpara.com or contact support
2874
2882
  onCancel,
2875
2883
  onPoll
2876
2884
  }) {
2885
+ var _a;
2877
2886
  this.assertIsValidWalletId(walletId);
2878
2887
  const wallet = this.wallets[walletId];
2879
2888
  let signerId = this.userId;
@@ -2906,27 +2915,28 @@ Need help? Visit: https://docs.getpara.com or contact support
2906
2915
  break;
2907
2916
  }
2908
2917
  yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2918
+ let pendingTransaction;
2909
2919
  try {
2910
- yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
2920
+ pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2911
2921
  } catch (err) {
2912
2922
  const error = new import_errors.TransactionReviewDenied();
2913
2923
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
2914
2924
  throw error;
2915
2925
  }
2916
- signRes = yield this.platformUtils.signTransaction(
2917
- this.ctx,
2918
- signerId,
2919
- walletId,
2920
- this.wallets[walletId].signer,
2921
- rlpEncodedTxBase64,
2922
- chainId,
2923
- this.retrieveSessionCookie(),
2924
- wallet.scheme === "DKLS"
2925
- );
2926
- if (signRes.pendingTransactionId) {
2926
+ if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
2927
2927
  onPoll == null ? void 0 : onPoll();
2928
2928
  continue;
2929
2929
  } else {
2930
+ signRes = yield this.platformUtils.signTransaction(
2931
+ this.ctx,
2932
+ signerId,
2933
+ walletId,
2934
+ this.wallets[walletId].signer,
2935
+ rlpEncodedTxBase64,
2936
+ chainId,
2937
+ this.retrieveSessionCookie(),
2938
+ wallet.scheme === "DKLS"
2939
+ );
2930
2940
  break;
2931
2941
  }
2932
2942
  }
@@ -3711,10 +3721,11 @@ prepareLoginState_fn = function(_0, _1) {
3711
3721
  portalTheme,
3712
3722
  sessionLookupId
3713
3723
  }) {
3714
- const _a = loginState, { loginAuthMethods, hasPasswordWithoutPIN } = _a, authState = __objRest(_a, ["loginAuthMethods", "hasPasswordWithoutPIN"]);
3724
+ const _a = loginState, { loginAuthMethods = [], hasPasswordWithoutPIN } = _a, authState = __objRest(_a, ["loginAuthMethods", "hasPasswordWithoutPIN"]);
3715
3725
  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);
3716
3726
  return __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
3717
- isPasskeySupported
3727
+ isPasskeySupported,
3728
+ loginAuthMethods
3718
3729
  }), isPasskeyPossible ? {
3719
3730
  passkeyUrl: yield this.getLoginUrl({ sessionId: sessionLookupId, shorten, portalTheme }),
3720
3731
  passkeyKnownDeviceUrl: yield this.constructPortalUrl("loginAuth", {
@@ -3745,7 +3756,7 @@ prepareLoginState_fn = function(_0, _1) {
3745
3756
  };
3746
3757
  prepareSignUpState_fn = function(_0, _1) {
3747
3758
  return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
3748
- const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
3759
+ const _a = serverSignupState, { signupAuthMethods = [] } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
3749
3760
  const isPasskeySupported = yield this.isPasskeySupported();
3750
3761
  const [isPasskey, isPassword, isPIN] = [
3751
3762
  signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY),
@@ -3757,7 +3768,10 @@ prepareSignUpState_fn = function(_0, _1) {
3757
3768
  "No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys, passwords or PINs in your Developer Portal settings."
3758
3769
  );
3759
3770
  }
3760
- const signupState = __spreadProps(__spreadValues({}, authState), { isPasskeySupported });
3771
+ const signupState = __spreadProps(__spreadValues({}, authState), {
3772
+ isPasskeySupported,
3773
+ signupAuthMethods
3774
+ });
3761
3775
  if (isPasskey) {
3762
3776
  const { url: passkeyUrl, credentialId: passkeyId } = yield this.getNewCredentialAndUrl({
3763
3777
  authMethod: "PASSKEY",
@@ -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.57";
46
+ const PARA_CORE_VERSION = "2.0.0-alpha.59";
47
47
  const PREFIX = "@CAPSULE/";
48
48
  const PARA_PREFIX = "@PARA/";
49
49
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -591,6 +591,12 @@ const _ParaCore = class _ParaCore {
591
591
  if (typeof window === "undefined") return false;
592
592
  return !!((_a = window.location) == null ? void 0 : _a.host) && getPortalBaseURL(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host);
593
593
  }
594
+ isRecoveryPortal(envOverride) {
595
+ var _a, _b;
596
+ if (typeof window === "undefined") return false;
597
+ const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("getpara", "usecapsule");
598
+ return !!normalizedUrl && getPortalBaseURL(envOverride ? { env: envOverride } : this.ctx).includes(normalizedUrl);
599
+ }
594
600
  isParaConnect() {
595
601
  var _a;
596
602
  if (typeof window === "undefined") return false;
@@ -886,7 +892,7 @@ const _ParaCore = class _ParaCore {
886
892
  throw error;
887
893
  }
888
894
  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) {
889
- if (!session.partnerId) {
895
+ if (!session.partnerId && !this.isRecoveryPortal()) {
890
896
  this.displayModalError(
891
897
  `Invalid API Key. Please ensure you have a valid API key for the current environment: ${(_d = this.ctx.env) == null ? void 0 : _d.toUpperCase()}.`
892
898
  );
@@ -2735,6 +2741,7 @@ Need help? Visit: https://docs.getpara.com or contact support
2735
2741
  onCancel,
2736
2742
  onPoll
2737
2743
  }) {
2744
+ var _a;
2738
2745
  this.assertIsValidWalletId(walletId);
2739
2746
  const wallet = this.wallets[walletId];
2740
2747
  let signerId = this.userId;
@@ -2758,18 +2765,19 @@ Need help? Visit: https://docs.getpara.com or contact support
2758
2765
  break;
2759
2766
  }
2760
2767
  yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2768
+ let pendingTransaction;
2761
2769
  try {
2762
- yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
2770
+ pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2763
2771
  } catch (err) {
2764
2772
  const error = new TransactionReviewDenied();
2765
2773
  dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
2766
2774
  throw error;
2767
2775
  }
2768
- signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2769
- if (signRes.pendingTransactionId) {
2776
+ if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
2770
2777
  onPoll == null ? void 0 : onPoll();
2771
2778
  continue;
2772
2779
  } else {
2780
+ signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2773
2781
  break;
2774
2782
  }
2775
2783
  }
@@ -2838,6 +2846,7 @@ Need help? Visit: https://docs.getpara.com or contact support
2838
2846
  onCancel,
2839
2847
  onPoll
2840
2848
  }) {
2849
+ var _a;
2841
2850
  this.assertIsValidWalletId(walletId);
2842
2851
  const wallet = this.wallets[walletId];
2843
2852
  let signerId = this.userId;
@@ -2870,27 +2879,28 @@ Need help? Visit: https://docs.getpara.com or contact support
2870
2879
  break;
2871
2880
  }
2872
2881
  yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2882
+ let pendingTransaction;
2873
2883
  try {
2874
- yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
2884
+ pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2875
2885
  } catch (err) {
2876
2886
  const error = new TransactionReviewDenied();
2877
2887
  dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
2878
2888
  throw error;
2879
2889
  }
2880
- signRes = yield this.platformUtils.signTransaction(
2881
- this.ctx,
2882
- signerId,
2883
- walletId,
2884
- this.wallets[walletId].signer,
2885
- rlpEncodedTxBase64,
2886
- chainId,
2887
- this.retrieveSessionCookie(),
2888
- wallet.scheme === "DKLS"
2889
- );
2890
- if (signRes.pendingTransactionId) {
2890
+ if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
2891
2891
  onPoll == null ? void 0 : onPoll();
2892
2892
  continue;
2893
2893
  } else {
2894
+ signRes = yield this.platformUtils.signTransaction(
2895
+ this.ctx,
2896
+ signerId,
2897
+ walletId,
2898
+ this.wallets[walletId].signer,
2899
+ rlpEncodedTxBase64,
2900
+ chainId,
2901
+ this.retrieveSessionCookie(),
2902
+ wallet.scheme === "DKLS"
2903
+ );
2894
2904
  break;
2895
2905
  }
2896
2906
  }
@@ -3675,10 +3685,11 @@ prepareLoginState_fn = function(_0, _1) {
3675
3685
  portalTheme,
3676
3686
  sessionLookupId
3677
3687
  }) {
3678
- const _a = loginState, { loginAuthMethods, hasPasswordWithoutPIN } = _a, authState = __objRest(_a, ["loginAuthMethods", "hasPasswordWithoutPIN"]);
3688
+ const _a = loginState, { loginAuthMethods = [], hasPasswordWithoutPIN } = _a, authState = __objRest(_a, ["loginAuthMethods", "hasPasswordWithoutPIN"]);
3679
3689
  const isPasskeySupported = yield this.isPasskeySupported(), isPasskeyPossible = loginAuthMethods.includes(AuthMethod.PASSKEY) && !this.isNativePasskey, isPasswordPossible = loginAuthMethods.includes(AuthMethod.PASSWORD) && hasPasswordWithoutPIN, isPINPossible = loginAuthMethods.includes(AuthMethod.PIN);
3680
3690
  return __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
3681
- isPasskeySupported
3691
+ isPasskeySupported,
3692
+ loginAuthMethods
3682
3693
  }), isPasskeyPossible ? {
3683
3694
  passkeyUrl: yield this.getLoginUrl({ sessionId: sessionLookupId, shorten, portalTheme }),
3684
3695
  passkeyKnownDeviceUrl: yield this.constructPortalUrl("loginAuth", {
@@ -3709,7 +3720,7 @@ prepareLoginState_fn = function(_0, _1) {
3709
3720
  };
3710
3721
  prepareSignUpState_fn = function(_0, _1) {
3711
3722
  return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
3712
- const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
3723
+ const _a = serverSignupState, { signupAuthMethods = [] } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
3713
3724
  const isPasskeySupported = yield this.isPasskeySupported();
3714
3725
  const [isPasskey, isPassword, isPIN] = [
3715
3726
  signupAuthMethods.includes(AuthMethod.PASSKEY),
@@ -3721,7 +3732,10 @@ prepareSignUpState_fn = function(_0, _1) {
3721
3732
  "No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys, passwords or PINs in your Developer Portal settings."
3722
3733
  );
3723
3734
  }
3724
- const signupState = __spreadProps(__spreadValues({}, authState), { isPasskeySupported });
3735
+ const signupState = __spreadProps(__spreadValues({}, authState), {
3736
+ isPasskeySupported,
3737
+ signupAuthMethods
3738
+ });
3725
3739
  if (isPasskey) {
3726
3740
  const { url: passkeyUrl, credentialId: passkeyId } = yield this.getNewCredentialAndUrl({
3727
3741
  authMethod: "PASSKEY",
@@ -1,5 +1,5 @@
1
1
  import "./chunk-W5CT3TVS.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.57";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.59";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const PARA_PREFIX = "@PARA/";
5
5
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -163,6 +163,7 @@ export declare abstract class ParaCore implements CoreInterface {
163
163
  private convertBigInt;
164
164
  private convertEncryptionKeyPair;
165
165
  protected isPortal(envOverride?: Environment): boolean;
166
+ protected isRecoveryPortal(envOverride?: Environment): boolean;
166
167
  private isParaConnect;
167
168
  private requireApiKey;
168
169
  private isWalletSupported;
@@ -146,6 +146,10 @@ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & Wi
146
146
  * A Para Portal URL for logging in via a PIN.
147
147
  */
148
148
  pinUrl?: string;
149
+ /**
150
+ * Supported login auth methods for this session.
151
+ */
152
+ loginAuthMethods?: AuthMethod[];
149
153
  };
150
154
  export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
151
155
  /**
@@ -172,8 +176,14 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
172
176
  * The Para system ID for the newly generated PIN.
173
177
  */
174
178
  pinId?: string;
179
+ /**
180
+ * Supported signup auth methods for this session.
181
+ */
182
+ signupAuthMethods?: AuthMethod[];
183
+ };
184
+ export type AuthStateDone = Omit<ServerAuthStateDone, 'authMethods'> & {
185
+ authMethods: AuthMethod[];
175
186
  };
176
- export type AuthStateDone = ServerAuthStateDone;
177
187
  export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
178
188
  export type AuthStateSignupOrLoginOrDone = AuthStateSignup | AuthStateLogin | AuthStateDone;
179
189
  export type OAuthResponse = AuthStateSignupOrLoginOrDone;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.57",
3
+ "version": "2.0.0-alpha.59",
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.57",
8
+ "@getpara/user-management-client": "2.0.0-alpha.59",
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": "6af8b61e587b4c2f3cd0f8d8accc2f0878667552",
30
+ "gitHead": "e15908ac8eafff6f3b264fffa43742870b14b275",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {