@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.
- package/dist/acceptance.d.ts +0 -20
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +6 -26
- package/dist/acceptance.js.map +1 -1
- package/dist/{auth.d.ts → client/auth.d.ts} +1 -6
- package/dist/client/auth.d.ts.map +1 -0
- package/dist/client/auth.js +8 -0
- package/dist/client/auth.js.map +1 -0
- package/dist/client/claims.d.ts +11 -0
- package/dist/client/claims.d.ts.map +1 -0
- package/dist/client/claims.js +30 -0
- package/dist/client/claims.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/email-verification.d.ts +0 -13
- package/dist/email-verification.d.ts.map +1 -1
- package/dist/email-verification.js +3 -19
- package/dist/email-verification.js.map +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/env.js +5 -5
- package/dist/env.js.map +1 -1
- package/dist/errors.d.ts +1 -3
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +79 -86
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -12
- package/dist/index.js.map +1 -1
- package/dist/react/AuthProvider.d.ts +3 -3
- package/dist/react/AuthProvider.d.ts.map +1 -1
- package/dist/react/AuthProvider.js +18 -36
- package/dist/react/AuthProvider.js.map +1 -1
- package/dist/react/index.d.ts +8 -8
- package/dist/react/index.js +6 -6
- package/dist/react/index.js.map +1 -1
- package/dist/react/redirect-storage.d.ts.map +1 -1
- package/dist/react/redirect-storage.js +5 -14
- package/dist/react/redirect-storage.js.map +1 -1
- package/dist/react/types.d.ts +1 -22
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/types.js.map +1 -1
- package/dist/react/useAuth.d.ts +1 -5
- package/dist/react/useAuth.d.ts.map +1 -1
- package/dist/react/useAuth.js +4 -8
- package/dist/react/useAuth.js.map +1 -1
- package/dist/react/useAuthGuard.d.ts +0 -33
- package/dist/react/useAuthGuard.d.ts.map +1 -1
- package/dist/react/useAuthGuard.js +7 -37
- package/dist/react/useAuthGuard.js.map +1 -1
- package/dist/react/useAuthState.d.ts +1 -1
- package/dist/react/useAuthState.d.ts.map +1 -1
- package/dist/react/useAuthState.js +2 -6
- package/dist/react/useAuthState.js.map +1 -1
- package/dist/refusal.d.ts +0 -6
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +6 -16
- package/dist/refusal.js.map +1 -1
- package/dist/server/assertAuth.d.ts +2 -2
- package/dist/server/assertAuth.d.ts.map +1 -1
- package/dist/server/assertAuth.js +13 -38
- package/dist/server/assertAuth.js.map +1 -1
- package/dist/server/authError.d.ts +3 -51
- package/dist/server/authError.d.ts.map +1 -1
- package/dist/server/authError.js +1 -1
- package/dist/server/authError.js.map +1 -1
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/types.d.ts +9 -109
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js +0 -2
- package/dist/server/types.js.map +1 -1
- package/package.json +3 -3
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -13
- package/dist/auth.js.map +0 -1
- package/dist/claims.d.ts +0 -38
- package/dist/claims.d.ts.map +0 -1
- package/dist/claims.js +0 -55
- package/dist/claims.js.map +0 -1
- package/dist/client.d.ts +0 -2
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -5
- package/dist/client.js.map +0 -1
package/dist/claims.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
/**
|
|
8
|
-
* Get the current user's ID token claims.
|
|
9
|
-
* Returns null if no current user.
|
|
10
|
-
*
|
|
11
|
-
* STALE-VERIFICATION RECONCILIATION: when the ACCOUNT says the email is
|
|
12
|
-
* verified but the cached token claim still says it is not, force-mint a fresh
|
|
13
|
-
* token and return ITS claims. Firebase ID tokens live for up to an hour and a
|
|
14
|
-
* backend-side `emailVerified` flip (verification link applied elsewhere, or an
|
|
15
|
-
* Admin SDK update) never invalidates them — without this, the UI (account
|
|
16
|
-
* state) believes the user is verified while every backend call (token claim)
|
|
17
|
-
* rejects with "Email must be verified" until the token happens to rotate.
|
|
18
|
-
* One forced mint converges the two (the fresh token carries
|
|
19
|
-
* `email_verified: true`); the check is directional, so an already-consistent
|
|
20
|
-
* user never pays a forced refresh.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getIdTokenClaims(user: User | null): Promise<IdTokenClaims | null>;
|
|
23
|
-
/**
|
|
24
|
-
* Forces refresh of ID token + claims.
|
|
25
|
-
* Returns null if no current user.
|
|
26
|
-
*/
|
|
27
|
-
export declare function refreshClaims(user: User | null): Promise<IdTokenClaims | null>;
|
|
28
|
-
/**
|
|
29
|
-
* Convenience helper when you only have Auth.
|
|
30
|
-
*/
|
|
31
|
-
export declare function refreshClaimsFromAuth(auth: Auth): Promise<IdTokenClaims | null>;
|
|
32
|
-
/**
|
|
33
|
-
* Keep parsing intentionally minimal and generic:
|
|
34
|
-
* - normalize "roles" into string[]
|
|
35
|
-
* - keep raw claims attached
|
|
36
|
-
*/
|
|
37
|
-
export declare function parseClaims(claims: IdTokenClaims | null | undefined): ParsedClaims;
|
|
38
|
-
//# sourceMappingURL=claims.d.ts.map
|
package/dist/claims.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../src/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;IAEzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAEhB,GAAG,EAAE,aAAa,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAQvF;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAIpF;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAErF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,CAUlF"}
|
package/dist/claims.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the current user's ID token claims.
|
|
3
|
-
* Returns null if no current user.
|
|
4
|
-
*
|
|
5
|
-
* STALE-VERIFICATION RECONCILIATION: when the ACCOUNT says the email is
|
|
6
|
-
* verified but the cached token claim still says it is not, force-mint a fresh
|
|
7
|
-
* token and return ITS claims. Firebase ID tokens live for up to an hour and a
|
|
8
|
-
* backend-side `emailVerified` flip (verification link applied elsewhere, or an
|
|
9
|
-
* Admin SDK update) never invalidates them — without this, the UI (account
|
|
10
|
-
* state) believes the user is verified while every backend call (token claim)
|
|
11
|
-
* rejects with "Email must be verified" until the token happens to rotate.
|
|
12
|
-
* One forced mint converges the two (the fresh token carries
|
|
13
|
-
* `email_verified: true`); the check is directional, so an already-consistent
|
|
14
|
-
* user never pays a forced refresh.
|
|
15
|
-
*/
|
|
16
|
-
export async function getIdTokenClaims(user) {
|
|
17
|
-
if (!user)
|
|
18
|
-
return null;
|
|
19
|
-
const res = await user.getIdTokenResult(false);
|
|
20
|
-
if (user.emailVerified === true && res.claims.email_verified !== true) {
|
|
21
|
-
const fresh = await user.getIdTokenResult(true);
|
|
22
|
-
return fresh.claims;
|
|
23
|
-
}
|
|
24
|
-
return res.claims;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Forces refresh of ID token + claims.
|
|
28
|
-
* Returns null if no current user.
|
|
29
|
-
*/
|
|
30
|
-
export async function refreshClaims(user) {
|
|
31
|
-
if (!user)
|
|
32
|
-
return null;
|
|
33
|
-
const res = await user.getIdTokenResult(true);
|
|
34
|
-
return res.claims;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Convenience helper when you only have Auth.
|
|
38
|
-
*/
|
|
39
|
-
export async function refreshClaimsFromAuth(auth) {
|
|
40
|
-
return refreshClaims(auth.currentUser);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Keep parsing intentionally minimal and generic:
|
|
44
|
-
* - normalize "roles" into string[]
|
|
45
|
-
* - keep raw claims attached
|
|
46
|
-
*/
|
|
47
|
-
export function parseClaims(claims) {
|
|
48
|
-
const raw = (claims ?? {});
|
|
49
|
-
const rolesValue = raw.roles;
|
|
50
|
-
const roles = Array.isArray(rolesValue) ? rolesValue.filter((x) => typeof x === "string") :
|
|
51
|
-
typeof rolesValue === "string" ? [rolesValue] :
|
|
52
|
-
[];
|
|
53
|
-
return { roles, raw };
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=claims.js.map
|
package/dist/claims.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claims.js","sourceRoot":"","sources":["../src/claims.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAiB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AE,CAAC;AACxB,CAAC","sourcesContent":["import type { Auth, User, IdTokenResult } from \"firebase/auth\";\n\nexport type IdTokenClaims = IdTokenResult[\"claims\"];\n\nexport type ParsedClaims = {\n // common defaults (kept generic)\n roles: string[];\n // raw claims for app-level decisions\n raw: IdTokenClaims;\n};\n\n/**\n * Get the current user's ID token claims.\n * Returns null if no current user.\n *\n * STALE-VERIFICATION RECONCILIATION: when the ACCOUNT says the email is\n * verified but the cached token claim still says it is not, force-mint a fresh\n * token and return ITS claims. Firebase ID tokens live for up to an hour and a\n * backend-side `emailVerified` flip (verification link applied elsewhere, or an\n * Admin SDK update) never invalidates them — without this, the UI (account\n * state) believes the user is verified while every backend call (token claim)\n * rejects with \"Email must be verified\" until the token happens to rotate.\n * One forced mint converges the two (the fresh token carries\n * `email_verified: true`); the check is directional, so an already-consistent\n * user never pays a forced refresh.\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\n/**\n * Forces refresh of ID token + claims.\n * Returns null if no current user.\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\n/**\n * Convenience helper when you only have Auth.\n */\nexport async function refreshClaimsFromAuth(auth: Auth): Promise<IdTokenClaims | null> {\n return refreshClaims(auth.currentUser);\n}\n\n/**\n * Keep parsing intentionally minimal and generic:\n * - normalize \"roles\" into string[]\n * - keep raw claims attached\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 =\n Array.isArray(rolesValue) ? rolesValue.filter((x) => typeof x === \"string\") :\n typeof rolesValue === \"string\" ? [rolesValue] :\n [];\n\n return { roles, raw };\n}\n"]}
|
package/dist/client.d.ts
DELETED
package/dist/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,cAAc,WAAW,CAAC"}
|
package/dist/client.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Firebase *client* auth runtime. Importing this subpath pulls firebase/auth
|
|
2
|
-
// at runtime (e.g. onAuthStateChanged), so it is intentionally kept off the
|
|
3
|
-
// pure root. The pure root exposes only contracts/config/errors.
|
|
4
|
-
export * from "./auth.js";
|
|
5
|
-
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,iEAAiE;AACjE,cAAc,WAAW,CAAC","sourcesContent":["// Firebase *client* auth runtime. Importing this subpath pulls firebase/auth\n// at runtime (e.g. onAuthStateChanged), so it is intentionally kept off the\n// pure root. The pure root exposes only contracts/config/errors.\nexport * from \"./auth.js\";\n"]}
|