@ttt-productions/auth-core 1.6.15 → 1.6.17

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.
Files changed (88) hide show
  1. package/dist/acceptance.d.ts +0 -20
  2. package/dist/acceptance.d.ts.map +1 -1
  3. package/dist/acceptance.js +6 -26
  4. package/dist/acceptance.js.map +1 -1
  5. package/dist/{auth.d.ts → client/auth.d.ts} +1 -6
  6. package/dist/client/auth.d.ts.map +1 -0
  7. package/dist/client/auth.js +8 -0
  8. package/dist/client/auth.js.map +1 -0
  9. package/dist/client/claims.d.ts +11 -0
  10. package/dist/client/claims.d.ts.map +1 -0
  11. package/dist/client/claims.js +30 -0
  12. package/dist/client/claims.js.map +1 -0
  13. package/dist/client/index.d.ts +3 -0
  14. package/dist/client/index.d.ts.map +1 -0
  15. package/dist/client/index.js +3 -0
  16. package/dist/client/index.js.map +1 -0
  17. package/dist/email-verification.d.ts +0 -13
  18. package/dist/email-verification.d.ts.map +1 -1
  19. package/dist/email-verification.js +3 -19
  20. package/dist/email-verification.js.map +1 -1
  21. package/dist/env.d.ts +1 -1
  22. package/dist/env.js +5 -5
  23. package/dist/env.js.map +1 -1
  24. package/dist/errors.d.ts +1 -3
  25. package/dist/errors.d.ts.map +1 -1
  26. package/dist/errors.js +79 -86
  27. package/dist/errors.js.map +1 -1
  28. package/dist/index.d.ts +4 -5
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +4 -12
  31. package/dist/index.js.map +1 -1
  32. package/dist/react/AuthProvider.d.ts +3 -3
  33. package/dist/react/AuthProvider.d.ts.map +1 -1
  34. package/dist/react/AuthProvider.js +18 -36
  35. package/dist/react/AuthProvider.js.map +1 -1
  36. package/dist/react/index.d.ts +8 -8
  37. package/dist/react/index.js +6 -6
  38. package/dist/react/index.js.map +1 -1
  39. package/dist/react/redirect-storage.d.ts.map +1 -1
  40. package/dist/react/redirect-storage.js +5 -14
  41. package/dist/react/redirect-storage.js.map +1 -1
  42. package/dist/react/types.d.ts +1 -22
  43. package/dist/react/types.d.ts.map +1 -1
  44. package/dist/react/types.js.map +1 -1
  45. package/dist/react/useAuth.d.ts +1 -5
  46. package/dist/react/useAuth.d.ts.map +1 -1
  47. package/dist/react/useAuth.js +4 -8
  48. package/dist/react/useAuth.js.map +1 -1
  49. package/dist/react/useAuthGuard.d.ts +0 -33
  50. package/dist/react/useAuthGuard.d.ts.map +1 -1
  51. package/dist/react/useAuthGuard.js +7 -37
  52. package/dist/react/useAuthGuard.js.map +1 -1
  53. package/dist/react/useAuthState.d.ts +1 -1
  54. package/dist/react/useAuthState.d.ts.map +1 -1
  55. package/dist/react/useAuthState.js +2 -6
  56. package/dist/react/useAuthState.js.map +1 -1
  57. package/dist/refusal.d.ts +0 -6
  58. package/dist/refusal.d.ts.map +1 -1
  59. package/dist/refusal.js +6 -16
  60. package/dist/refusal.js.map +1 -1
  61. package/dist/server/assertAuth.d.ts +2 -2
  62. package/dist/server/assertAuth.d.ts.map +1 -1
  63. package/dist/server/assertAuth.js +13 -38
  64. package/dist/server/assertAuth.js.map +1 -1
  65. package/dist/server/authError.d.ts +3 -51
  66. package/dist/server/authError.d.ts.map +1 -1
  67. package/dist/server/authError.js +1 -1
  68. package/dist/server/authError.js.map +1 -1
  69. package/dist/server/index.d.ts +4 -4
  70. package/dist/server/index.d.ts.map +1 -1
  71. package/dist/server/index.js +2 -3
  72. package/dist/server/index.js.map +1 -1
  73. package/dist/server/types.d.ts +9 -109
  74. package/dist/server/types.d.ts.map +1 -1
  75. package/dist/server/types.js +0 -2
  76. package/dist/server/types.js.map +1 -1
  77. package/package.json +3 -3
  78. package/dist/auth.d.ts.map +0 -1
  79. package/dist/auth.js +0 -13
  80. package/dist/auth.js.map +0 -1
  81. package/dist/claims.d.ts +0 -38
  82. package/dist/claims.d.ts.map +0 -1
  83. package/dist/claims.js +0 -55
  84. package/dist/claims.js.map +0 -1
  85. package/dist/client.d.ts +0 -2
  86. package/dist/client.d.ts.map +0 -1
  87. package/dist/client.js +0 -5
  88. package/dist/client.js.map +0 -1
@@ -1,30 +1,10 @@
1
- /** The `details.reason` of the refusal a caller below the required level receives. */
2
1
  export declare const ACCEPTANCE_REQUIRED_REASON: "acceptance-required";
3
- /**
4
- * Structured details carried by the acceptance refusal. Server side it rides
5
- * `AuthAssertionError.details`; the consuming app forwards it as the `HttpsError` details, so
6
- * the client receives it on the callable error's `details`.
7
- */
8
2
  export interface AcceptanceRequiredDetails {
9
3
  readonly reason: typeof ACCEPTANCE_REQUIRED_REASON;
10
- /** The level the backend currently requires. */
11
4
  readonly requiredLevel: number;
12
- /** The level read from the caller's token (0 when absent or unreadable). */
13
5
  readonly acceptedLevel: number;
14
6
  }
15
- /**
16
- * Normalize an acceptance level: a finite number ≥ 0, floored to a whole number. Anything
17
- * else — absent, a string, NaN, a negative — is 0. Applied to BOTH sides of the comparison:
18
- * an unreadable accepted level can never satisfy a positive requirement, and an unreadable
19
- * required level requires nothing.
20
- */
21
7
  export declare function normalizeAcceptanceLevel(value: unknown): number;
22
- /** True when `details` is the acceptance refusal's structured details. */
23
8
  export declare function isAcceptanceRequiredDetails(details: unknown): details is AcceptanceRequiredDetails;
24
- /**
25
- * True when `err` is the acceptance refusal — a `failed-precondition` whose details carry
26
- * `reason: 'acceptance-required'`. Works on the server-side error and on the client-side
27
- * callable error alike, so the app has one recognizer for "show the acceptance prompt".
28
- */
29
9
  export declare function isAcceptanceRequiredError(err: unknown): boolean;
30
10
  //# sourceMappingURL=acceptance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"acceptance.d.ts","sourceRoot":"","sources":["../src/acceptance.ts"],"names":[],"mappings":"AAUA,sFAAsF;AACtF,eAAO,MAAM,0BAA0B,EAAG,qBAA8B,CAAC;AAEzE;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,OAAO,0BAA0B,CAAC;IACnD,gDAAgD;IAChD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAG/D;AAED,0EAA0E;AAC1E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,yBAAyB,CAQlG;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE/D"}
1
+ {"version":3,"file":"acceptance.d.ts","sourceRoot":"","sources":["../src/acceptance.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,EAAG,qBAA8B,CAAC;AAEzE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,OAAO,0BAA0B,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAG/D;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,yBAAyB,CAQtC;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE/D"}
@@ -1,38 +1,18 @@
1
- // The acceptance-level contract shared by the server gate (`createAssertAuth`'s optional
2
- // `acceptance` config on ./server) and the client that answers it. Pure: no Firebase runtime.
3
- //
4
- // A consuming app publishes documents its users must accept, and tracks acceptance as a
5
- // monotonically increasing whole-number LEVEL: the app decides what raises the required level
6
- // and where the caller's accepted level is stored (a custom claim named by the app). The package
7
- // only compares the two numbers and reports a refusal in one recognisable shape.
8
- import { failedPreconditionDetails } from "./refusal.js";
9
- /** The `details.reason` of the refusal a caller below the required level receives. */
10
- export const ACCEPTANCE_REQUIRED_REASON = "acceptance-required";
11
- /**
12
- * Normalize an acceptance level: a finite number ≥ 0, floored to a whole number. Anything
13
- * else — absent, a string, NaN, a negative — is 0. Applied to BOTH sides of the comparison:
14
- * an unreadable accepted level can never satisfy a positive requirement, and an unreadable
15
- * required level requires nothing.
16
- */
1
+ import { failedPreconditionDetails } from './refusal.js';
2
+ export const ACCEPTANCE_REQUIRED_REASON = 'acceptance-required';
17
3
  export function normalizeAcceptanceLevel(value) {
18
- if (typeof value !== "number" || !Number.isFinite(value) || value <= 0)
4
+ if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0)
19
5
  return 0;
20
6
  return Math.floor(value);
21
7
  }
22
- /** True when `details` is the acceptance refusal's structured details. */
23
8
  export function isAcceptanceRequiredDetails(details) {
24
- if (!details || typeof details !== "object")
9
+ if (!details || typeof details !== 'object')
25
10
  return false;
26
11
  const d = details;
27
12
  return (d.reason === ACCEPTANCE_REQUIRED_REASON &&
28
- typeof d.requiredLevel === "number" &&
29
- typeof d.acceptedLevel === "number");
13
+ typeof d.requiredLevel === 'number' &&
14
+ typeof d.acceptedLevel === 'number');
30
15
  }
31
- /**
32
- * True when `err` is the acceptance refusal — a `failed-precondition` whose details carry
33
- * `reason: 'acceptance-required'`. Works on the server-side error and on the client-side
34
- * callable error alike, so the app has one recognizer for "show the acceptance prompt".
35
- */
36
16
  export function isAcceptanceRequiredError(err) {
37
17
  return isAcceptanceRequiredDetails(failedPreconditionDetails(err));
38
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"acceptance.js","sourceRoot":"","sources":["../src/acceptance.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,8FAA8F;AAC9F,EAAE;AACF,wFAAwF;AACxF,8FAA8F;AAC9F,iGAAiG;AACjG,iFAAiF;AAEjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,sFAAsF;AACtF,MAAM,CAAC,MAAM,0BAA0B,GAAG,qBAA8B,CAAC;AAezE;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACjF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,2BAA2B,CAAC,OAAgB;IAC1D,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,CAAC,GAAG,OAAkC,CAAC;IAC7C,OAAO,CACL,CAAC,CAAC,MAAM,KAAK,0BAA0B;QACvC,OAAO,CAAC,CAAC,aAAa,KAAK,QAAQ;QACnC,OAAO,CAAC,CAAC,aAAa,KAAK,QAAQ,CACpC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAAY;IACpD,OAAO,2BAA2B,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;AACrE,CAAC","sourcesContent":["// The acceptance-level contract shared by the server gate (`createAssertAuth`'s optional\n// `acceptance` config on ./server) and the client that answers it. Pure: no Firebase runtime.\n//\n// A consuming app publishes documents its users must accept, and tracks acceptance as a\n// monotonically increasing whole-number LEVEL: the app decides what raises the required level\n// and where the caller's accepted level is stored (a custom claim named by the app). The package\n// only compares the two numbers and reports a refusal in one recognisable shape.\n\nimport { failedPreconditionDetails } from \"./refusal.js\";\n\n/** The `details.reason` of the refusal a caller below the required level receives. */\nexport const ACCEPTANCE_REQUIRED_REASON = \"acceptance-required\" as const;\n\n/**\n * Structured details carried by the acceptance refusal. Server side it rides\n * `AuthAssertionError.details`; the consuming app forwards it as the `HttpsError` details, so\n * the client receives it on the callable error's `details`.\n */\nexport interface AcceptanceRequiredDetails {\n readonly reason: typeof ACCEPTANCE_REQUIRED_REASON;\n /** The level the backend currently requires. */\n readonly requiredLevel: number;\n /** The level read from the caller's token (0 when absent or unreadable). */\n readonly acceptedLevel: number;\n}\n\n/**\n * Normalize an acceptance level: a finite number ≥ 0, floored to a whole number. Anything\n * else — absent, a string, NaN, a negative — is 0. Applied to BOTH sides of the comparison:\n * an unreadable accepted level can never satisfy a positive requirement, and an unreadable\n * required level requires nothing.\n */\nexport function normalizeAcceptanceLevel(value: unknown): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) return 0;\n return Math.floor(value);\n}\n\n/** True when `details` is the acceptance refusal's structured details. */\nexport function isAcceptanceRequiredDetails(details: unknown): details is AcceptanceRequiredDetails {\n if (!details || typeof details !== \"object\") return false;\n const d = details as Record<string, unknown>;\n return (\n d.reason === ACCEPTANCE_REQUIRED_REASON &&\n typeof d.requiredLevel === \"number\" &&\n typeof d.acceptedLevel === \"number\"\n );\n}\n\n/**\n * True when `err` is the acceptance refusal — a `failed-precondition` whose details carry\n * `reason: 'acceptance-required'`. Works on the server-side error and on the client-side\n * callable error alike, so the app has one recognizer for \"show the acceptance prompt\".\n */\nexport function isAcceptanceRequiredError(err: unknown): boolean {\n return isAcceptanceRequiredDetails(failedPreconditionDetails(err));\n}\n"]}
1
+ {"version":3,"file":"acceptance.js","sourceRoot":"","sources":["../src/acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,qBAA8B,CAAC;AAQzE,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACjF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,OAAgB;IAEhB,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,CAAC,GAAG,OAAkC,CAAC;IAC7C,OAAO,CACL,CAAC,CAAC,MAAM,KAAK,0BAA0B;QACvC,OAAO,CAAC,CAAC,aAAa,KAAK,QAAQ;QACnC,OAAO,CAAC,CAAC,aAAa,KAAK,QAAQ,CACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,GAAY;IACpD,OAAO,2BAA2B,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { failedPreconditionDetails } from './refusal.js';\n\nexport const ACCEPTANCE_REQUIRED_REASON = 'acceptance-required' as const;\n\nexport interface AcceptanceRequiredDetails {\n readonly reason: typeof ACCEPTANCE_REQUIRED_REASON;\n readonly requiredLevel: number;\n readonly acceptedLevel: number;\n}\n\nexport function normalizeAcceptanceLevel(value: unknown): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) return 0;\n return Math.floor(value);\n}\n\nexport function isAcceptanceRequiredDetails(\n details: unknown,\n): details is AcceptanceRequiredDetails {\n if (!details || typeof details !== 'object') return false;\n const d = details as Record<string, unknown>;\n return (\n d.reason === ACCEPTANCE_REQUIRED_REASON &&\n typeof d.requiredLevel === 'number' &&\n typeof d.acceptedLevel === 'number'\n );\n}\n\nexport function isAcceptanceRequiredError(err: unknown): boolean {\n return isAcceptanceRequiredDetails(failedPreconditionDetails(err));\n}\n"]}
@@ -1,10 +1,5 @@
1
- import type { Auth, User } from "firebase/auth";
1
+ import type { Auth, User } from 'firebase/auth';
2
2
  export type Unsubscribe = () => void;
3
3
  export declare function getAuthUser(auth: Auth): User | null;
4
- /**
5
- * Thin wrapper around Firebase onAuthStateChanged.
6
- * - always returns the unsubscribe function
7
- * - preserves Firebase callback signature
8
- */
9
4
  export declare function onAuthStateChanged(auth: Auth, cb: (user: User | null) => void, onError?: (error: unknown) => void): Unsubscribe;
10
5
  //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/client/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAEnD;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,EAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,WAAW,CAEb"}
@@ -0,0 +1,8 @@
1
+ import { onAuthStateChanged as fbOnAuthStateChanged } from 'firebase/auth';
2
+ export function getAuthUser(auth) {
3
+ return auth.currentUser;
4
+ }
5
+ export function onAuthStateChanged(auth, cb, onError) {
6
+ return fbOnAuthStateChanged(auth, cb, onError);
7
+ }
8
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/client/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,IAAI,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI3E,MAAM,UAAU,WAAW,CAAC,IAAU;IACpC,OAAO,IAAI,CAAC,WAAW,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,IAAU,EACV,EAA+B,EAC/B,OAAkC;IAElC,OAAO,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import type { Auth, User } from 'firebase/auth';\nimport { onAuthStateChanged as fbOnAuthStateChanged } from 'firebase/auth';\n\nexport type Unsubscribe = () => void;\n\nexport function getAuthUser(auth: Auth): User | null {\n return auth.currentUser;\n}\n\nexport function onAuthStateChanged(\n auth: Auth,\n cb: (user: User | null) => void,\n onError?: (error: unknown) => void,\n): Unsubscribe {\n return fbOnAuthStateChanged(auth, cb, onError);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { Auth, User, IdTokenResult } from 'firebase/auth';
2
+ export type IdTokenClaims = IdTokenResult['claims'];
3
+ export type ParsedClaims = {
4
+ roles: string[];
5
+ raw: IdTokenClaims;
6
+ };
7
+ export declare function getIdTokenClaims(user: User | null): Promise<IdTokenClaims | null>;
8
+ export declare function refreshClaims(user: User | null): Promise<IdTokenClaims | null>;
9
+ export declare function refreshClaimsFromAuth(auth: Auth): Promise<IdTokenClaims | null>;
10
+ export declare function parseClaims(claims: IdTokenClaims | null | undefined): ParsedClaims;
11
+ //# sourceMappingURL=claims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../../src/client/claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,EAAE,aAAa,CAAC;CACpB,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAQvF;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAIpF;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAErF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,CAWlF"}
@@ -0,0 +1,30 @@
1
+ export async function getIdTokenClaims(user) {
2
+ if (!user)
3
+ return null;
4
+ const res = await user.getIdTokenResult(false);
5
+ if (user.emailVerified === true && res.claims.email_verified !== true) {
6
+ const fresh = await user.getIdTokenResult(true);
7
+ return fresh.claims;
8
+ }
9
+ return res.claims;
10
+ }
11
+ export async function refreshClaims(user) {
12
+ if (!user)
13
+ return null;
14
+ const res = await user.getIdTokenResult(true);
15
+ return res.claims;
16
+ }
17
+ export async function refreshClaimsFromAuth(auth) {
18
+ return refreshClaims(auth.currentUser);
19
+ }
20
+ export function parseClaims(claims) {
21
+ const raw = (claims ?? {});
22
+ const rolesValue = raw.roles;
23
+ const roles = Array.isArray(rolesValue)
24
+ ? rolesValue.filter((x) => typeof x === 'string')
25
+ : typeof rolesValue === 'string'
26
+ ? [rolesValue]
27
+ : [];
28
+ return { roles, raw };
29
+ }
30
+ //# sourceMappingURL=claims.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claims.js","sourceRoot":"","sources":["../../src/client/claims.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAiB;IACtD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;QACtE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAiB;IACnD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAAU;IACpD,OAAO,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAwC;IAClE,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAkB,CAAC;IAE5C,MAAM,UAAU,GAAI,GAAW,CAAC,KAAK,CAAC;IACtC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QACrC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;QACjD,CAAC,CAAC,OAAO,UAAU,KAAK,QAAQ;YAC9B,CAAC,CAAC,CAAC,UAAU,CAAC;YACd,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACxB,CAAC","sourcesContent":["import type { Auth, User, IdTokenResult } from 'firebase/auth';\n\nexport type IdTokenClaims = IdTokenResult['claims'];\n\nexport type ParsedClaims = {\n roles: string[];\n raw: IdTokenClaims;\n};\n\nexport async function getIdTokenClaims(user: User | null): Promise<IdTokenClaims | null> {\n if (!user) return null;\n const res = await user.getIdTokenResult(false);\n if (user.emailVerified === true && res.claims.email_verified !== true) {\n const fresh = await user.getIdTokenResult(true);\n return fresh.claims;\n }\n return res.claims;\n}\n\nexport async function refreshClaims(user: User | null): Promise<IdTokenClaims | null> {\n if (!user) return null;\n const res = await user.getIdTokenResult(true);\n return res.claims;\n}\n\nexport async function refreshClaimsFromAuth(auth: Auth): Promise<IdTokenClaims | null> {\n return refreshClaims(auth.currentUser);\n}\n\nexport function parseClaims(claims: IdTokenClaims | null | undefined): ParsedClaims {\n const raw = (claims ?? {}) as IdTokenClaims;\n\n const rolesValue = (raw as any).roles;\n const roles = Array.isArray(rolesValue)\n ? rolesValue.filter((x) => typeof x === 'string')\n : typeof rolesValue === 'string'\n ? [rolesValue]\n : [];\n\n return { roles, raw };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './auth.js';
2
+ export * from './claims.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './auth.js';
2
+ export * from './claims.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC","sourcesContent":["export * from './auth.js';\nexport * from './claims.js';\n"]}
@@ -1,20 +1,7 @@
1
- /** The `details.reason` of the refusal a caller without a verified email receives. */
2
1
  export declare const EMAIL_VERIFICATION_REQUIRED_REASON: "email-verification-required";
3
- /**
4
- * Structured details carried by the email-verification refusal. Server side it rides
5
- * `AuthAssertionError.details`; the consuming app forwards it as the `HttpsError` details, so
6
- * the client receives it on the callable error's `details`.
7
- */
8
2
  export interface EmailVerificationRequiredDetails {
9
3
  readonly reason: typeof EMAIL_VERIFICATION_REQUIRED_REASON;
10
4
  }
11
- /** True when `details` is the email-verification refusal's structured details. */
12
5
  export declare function isEmailVerificationRequiredDetails(details: unknown): details is EmailVerificationRequiredDetails;
13
- /**
14
- * True when `err` is the email-verification refusal — a `failed-precondition` whose details
15
- * carry `reason: 'email-verification-required'`. Works on the server-side error and on the
16
- * client-side callable error alike, so the app has one recognizer for "show the verify-email
17
- * surface".
18
- */
19
6
  export declare function isEmailVerificationRequiredError(err: unknown): boolean;
20
7
  //# sourceMappingURL=email-verification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-verification.d.ts","sourceRoot":"","sources":["../src/email-verification.ts"],"names":[],"mappings":"AAWA,sFAAsF;AACtF,eAAO,MAAM,kCAAkC,EAAG,6BAAsC,CAAC;AAEzF;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,MAAM,EAAE,OAAO,kCAAkC,CAAC;CAC5D;AAED,kFAAkF;AAClF,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,gCAAgC,CAG7C;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEtE"}
1
+ {"version":3,"file":"email-verification.d.ts","sourceRoot":"","sources":["../src/email-verification.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kCAAkC,EAAG,6BAAsC,CAAC;AAEzF,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,MAAM,EAAE,OAAO,kCAAkC,CAAC;CAC5D;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,gCAAgC,CAG7C;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEtE"}
@@ -1,26 +1,10 @@
1
- // The email-verification refusal contract shared by the server gate (`createAssertAuth`'s
2
- // `emailVerified` requirement on ./server) and the client that answers it. Pure: no Firebase
3
- // runtime.
4
- //
5
- // A callable that requires a verified email refuses a caller whose ID token is not
6
- // email-verified. The package owns that refusal, so it owns its one recognisable shape: a
7
- // `failed-precondition` whose details name the reason. The client tells it apart from every
8
- // other failed-precondition by that reason — never by the message text.
9
- import { failedPreconditionDetails } from "./refusal.js";
10
- /** The `details.reason` of the refusal a caller without a verified email receives. */
11
- export const EMAIL_VERIFICATION_REQUIRED_REASON = "email-verification-required";
12
- /** True when `details` is the email-verification refusal's structured details. */
1
+ import { failedPreconditionDetails } from './refusal.js';
2
+ export const EMAIL_VERIFICATION_REQUIRED_REASON = 'email-verification-required';
13
3
  export function isEmailVerificationRequiredDetails(details) {
14
- if (!details || typeof details !== "object")
4
+ if (!details || typeof details !== 'object')
15
5
  return false;
16
6
  return details.reason === EMAIL_VERIFICATION_REQUIRED_REASON;
17
7
  }
18
- /**
19
- * True when `err` is the email-verification refusal — a `failed-precondition` whose details
20
- * carry `reason: 'email-verification-required'`. Works on the server-side error and on the
21
- * client-side callable error alike, so the app has one recognizer for "show the verify-email
22
- * surface".
23
- */
24
8
  export function isEmailVerificationRequiredError(err) {
25
9
  return isEmailVerificationRequiredDetails(failedPreconditionDetails(err));
26
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"email-verification.js","sourceRoot":"","sources":["../src/email-verification.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,6FAA6F;AAC7F,WAAW;AACX,EAAE;AACF,mFAAmF;AACnF,0FAA0F;AAC1F,4FAA4F;AAC5F,wEAAwE;AAExE,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,sFAAsF;AACtF,MAAM,CAAC,MAAM,kCAAkC,GAAG,6BAAsC,CAAC;AAWzF,kFAAkF;AAClF,MAAM,UAAU,kCAAkC,CAChD,OAAgB;IAEhB,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC1D,OAAQ,OAAmC,CAAC,MAAM,KAAK,kCAAkC,CAAC;AAC5F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAAC,GAAY;IAC3D,OAAO,kCAAkC,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["// The email-verification refusal contract shared by the server gate (`createAssertAuth`'s\n// `emailVerified` requirement on ./server) and the client that answers it. Pure: no Firebase\n// runtime.\n//\n// A callable that requires a verified email refuses a caller whose ID token is not\n// email-verified. The package owns that refusal, so it owns its one recognisable shape: a\n// `failed-precondition` whose details name the reason. The client tells it apart from every\n// other failed-precondition by that reason — never by the message text.\n\nimport { failedPreconditionDetails } from \"./refusal.js\";\n\n/** The `details.reason` of the refusal a caller without a verified email receives. */\nexport const EMAIL_VERIFICATION_REQUIRED_REASON = \"email-verification-required\" as const;\n\n/**\n * Structured details carried by the email-verification refusal. Server side it rides\n * `AuthAssertionError.details`; the consuming app forwards it as the `HttpsError` details, so\n * the client receives it on the callable error's `details`.\n */\nexport interface EmailVerificationRequiredDetails {\n readonly reason: typeof EMAIL_VERIFICATION_REQUIRED_REASON;\n}\n\n/** True when `details` is the email-verification refusal's structured details. */\nexport function isEmailVerificationRequiredDetails(\n details: unknown\n): details is EmailVerificationRequiredDetails {\n if (!details || typeof details !== \"object\") return false;\n return (details as Record<string, unknown>).reason === EMAIL_VERIFICATION_REQUIRED_REASON;\n}\n\n/**\n * True when `err` is the email-verification refusal — a `failed-precondition` whose details\n * carry `reason: 'email-verification-required'`. Works on the server-side error and on the\n * client-side callable error alike, so the app has one recognizer for \"show the verify-email\n * surface\".\n */\nexport function isEmailVerificationRequiredError(err: unknown): boolean {\n return isEmailVerificationRequiredDetails(failedPreconditionDetails(err));\n}\n"]}
1
+ {"version":3,"file":"email-verification.js","sourceRoot":"","sources":["../src/email-verification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,CAAC,MAAM,kCAAkC,GAAG,6BAAsC,CAAC;AAMzF,MAAM,UAAU,kCAAkC,CAChD,OAAgB;IAEhB,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC1D,OAAQ,OAAmC,CAAC,MAAM,KAAK,kCAAkC,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,GAAY;IAC3D,OAAO,kCAAkC,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { failedPreconditionDetails } from './refusal.js';\n\nexport const EMAIL_VERIFICATION_REQUIRED_REASON = 'email-verification-required' as const;\n\nexport interface EmailVerificationRequiredDetails {\n readonly reason: typeof EMAIL_VERIFICATION_REQUIRED_REASON;\n}\n\nexport function isEmailVerificationRequiredDetails(\n details: unknown,\n): details is EmailVerificationRequiredDetails {\n if (!details || typeof details !== 'object') return false;\n return (details as Record<string, unknown>).reason === EMAIL_VERIFICATION_REQUIRED_REASON;\n}\n\nexport function isEmailVerificationRequiredError(err: unknown): boolean {\n return isEmailVerificationRequiredDetails(failedPreconditionDetails(err));\n}\n"]}
package/dist/env.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type AppEnvironment = "development" | "production";
1
+ export type AppEnvironment = 'development' | 'production';
2
2
  export declare function getAppEnvironment(): AppEnvironment;
3
3
  export declare function isDevelopment(): boolean;
4
4
  export declare function isProduction(): boolean;
package/dist/env.js CHANGED
@@ -1,13 +1,13 @@
1
1
  export function getAppEnvironment() {
2
- if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_APP_ENV === "production") {
3
- return "production";
2
+ if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_APP_ENV === 'production') {
3
+ return 'production';
4
4
  }
5
- return "development";
5
+ return 'development';
6
6
  }
7
7
  export function isDevelopment() {
8
- return getAppEnvironment() === "development";
8
+ return getAppEnvironment() === 'development';
9
9
  }
10
10
  export function isProduction() {
11
- return getAppEnvironment() === "production";
11
+ return getAppEnvironment() === 'production';
12
12
  }
13
13
  //# sourceMappingURL=env.js.map
package/dist/env.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,mBAAmB,KAAK,YAAY,EAAE,CAAC;QACxF,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,iBAAiB,EAAE,KAAK,aAAa,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,iBAAiB,EAAE,KAAK,YAAY,CAAC;AAC9C,CAAC","sourcesContent":["export type AppEnvironment = \"development\" | \"production\";\n\nexport function getAppEnvironment(): AppEnvironment {\n if (typeof process !== \"undefined\" && process.env?.NEXT_PUBLIC_APP_ENV === \"production\") {\n return \"production\";\n }\n return \"development\";\n}\n\nexport function isDevelopment(): boolean {\n return getAppEnvironment() === \"development\";\n}\n\nexport function isProduction(): boolean {\n return getAppEnvironment() === \"production\";\n}\n"]}
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,mBAAmB,KAAK,YAAY,EAAE,CAAC;QACxF,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,iBAAiB,EAAE,KAAK,aAAa,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,iBAAiB,EAAE,KAAK,YAAY,CAAC;AAC9C,CAAC","sourcesContent":["export type AppEnvironment = 'development' | 'production';\n\nexport function getAppEnvironment(): AppEnvironment {\n if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_APP_ENV === 'production') {\n return 'production';\n }\n return 'development';\n}\n\nexport function isDevelopment(): boolean {\n return getAppEnvironment() === 'development';\n}\n\nexport function isProduction(): boolean {\n return getAppEnvironment() === 'production';\n}\n"]}
package/dist/errors.d.ts CHANGED
@@ -1,13 +1,11 @@
1
- export type AuthErrorCode = "AUTH_UNKNOWN" | "AUTH_NETWORK_ERROR" | "AUTH_TOO_MANY_REQUESTS" | "AUTH_POPUP_CLOSED" | "AUTH_POPUP_BLOCKED" | "AUTH_CANCELLED" | "AUTH_USER_DISABLED" | "AUTH_USER_NOT_FOUND" | "AUTH_WRONG_PASSWORD" | "AUTH_INVALID_EMAIL" | "AUTH_EMAIL_ALREADY_IN_USE" | "AUTH_WEAK_PASSWORD" | "AUTH_REQUIRES_RECENT_LOGIN" | "AUTH_INVALID_CREDENTIAL" | "AUTH_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL" | "AUTH_PROVIDER_ALREADY_LINKED" | "AUTH_CREDENTIAL_ALREADY_IN_USE" | "AUTH_EXPIRED_ACTION_CODE" | "AUTH_INVALID_ACTION_CODE";
1
+ export type AuthErrorCode = 'AUTH_UNKNOWN' | 'AUTH_NETWORK_ERROR' | 'AUTH_TOO_MANY_REQUESTS' | 'AUTH_POPUP_CLOSED' | 'AUTH_POPUP_BLOCKED' | 'AUTH_CANCELLED' | 'AUTH_USER_DISABLED' | 'AUTH_USER_NOT_FOUND' | 'AUTH_WRONG_PASSWORD' | 'AUTH_INVALID_EMAIL' | 'AUTH_EMAIL_ALREADY_IN_USE' | 'AUTH_WEAK_PASSWORD' | 'AUTH_REQUIRES_RECENT_LOGIN' | 'AUTH_INVALID_CREDENTIAL' | 'AUTH_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL' | 'AUTH_PROVIDER_ALREADY_LINKED' | 'AUTH_CREDENTIAL_ALREADY_IN_USE' | 'AUTH_EXPIRED_ACTION_CODE' | 'AUTH_INVALID_ACTION_CODE';
2
2
  export type NormalizedAuthError = {
3
3
  code: AuthErrorCode;
4
4
  message: string;
5
5
  firebaseCode?: string;
6
6
  details?: Record<string, unknown>;
7
7
  };
8
- /** The copy for every auth failure no mapped code covers. */
9
8
  export declare const UNKNOWN_AUTH_ERROR_MESSAGE = "Authentication error. Please try again.";
10
9
  export declare function normalizeAuthError(err: unknown, details?: Record<string, unknown>): NormalizedAuthError;
11
- /** Convenience: returns just the user-facing message string */
12
10
  export declare function getErrorMessage(error: unknown): string;
13
11
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,mBAAmB,GACnB,oBAAoB,GACpB,gBAAgB,GAChB,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,2BAA2B,GAC3B,oBAAoB,GACpB,4BAA4B,GAC5B,yBAAyB,GACzB,+CAA+C,GAC/C,8BAA8B,GAC9B,gCAAgC,GAChC,0BAA0B,GAC1B,0BAA0B,CAAC;AAE/B,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAwFF,6DAA6D;AAC7D,eAAO,MAAM,0BAA0B,4CAA4C,CAAC;AAEpF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,mBAAmB,CAsBvG;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,mBAAmB,GACnB,oBAAoB,GACpB,gBAAgB,GAChB,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,2BAA2B,GAC3B,oBAAoB,GACpB,4BAA4B,GAC5B,yBAAyB,GACzB,+CAA+C,GAC/C,8BAA8B,GAC9B,gCAAgC,GAChC,0BAA0B,GAC1B,0BAA0B,CAAC;AAE/B,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAqFF,eAAO,MAAM,0BAA0B,4CAA4C,CAAC;AAEpF,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,mBAAmB,CAoBrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
package/dist/errors.js CHANGED
@@ -1,89 +1,85 @@
1
1
  function pickFirebaseCode(err) {
2
- if (!err || typeof err !== "object")
2
+ if (!err || typeof err !== 'object')
3
3
  return undefined;
4
4
  const anyErr = err;
5
5
  const c = anyErr.code;
6
- return typeof c === "string" ? c : undefined;
6
+ return typeof c === 'string' ? c : undefined;
7
7
  }
8
8
  const MAP = {
9
- "auth/network-request-failed": {
10
- code: "AUTH_NETWORK_ERROR",
11
- message: "Network error. Please check your connection and try again."
12
- },
13
- "auth/too-many-requests": {
14
- code: "AUTH_TOO_MANY_REQUESTS",
15
- message: "Too many attempts. Please wait a moment and try again."
16
- },
17
- "auth/popup-closed-by-user": {
18
- code: "AUTH_POPUP_CLOSED",
19
- message: "Sign-in popup was closed."
20
- },
21
- "auth/popup-blocked": {
22
- code: "AUTH_POPUP_BLOCKED",
23
- message: "Sign-in popup was blocked by the browser."
24
- },
25
- "auth/cancelled-popup-request": {
26
- code: "AUTH_CANCELLED",
27
- message: "Sign-in was cancelled."
28
- },
29
- "auth/user-disabled": {
30
- code: "AUTH_USER_DISABLED",
31
- message: "This account has been disabled."
32
- },
33
- "auth/user-not-found": {
34
- code: "AUTH_USER_NOT_FOUND",
35
- message: "No account found with that email."
36
- },
37
- "auth/wrong-password": {
38
- code: "AUTH_WRONG_PASSWORD",
39
- message: "Incorrect password."
40
- },
41
- "auth/invalid-email": {
42
- code: "AUTH_INVALID_EMAIL",
43
- message: "Invalid email address."
44
- },
45
- "auth/email-already-in-use": {
46
- code: "AUTH_EMAIL_ALREADY_IN_USE",
47
- message: "That email is already in use."
48
- },
49
- "auth/weak-password": {
50
- code: "AUTH_WEAK_PASSWORD",
51
- message: "Password is too weak."
52
- },
53
- "auth/requires-recent-login": {
54
- code: "AUTH_REQUIRES_RECENT_LOGIN",
55
- message: "Please re-authenticate and try again."
56
- },
57
- "auth/invalid-credential": {
58
- code: "AUTH_INVALID_CREDENTIAL",
59
- message: "Invalid credentials. Please try again."
60
- },
61
- "auth/account-exists-with-different-credential": {
62
- code: "AUTH_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL",
63
- message: "An account already exists with a different sign-in method."
64
- },
65
- "auth/provider-already-linked": {
66
- code: "AUTH_PROVIDER_ALREADY_LINKED",
67
- message: "That provider is already linked to this account."
68
- },
69
- "auth/credential-already-in-use": {
70
- code: "AUTH_CREDENTIAL_ALREADY_IN_USE",
71
- message: "Those credentials are already associated with another account."
72
- },
73
- // Email-action (oobCode) links — password reset, email verification, email recovery.
74
- // The copy is deliberately generic: it never reveals whether an account exists, and it
75
- // always points at the one recovery affordance (request a fresh link).
76
- "auth/expired-action-code": {
77
- code: "AUTH_EXPIRED_ACTION_CODE",
78
- message: "This email action link has expired. Request a new link and try again."
79
- },
80
- "auth/invalid-action-code": {
81
- code: "AUTH_INVALID_ACTION_CODE",
82
- message: "This email action link is invalid or has already been used. Request a new link and try again."
83
- }
9
+ 'auth/network-request-failed': {
10
+ code: 'AUTH_NETWORK_ERROR',
11
+ message: 'Network error. Please check your connection and try again.',
12
+ },
13
+ 'auth/too-many-requests': {
14
+ code: 'AUTH_TOO_MANY_REQUESTS',
15
+ message: 'Too many attempts. Please wait a moment and try again.',
16
+ },
17
+ 'auth/popup-closed-by-user': {
18
+ code: 'AUTH_POPUP_CLOSED',
19
+ message: 'Sign-in popup was closed.',
20
+ },
21
+ 'auth/popup-blocked': {
22
+ code: 'AUTH_POPUP_BLOCKED',
23
+ message: 'Sign-in popup was blocked by the browser.',
24
+ },
25
+ 'auth/cancelled-popup-request': {
26
+ code: 'AUTH_CANCELLED',
27
+ message: 'Sign-in was cancelled.',
28
+ },
29
+ 'auth/user-disabled': {
30
+ code: 'AUTH_USER_DISABLED',
31
+ message: 'This account has been disabled.',
32
+ },
33
+ 'auth/user-not-found': {
34
+ code: 'AUTH_USER_NOT_FOUND',
35
+ message: 'No account found with that email.',
36
+ },
37
+ 'auth/wrong-password': {
38
+ code: 'AUTH_WRONG_PASSWORD',
39
+ message: 'Incorrect password.',
40
+ },
41
+ 'auth/invalid-email': {
42
+ code: 'AUTH_INVALID_EMAIL',
43
+ message: 'Invalid email address.',
44
+ },
45
+ 'auth/email-already-in-use': {
46
+ code: 'AUTH_EMAIL_ALREADY_IN_USE',
47
+ message: 'That email is already in use.',
48
+ },
49
+ 'auth/weak-password': {
50
+ code: 'AUTH_WEAK_PASSWORD',
51
+ message: 'Password is too weak.',
52
+ },
53
+ 'auth/requires-recent-login': {
54
+ code: 'AUTH_REQUIRES_RECENT_LOGIN',
55
+ message: 'Please re-authenticate and try again.',
56
+ },
57
+ 'auth/invalid-credential': {
58
+ code: 'AUTH_INVALID_CREDENTIAL',
59
+ message: 'Invalid credentials. Please try again.',
60
+ },
61
+ 'auth/account-exists-with-different-credential': {
62
+ code: 'AUTH_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL',
63
+ message: 'An account already exists with a different sign-in method.',
64
+ },
65
+ 'auth/provider-already-linked': {
66
+ code: 'AUTH_PROVIDER_ALREADY_LINKED',
67
+ message: 'That provider is already linked to this account.',
68
+ },
69
+ 'auth/credential-already-in-use': {
70
+ code: 'AUTH_CREDENTIAL_ALREADY_IN_USE',
71
+ message: 'Those credentials are already associated with another account.',
72
+ },
73
+ 'auth/expired-action-code': {
74
+ code: 'AUTH_EXPIRED_ACTION_CODE',
75
+ message: 'This email action link has expired. Request a new link and try again.',
76
+ },
77
+ 'auth/invalid-action-code': {
78
+ code: 'AUTH_INVALID_ACTION_CODE',
79
+ message: 'This email action link is invalid or has already been used. Request a new link and try again.',
80
+ },
84
81
  };
85
- /** The copy for every auth failure no mapped code covers. */
86
- export const UNKNOWN_AUTH_ERROR_MESSAGE = "Authentication error. Please try again.";
82
+ export const UNKNOWN_AUTH_ERROR_MESSAGE = 'Authentication error. Please try again.';
87
83
  export function normalizeAuthError(err, details) {
88
84
  const firebaseCode = pickFirebaseCode(err);
89
85
  const mapped = firebaseCode ? MAP[firebaseCode] : undefined;
@@ -92,20 +88,17 @@ export function normalizeAuthError(err, details) {
92
88
  code: mapped.code,
93
89
  message: mapped.message,
94
90
  firebaseCode,
95
- details
91
+ details,
96
92
  };
97
93
  }
98
- // Never the error's own message: for an unclassified failure it is the SDK's internal diagnostic
99
- // ("Firebase: Cloud function deadline exceeded. (auth/internal-error)."), not an answer the person
100
- // can act on. The consumer reports the error itself to its monitoring.
94
+ // Never the error's own message: for an unclassified failure it is the SDK's internal diagnostic.
101
95
  return {
102
- code: "AUTH_UNKNOWN",
96
+ code: 'AUTH_UNKNOWN',
103
97
  message: UNKNOWN_AUTH_ERROR_MESSAGE,
104
98
  firebaseCode,
105
- details
99
+ details,
106
100
  };
107
101
  }
108
- /** Convenience: returns just the user-facing message string */
109
102
  export function getErrorMessage(error) {
110
103
  return normalizeAuthError(error).message;
111
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AA4BA,SAAS,gBAAgB,CAAC,GAAY;IACpC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACtD,MAAM,MAAM,GAAG,GAAU,CAAC;IAC1B,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;IACtB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/C,CAAC;AAED,MAAM,GAAG,GAA6D;IACpE,6BAA6B,EAAE;QAC7B,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,4DAA4D;KACtE;IACD,wBAAwB,EAAE;QACxB,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EAAE,wDAAwD;KAClE;IACD,2BAA2B,EAAE;QAC3B,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,2BAA2B;KACrC;IACD,oBAAoB,EAAE;QACpB,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,2CAA2C;KACrD;IACD,8BAA8B,EAAE;QAC9B,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,wBAAwB;KAClC;IACD,oBAAoB,EAAE;QACpB,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,iCAAiC;KAC3C;IACD,qBAAqB,EAAE;QACrB,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,mCAAmC;KAC7C;IACD,qBAAqB,EAAE;QACrB,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,qBAAqB;KAC/B;IACD,oBAAoB,EAAE;QACpB,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,wBAAwB;KAClC;IACD,2BAA2B,EAAE;QAC3B,IAAI,EAAE,2BAA2B;QACjC,OAAO,EAAE,+BAA+B;KACzC;IACD,oBAAoB,EAAE;QACpB,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,uBAAuB;KACjC;IACD,4BAA4B,EAAE;QAC5B,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,uCAAuC;KACjD;IACD,yBAAyB,EAAE;QACzB,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,wCAAwC;KAClD;IACD,+CAA+C,EAAE;QAC/C,IAAI,EAAE,+CAA+C;QACrD,OAAO,EAAE,4DAA4D;KACtE;IACD,8BAA8B,EAAE;QAC9B,IAAI,EAAE,8BAA8B;QACpC,OAAO,EAAE,kDAAkD;KAC5D;IACD,gCAAgC,EAAE;QAChC,IAAI,EAAE,gCAAgC;QACtC,OAAO,EAAE,gEAAgE;KAC1E;IACD,qFAAqF;IACrF,uFAAuF;IACvF,uEAAuE;IACvE,0BAA0B,EAAE;QAC1B,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,uEAAuE;KACjF;IACD,0BAA0B,EAAE;QAC1B,IAAI,EAAE,0BAA0B;QAChC,OAAO,EACL,+FAA+F;KAClG;CACF,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,0BAA0B,GAAG,yCAAyC,CAAC;AAEpF,MAAM,UAAU,kBAAkB,CAAC,GAAY,EAAE,OAAiC;IAChF,MAAM,YAAY,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,YAAY;YACZ,OAAO;SACR,CAAC;IACJ,CAAC;IAED,iGAAiG;IACjG,mGAAmG;IACnG,uEAAuE;IACvE,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,0BAA0B;QACnC,YAAY;QACZ,OAAO;KACR,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC3C,CAAC","sourcesContent":["export type AuthErrorCode =\n | \"AUTH_UNKNOWN\"\n | \"AUTH_NETWORK_ERROR\"\n | \"AUTH_TOO_MANY_REQUESTS\"\n | \"AUTH_POPUP_CLOSED\"\n | \"AUTH_POPUP_BLOCKED\"\n | \"AUTH_CANCELLED\"\n | \"AUTH_USER_DISABLED\"\n | \"AUTH_USER_NOT_FOUND\"\n | \"AUTH_WRONG_PASSWORD\"\n | \"AUTH_INVALID_EMAIL\"\n | \"AUTH_EMAIL_ALREADY_IN_USE\"\n | \"AUTH_WEAK_PASSWORD\"\n | \"AUTH_REQUIRES_RECENT_LOGIN\"\n | \"AUTH_INVALID_CREDENTIAL\"\n | \"AUTH_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL\"\n | \"AUTH_PROVIDER_ALREADY_LINKED\"\n | \"AUTH_CREDENTIAL_ALREADY_IN_USE\"\n | \"AUTH_EXPIRED_ACTION_CODE\"\n | \"AUTH_INVALID_ACTION_CODE\";\n\nexport type NormalizedAuthError = {\n code: AuthErrorCode;\n message: string;\n firebaseCode?: string;\n details?: Record<string, unknown>;\n};\n\nfunction pickFirebaseCode(err: unknown): string | undefined {\n if (!err || typeof err !== \"object\") return undefined;\n const anyErr = err as any;\n const c = anyErr.code;\n return typeof c === \"string\" ? c : undefined;\n}\n\nconst MAP: Record<string, { code: AuthErrorCode; message: string }> = {\n \"auth/network-request-failed\": {\n code: \"AUTH_NETWORK_ERROR\",\n message: \"Network error. Please check your connection and try again.\"\n },\n \"auth/too-many-requests\": {\n code: \"AUTH_TOO_MANY_REQUESTS\",\n message: \"Too many attempts. Please wait a moment and try again.\"\n },\n \"auth/popup-closed-by-user\": {\n code: \"AUTH_POPUP_CLOSED\",\n message: \"Sign-in popup was closed.\"\n },\n \"auth/popup-blocked\": {\n code: \"AUTH_POPUP_BLOCKED\",\n message: \"Sign-in popup was blocked by the browser.\"\n },\n \"auth/cancelled-popup-request\": {\n code: \"AUTH_CANCELLED\",\n message: \"Sign-in was cancelled.\"\n },\n \"auth/user-disabled\": {\n code: \"AUTH_USER_DISABLED\",\n message: \"This account has been disabled.\"\n },\n \"auth/user-not-found\": {\n code: \"AUTH_USER_NOT_FOUND\",\n message: \"No account found with that email.\"\n },\n \"auth/wrong-password\": {\n code: \"AUTH_WRONG_PASSWORD\",\n message: \"Incorrect password.\"\n },\n \"auth/invalid-email\": {\n code: \"AUTH_INVALID_EMAIL\",\n message: \"Invalid email address.\"\n },\n \"auth/email-already-in-use\": {\n code: \"AUTH_EMAIL_ALREADY_IN_USE\",\n message: \"That email is already in use.\"\n },\n \"auth/weak-password\": {\n code: \"AUTH_WEAK_PASSWORD\",\n message: \"Password is too weak.\"\n },\n \"auth/requires-recent-login\": {\n code: \"AUTH_REQUIRES_RECENT_LOGIN\",\n message: \"Please re-authenticate and try again.\"\n },\n \"auth/invalid-credential\": {\n code: \"AUTH_INVALID_CREDENTIAL\",\n message: \"Invalid credentials. Please try again.\"\n },\n \"auth/account-exists-with-different-credential\": {\n code: \"AUTH_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL\",\n message: \"An account already exists with a different sign-in method.\"\n },\n \"auth/provider-already-linked\": {\n code: \"AUTH_PROVIDER_ALREADY_LINKED\",\n message: \"That provider is already linked to this account.\"\n },\n \"auth/credential-already-in-use\": {\n code: \"AUTH_CREDENTIAL_ALREADY_IN_USE\",\n message: \"Those credentials are already associated with another account.\"\n },\n // Email-action (oobCode) links — password reset, email verification, email recovery.\n // The copy is deliberately generic: it never reveals whether an account exists, and it\n // always points at the one recovery affordance (request a fresh link).\n \"auth/expired-action-code\": {\n code: \"AUTH_EXPIRED_ACTION_CODE\",\n message: \"This email action link has expired. Request a new link and try again.\"\n },\n \"auth/invalid-action-code\": {\n code: \"AUTH_INVALID_ACTION_CODE\",\n message:\n \"This email action link is invalid or has already been used. Request a new link and try again.\"\n }\n};\n\n/** The copy for every auth failure no mapped code covers. */\nexport const UNKNOWN_AUTH_ERROR_MESSAGE = \"Authentication error. Please try again.\";\n\nexport function normalizeAuthError(err: unknown, details?: Record<string, unknown>): NormalizedAuthError {\n const firebaseCode = pickFirebaseCode(err);\n\n const mapped = firebaseCode ? MAP[firebaseCode] : undefined;\n if (mapped) {\n return {\n code: mapped.code,\n message: mapped.message,\n firebaseCode,\n details\n };\n }\n\n // Never the error's own message: for an unclassified failure it is the SDK's internal diagnostic\n // (\"Firebase: Cloud function deadline exceeded. (auth/internal-error).\"), not an answer the person\n // can act on. The consumer reports the error itself to its monitoring.\n return {\n code: \"AUTH_UNKNOWN\",\n message: UNKNOWN_AUTH_ERROR_MESSAGE,\n firebaseCode,\n details\n };\n}\n\n/** Convenience: returns just the user-facing message string */\nexport function getErrorMessage(error: unknown): string {\n return normalizeAuthError(error).message;\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"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","sourcesContent":["export type AuthErrorCode =\n | 'AUTH_UNKNOWN'\n | 'AUTH_NETWORK_ERROR'\n | 'AUTH_TOO_MANY_REQUESTS'\n | 'AUTH_POPUP_CLOSED'\n | 'AUTH_POPUP_BLOCKED'\n | 'AUTH_CANCELLED'\n | 'AUTH_USER_DISABLED'\n | 'AUTH_USER_NOT_FOUND'\n | 'AUTH_WRONG_PASSWORD'\n | 'AUTH_INVALID_EMAIL'\n | 'AUTH_EMAIL_ALREADY_IN_USE'\n | 'AUTH_WEAK_PASSWORD'\n | 'AUTH_REQUIRES_RECENT_LOGIN'\n | 'AUTH_INVALID_CREDENTIAL'\n | 'AUTH_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL'\n | 'AUTH_PROVIDER_ALREADY_LINKED'\n | 'AUTH_CREDENTIAL_ALREADY_IN_USE'\n | 'AUTH_EXPIRED_ACTION_CODE'\n | 'AUTH_INVALID_ACTION_CODE';\n\nexport type NormalizedAuthError = {\n code: AuthErrorCode;\n message: string;\n firebaseCode?: string;\n details?: Record<string, unknown>;\n};\n\nfunction pickFirebaseCode(err: unknown): string | undefined {\n if (!err || typeof err !== 'object') return undefined;\n const anyErr = err as any;\n const c = anyErr.code;\n return typeof c === 'string' ? c : undefined;\n}\n\nconst MAP: Record<string, { code: AuthErrorCode; message: string }> = {\n 'auth/network-request-failed': {\n code: 'AUTH_NETWORK_ERROR',\n message: 'Network error. Please check your connection and try again.',\n },\n 'auth/too-many-requests': {\n code: 'AUTH_TOO_MANY_REQUESTS',\n message: 'Too many attempts. Please wait a moment and try again.',\n },\n 'auth/popup-closed-by-user': {\n code: 'AUTH_POPUP_CLOSED',\n message: 'Sign-in popup was closed.',\n },\n 'auth/popup-blocked': {\n code: 'AUTH_POPUP_BLOCKED',\n message: 'Sign-in popup was blocked by the browser.',\n },\n 'auth/cancelled-popup-request': {\n code: 'AUTH_CANCELLED',\n message: 'Sign-in was cancelled.',\n },\n 'auth/user-disabled': {\n code: 'AUTH_USER_DISABLED',\n message: 'This account has been disabled.',\n },\n 'auth/user-not-found': {\n code: 'AUTH_USER_NOT_FOUND',\n message: 'No account found with that email.',\n },\n 'auth/wrong-password': {\n code: 'AUTH_WRONG_PASSWORD',\n message: 'Incorrect password.',\n },\n 'auth/invalid-email': {\n code: 'AUTH_INVALID_EMAIL',\n message: 'Invalid email address.',\n },\n 'auth/email-already-in-use': {\n code: 'AUTH_EMAIL_ALREADY_IN_USE',\n message: 'That email is already in use.',\n },\n 'auth/weak-password': {\n code: 'AUTH_WEAK_PASSWORD',\n message: 'Password is too weak.',\n },\n 'auth/requires-recent-login': {\n code: 'AUTH_REQUIRES_RECENT_LOGIN',\n message: 'Please re-authenticate and try again.',\n },\n 'auth/invalid-credential': {\n code: 'AUTH_INVALID_CREDENTIAL',\n message: 'Invalid credentials. Please try again.',\n },\n 'auth/account-exists-with-different-credential': {\n code: 'AUTH_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL',\n message: 'An account already exists with a different sign-in method.',\n },\n 'auth/provider-already-linked': {\n code: 'AUTH_PROVIDER_ALREADY_LINKED',\n message: 'That provider is already linked to this account.',\n },\n 'auth/credential-already-in-use': {\n code: 'AUTH_CREDENTIAL_ALREADY_IN_USE',\n message: 'Those credentials are already associated with another account.',\n },\n 'auth/expired-action-code': {\n code: 'AUTH_EXPIRED_ACTION_CODE',\n message: 'This email action link has expired. Request a new link and try again.',\n },\n 'auth/invalid-action-code': {\n code: 'AUTH_INVALID_ACTION_CODE',\n message:\n 'This email action link is invalid or has already been used. Request a new link and try again.',\n },\n};\n\nexport const UNKNOWN_AUTH_ERROR_MESSAGE = 'Authentication error. Please try again.';\n\nexport function normalizeAuthError(\n err: unknown,\n details?: Record<string, unknown>,\n): NormalizedAuthError {\n const firebaseCode = pickFirebaseCode(err);\n\n const mapped = firebaseCode ? MAP[firebaseCode] : undefined;\n if (mapped) {\n return {\n code: mapped.code,\n message: mapped.message,\n firebaseCode,\n details,\n };\n }\n\n // Never the error's own message: for an unclassified failure it is the SDK's internal diagnostic.\n return {\n code: 'AUTH_UNKNOWN',\n message: UNKNOWN_AUTH_ERROR_MESSAGE,\n firebaseCode,\n details,\n };\n}\n\nexport function getErrorMessage(error: unknown): string {\n return normalizeAuthError(error).message;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- export * from "./claims.js";
2
- export * from "./errors.js";
3
- export * from "./env.js";
4
- export * from "./acceptance.js";
5
- export * from "./email-verification.js";
1
+ export * from './errors.js';
2
+ export * from './env.js';
3
+ export * from './acceptance.js';
4
+ export * from './email-verification.js';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}