@account-kit/signer 4.27.0 → 4.28.1

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.
@@ -17,25 +17,12 @@ import type {
17
17
  OauthConfig,
18
18
  OtpParams,
19
19
  User,
20
- MfaFactor,
21
- EnableMfaParams,
22
- EnableMfaResult,
23
- VerifyMfaParams,
24
- RemoveMfaParams,
25
20
  SubmitOtpCodeResponse,
26
- ValidateMultiFactorsParams,
27
21
  } from "./types.js";
28
- import { MfaRequiredError, NotAuthenticatedError } from "../errors.js";
22
+ import { MfaRequiredError } from "../errors.js";
29
23
  import { parseMfaError } from "../utils/parseMfaError.js";
30
24
 
31
25
  const CHECK_CLOSE_INTERVAL = 500;
32
- const MFA_PAYLOAD = {
33
- GET: "get_mfa",
34
- ADD: "add_mfa",
35
- DELETE: "delete_mfas",
36
- VERIFY: "verify_mfa",
37
- LIST: "list_mfas",
38
- };
39
26
 
40
27
  export const AlchemySignerClientParamsSchema = z.object({
41
28
  connection: ConnectionConfigSchema,
@@ -722,169 +709,6 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
722
709
  const nonce = this.getOauthNonce(publicKey);
723
710
  return this.request("/v1/prepare-oauth", { nonce });
724
711
  };
725
-
726
- /**
727
- * Retrieves the list of MFA factors configured for the current user.
728
- *
729
- * @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to an array of configured MFA factors
730
- * @throws {NotAuthenticatedError} If no user is authenticated
731
- */
732
- public override getMfaFactors = async (): Promise<{
733
- multiFactors: MfaFactor[];
734
- }> => {
735
- if (!this.user) {
736
- throw new NotAuthenticatedError();
737
- }
738
-
739
- const stampedRequest = await this.turnkeyClient.stampSignRawPayload({
740
- organizationId: this.user.orgId,
741
- type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
742
- timestampMs: Date.now().toString(),
743
- parameters: {
744
- encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
745
- hashFunction: "HASH_FUNCTION_NO_OP",
746
- payload: MFA_PAYLOAD.LIST,
747
- signWith: this.user.address,
748
- },
749
- });
750
-
751
- return this.request("/v1/auth-list-multi-factors", {
752
- stampedRequest,
753
- });
754
- };
755
-
756
- /**
757
- * Initiates the setup of a new MFA factor for the current user. Mfa will need to be verified before it is active.
758
- *
759
- * @param {EnableMfaParams} params The parameters required to enable a new MFA factor
760
- * @returns {Promise<EnableMfaResult>} A promise that resolves to the factor setup information
761
- * @throws {NotAuthenticatedError} If no user is authenticated
762
- * @throws {Error} If an unsupported factor type is provided
763
- */
764
- public override addMfa = async (
765
- params: EnableMfaParams
766
- ): Promise<EnableMfaResult> => {
767
- if (!this.user) {
768
- throw new NotAuthenticatedError();
769
- }
770
-
771
- const stampedRequest = await this.turnkeyClient.stampSignRawPayload({
772
- organizationId: this.user.orgId,
773
- type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
774
- timestampMs: Date.now().toString(),
775
- parameters: {
776
- encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
777
- hashFunction: "HASH_FUNCTION_NO_OP",
778
- payload: MFA_PAYLOAD.ADD,
779
- signWith: this.user.address,
780
- },
781
- });
782
-
783
- switch (params.multiFactorType) {
784
- case "totp":
785
- return this.request("/v1/auth-request-multi-factor", {
786
- stampedRequest,
787
- multiFactorType: params.multiFactorType,
788
- });
789
- default:
790
- throw new Error(
791
- `Unsupported MFA factor type: ${params.multiFactorType}`
792
- );
793
- }
794
- };
795
-
796
- /**
797
- * Verifies a newly created MFA factor to complete the setup process.
798
- *
799
- * @param {VerifyMfaParams} params The parameters required to verify the MFA factor
800
- * @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors
801
- * @throws {NotAuthenticatedError} If no user is authenticated
802
- */
803
- public override verifyMfa = async (
804
- params: VerifyMfaParams
805
- ): Promise<{ multiFactors: MfaFactor[] }> => {
806
- if (!this.user) {
807
- throw new NotAuthenticatedError();
808
- }
809
-
810
- const stampedRequest = await this.turnkeyClient.stampSignRawPayload({
811
- organizationId: this.user.orgId,
812
- type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
813
- timestampMs: Date.now().toString(),
814
- parameters: {
815
- encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
816
- hashFunction: "HASH_FUNCTION_NO_OP",
817
- payload: MFA_PAYLOAD.VERIFY,
818
- signWith: this.user.address,
819
- },
820
- });
821
-
822
- return this.request("/v1/auth-verify-multi-factor", {
823
- stampedRequest,
824
- multiFactorId: params.multiFactorId,
825
- multiFactorCode: params.multiFactorCode,
826
- });
827
- };
828
-
829
- /**
830
- * Removes existing MFA factors by ID.
831
- *
832
- * @param {RemoveMfaParams} params The parameters specifying which factors to disable
833
- * @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors
834
- * @throws {NotAuthenticatedError} If no user is authenticated
835
- */
836
- public override removeMfa = async (
837
- params: RemoveMfaParams
838
- ): Promise<{ multiFactors: MfaFactor[] }> => {
839
- if (!this.user) {
840
- throw new NotAuthenticatedError();
841
- }
842
-
843
- const stampedRequest = await this.turnkeyClient.stampSignRawPayload({
844
- organizationId: this.user.orgId,
845
- type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
846
- timestampMs: Date.now().toString(),
847
- parameters: {
848
- encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
849
- hashFunction: "HASH_FUNCTION_NO_OP",
850
- payload: MFA_PAYLOAD.DELETE,
851
- signWith: this.user.address,
852
- },
853
- });
854
-
855
- return this.request("/v1/auth-delete-multi-factors", {
856
- stampedRequest,
857
- multiFactorIds: params.multiFactorIds,
858
- });
859
- };
860
-
861
- /**
862
- * Validates multiple MFA factors using the provided encrypted payload and MFA codes.
863
- *
864
- * @param {ValidateMultiFactorsParams} params The validation parameters
865
- * @returns {Promise<{ bundle: string }>} A promise that resolves to an object containing the credential bundle
866
- * @throws {Error} If no credential bundle is returned from the server
867
- */
868
- public override async validateMultiFactors(
869
- params: ValidateMultiFactorsParams
870
- ): Promise<{ bundle: string }> {
871
- // Send the encryptedPayload plus TOTP codes, etc:
872
- const response = await this.request("/v1/auth-validate-multi-factors", {
873
- encryptedPayload: params.encryptedPayload,
874
- multiFactors: params.multiFactors,
875
- });
876
-
877
- // The server is expected to return the *decrypted* payload in `response.payload.credentialBundle`
878
- if (!response.payload || !response.payload.credentialBundle) {
879
- throw new Error(
880
- "Request to validateMultiFactors did not return a credential bundle"
881
- );
882
- }
883
-
884
- return {
885
- bundle: response.payload.credentialBundle,
886
- };
887
- }
888
712
  }
889
713
 
890
714
  /**
@@ -208,7 +208,7 @@ export type SignerEndpoints = [
208
208
  stampedRequest: TSignedRequest;
209
209
  multiFactorType: MultiFactorType;
210
210
  };
211
- Response: EnableMfaResult;
211
+ Response: AddMfaResult;
212
212
  },
213
213
  {
214
214
  Route: "/v1/auth-verify-multi-factor";
@@ -287,11 +287,11 @@ export type MfaFactor = {
287
287
 
288
288
  type MultiFactorType = "totp";
289
289
 
290
- export type EnableMfaParams = {
290
+ export type AddMfaParams = {
291
291
  multiFactorType: MultiFactorType;
292
292
  };
293
293
 
294
- export type EnableMfaResult = {
294
+ export type AddMfaResult = {
295
295
  multiFactorType: MultiFactorType;
296
296
  multiFactorId: string;
297
297
  multiFactorTotpUrl: string;
@@ -308,10 +308,7 @@ export type RemoveMfaParams = {
308
308
 
309
309
  export type ValidateMultiFactorsParams = {
310
310
  encryptedPayload: string;
311
- multiFactors: Array<{
312
- multiFactorId: string;
313
- multiFactorCode: string;
314
- }>;
311
+ multiFactors: VerifyMfaParams[];
315
312
  };
316
313
 
317
314
  export type MfaChallenge = {
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.27.0";
3
+ export const VERSION = "4.28.1";