@metamask-previews/seedless-onboarding-controller 7.1.0-preview-7cfbb337 → 7.1.0-preview-bea9ae5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,cAAc,EACf,sCAAsC;AAEvC,OAAO,EAAE,wCAAwC,EAAE,wBAAoB;AAGvE;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAC/C,SAAyB,EACzB,cAAsB;IAEtB,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,cAAc,CAAC,iBAAiB;YACnC,OAAO,wCAAwC,CAAC,oBAAoB,CAAC;QACvE,KAAK,cAAc,CAAC,2BAA2B;YAC7C,OAAO,wCAAwC,CAAC,iBAAiB,CAAC;QACpE,KAAK,cAAc,CAAC,qBAAqB;YACvC,OAAO,wCAAwC,CAAC,uBAAuB,CAAC;QAC1E,KAAK,cAAc,CAAC,gBAAgB;YAClC,OAAO,wCAAwC,CAAC,qBAAqB,CAAC;QACxE;YACE,OAAO,cAAc,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,qBAAqB,CAC5B,KAAiB;IAEjB,IACE,KAAK,CAAC,IAAI,IAAI,iCAAiC;QAC/C,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,iBAAiB;QAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,gBAAgB,KAAK,QAAQ;QAC/C,KAAK,CAAC,IAAI,CAAC,gBAAgB,KAAK,IAAI;QACpC,eAAe,IAAI,KAAK,CAAC,IAAI,CAAC,gBAAgB;QAC9C,OAAO,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,KAAK,QAAQ;QAC7D,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,gBAAgB;QACxC,OAAO,KAAK,CAAC,IAAI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AAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,8CAA8C,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,aAAa,CACtB,wCAAwC,CAAC,gBAAgB,CAC1D,CAAC;QACJ,CAAC;QAED,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAExD,MAAM,iBAAiB,GAAG,kBAAkB;YAC1C,CAAC,CAAC;gBACE,gBAAgB,EAAE,kBAAkB,CAAC,UAAU;gBAC/C,aAAa,EAAE,kBAAkB,CAAC,aAAa;aAChD;YACH,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,YAAY,GAAG,iCAAiC,CACpD,KAAK,CAAC,IAAI,EACV,wCAAwC,CAAC,gBAAgB,CAC1D,CAAC;QACF,OAAO,IAAI,aAAa,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["import {\n type RateLimitErrorData,\n TOPRFError,\n TOPRFErrorCode,\n} from '@metamask/toprf-secure-backup';\n\nimport { SeedlessOnboardingControllerErrorMessage } from './constants';\nimport type { RecoveryErrorData } from './types';\n\n/**\n * Get the error message from the TOPRF error code.\n *\n * @param errorCode - The TOPRF error code.\n * @param defaultMessage - The default error message if the error code is not found.\n * @returns The error message.\n */\nexport function getErrorMessageFromTOPRFErrorCode(\n errorCode: TOPRFErrorCode,\n defaultMessage: string,\n): string {\n switch (errorCode) {\n case TOPRFErrorCode.RateLimitExceeded:\n return SeedlessOnboardingControllerErrorMessage.TooManyLoginAttempts;\n case TOPRFErrorCode.CouldNotDeriveEncryptionKey:\n return SeedlessOnboardingControllerErrorMessage.IncorrectPassword;\n case TOPRFErrorCode.CouldNotFetchPassword:\n return SeedlessOnboardingControllerErrorMessage.CouldNotRecoverPassword;\n case TOPRFErrorCode.AuthTokenExpired:\n return SeedlessOnboardingControllerErrorMessage.InsufficientAuthToken;\n default:\n return defaultMessage;\n }\n}\n\n/**\n * Check if the provided error is a rate limit error triggered by too many login attempts.\n *\n * Return a new TooManyLoginAttemptsError if the error is a rate limit error, otherwise undefined.\n *\n * @param error - The error to check.\n * @returns The rate limit error if the error is a rate limit error, otherwise undefined.\n */\nfunction getRateLimitErrorData(\n error: TOPRFError,\n): RateLimitErrorData | undefined {\n if (\n error.meta && // error metadata must be present\n error.code === TOPRFErrorCode.RateLimitExceeded &&\n typeof error.meta.rateLimitDetails === 'object' &&\n error.meta.rateLimitDetails !== null &&\n 'remainingTime' in error.meta.rateLimitDetails &&\n typeof error.meta.rateLimitDetails.remainingTime === 'number' &&\n 'message' in error.meta.rateLimitDetails &&\n typeof error.meta.rateLimitDetails.message === 'string' &&\n 'lockTime' in error.meta.rateLimitDetails &&\n typeof error.meta.rateLimitDetails.lockTime === 'number' &&\n 'guessCount' in error.meta.rateLimitDetails &&\n typeof error.meta.rateLimitDetails.guessCount === 'number'\n ) {\n return {\n remainingTime: error.meta.rateLimitDetails.remainingTime,\n message: error.meta.rateLimitDetails.message,\n lockTime: error.meta.rateLimitDetails.lockTime,\n guessCount: error.meta.rateLimitDetails.guessCount,\n };\n }\n return undefined;\n}\n\n/**\n * The PasswordSyncError class is used to handle errors that occur during the password sync process.\n */\nexport class PasswordSyncError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'SeedlessOnboardingController - PasswordSyncError';\n }\n\n /**\n * Get an instance of the PasswordSyncError class.\n *\n * @param error - The error to get the instance of.\n * @returns The instance of the PasswordSyncError class.\n */\n static getInstance(error: unknown): PasswordSyncError {\n if (error instanceof TOPRFError) {\n const errorMessage = getErrorMessageFromTOPRFErrorCode(\n error.code,\n SeedlessOnboardingControllerErrorMessage.CouldNotRecoverPassword,\n );\n return new PasswordSyncError(errorMessage);\n }\n return new PasswordSyncError(\n SeedlessOnboardingControllerErrorMessage.CouldNotRecoverPassword,\n );\n }\n}\n\n/**\n * The RecoveryError class is used to handle errors that occur during the recover encryption key process from the passwrord.\n * It extends the Error class and includes a data property that can be used to store additional information.\n */\nexport class RecoveryError extends Error {\n data: RecoveryErrorData | undefined;\n\n constructor(message: string, data?: RecoveryErrorData) {\n super(message);\n this.data = data;\n this.name = 'SeedlessOnboardingController - RecoveryError';\n }\n\n /**\n * Get an instance of the RecoveryError class.\n *\n * @param error - The error to get the instance of.\n * @returns The instance of the RecoveryError class.\n */\n static getInstance(error: unknown): RecoveryError {\n if (!(error instanceof TOPRFError)) {\n return new RecoveryError(\n SeedlessOnboardingControllerErrorMessage.LoginFailedError,\n );\n }\n\n const rateLimitErrorData = getRateLimitErrorData(error);\n\n const recoveryErrorData = rateLimitErrorData\n ? {\n numberOfAttempts: rateLimitErrorData.guessCount,\n remainingTime: rateLimitErrorData.remainingTime,\n }\n : undefined;\n\n const errorMessage = getErrorMessageFromTOPRFErrorCode(\n error.code,\n SeedlessOnboardingControllerErrorMessage.LoginFailedError,\n );\n return new RecoveryError(errorMessage, recoveryErrorData);\n }\n}\n"]}
1
+ {"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,sCAAsC;AAG3E,OAAO,EAAE,wCAAwC,EAAE,wBAAoB;AAGvE;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAC/C,SAAyB,EACzB,cAAsB;IAEtB,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,cAAc,CAAC,iBAAiB;YACnC,OAAO,wCAAwC,CAAC,oBAAoB,CAAC;QACvE,KAAK,cAAc,CAAC,2BAA2B;YAC7C,OAAO,wCAAwC,CAAC,iBAAiB,CAAC;QACpE,KAAK,cAAc,CAAC,qBAAqB;YACvC,OAAO,wCAAwC,CAAC,uBAAuB,CAAC;QAC1E,KAAK,cAAc,CAAC,gBAAgB;YAClC,OAA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,CAAC;CACF","sourcesContent":["import { TOPRFError, TOPRFErrorCode } from '@metamask/toprf-secure-backup';\nimport type { RateLimitErrorData } from '@metamask/toprf-secure-backup';\n\nimport { SeedlessOnboardingControllerErrorMessage } from './constants';\nimport type { RecoveryErrorData } from './types';\n\n/**\n * Get the error message from the TOPRF error code.\n *\n * @param errorCode - The TOPRF error code.\n * @param defaultMessage - The default error message if the error code is not found.\n * @returns The error message.\n */\nexport function getErrorMessageFromTOPRFErrorCode(\n errorCode: TOPRFErrorCode,\n defaultMessage: string,\n): string {\n switch (errorCode) {\n case TOPRFErrorCode.RateLimitExceeded:\n return SeedlessOnboardingControllerErrorMessage.TooManyLoginAttempts;\n case TOPRFErrorCode.CouldNotDeriveEncryptionKey:\n return SeedlessOnboardingControllerErrorMessage.IncorrectPassword;\n case TOPRFErrorCode.CouldNotFetchPassword:\n return SeedlessOnboardingControllerErrorMessage.CouldNotRecoverPassword;\n case TOPRFErrorCode.AuthTokenExpired:\n return SeedlessOnboardingControllerErrorMessage.InsufficientAuthToken;\n default:\n return defaultMessage;\n }\n}\n\n/**\n * Check if the provided error is a rate limit error triggered by too many login attempts.\n *\n * Return a new TooManyLoginAttemptsError if the error is a rate limit error, otherwise undefined.\n *\n * @param error - The error to check.\n * @returns The rate limit error if the error is a rate limit error, otherwise undefined.\n */\nfunction getRateLimitErrorData(\n error: TOPRFError,\n): RateLimitErrorData | undefined {\n if (\n error.meta && // error metadata must be present\n error.code === TOPRFErrorCode.RateLimitExceeded &&\n typeof error.meta.rateLimitDetails === 'object' &&\n error.meta.rateLimitDetails !== null &&\n 'remainingTime' in error.meta.rateLimitDetails &&\n typeof error.meta.rateLimitDetails.remainingTime === 'number' &&\n 'message' in error.meta.rateLimitDetails &&\n typeof error.meta.rateLimitDetails.message === 'string' &&\n 'lockTime' in error.meta.rateLimitDetails &&\n typeof error.meta.rateLimitDetails.lockTime === 'number' &&\n 'guessCount' in error.meta.rateLimitDetails &&\n typeof error.meta.rateLimitDetails.guessCount === 'number'\n ) {\n return {\n remainingTime: error.meta.rateLimitDetails.remainingTime,\n message: error.meta.rateLimitDetails.message,\n lockTime: error.meta.rateLimitDetails.lockTime,\n guessCount: error.meta.rateLimitDetails.guessCount,\n };\n }\n return undefined;\n}\n\n/**\n * The PasswordSyncError class is used to handle errors that occur during the password sync process.\n */\nexport class PasswordSyncError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'SeedlessOnboardingController - PasswordSyncError';\n }\n\n /**\n * Get an instance of the PasswordSyncError class.\n *\n * @param error - The error to get the instance of.\n * @returns The instance of the PasswordSyncError class.\n */\n static getInstance(error: unknown): PasswordSyncError {\n if (error instanceof TOPRFError) {\n const errorMessage = getErrorMessageFromTOPRFErrorCode(\n error.code,\n SeedlessOnboardingControllerErrorMessage.CouldNotRecoverPassword,\n );\n return new PasswordSyncError(errorMessage);\n }\n return new PasswordSyncError(\n SeedlessOnboardingControllerErrorMessage.CouldNotRecoverPassword,\n );\n }\n}\n\n/**\n * The RecoveryError class is used to handle errors that occur during the recover encryption key process from the passwrord.\n * It extends the Error class and includes a data property that can be used to store additional information.\n */\nexport class RecoveryError extends Error {\n data: RecoveryErrorData | undefined;\n\n constructor(message: string, data?: RecoveryErrorData) {\n super(message);\n this.data = data;\n this.name = 'SeedlessOnboardingController - RecoveryError';\n }\n\n /**\n * Get an instance of the RecoveryError class.\n *\n * @param error - The error to get the instance of.\n * @returns The instance of the RecoveryError class.\n */\n static getInstance(error: unknown): RecoveryError {\n if (!(error instanceof TOPRFError)) {\n return new RecoveryError(\n SeedlessOnboardingControllerErrorMessage.LoginFailedError,\n );\n }\n\n const rateLimitErrorData = getRateLimitErrorData(error);\n\n const recoveryErrorData = rateLimitErrorData\n ? {\n numberOfAttempts: rateLimitErrorData.guessCount,\n remainingTime: rateLimitErrorData.remainingTime,\n }\n : undefined;\n\n const errorMessage = getErrorMessageFromTOPRFErrorCode(\n error.code,\n SeedlessOnboardingControllerErrorMessage.LoginFailedError,\n );\n return new RecoveryError(errorMessage, recoveryErrorData);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/seedless-onboarding-controller",
3
- "version": "7.1.0-preview-7cfbb337",
3
+ "version": "7.1.0-preview-bea9ae5",
4
4
  "description": "Backup and rehydrate SRP(s) using social login and password",
5
5
  "keywords": [
6
6
  "MetaMask",