@metamask-previews/profile-sync-controller 32.1.1-preview-c6cdff1dd → 32.1.1-preview-db287901b
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 +0 -2
- package/dist/controllers/authentication/AuthenticationController.d.ts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.js +5 -6
- package/dist/controllers/authentication/AuthenticationController.js.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.ts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.js +5 -6
- package/dist/controllers/user-storage/UserStorageController.js.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts +1 -56
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js +1 -119
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +1 -1
- package/dist/sdk/authentication.d.ts +6 -15
- package/dist/sdk/authentication.d.ts.map +1 -1
- package/dist/sdk/authentication.js +0 -24
- package/dist/sdk/authentication.js.map +1 -1
- package/dist/sdk/constants.d.ts +0 -2
- package/dist/sdk/constants.d.ts.map +1 -1
- package/dist/sdk/constants.js +0 -2
- package/dist/sdk/constants.js.map +1 -1
- package/dist/sdk/errors.d.ts +0 -91
- package/dist/sdk/errors.d.ts.map +1 -1
- package/dist/sdk/errors.js +0 -161
- package/dist/sdk/errors.js.map +1 -1
- package/dist/sdk/index.d.ts +0 -3
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +0 -1
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/mocks/auth.d.ts +0 -63
- package/dist/sdk/mocks/auth.d.ts.map +1 -1
- package/dist/sdk/mocks/auth.js +0 -90
- package/dist/sdk/mocks/auth.js.map +1 -1
- package/dist/sdk/utils/validate-login-response.d.ts.map +1 -1
- package/dist/sdk/utils/validate-login-response.js +7 -5
- package/dist/sdk/utils/validate-login-response.js.map +1 -1
- package/dist/shared/utils/entropy-source.d.ts +12 -3
- package/dist/shared/utils/entropy-source.d.ts.map +1 -1
- package/dist/shared/utils/entropy-source.js +17 -4
- package/dist/shared/utils/entropy-source.js.map +1 -1
- package/package.json +1 -3
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.d.ts +0 -691
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.js +0 -265
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/services.d.ts +0 -104
- package/dist/sdk/authentication-jwt-bearer/mfa/services.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/services.js +0 -363
- package/dist/sdk/authentication-jwt-bearer/mfa/services.js.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/types.d.ts +0 -125
- package/dist/sdk/authentication-jwt-bearer/mfa/types.d.ts.map +0 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/types.js +0 -3
- package/dist/sdk/authentication-jwt-bearer/mfa/types.js.map +0 -1
- package/dist/sdk/utils/as-record.d.ts +0 -10
- package/dist/sdk/utils/as-record.d.ts.map +0 -1
- package/dist/sdk/utils/as-record.js +0 -14
- package/dist/sdk/utils/as-record.js.map +0 -1
- package/dist/sdk/utils/jwt.d.ts +0 -13
- package/dist/sdk/utils/jwt.d.ts.map +0 -1
- package/dist/sdk/utils/jwt.js +0 -21
- package/dist/sdk/utils/jwt.js.map +0 -1
- package/dist/sdk/utils/to-error-message.d.ts +0 -8
- package/dist/sdk/utils/to-error-message.d.ts.map +0 -1
- package/dist/sdk/utils/to-error-message.js +0 -10
- package/dist/sdk/utils/to-error-message.js.map +0 -1
package/dist/sdk/errors.js
CHANGED
|
@@ -1,165 +1,4 @@
|
|
|
1
1
|
import { HTTP_STATUS_CODES } from './constants.js';
|
|
2
|
-
import { asRecord } from './utils/as-record.js';
|
|
3
|
-
/**
|
|
4
|
-
* Base error for MFA operations.
|
|
5
|
-
*
|
|
6
|
-
* The machine-readable code is an enumerable own property so it survives
|
|
7
|
-
* JSON-RPC error serialization.
|
|
8
|
-
*/
|
|
9
|
-
export class MfaError extends Error {
|
|
10
|
-
mfaCode;
|
|
11
|
-
status;
|
|
12
|
-
retryAfterMs;
|
|
13
|
-
constructor(mfaCode, message, options) {
|
|
14
|
-
super(`MFA[${mfaCode}]: ${message}`);
|
|
15
|
-
this.name = 'MfaError';
|
|
16
|
-
this.mfaCode = mfaCode;
|
|
17
|
-
this.status = options?.status;
|
|
18
|
-
this.retryAfterMs = options?.retryAfterMs;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export class CredentialAlreadyEnrolledError extends MfaError {
|
|
22
|
-
constructor(code, message, status = HTTP_STATUS_CODES.CONFLICT) {
|
|
23
|
-
super(code, message, { status });
|
|
24
|
-
this.name = 'CredentialAlreadyEnrolledError';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export class CredentialNotEnrolledError extends MfaError {
|
|
28
|
-
constructor(message, status = HTTP_STATUS_CODES.CONFLICT) {
|
|
29
|
-
super('credential_not_enrolled', message, { status });
|
|
30
|
-
this.name = 'CredentialNotEnrolledError';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The begin/complete flow is stale or unknown; the client must restart it.
|
|
35
|
-
*/
|
|
36
|
-
export class MfaFlowExpiredError extends MfaError {
|
|
37
|
-
constructor(code, message, status) {
|
|
38
|
-
super(code, message, { status });
|
|
39
|
-
this.name = 'MfaFlowExpiredError';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The profile has no identity-provider record yet. Not a stale flow: the
|
|
44
|
-
* user must enroll a first credential before verifying.
|
|
45
|
-
*/
|
|
46
|
-
export class MfaIdentityMissingError extends MfaError {
|
|
47
|
-
constructor(message, status = HTTP_STATUS_CODES.CONFLICT) {
|
|
48
|
-
super('mfa_identity_missing', message, { status });
|
|
49
|
-
this.name = 'MfaIdentityMissingError';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export class MfaVerificationFailedError extends MfaError {
|
|
53
|
-
constructor(code, message, status) {
|
|
54
|
-
super(code, message, { status });
|
|
55
|
-
this.name = 'MfaVerificationFailedError';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export class TooManyAttemptsError extends MfaError {
|
|
59
|
-
constructor(message, status) {
|
|
60
|
-
super('too_many_attempts', message, { status });
|
|
61
|
-
this.name = 'TooManyAttemptsError';
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export class MaxPasskeysReachedError extends MfaError {
|
|
65
|
-
constructor(message, status = HTTP_STATUS_CODES.UNPROCESSABLE_ENTITY) {
|
|
66
|
-
super('max_passkeys_reached', message, { status });
|
|
67
|
-
this.name = 'MaxPasskeysReachedError';
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export class MaxIdentifiersReachedError extends MfaError {
|
|
71
|
-
constructor(message, status = HTTP_STATUS_CODES.CONFLICT) {
|
|
72
|
-
super('max_identifiers_reached', message, { status });
|
|
73
|
-
this.name = 'MaxIdentifiersReachedError';
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
export class OtpResendCooldownError extends MfaError {
|
|
77
|
-
constructor(message, retryAfterMs, status = HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {
|
|
78
|
-
super('otp_resend_cooldown', message, { status, retryAfterMs });
|
|
79
|
-
this.name = 'OtpResendCooldownError';
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* A 429 without an MFA-specific code: generic throttling, not an OTP resend
|
|
84
|
-
* cooldown.
|
|
85
|
-
*/
|
|
86
|
-
export class MfaRateLimitedError extends MfaError {
|
|
87
|
-
constructor(message, retryAfterMs, status = HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {
|
|
88
|
-
super('rate_limited', message, { status, retryAfterMs });
|
|
89
|
-
this.name = 'MfaRateLimitedError';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* The identity provider or the network is unreachable. Safe to retry.
|
|
94
|
-
* `status` is only set when the service answered.
|
|
95
|
-
*/
|
|
96
|
-
export class MfaUnavailableError extends MfaError {
|
|
97
|
-
constructor(message, status) {
|
|
98
|
-
super('kratos_unavailable', message, { status });
|
|
99
|
-
this.name = 'MfaUnavailableError';
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export class ElevatedTokenInvalidError extends MfaError {
|
|
103
|
-
constructor(message) {
|
|
104
|
-
super('elevated_token_invalid', message);
|
|
105
|
-
this.name = 'ElevatedTokenInvalidError';
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Gets an MFA code from direct, serialized, or message-only errors.
|
|
110
|
-
*
|
|
111
|
-
* @param error - Value to inspect.
|
|
112
|
-
* @returns The stable code, if present.
|
|
113
|
-
*/
|
|
114
|
-
export function getMfaErrorCode(error) {
|
|
115
|
-
const direct = asRecord(error);
|
|
116
|
-
if (typeof direct?.mfaCode === 'string') {
|
|
117
|
-
return direct.mfaCode;
|
|
118
|
-
}
|
|
119
|
-
const data = asRecord(direct?.data);
|
|
120
|
-
const cause = asRecord(data?.cause);
|
|
121
|
-
if (typeof cause?.mfaCode === 'string') {
|
|
122
|
-
return cause.mfaCode;
|
|
123
|
-
}
|
|
124
|
-
const messages = [direct?.message, cause?.message];
|
|
125
|
-
for (const message of messages) {
|
|
126
|
-
if (typeof message === 'string') {
|
|
127
|
-
const match = /^MFA\[([^\]]+)\]:/u.exec(message);
|
|
128
|
-
if (match?.[1]) {
|
|
129
|
-
return match[1];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return undefined;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Checks whether a value carries an MFA error code.
|
|
137
|
-
*
|
|
138
|
-
* @param error - Value to inspect.
|
|
139
|
-
* @param codes - Optional codes to match.
|
|
140
|
-
* @returns Whether the value is an MFA error with a requested code.
|
|
141
|
-
*/
|
|
142
|
-
export function isMfaError(error, ...codes) {
|
|
143
|
-
const code = getMfaErrorCode(error);
|
|
144
|
-
return code !== undefined && (codes.length === 0 || codes.includes(code));
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Gets a retry delay from direct or serialized MFA errors.
|
|
148
|
-
*
|
|
149
|
-
* @param error - Value to inspect.
|
|
150
|
-
* @returns Retry delay in milliseconds, if present.
|
|
151
|
-
*/
|
|
152
|
-
export function getMfaRetryAfterMs(error) {
|
|
153
|
-
const direct = asRecord(error);
|
|
154
|
-
if (typeof direct?.retryAfterMs === 'number') {
|
|
155
|
-
return direct.retryAfterMs;
|
|
156
|
-
}
|
|
157
|
-
const data = asRecord(direct?.data);
|
|
158
|
-
const cause = asRecord(data?.cause);
|
|
159
|
-
return typeof cause?.retryAfterMs === 'number'
|
|
160
|
-
? cause.retryAfterMs
|
|
161
|
-
: undefined;
|
|
162
|
-
}
|
|
163
2
|
export class NonceRetrievalError extends Error {
|
|
164
3
|
constructor(message) {
|
|
165
4
|
super(message);
|
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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AY,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\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_REQUEST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AAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,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 { HTTP_STATUS_CODES } from './constants.js';\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/dist/sdk/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export * from './authentication.js';
|
|
2
|
-
export { MFA_CREDENTIAL_TYPES } from './authentication-jwt-bearer/mfa/types.js';
|
|
3
|
-
export type { MfaCredentialType, MfaCredentialStatus, MfaErrorCode, EnrolledCredential, TokenReason, EnrollmentChallenge, EnrollmentProof, StepUpChallenge, StepUpProof, ElevatedProfileToken, BeginEnrollmentRequest, CompleteEnrollmentRequest, BeginStepUpRequest, CompleteStepUpRequest, GetElevatedTokenRequest, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON, AuthenticationResponseJSON, } from './authentication-jwt-bearer/mfa/types.js';
|
|
4
|
-
export type { MfaStepUpAssertion } from './authentication-jwt-bearer/mfa/services.js';
|
|
5
2
|
export * from './user-storage.js';
|
|
6
3
|
export * from './errors.js';
|
|
7
4
|
export * from './utils/messaging-signing-snap-requests.js';
|
package/dist/sdk/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,4CAA4C,CAAC;AAC3D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC"}
|
package/dist/sdk/index.js
CHANGED
package/dist/sdk/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,4CAA4C,CAAC;AAC3D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC","sourcesContent":["export * from './authentication.js';\nexport * from './user-storage.js';\nexport * from './errors.js';\nexport * from './utils/messaging-signing-snap-requests.js';\nexport * from '../shared/encryption/index.js';\nexport * from '../shared/env.js';\nexport * from '../shared/storage-schema.js';\n"]}
|
package/dist/sdk/mocks/auth.d.ts
CHANGED
|
@@ -9,69 +9,6 @@ export declare const MOCK_PAIR_SOCIAL_IDENTIFIER_URL: string;
|
|
|
9
9
|
export declare const MOCK_PROFILE_LINEAGE_URL: string;
|
|
10
10
|
export declare const MOCK_CUSTOMER_SERVICE_TOKEN_URL: string;
|
|
11
11
|
export declare const MOCK_PARTNER_IDENTITY_TOKEN_URL: string;
|
|
12
|
-
export declare const MOCK_MFA_ENROLL_URL: string;
|
|
13
|
-
export declare const MOCK_MFA_ENROLL_COMPLETE_URL: string;
|
|
14
|
-
export declare const MOCK_MFA_VERIFY_URL: string;
|
|
15
|
-
export declare const MOCK_MFA_VERIFY_COMPLETE_URL: string;
|
|
16
|
-
export declare const MOCK_MFA_CREDENTIALS_URL: string;
|
|
17
|
-
export declare const MOCK_MFA_ENROLL_PASSKEY_RESPONSE: {
|
|
18
|
-
flow_id: string;
|
|
19
|
-
expires_at: string;
|
|
20
|
-
passkey_create_data: string;
|
|
21
|
-
};
|
|
22
|
-
export declare const MOCK_MFA_ENROLL_EMAIL_RESPONSE: {
|
|
23
|
-
flow_id: string;
|
|
24
|
-
expires_at: string;
|
|
25
|
-
};
|
|
26
|
-
export declare const MOCK_MFA_ENROLL_COMPLETE_RESPONSE: {
|
|
27
|
-
status: string;
|
|
28
|
-
};
|
|
29
|
-
export declare const MOCK_MFA_VERIFY_PASSKEY_RESPONSE: {
|
|
30
|
-
flow_id: string;
|
|
31
|
-
expires_at: string;
|
|
32
|
-
passkey_request_data: string;
|
|
33
|
-
};
|
|
34
|
-
export declare const MOCK_MFA_VERIFY_EMAIL_RESPONSE: {
|
|
35
|
-
flow_id: string;
|
|
36
|
-
expires_at: string;
|
|
37
|
-
};
|
|
38
|
-
export declare const MOCK_MFA_ASSERTION_JWT = "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJmODgyMjdiZC1iNjE1LTQxYTMtYjBiZS00NjdkZDc4MWE0YWQiLCJhYWwiOjIsImFtciI6InBhc3NrZXkiLCJleHAiOjQxMDI0NDQ4MDB9.signature";
|
|
39
|
-
export declare const MOCK_MFA_VERIFY_COMPLETE_RESPONSE: {
|
|
40
|
-
token: string;
|
|
41
|
-
expires_in: number;
|
|
42
|
-
profile: {
|
|
43
|
-
profile_id: string;
|
|
44
|
-
identifier_id: string;
|
|
45
|
-
identifier_type: string;
|
|
46
|
-
};
|
|
47
|
-
profile_aliases: never[];
|
|
48
|
-
};
|
|
49
|
-
export declare const MOCK_MFA_CREDENTIALS_RESPONSE: {
|
|
50
|
-
credentials: ({
|
|
51
|
-
credential_type: string;
|
|
52
|
-
status: string;
|
|
53
|
-
enrolled_at: string;
|
|
54
|
-
passkey: {
|
|
55
|
-
display_name: string;
|
|
56
|
-
added_at: string;
|
|
57
|
-
};
|
|
58
|
-
email?: undefined;
|
|
59
|
-
} | {
|
|
60
|
-
passkey?: undefined;
|
|
61
|
-
credential_type: string;
|
|
62
|
-
status: string;
|
|
63
|
-
enrolled_at: string;
|
|
64
|
-
email: {
|
|
65
|
-
address: string;
|
|
66
|
-
verified: boolean;
|
|
67
|
-
};
|
|
68
|
-
})[];
|
|
69
|
-
};
|
|
70
|
-
export declare const MOCK_ELEVATED_ACCESS_JWT = "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJmODgyMjdiZC1iNjE1LTQxYTMtYjBiZS00NjdkZDc4MWE0YWQiLCJhYWwiOjIsImFtciI6WyJwYXNza2V5Il0sImV4cCI6NDEwMjQ0NDgwMH0.signature";
|
|
71
|
-
export declare const MOCK_ELEVATED_ACCESS_TOKEN_RESPONSE: {
|
|
72
|
-
access_token: string;
|
|
73
|
-
expires_in: number;
|
|
74
|
-
};
|
|
75
12
|
export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ";
|
|
76
13
|
export declare const MOCK_ACCESS_JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
|
|
77
14
|
export declare const MOCK_NONCE_RESPONSE: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAA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eAAe;QACf,UAAU;;;CAGb,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;;;;;;;CAmB9C,CAAC"}
|
package/dist/sdk/mocks/auth.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Env, Platform } from '../../shared/env.js';
|
|
2
|
-
import { MFA_CREDENTIALS_URL, MFA_ENROLL_COMPLETE_URL, MFA_ENROLL_URL, MFA_VERIFY_COMPLETE_URL, MFA_VERIFY_URL, } from '../authentication-jwt-bearer/mfa/services.js';
|
|
3
2
|
import { NONCE_URL, SIWE_LOGIN_URL, SRP_LOGIN_URL, OIDC_TOKEN_URL, PAIR_IDENTIFIERS, PAIR_PROFILES_URL, PAIR_SOCIAL_IDENTIFIER_URL, PROFILE_LINEAGE_URL, CUSTOMER_SERVICE_TOKEN_URL, PARTNER_IDENTITY_TOKEN_URL, } from '../authentication-jwt-bearer/services.js';
|
|
4
3
|
export const MOCK_NONCE_URL = NONCE_URL(Env.PRD);
|
|
5
4
|
export const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);
|
|
@@ -11,95 +10,6 @@ export const MOCK_PAIR_SOCIAL_IDENTIFIER_URL = PAIR_SOCIAL_IDENTIFIER_URL(Env.PR
|
|
|
11
10
|
export const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);
|
|
12
11
|
export const MOCK_CUSTOMER_SERVICE_TOKEN_URL = CUSTOMER_SERVICE_TOKEN_URL(Env.PRD);
|
|
13
12
|
export const MOCK_PARTNER_IDENTITY_TOKEN_URL = PARTNER_IDENTITY_TOKEN_URL(Env.PRD);
|
|
14
|
-
export const MOCK_MFA_ENROLL_URL = MFA_ENROLL_URL(Env.PRD);
|
|
15
|
-
export const MOCK_MFA_ENROLL_COMPLETE_URL = MFA_ENROLL_COMPLETE_URL(Env.PRD);
|
|
16
|
-
export const MOCK_MFA_VERIFY_URL = MFA_VERIFY_URL(Env.PRD);
|
|
17
|
-
export const MOCK_MFA_VERIFY_COMPLETE_URL = MFA_VERIFY_COMPLETE_URL(Env.PRD);
|
|
18
|
-
export const MOCK_MFA_CREDENTIALS_URL = MFA_CREDENTIALS_URL(Env.PRD);
|
|
19
|
-
const MOCK_PASSKEY_CREATE_DATA = {
|
|
20
|
-
publicKey: {
|
|
21
|
-
rp: {
|
|
22
|
-
name: 'MetaMask',
|
|
23
|
-
id: 'authentication.api.cx.metamask.io',
|
|
24
|
-
},
|
|
25
|
-
user: {
|
|
26
|
-
name: 'MetaMask 3f9a1c2b',
|
|
27
|
-
id: 'cHJvZmlsZS1pZA',
|
|
28
|
-
displayName: 'MetaMask 3f9a1c2b',
|
|
29
|
-
},
|
|
30
|
-
challenge: 'Y3JlYXRlLWNoYWxsZW5nZQ',
|
|
31
|
-
pubKeyCredParams: [{ type: 'public-key', alg: -7 }],
|
|
32
|
-
excludeCredentials: [],
|
|
33
|
-
attestation: 'none',
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
const MOCK_PASSKEY_REQUEST_DATA = {
|
|
37
|
-
publicKey: {
|
|
38
|
-
rpId: 'authentication.api.cx.metamask.io',
|
|
39
|
-
challenge: 'dmVyaWZ5LWNoYWxsZW5nZQ',
|
|
40
|
-
allowCredentials: [{ type: 'public-key', id: 'Y3JlZGVudGlhbC1pZA' }],
|
|
41
|
-
userVerification: 'required',
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
export const MOCK_MFA_ENROLL_PASSKEY_RESPONSE = {
|
|
45
|
-
flow_id: 'enroll-passkey-flow-id',
|
|
46
|
-
expires_at: '2099-09-07T14:30:00Z',
|
|
47
|
-
passkey_create_data: JSON.stringify(MOCK_PASSKEY_CREATE_DATA),
|
|
48
|
-
};
|
|
49
|
-
export const MOCK_MFA_ENROLL_EMAIL_RESPONSE = {
|
|
50
|
-
flow_id: 'enroll-email-flow-id',
|
|
51
|
-
expires_at: '2099-09-07T14:30:00Z',
|
|
52
|
-
};
|
|
53
|
-
export const MOCK_MFA_ENROLL_COMPLETE_RESPONSE = {
|
|
54
|
-
status: 'enrolled',
|
|
55
|
-
};
|
|
56
|
-
export const MOCK_MFA_VERIFY_PASSKEY_RESPONSE = {
|
|
57
|
-
flow_id: 'verify-passkey-flow-id',
|
|
58
|
-
expires_at: '2099-09-07T14:30:00Z',
|
|
59
|
-
passkey_request_data: JSON.stringify(MOCK_PASSKEY_REQUEST_DATA),
|
|
60
|
-
};
|
|
61
|
-
export const MOCK_MFA_VERIFY_EMAIL_RESPONSE = {
|
|
62
|
-
flow_id: 'verify-email-flow-id',
|
|
63
|
-
expires_at: '2099-09-07T14:30:00Z',
|
|
64
|
-
};
|
|
65
|
-
export const MOCK_MFA_ASSERTION_JWT = 'eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJmODgyMjdiZC1iNjE1LTQxYTMtYjBiZS00NjdkZDc4MWE0YWQiLCJhYWwiOjIsImFtciI6InBhc3NrZXkiLCJleHAiOjQxMDI0NDQ4MDB9.signature';
|
|
66
|
-
export const MOCK_MFA_VERIFY_COMPLETE_RESPONSE = {
|
|
67
|
-
token: MOCK_MFA_ASSERTION_JWT,
|
|
68
|
-
expires_in: 900,
|
|
69
|
-
profile: {
|
|
70
|
-
profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',
|
|
71
|
-
identifier_id: 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',
|
|
72
|
-
identifier_type: 'SRP',
|
|
73
|
-
},
|
|
74
|
-
profile_aliases: [],
|
|
75
|
-
};
|
|
76
|
-
export const MOCK_MFA_CREDENTIALS_RESPONSE = {
|
|
77
|
-
credentials: [
|
|
78
|
-
{
|
|
79
|
-
credential_type: 'passkey',
|
|
80
|
-
status: 'active',
|
|
81
|
-
enrolled_at: '2026-09-15T10:00:00Z',
|
|
82
|
-
passkey: {
|
|
83
|
-
display_name: 'MetaMask 3f9a1c2b',
|
|
84
|
-
added_at: '2026-09-15T10:00:00Z',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
credential_type: 'email_otp',
|
|
89
|
-
status: 'pending',
|
|
90
|
-
enrolled_at: '2026-09-15T10:05:00Z',
|
|
91
|
-
email: {
|
|
92
|
-
address: 'user@example.com',
|
|
93
|
-
verified: false,
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
};
|
|
98
|
-
export const MOCK_ELEVATED_ACCESS_JWT = 'eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJmODgyMjdiZC1iNjE1LTQxYTMtYjBiZS00NjdkZDc4MWE0YWQiLCJhYWwiOjIsImFtciI6WyJwYXNza2V5Il0sImV4cCI6NDEwMjQ0NDgwMH0.signature';
|
|
99
|
-
export const MOCK_ELEVATED_ACCESS_TOKEN_RESPONSE = {
|
|
100
|
-
access_token: MOCK_ELEVATED_ACCESS_JWT,
|
|
101
|
-
expires_in: 900,
|
|
102
|
-
};
|
|
103
13
|
export const MOCK_JWT = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';
|
|
104
14
|
export const MOCK_ACCESS_JWT = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
|
|
105
15
|
export const MOCK_NONCE_RESPONSE = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,uBAAuB,EACvB,cAAc,GACf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,0CAA0C,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,CAAC,MA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ACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,QAAQ,CAAC,SAAS;YACzB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;KACF;CACF,CAAC","sourcesContent":["import { Env, Platform } from '../../shared/env.js';\nimport {\n MFA_CREDENTIALS_URL,\n MFA_ENROLL_COMPLETE_URL,\n MFA_ENROLL_URL,\n MFA_VERIFY_COMPLETE_URL,\n MFA_VERIFY_URL,\n} from '../authentication-jwt-bearer/mfa/services.js';\nimport {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n PAIR_PROFILES_URL,\n PAIR_SOCIAL_IDENTIFIER_URL,\n PROFILE_LINEAGE_URL,\n CUSTOMER_SERVICE_TOKEN_URL,\n PARTNER_IDENTITY_TOKEN_URL,\n} from '../authentication-jwt-bearer/services.js';\n\nexport const MOCK_NONCE_URL = NONCE_URL(Env.PRD);\nexport const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);\nexport const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.PRD);\nexport const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.PRD);\nexport const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.PRD);\nexport const MOCK_PAIR_PROFILES_URL = PAIR_PROFILES_URL(Env.PRD);\nexport const MOCK_PAIR_SOCIAL_IDENTIFIER_URL = PAIR_SOCIAL_IDENTIFIER_URL(\n Env.PRD,\n);\nexport const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);\nexport const MOCK_CUSTOMER_SERVICE_TOKEN_URL = CUSTOMER_SERVICE_TOKEN_URL(\n Env.PRD,\n);\nexport const MOCK_PARTNER_IDENTITY_TOKEN_URL = PARTNER_IDENTITY_TOKEN_URL(\n Env.PRD,\n);\nexport const MOCK_MFA_ENROLL_URL = MFA_ENROLL_URL(Env.PRD);\nexport const MOCK_MFA_ENROLL_COMPLETE_URL = MFA_ENROLL_COMPLETE_URL(Env.PRD);\nexport const MOCK_MFA_VERIFY_URL = MFA_VERIFY_URL(Env.PRD);\nexport const MOCK_MFA_VERIFY_COMPLETE_URL = MFA_VERIFY_COMPLETE_URL(Env.PRD);\nexport const MOCK_MFA_CREDENTIALS_URL = MFA_CREDENTIALS_URL(Env.PRD);\n\nconst MOCK_PASSKEY_CREATE_DATA = {\n publicKey: {\n rp: {\n name: 'MetaMask',\n id: 'authentication.api.cx.metamask.io',\n },\n user: {\n name: 'MetaMask 3f9a1c2b',\n id: 'cHJvZmlsZS1pZA',\n displayName: 'MetaMask 3f9a1c2b',\n },\n challenge: 'Y3JlYXRlLWNoYWxsZW5nZQ',\n pubKeyCredParams: [{ type: 'public-key', alg: -7 }],\n excludeCredentials: [],\n attestation: 'none',\n },\n};\n\nconst MOCK_PASSKEY_REQUEST_DATA = {\n publicKey: {\n rpId: 'authentication.api.cx.metamask.io',\n challenge: 'dmVyaWZ5LWNoYWxsZW5nZQ',\n allowCredentials: [{ type: 'public-key', id: 'Y3JlZGVudGlhbC1pZA' }],\n userVerification: 'required',\n },\n};\n\nexport const MOCK_MFA_ENROLL_PASSKEY_RESPONSE = {\n flow_id: 'enroll-passkey-flow-id',\n expires_at: '2099-09-07T14:30:00Z',\n passkey_create_data: JSON.stringify(MOCK_PASSKEY_CREATE_DATA),\n};\n\nexport const MOCK_MFA_ENROLL_EMAIL_RESPONSE = {\n flow_id: 'enroll-email-flow-id',\n expires_at: '2099-09-07T14:30:00Z',\n};\n\nexport const MOCK_MFA_ENROLL_COMPLETE_RESPONSE = {\n status: 'enrolled',\n};\n\nexport const MOCK_MFA_VERIFY_PASSKEY_RESPONSE = {\n flow_id: 'verify-passkey-flow-id',\n expires_at: '2099-09-07T14:30:00Z',\n passkey_request_data: JSON.stringify(MOCK_PASSKEY_REQUEST_DATA),\n};\n\nexport const MOCK_MFA_VERIFY_EMAIL_RESPONSE = {\n flow_id: 'verify-email-flow-id',\n expires_at: '2099-09-07T14:30:00Z',\n};\n\nexport const MOCK_MFA_ASSERTION_JWT =\n 'eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJmODgyMjdiZC1iNjE1LTQxYTMtYjBiZS00NjdkZDc4MWE0YWQiLCJhYWwiOjIsImFtciI6InBhc3NrZXkiLCJleHAiOjQxMDI0NDQ4MDB9.signature';\n\nexport const MOCK_MFA_VERIFY_COMPLETE_RESPONSE = {\n token: MOCK_MFA_ASSERTION_JWT,\n expires_in: 900,\n profile: {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n identifier_type: 'SRP',\n },\n profile_aliases: [],\n};\n\nexport const MOCK_MFA_CREDENTIALS_RESPONSE = {\n credentials: [\n {\n credential_type: 'passkey',\n status: 'active',\n enrolled_at: '2026-09-15T10:00:00Z',\n passkey: {\n display_name: 'MetaMask 3f9a1c2b',\n added_at: '2026-09-15T10:00:00Z',\n },\n },\n {\n credential_type: 'email_otp',\n status: 'pending',\n enrolled_at: '2026-09-15T10:05:00Z',\n email: {\n address: 'user@example.com',\n verified: false,\n },\n },\n ],\n};\n\nexport const MOCK_ELEVATED_ACCESS_JWT =\n 'eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJmODgyMjdiZC1iNjE1LTQxYTMtYjBiZS00NjdkZDc4MWE0YWQiLCJhYWwiOjIsImFtciI6WyJwYXNza2V5Il0sImV4cCI6NDEwMjQ0NDgwMH0.signature';\n\nexport const MOCK_ELEVATED_ACCESS_TOKEN_RESPONSE = {\n access_token: MOCK_ELEVATED_ACCESS_JWT,\n expires_in: 900,\n};\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nexport const MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n expires_in: 300,\n};\n\nexport const MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n identifier_type: 'SIWE',\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n identifier_type: 'SRP',\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n profile_aliases: [],\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n expires_in: 3600,\n};\n\nexport const MOCK_CUSTOMER_SERVICE_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n refresh_token: 'ory_rt_mock_refresh_token',\n expires_in: 3600,\n token_type: 'bearer',\n};\n\nexport const MOCK_PARTNER_IDENTITY_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n refresh_token: 'ory_rt_mock_refresh_token',\n expires_in: 3600,\n token_type: 'bearer',\n};\n\nexport const MOCK_PAIR_PROFILES_RESPONSE = {\n profile: {\n identifier_id: MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,\n metametrics_id: MOCK_SRP_LOGIN_RESPONSE.profile.metametrics_id,\n profile_id: MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,\n },\n profile_aliases: [],\n};\n\nexport const MOCK_PAIR_SOCIAL_IDENTIFIER_RESPONSE = {\n expires_in: 3600,\n profile: {\n created_at: '2024-01-15T10:30:00Z',\n identifier_id: MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,\n identifier_type: 'GOOGLE',\n profile_id: MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,\n },\n token: MOCK_JWT,\n};\n\nexport const MOCK_USER_PROFILE_LINEAGE_RESPONSE = {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n created_at: '2025-10-01T12:00:00Z',\n lineage: [\n {\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n agent: Platform.MOBILE,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 1,\n },\n {\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n agent: Platform.EXTENSION,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 2,\n },\n ],\n};\n"]}
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,0CAA0C,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,+BAA+B,GAAG,0BA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IN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n PAIR_PROFILES_URL,\n PAIR_SOCIAL_IDENTIFIER_URL,\n PROFILE_LINEAGE_URL,\n CUSTOMER_SERVICE_TOKEN_URL,\n PARTNER_IDENTITY_TOKEN_URL,\n} from '../authentication-jwt-bearer/services.js';\n\nexport const MOCK_NONCE_URL = NONCE_URL(Env.PRD);\nexport const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);\nexport const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.PRD);\nexport const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.PRD);\nexport const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.PRD);\nexport const MOCK_PAIR_PROFILES_URL = PAIR_PROFILES_URL(Env.PRD);\nexport const MOCK_PAIR_SOCIAL_IDENTIFIER_URL = PAIR_SOCIAL_IDENTIFIER_URL(\n Env.PRD,\n);\nexport const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);\nexport const MOCK_CUSTOMER_SERVICE_TOKEN_URL = CUSTOMER_SERVICE_TOKEN_URL(\n Env.PRD,\n);\nexport const MOCK_PARTNER_IDENTITY_TOKEN_URL = PARTNER_IDENTITY_TOKEN_URL(\n Env.PRD,\n);\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nexport const MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n expires_in: 300,\n};\n\nexport const MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n identifier_type: 'SIWE',\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n identifier_type: 'SRP',\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n profile_aliases: [],\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n expires_in: 3600,\n};\n\nexport const MOCK_CUSTOMER_SERVICE_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n refresh_token: 'ory_rt_mock_refresh_token',\n expires_in: 3600,\n token_type: 'bearer',\n};\n\nexport const MOCK_PARTNER_IDENTITY_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n refresh_token: 'ory_rt_mock_refresh_token',\n expires_in: 3600,\n token_type: 'bearer',\n};\n\nexport const MOCK_PAIR_PROFILES_RESPONSE = {\n profile: {\n identifier_id: MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,\n metametrics_id: MOCK_SRP_LOGIN_RESPONSE.profile.metametrics_id,\n profile_id: MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,\n },\n profile_aliases: [],\n};\n\nexport const MOCK_PAIR_SOCIAL_IDENTIFIER_RESPONSE = {\n expires_in: 3600,\n profile: {\n created_at: '2024-01-15T10:30:00Z',\n identifier_id: MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,\n identifier_type: 'GOOGLE',\n profile_id: MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,\n },\n token: MOCK_JWT,\n};\n\nexport const MOCK_USER_PROFILE_LINEAGE_RESPONSE = {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n created_at: '2025-10-01T12:00:00Z',\n lineage: [\n {\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n agent: Platform.MOBILE,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 1,\n },\n {\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n agent: Platform.EXTENSION,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 2,\n },\n ],\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-login-response.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"validate-login-response.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAgB5E"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { decodeJwtPayload } from './jwt.js';
|
|
2
1
|
/**
|
|
3
2
|
* Validates that the input is a well-formed, non-expired LoginResponse.
|
|
4
3
|
*
|
|
@@ -31,10 +30,13 @@ export function validateLoginResponse(input) {
|
|
|
31
30
|
*/
|
|
32
31
|
function isJwtExpired(token) {
|
|
33
32
|
try {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const parts = token.split('.');
|
|
34
|
+
if (parts.length !== 3) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');
|
|
38
|
+
const { exp } = JSON.parse(atob(base64));
|
|
39
|
+
return !Number.isInteger(exp) || exp * 1000 <= Date.now();
|
|
38
40
|
}
|
|
39
41
|
catch {
|
|
40
42
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-login-response.js","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-login-response.js","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { LoginResponse } from '../authentication.js';\n\n/**\n * Validates that the input is a well-formed, non-expired LoginResponse.\n *\n * Checks structural shape (token + profile objects exist) and verifies\n * the JWT access token's `exp` claim is still in the future. This acts\n * as a hard guard against stale cached tokens regardless of client-side\n * TTL tracking (obtainedAt / expiresIn), which can be corrupted.\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is a valid, non-expired LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n if (isJwtExpired(assumedInput.token.accessToken)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks whether a JWT has expired by decoding its `exp` claim.\n *\n * @param token - A JWT string.\n * @returns true if the token is expired or cannot be decoded; false if still valid.\n */\nfunction isJwtExpired(token: string): boolean {\n try {\n const parts = token.split('.');\n if (parts.length !== 3) {\n return true;\n }\n const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');\n const { exp } = JSON.parse(atob(base64));\n return !Number.isInteger(exp) || exp * 1000 <= Date.now();\n } catch {\n return true;\n }\n}\n"]}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { KeyringObject } from '@metamask/keyring-controller';
|
|
2
|
+
/**
|
|
3
|
+
* Reads HD keyring entropy source IDs (metadata IDs) from KeyringController
|
|
4
|
+
* keyrings, primary first. Returns an empty array when none are available
|
|
5
|
+
* (e.g. the wallet is locked, where `keyrings` is cleared).
|
|
6
|
+
*
|
|
7
|
+
* @param keyrings - Keyrings from `KeyringController:getState`.
|
|
8
|
+
* @returns The HD keyring metadata IDs, primary first.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getHdKeyringEntropySourceIds(keyrings: KeyringObject[] | null | undefined): string[];
|
|
2
11
|
/**
|
|
3
12
|
* Resolves the primary SRP's entropy source ID (the first HD keyring's
|
|
4
13
|
* metadata ID). The ID is randomly regenerated whenever the vault is
|
|
5
14
|
* recreated (e.g. on restore).
|
|
6
15
|
*
|
|
7
|
-
* @param
|
|
16
|
+
* @param keyrings - Keyrings from `KeyringController:getState`.
|
|
8
17
|
* @returns The primary HD keyring metadata ID.
|
|
9
18
|
* @throws If no HD keyring is available; callers must only resolve while
|
|
10
19
|
* the wallet is unlocked.
|
|
11
20
|
*/
|
|
12
|
-
export declare function getPrimaryHdKeyringEntropySourceId(
|
|
21
|
+
export declare function getPrimaryHdKeyringEntropySourceId(keyrings: KeyringObject[] | null | undefined): string;
|
|
13
22
|
//# sourceMappingURL=entropy-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entropy-source.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/entropy-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"entropy-source.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/entropy-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI,GAAG,SAAS,GAC3C,MAAM,EAAE,CAIV;AAED;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI,GAAG,SAAS,GAC3C,MAAM,CAQR"}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KeyringTypes } from '@metamask/keyring-controller';
|
|
2
|
+
/**
|
|
3
|
+
* Reads HD keyring entropy source IDs (metadata IDs) from KeyringController
|
|
4
|
+
* keyrings, primary first. Returns an empty array when none are available
|
|
5
|
+
* (e.g. the wallet is locked, where `keyrings` is cleared).
|
|
6
|
+
*
|
|
7
|
+
* @param keyrings - Keyrings from `KeyringController:getState`.
|
|
8
|
+
* @returns The HD keyring metadata IDs, primary first.
|
|
9
|
+
*/
|
|
10
|
+
export function getHdKeyringEntropySourceIds(keyrings) {
|
|
11
|
+
return (keyrings ?? [])
|
|
12
|
+
.filter((keyring) => keyring.type === KeyringTypes.hd.toString())
|
|
13
|
+
.map((keyring) => keyring.metadata.id);
|
|
14
|
+
}
|
|
2
15
|
/**
|
|
3
16
|
* Resolves the primary SRP's entropy source ID (the first HD keyring's
|
|
4
17
|
* metadata ID). The ID is randomly regenerated whenever the vault is
|
|
5
18
|
* recreated (e.g. on restore).
|
|
6
19
|
*
|
|
7
|
-
* @param
|
|
20
|
+
* @param keyrings - Keyrings from `KeyringController:getState`.
|
|
8
21
|
* @returns The primary HD keyring metadata ID.
|
|
9
22
|
* @throws If no HD keyring is available; callers must only resolve while
|
|
10
23
|
* the wallet is unlocked.
|
|
11
24
|
*/
|
|
12
|
-
export function getPrimaryHdKeyringEntropySourceId(
|
|
13
|
-
const primaryEntropySourceId =
|
|
25
|
+
export function getPrimaryHdKeyringEntropySourceId(keyrings) {
|
|
26
|
+
const [primaryEntropySourceId] = getHdKeyringEntropySourceIds(keyrings);
|
|
14
27
|
if (!primaryEntropySourceId) {
|
|
15
28
|
throw new Error('getPrimaryHdKeyringEntropySourceId - no HD keyring available');
|
|
16
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entropy-source.js","sourceRoot":"","sources":["../../../src/shared/utils/entropy-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"entropy-source.js","sourceRoot":"","sources":["../../../src/shared/utils/entropy-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,QAA4C;IAE5C,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;SAChE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kCAAkC,CAChD,QAA4C;IAE5C,MAAM,CAAC,sBAAsB,CAAC,GAAG,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACxE,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\nimport type { KeyringObject } from '@metamask/keyring-controller';\n\n/**\n * Reads HD keyring entropy source IDs (metadata IDs) from KeyringController\n * keyrings, primary first. Returns an empty array when none are available\n * (e.g. the wallet is locked, where `keyrings` is cleared).\n *\n * @param keyrings - Keyrings from `KeyringController:getState`.\n * @returns The HD keyring metadata IDs, primary first.\n */\nexport function getHdKeyringEntropySourceIds(\n keyrings: KeyringObject[] | null | undefined,\n): string[] {\n return (keyrings ?? [])\n .filter((keyring) => keyring.type === KeyringTypes.hd.toString())\n .map((keyring) => keyring.metadata.id);\n}\n\n/**\n * Resolves the primary SRP's entropy source ID (the first HD keyring's\n * metadata ID). The ID is randomly regenerated whenever the vault is\n * recreated (e.g. on restore).\n *\n * @param keyrings - Keyrings from `KeyringController:getState`.\n * @returns The primary HD keyring metadata ID.\n * @throws If no HD keyring is available; callers must only resolve while\n * the wallet is unlocked.\n */\nexport function getPrimaryHdKeyringEntropySourceId(\n keyrings: KeyringObject[] | null | undefined,\n): string {\n const [primaryEntropySourceId] = getHdKeyringEntropySourceIds(keyrings);\n if (!primaryEntropySourceId) {\n throw new Error(\n 'getPrimaryHdKeyringEntropySourceId - no HD keyring available',\n );\n }\n return primaryEntropySourceId;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/profile-sync-controller",
|
|
3
|
-
"version": "32.1.1-preview-
|
|
3
|
+
"version": "32.1.1-preview-db287901b",
|
|
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",
|
|
@@ -79,7 +79,6 @@
|
|
|
79
79
|
"@metamask/keyring-controller": "^28.0.0",
|
|
80
80
|
"@metamask/messenger": "^3.0.0",
|
|
81
81
|
"@metamask/seedless-onboarding-controller": "^11.0.0",
|
|
82
|
-
"@metamask/superstruct": "^3.4.1",
|
|
83
82
|
"@metamask/utils": "^12.0.0",
|
|
84
83
|
"@noble/ciphers": "^1.3.0",
|
|
85
84
|
"@noble/curves": "^1.9.2",
|
|
@@ -96,7 +95,6 @@
|
|
|
96
95
|
"@metamask/keyring-api": "^24.0.0",
|
|
97
96
|
"@metamask/keyring-internal-api": "^12.0.0",
|
|
98
97
|
"@metamask/providers": "^22.1.0",
|
|
99
|
-
"@metamask/rpc-errors": "^7.0.2",
|
|
100
98
|
"@types/jest": "^30.0.0",
|
|
101
99
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
102
100
|
"deepmerge": "^4.2.2",
|