@metamask-previews/profile-sync-controller 32.1.1-preview-d3f9964be → 32.2.0-preview-aecbce4ff
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.
- package/CHANGELOG.md +16 -1
- package/README.md +21 -0
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts +43 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.ts +42 -1
- package/dist/controllers/authentication/AuthenticationController.d.ts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.js +167 -10
- package/dist/controllers/authentication/AuthenticationController.js.map +1 -1
- package/dist/controllers/authentication/index.d.ts +1 -1
- package/dist/controllers/authentication/index.d.ts.map +1 -1
- package/dist/controllers/authentication/index.js.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts +3 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js +3 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.d.ts +2 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.d.ts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.js +1 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.js.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/services.d.ts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/services.js +16 -11
- package/dist/sdk/authentication-jwt-bearer/mfa/services.js.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/types.d.ts +1 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/types.d.ts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/types.js.map +1 -1
- package/dist/sdk/authentication.d.ts +1 -0
- package/dist/sdk/authentication.d.ts.map +1 -1
- package/dist/sdk/authentication.js.map +1 -1
- package/dist/sdk/constants.d.ts +1 -0
- package/dist/sdk/constants.d.ts.map +1 -1
- package/dist/sdk/constants.js +1 -0
- package/dist/sdk/constants.js.map +1 -1
- package/dist/sdk/errors.d.ts +16 -1
- package/dist/sdk/errors.d.ts.map +1 -1
- package/dist/sdk/errors.js +18 -0
- package/dist/sdk/errors.js.map +1 -1
- package/package.json +9 -9
package/dist/sdk/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/sdk/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,OAAO,CAAyB;IAEhC,MAAM,CAAU;IAEhB,YAAY,CAAU;IAE/B,YACE,OAA+B,EAC/B,OAAe,EACf,OAAoD;QAEpD,KAAK,CAAC,OAAO,OAAO,MAAM,OAAO,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,CAAC;IAC5C,CAAC;CACF;AAED,MAAM,OAAO,8BAA+B,SAAQ,QAAQ;IAC1D,YACE,IAA8D,EAC9D,OAAe,EACf,MAAM,GAAG,iBAAiB,CAAC,QAAQ;QAEnC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AAED,MAAM,OAAO,0BAA2B,SAAQ,Q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faErrorCode } from './authentication-jwt-bearer/mfa/types.js';\nimport { HTTP_STATUS_CODES } from './constants.js';\nimport { asRecord } from './utils/as-record.js';\n\ntype ExtensibleMfaErrorCode = MfaErrorCode | (string & {});\n\n/**\n * Base error for MFA operations.\n *\n * The machine-readable code is an enumerable own property so it survives\n * JSON-RPC error serialization.\n */\nexport class MfaError extends Error {\n readonly mfaCode: ExtensibleMfaErrorCode;\n\n readonly status?: number;\n\n readonly retryAfterMs?: number;\n\n constructor(\n mfaCode: ExtensibleMfaErrorCode,\n message: string,\n options?: { status?: number; retryAfterMs?: number },\n ) {\n super(`MFA[${mfaCode}]: ${message}`);\n this.name = 'MfaError';\n this.mfaCode = mfaCode;\n this.status = options?.status;\n this.retryAfterMs = options?.retryAfterMs;\n }\n}\n\nexport class CredentialAlreadyEnrolledError extends MfaError {\n constructor(\n code: 'credential_already_enrolled' | 'email_already_enrolled',\n message: string,\n status = HTTP_STATUS_CODES.CONFLICT,\n ) {\n super(code, message, { status });\n this.name = 'CredentialAlreadyEnrolledError';\n }\n}\n\nexport class CredentialNotEnrolledError extends MfaError {\n constructor(message: string, status = HTTP_STATUS_CODES.CONFLICT) {\n super('credential_not_enrolled', message, { status });\n this.name = 'CredentialNotEnrolledError';\n }\n}\n\n/**\n * The begin/complete flow is stale or unknown; the client must restart it.\n */\nexport class MfaFlowExpiredError extends MfaError {\n constructor(\n code: 'flow_expired' | 'invalid_flow',\n message: string,\n status?: number,\n ) {\n super(code, message, { status });\n this.name = 'MfaFlowExpiredError';\n }\n}\n\n/**\n * The profile has no identity-provider record yet. Not a stale flow: the\n * user must enroll a first credential before verifying.\n */\nexport class MfaIdentityMissingError extends MfaError {\n constructor(message: string, status = HTTP_STATUS_CODES.CONFLICT) {\n super('mfa_identity_missing', message, { status });\n this.name = 'MfaIdentityMissingError';\n }\n}\n\nexport class MfaVerificationFailedError extends MfaError {\n constructor(\n code: 'invalid_code' | 'invalid_attestation' | 'invalid_assertion',\n message: string,\n status?: number,\n ) {\n super(code, message, { status });\n this.name = 'MfaVerificationFailedError';\n }\n}\n\nexport class TooManyAttemptsError extends MfaError {\n constructor(message: string, status?: number) {\n super('too_many_attempts', message, { status });\n this.name = 'TooManyAttemptsError';\n }\n}\n\nexport class MaxPasskeysReachedError extends MfaError {\n constructor(\n message: string,\n status = HTTP_STATUS_CODES.UNPROCESSABLE_ENTITY,\n ) {\n super('max_passkeys_reached', message, { status });\n this.name = 'MaxPasskeysReachedError';\n }\n}\n\nexport class MaxIdentifiersReachedError extends MfaError {\n constructor(message: string, status = HTTP_STATUS_CODES.CONFLICT) {\n super('max_identifiers_reached', message, { status });\n this.name = 'MaxIdentifiersReachedError';\n }\n}\n\nexport class OtpResendCooldownError extends MfaError {\n constructor(\n message: string,\n retryAfterMs?: number,\n status = HTTP_STATUS_CODES.TOO_MANY_REQUESTS,\n ) {\n super('otp_resend_cooldown', message, { status, retryAfterMs });\n this.name = 'OtpResendCooldownError';\n }\n}\n\n/**\n * A 429 without an MFA-specific code: generic throttling, not an OTP resend\n * cooldown.\n */\nexport class MfaRateLimitedError extends MfaError {\n constructor(\n message: string,\n retryAfterMs?: number,\n status = HTTP_STATUS_CODES.TOO_MANY_REQUESTS,\n ) {\n super('rate_limited', message, { status, retryAfterMs });\n this.name = 'MfaRateLimitedError';\n }\n}\n\n/**\n * The identity provider or the network is unreachable. Safe to retry.\n * `status` is only set when the service answered.\n */\nexport class MfaUnavailableError extends MfaError {\n constructor(message: string, status?: number) {\n super('kratos_unavailable', message, { status });\n this.name = 'MfaUnavailableError';\n }\n}\n\nexport class ElevatedTokenInvalidError extends MfaError {\n constructor(message: string) {\n super('elevated_token_invalid', message);\n this.name = 'ElevatedTokenInvalidError';\n }\n}\n\n/**\n * Gets an MFA code from direct, serialized, or message-only errors.\n *\n * @param error - Value to inspect.\n * @returns The stable code, if present.\n */\nexport function getMfaErrorCode(\n error: unknown,\n): ExtensibleMfaErrorCode | undefined {\n const direct = asRecord(error);\n if (typeof direct?.mfaCode === 'string') {\n return direct.mfaCode;\n }\n\n const data = asRecord(direct?.data);\n const cause = asRecord(data?.cause);\n if (typeof cause?.mfaCode === 'string') {\n return cause.mfaCode;\n }\n\n const messages = [direct?.message, cause?.message];\n for (const message of messages) {\n if (typeof message === 'string') {\n const match = /^MFA\\[([^\\]]+)\\]:/u.exec(message);\n if (match?.[1]) {\n return match[1];\n }\n }\n }\n return undefined;\n}\n\n/**\n * Checks whether a value carries an MFA error code.\n *\n * @param error - Value to inspect.\n * @param codes - Optional codes to match.\n * @returns Whether the value is an MFA error with a requested code.\n */\nexport function isMfaError(\n error: unknown,\n ...codes: ExtensibleMfaErrorCode[]\n): boolean {\n const code = getMfaErrorCode(error);\n return code !== undefined && (codes.length === 0 || codes.includes(code));\n}\n\n/**\n * Gets a retry delay from direct or serialized MFA errors.\n *\n * @param error - Value to inspect.\n * @returns Retry delay in milliseconds, if present.\n */\nexport function getMfaRetryAfterMs(error: unknown): number | undefined {\n const direct = asRecord(error);\n if (typeof direct?.retryAfterMs === 'number') {\n return direct.retryAfterMs;\n }\n const data = asRecord(direct?.data);\n const cause = asRecord(data?.cause);\n return typeof cause?.retryAfterMs === 'number'\n ? cause.retryAfterMs\n : undefined;\n}\n\nexport class NonceRetrievalError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'NonceRetrievalError';\n }\n}\n\nexport class SignInError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'SignInError';\n }\n}\n\nexport class PairError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'PairError';\n }\n}\n\n/**\n * Thrown when `POST /api/v2/profile/pair/identifier` returns 409 Conflict:\n * the social identifier already belongs to another canonical profile.\n * Retrying the same request cannot succeed.\n */\nexport class PairConflictError extends PairError {\n readonly status = HTTP_STATUS_CODES.CONFLICT;\n\n constructor(message: string) {\n super(message);\n this.name = 'PairConflictError';\n }\n}\n\n/**\n * Thrown when `POST /api/v2/oidc/token` returns 422: this profile has no\n * verified email on record. Consumers should send the user through email\n * OTP (or Google pair) and retry.\n */\nexport class EmailRequiredError extends Error {\n readonly status = HTTP_STATUS_CODES.UNPROCESSABLE_ENTITY;\n\n constructor(message: string) {\n super(message);\n this.name = 'EmailRequiredError';\n }\n}\n\nexport class UserStorageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UserStorageError';\n }\n}\n\nexport class ValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ValidationError';\n }\n}\n\nexport class UnsupportedAuthTypeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedAuthTypeError';\n }\n}\n\nexport class NotFoundError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'NotFoundError';\n }\n}\n\nexport class RateLimitedError extends Error {\n readonly status = HTTP_STATUS_CODES.TOO_MANY_REQUESTS;\n\n readonly retryAfterMs?: number;\n\n constructor(message: string, retryAfterMs?: number) {\n super(message);\n this.name = 'RateLimitedError';\n this.retryAfterMs = retryAfterMs;\n }\n\n /**\n * Check if an unknown error is a rate limit error (429 status).\n *\n * @param e - The error to check\n * @returns True if the error is a rate limit error\n */\n static isRateLimitError(e: unknown): e is RateLimitedError {\n return (\n e instanceof RateLimitedError ||\n (typeof e === 'object' &&\n e !== null &&\n 'status' in e &&\n e.status === HTTP_STATUS_CODES.TOO_MANY_REQUESTS)\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/sdk/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,OAAO,CAAyB;IAEhC,MAAM,CAAU;IAEhB,YAAY,CAAU;IAE/B,YACE,OAA+B,EAC/B,OAAe,EACf,OAAoD;QAEpD,KAAK,CAAC,OAAO,OAAO,MAAM,OAAO,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,IA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G,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,MAAM,GAAG,iBAAiB,CAAC,iBAAiB,CAAC;IAE7C,YAAY,CAAU;IAE/B,YAAY,OAAe,EAAE,YAAqB;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,CAAU;QAChC,OAAO,CACL,CAAC,YAAY,gBAAgB;YAC7B,CAAC,OAAO,CAAC,KAAK,QAAQ;gBACpB,CAAC,KAAK,IAAI;gBACV,QAAQ,IAAI,CAAC;gBACb,CAAC,CAAC,MAAM,KAAK,iBAAiB,CAAC,iBAAiB,CAAC,CACpD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { MfaErrorCode } from './authentication-jwt-bearer/mfa/types.js';\nimport { HTTP_STATUS_CODES } from './constants.js';\nimport { asRecord } from './utils/as-record.js';\n\ntype ExtensibleMfaErrorCode = MfaErrorCode | (string & {});\n\n/**\n * Base error for MFA operations.\n *\n * The machine-readable code is an enumerable own property so it survives\n * JSON-RPC error serialization.\n */\nexport class MfaError extends Error {\n readonly mfaCode: ExtensibleMfaErrorCode;\n\n readonly status?: number;\n\n readonly retryAfterMs?: number;\n\n constructor(\n mfaCode: ExtensibleMfaErrorCode,\n message: string,\n options?: { status?: number; retryAfterMs?: number },\n ) {\n super(`MFA[${mfaCode}]: ${message}`);\n this.name = 'MfaError';\n this.mfaCode = mfaCode;\n this.status = options?.status;\n this.retryAfterMs = options?.retryAfterMs;\n }\n}\n\n/**\n * The credential cannot be enrolled because an equivalent one already exists:\n * `email_already_enrolled` (this profile already has a verified email),\n * `email_socially_verified` (the email is verified through a social login), or\n * `credential_already_enrolled` (the email or passkey is enrolled on another\n * profile; the profiles must be paired or the credential removed).\n */\nexport class CredentialAlreadyEnrolledError extends MfaError {\n constructor(\n code:\n | 'credential_already_enrolled'\n | 'email_already_enrolled'\n | 'email_socially_verified',\n message: string,\n status = HTTP_STATUS_CODES.CONFLICT,\n ) {\n super(code, message, { status });\n this.name = 'CredentialAlreadyEnrolledError';\n }\n}\n\n/**\n * The profile already has MFA credentials, so enrolling another requires an\n * `aal:2` access token; the client must complete a step-up and retry with the\n * same flow.\n */\nexport class StepUpRequiredError extends MfaError {\n constructor(message: string, status = HTTP_STATUS_CODES.FORBIDDEN) {\n super('aal2_required', message, { status });\n this.name = 'StepUpRequiredError';\n }\n}\n\nexport class CredentialNotEnrolledError extends MfaError {\n constructor(message: string, status = HTTP_STATUS_CODES.CONFLICT) {\n super('credential_not_enrolled', message, { status });\n this.name = 'CredentialNotEnrolledError';\n }\n}\n\n/**\n * The begin/complete flow is stale or unknown; the client must restart it.\n */\nexport class MfaFlowExpiredError extends MfaError {\n constructor(\n code: 'flow_expired' | 'invalid_flow',\n message: string,\n status?: number,\n ) {\n super(code, message, { status });\n this.name = 'MfaFlowExpiredError';\n }\n}\n\n/**\n * The profile has no identity-provider record yet. Not a stale flow: the\n * user must enroll a first credential before verifying.\n */\nexport class MfaIdentityMissingError extends MfaError {\n constructor(message: string, status = HTTP_STATUS_CODES.CONFLICT) {\n super('mfa_identity_missing', message, { status });\n this.name = 'MfaIdentityMissingError';\n }\n}\n\nexport class MfaVerificationFailedError extends MfaError {\n constructor(\n code: 'invalid_code' | 'invalid_attestation' | 'invalid_assertion',\n message: string,\n status?: number,\n ) {\n super(code, message, { status });\n this.name = 'MfaVerificationFailedError';\n }\n}\n\nexport class TooManyAttemptsError extends MfaError {\n constructor(message: string, status?: number) {\n super('too_many_attempts', message, { status });\n this.name = 'TooManyAttemptsError';\n }\n}\n\nexport class MaxPasskeysReachedError extends MfaError {\n constructor(\n message: string,\n status = HTTP_STATUS_CODES.UNPROCESSABLE_ENTITY,\n ) {\n super('max_passkeys_reached', message, { status });\n this.name = 'MaxPasskeysReachedError';\n }\n}\n\nexport class MaxIdentifiersReachedError extends MfaError {\n constructor(message: string, status = HTTP_STATUS_CODES.CONFLICT) {\n super('max_identifiers_reached', message, { status });\n this.name = 'MaxIdentifiersReachedError';\n }\n}\n\nexport class OtpResendCooldownError extends MfaError {\n constructor(\n message: string,\n retryAfterMs?: number,\n status = HTTP_STATUS_CODES.TOO_MANY_REQUESTS,\n ) {\n super('otp_resend_cooldown', message, { status, retryAfterMs });\n this.name = 'OtpResendCooldownError';\n }\n}\n\n/**\n * A 429 without an MFA-specific code: generic throttling, not an OTP resend\n * cooldown.\n */\nexport class MfaRateLimitedError extends MfaError {\n constructor(\n message: string,\n retryAfterMs?: number,\n status = HTTP_STATUS_CODES.TOO_MANY_REQUESTS,\n ) {\n super('rate_limited', message, { status, retryAfterMs });\n this.name = 'MfaRateLimitedError';\n }\n}\n\n/**\n * The identity provider or the network is unreachable. Safe to retry.\n * `status` is only set when the service answered.\n */\nexport class MfaUnavailableError extends MfaError {\n constructor(message: string, status?: number) {\n super('kratos_unavailable', message, { status });\n this.name = 'MfaUnavailableError';\n }\n}\n\nexport class ElevatedTokenInvalidError extends MfaError {\n constructor(message: string) {\n super('elevated_token_invalid', message);\n this.name = 'ElevatedTokenInvalidError';\n }\n}\n\n/**\n * Gets an MFA code from direct, serialized, or message-only errors.\n *\n * @param error - Value to inspect.\n * @returns The stable code, if present.\n */\nexport function getMfaErrorCode(\n error: unknown,\n): ExtensibleMfaErrorCode | undefined {\n const direct = asRecord(error);\n if (typeof direct?.mfaCode === 'string') {\n return direct.mfaCode;\n }\n\n const data = asRecord(direct?.data);\n const cause = asRecord(data?.cause);\n if (typeof cause?.mfaCode === 'string') {\n return cause.mfaCode;\n }\n\n const messages = [direct?.message, cause?.message];\n for (const message of messages) {\n if (typeof message === 'string') {\n const match = /^MFA\\[([^\\]]+)\\]:/u.exec(message);\n if (match?.[1]) {\n return match[1];\n }\n }\n }\n return undefined;\n}\n\n/**\n * Checks whether a value carries an MFA error code.\n *\n * @param error - Value to inspect.\n * @param codes - Optional codes to match.\n * @returns Whether the value is an MFA error with a requested code.\n */\nexport function isMfaError(\n error: unknown,\n ...codes: ExtensibleMfaErrorCode[]\n): boolean {\n const code = getMfaErrorCode(error);\n return code !== undefined && (codes.length === 0 || codes.includes(code));\n}\n\n/**\n * Gets a retry delay from direct or serialized MFA errors.\n *\n * @param error - Value to inspect.\n * @returns Retry delay in milliseconds, if present.\n */\nexport function getMfaRetryAfterMs(error: unknown): number | undefined {\n const direct = asRecord(error);\n if (typeof direct?.retryAfterMs === 'number') {\n return direct.retryAfterMs;\n }\n const data = asRecord(direct?.data);\n const cause = asRecord(data?.cause);\n return typeof cause?.retryAfterMs === 'number'\n ? cause.retryAfterMs\n : undefined;\n}\n\nexport class NonceRetrievalError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'NonceRetrievalError';\n }\n}\n\nexport class SignInError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'SignInError';\n }\n}\n\nexport class PairError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'PairError';\n }\n}\n\n/**\n * Thrown when `POST /api/v2/profile/pair/identifier` returns 409 Conflict:\n * the social identifier already belongs to another canonical profile.\n * Retrying the same request cannot succeed.\n */\nexport class PairConflictError extends PairError {\n readonly status = HTTP_STATUS_CODES.CONFLICT;\n\n constructor(message: string) {\n super(message);\n this.name = 'PairConflictError';\n }\n}\n\n/**\n * Thrown when `POST /api/v2/oidc/token` returns 422: this profile has no\n * verified email on record. Consumers should send the user through email\n * OTP (or Google pair) and retry.\n */\nexport class EmailRequiredError extends Error {\n readonly status = HTTP_STATUS_CODES.UNPROCESSABLE_ENTITY;\n\n constructor(message: string) {\n super(message);\n this.name = 'EmailRequiredError';\n }\n}\n\nexport class UserStorageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UserStorageError';\n }\n}\n\nexport class ValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ValidationError';\n }\n}\n\nexport class UnsupportedAuthTypeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedAuthTypeError';\n }\n}\n\nexport class NotFoundError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'NotFoundError';\n }\n}\n\nexport class RateLimitedError extends Error {\n readonly status = HTTP_STATUS_CODES.TOO_MANY_REQUESTS;\n\n readonly retryAfterMs?: number;\n\n constructor(message: string, retryAfterMs?: number) {\n super(message);\n this.name = 'RateLimitedError';\n this.retryAfterMs = retryAfterMs;\n }\n\n /**\n * Check if an unknown error is a rate limit error (429 status).\n *\n * @param e - The error to check\n * @returns True if the error is a rate limit error\n */\n static isRateLimitError(e: unknown): e is RateLimitedError {\n return (\n e instanceof RateLimitedError ||\n (typeof e === 'object' &&\n e !== null &&\n 'status' in e &&\n e.status === HTTP_STATUS_CODES.TOO_MANY_REQUESTS)\n );\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/profile-sync-controller",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.2.0-preview-aecbce4ff",
|
|
4
4
|
"description": "The profile sync helps developers synchronize data across multiple clients and devices in a privacy-preserving way. All data saved in the user storage database is encrypted client-side to preserve privacy. The user storage provides a modular design, giving developers the flexibility to construct and manage their storage spaces in a way that best suits their needs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -86,13 +86,13 @@
|
|
|
86
86
|
"@noble/curves": "^1.9.2",
|
|
87
87
|
"@noble/hashes": "^1.8.0",
|
|
88
88
|
"@signinwithethereum/siwe": "^4.2.1",
|
|
89
|
-
"immer": "^9.0.
|
|
89
|
+
"immer": "^9.0.21",
|
|
90
90
|
"loglevel": "^1.8.1"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@lavamoat/allow-scripts": "^3.
|
|
93
|
+
"@lavamoat/allow-scripts": "^3.4.3",
|
|
94
94
|
"@lavamoat/preinstall-always-fail": "^2.1.0",
|
|
95
|
-
"@metamask/auto-changelog": "^6.1
|
|
95
|
+
"@metamask/auto-changelog": "^6.2.1",
|
|
96
96
|
"@metamask/eth-hd-keyring": "^15.0.0",
|
|
97
97
|
"@metamask/keyring-api": "^24.0.0",
|
|
98
98
|
"@metamask/keyring-internal-api": "^12.0.0",
|
|
@@ -101,13 +101,13 @@
|
|
|
101
101
|
"@types/jest": "^30.0.0",
|
|
102
102
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
103
103
|
"deepmerge": "^4.2.2",
|
|
104
|
-
"ethers": "^6.
|
|
104
|
+
"ethers": "^6.17.0",
|
|
105
105
|
"jest": "^30.4.2",
|
|
106
106
|
"jest-environment-jsdom": "^30.4.1",
|
|
107
|
-
"nock": "^13.
|
|
108
|
-
"rimraf": "^
|
|
109
|
-
"ts-jest": "^29.4.
|
|
110
|
-
"tsx": "^4.
|
|
107
|
+
"nock": "^13.5.6",
|
|
108
|
+
"rimraf": "^6.1.3",
|
|
109
|
+
"ts-jest": "^29.4.12",
|
|
110
|
+
"tsx": "^4.23.13",
|
|
111
111
|
"typedoc": "^0.25.13",
|
|
112
112
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
113
113
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|