@pristine-ts/gcp-identity-platform 2.0.16

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 (55) hide show
  1. package/LICENSE +201 -0
  2. package/dist/lib/cjs/authenticators/authenticators.js +18 -0
  3. package/dist/lib/cjs/authenticators/authenticators.js.map +1 -0
  4. package/dist/lib/cjs/authenticators/identity-platform.authenticator.js +186 -0
  5. package/dist/lib/cjs/authenticators/identity-platform.authenticator.js.map +1 -0
  6. package/dist/lib/cjs/gcp-identity-platform.configuration-keys.js +7 -0
  7. package/dist/lib/cjs/gcp-identity-platform.configuration-keys.js.map +1 -0
  8. package/dist/lib/cjs/gcp-identity-platform.module.js +46 -0
  9. package/dist/lib/cjs/gcp-identity-platform.module.js.map +1 -0
  10. package/dist/lib/cjs/gcp-identity-platform.module.keyname.js +5 -0
  11. package/dist/lib/cjs/gcp-identity-platform.module.keyname.js.map +1 -0
  12. package/dist/lib/cjs/guards/guards.js +18 -0
  13. package/dist/lib/cjs/guards/guards.js.map +1 -0
  14. package/dist/lib/cjs/guards/identity-platform-claim.guard.js +77 -0
  15. package/dist/lib/cjs/guards/identity-platform-claim.guard.js.map +1 -0
  16. package/dist/lib/cjs/interfaces/claim.interface.js +3 -0
  17. package/dist/lib/cjs/interfaces/claim.interface.js.map +1 -0
  18. package/dist/lib/cjs/interfaces/interfaces.js +19 -0
  19. package/dist/lib/cjs/interfaces/interfaces.js.map +1 -0
  20. package/dist/lib/cjs/interfaces/token-header.interface.js +3 -0
  21. package/dist/lib/cjs/interfaces/token-header.interface.js.map +1 -0
  22. package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  23. package/dist/lib/esm/authenticators/authenticators.js +2 -0
  24. package/dist/lib/esm/authenticators/authenticators.js.map +1 -0
  25. package/dist/lib/esm/authenticators/identity-platform.authenticator.js +150 -0
  26. package/dist/lib/esm/authenticators/identity-platform.authenticator.js.map +1 -0
  27. package/dist/lib/esm/gcp-identity-platform.configuration-keys.js +4 -0
  28. package/dist/lib/esm/gcp-identity-platform.configuration-keys.js.map +1 -0
  29. package/dist/lib/esm/gcp-identity-platform.module.js +29 -0
  30. package/dist/lib/esm/gcp-identity-platform.module.js.map +1 -0
  31. package/dist/lib/esm/gcp-identity-platform.module.keyname.js +2 -0
  32. package/dist/lib/esm/gcp-identity-platform.module.keyname.js.map +1 -0
  33. package/dist/lib/esm/guards/guards.js +2 -0
  34. package/dist/lib/esm/guards/guards.js.map +1 -0
  35. package/dist/lib/esm/guards/identity-platform-claim.guard.js +74 -0
  36. package/dist/lib/esm/guards/identity-platform-claim.guard.js.map +1 -0
  37. package/dist/lib/esm/interfaces/claim.interface.js +2 -0
  38. package/dist/lib/esm/interfaces/claim.interface.js.map +1 -0
  39. package/dist/lib/esm/interfaces/interfaces.js +3 -0
  40. package/dist/lib/esm/interfaces/interfaces.js.map +1 -0
  41. package/dist/lib/esm/interfaces/token-header.interface.js +2 -0
  42. package/dist/lib/esm/interfaces/token-header.interface.js.map +1 -0
  43. package/dist/lib/esm/tsconfig.tsbuildinfo +1 -0
  44. package/dist/types/authenticators/authenticators.d.ts +1 -0
  45. package/dist/types/authenticators/identity-platform.authenticator.d.ts +39 -0
  46. package/dist/types/gcp-identity-platform.configuration-keys.d.ts +10 -0
  47. package/dist/types/gcp-identity-platform.module.d.ts +7 -0
  48. package/dist/types/gcp-identity-platform.module.keyname.d.ts +1 -0
  49. package/dist/types/guards/guards.d.ts +1 -0
  50. package/dist/types/guards/identity-platform-claim.guard.d.ts +19 -0
  51. package/dist/types/interfaces/claim.interface.d.ts +30 -0
  52. package/dist/types/interfaces/interfaces.d.ts +2 -0
  53. package/dist/types/interfaces/token-header.interface.d.ts +9 -0
  54. package/package.json +72 -0
  55. package/readme.md +5 -0
@@ -0,0 +1,19 @@
1
+ import { IdentityInterface, Request } from "@pristine-ts/common";
2
+ import { GuardContextInterface, GuardInterface } from "@pristine-ts/security";
3
+ /**
4
+ * A guard that checks the authenticated identity has every named custom claim set
5
+ * to a truthy value. Use with the `@guard` decorator:
6
+ *
7
+ * ```ts
8
+ * @guard(IdentityPlatformClaimGuard, "admin-routes", { claims: ["admin", "billing"] })
9
+ * ```
10
+ *
11
+ * Mirror of `AwsCognitoGroupGuard` — that one checks `cognito:groups`; this one
12
+ * checks arbitrary top-level claim keys set via `admin.auth().setCustomUserClaims(...)`.
13
+ */
14
+ export declare class IdentityPlatformClaimGuard implements GuardInterface {
15
+ keyname: string;
16
+ guardContext?: GuardContextInterface;
17
+ setContext(context: any): Promise<void>;
18
+ isAuthorized(request: Request, identity?: IdentityInterface): Promise<boolean>;
19
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The standard claims found on a verified Firebase ID token. Custom claims (set via
3
+ * `admin.auth().setCustomUserClaims(...)`) appear as additional fields beyond these.
4
+ */
5
+ export interface ClaimInterface {
6
+ /** Issuer — `https://securetoken.google.com/{projectId}`. */
7
+ iss: string;
8
+ /** Audience — the Firebase project id. */
9
+ aud: string;
10
+ /** The auth time, in seconds since epoch. */
11
+ auth_time: number;
12
+ /** Issued-at time, in seconds since epoch. */
13
+ iat: number;
14
+ /** Expiry, in seconds since epoch. */
15
+ exp: number;
16
+ /** The Firebase user id. */
17
+ sub: string;
18
+ user_id?: string;
19
+ email?: string;
20
+ email_verified?: boolean;
21
+ /** Firebase-specific claims (sign_in_provider, identities, etc.). */
22
+ firebase?: {
23
+ identities?: {
24
+ [key: string]: any;
25
+ };
26
+ sign_in_provider?: string;
27
+ [key: string]: any;
28
+ };
29
+ [customClaim: string]: any;
30
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./claim.interface";
2
+ export * from "./token-header.interface";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The JWT header decoded from a Firebase ID token. The `kid` selects which of the
3
+ * fetched X.509 certs verifies the signature.
4
+ */
5
+ export interface TokenHeaderInterface {
6
+ alg: string;
7
+ typ?: string;
8
+ kid: string;
9
+ }
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@pristine-ts/gcp-identity-platform",
3
+ "version": "2.0.16",
4
+ "description": "",
5
+ "module": "dist/lib/esm/gcp-identity-platform.module.js",
6
+ "main": "dist/lib/cjs/gcp-identity-platform.module.js",
7
+ "types": "dist/types/gcp-identity-platform.module.d.ts",
8
+ "scripts": {
9
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
10
+ "prepublish": "npm run build",
11
+ "test": "jest",
12
+ "test:cov": "jest --coverage"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "author": "",
18
+ "license": "ISC",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "devDependencies": {
23
+ "@types/jsonwebtoken": "^9.0.4"
24
+ },
25
+ "dependencies": {
26
+ "@pristine-ts/common": "^2.0.16",
27
+ "@pristine-ts/http": "^2.0.16",
28
+ "@pristine-ts/networking": "^2.0.16",
29
+ "@pristine-ts/security": "^2.0.16",
30
+ "jsonwebtoken": "^9.0.2"
31
+ },
32
+ "jest": {
33
+ "transform": {
34
+ ".(ts|tsx)": "ts-jest"
35
+ },
36
+ "globals": {
37
+ "ts-jest": {
38
+ "tsconfig": {
39
+ "strictNullChecks": false
40
+ }
41
+ }
42
+ },
43
+ "testEnvironment": "node",
44
+ "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
45
+ "moduleFileExtensions": [
46
+ "ts",
47
+ "tsx",
48
+ "js"
49
+ ],
50
+ "coveragePathIgnorePatterns": [
51
+ "/node_modules/",
52
+ "/test/"
53
+ ],
54
+ "coverageThreshold": {
55
+ "global": {
56
+ "branches": 90,
57
+ "functions": 95,
58
+ "lines": 95,
59
+ "statements": 95
60
+ }
61
+ },
62
+ "collectCoverageFrom": [
63
+ "src/*.{js,ts}"
64
+ ]
65
+ },
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/magieno/pristine-ts.git",
69
+ "directory": "packages/gcp-identity-platform"
70
+ },
71
+ "gitHead": "a55d7d59862672a8cbbca4088fed090779b37705"
72
+ }
package/readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # @pristine-ts/gcp-identity-platform
2
+
3
+ Authenticator and guard for Firebase Auth / GCP Identity Platform. Mirror of
4
+ `@pristine-ts/aws-cognito`: verifies Firebase ID tokens against Google's public
5
+ X.509 certificate endpoint and gates routes on custom claims.