@dereekb/firebase-server 13.2.2 → 13.3.1

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 (166) hide show
  1. package/index.cjs.js +7506 -1884
  2. package/index.esm.js +7505 -1890
  3. package/mailgun/index.cjs.js +333 -31
  4. package/mailgun/index.esm.js +333 -31
  5. package/mailgun/package.json +8 -8
  6. package/mailgun/src/lib/auth.mailgun.d.ts +22 -3
  7. package/model/index.cjs.js +11334 -3830
  8. package/model/index.esm.js +11338 -3834
  9. package/model/package.json +10 -10
  10. package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +27 -1
  11. package/model/src/lib/notification/notification.action.init.service.d.ts +93 -1
  12. package/model/src/lib/notification/notification.action.service.d.ts +151 -2
  13. package/model/src/lib/notification/notification.config.d.ts +19 -7
  14. package/model/src/lib/notification/notification.config.service.d.ts +44 -6
  15. package/model/src/lib/notification/notification.create.run.d.ts +33 -5
  16. package/model/src/lib/notification/notification.error.d.ts +63 -0
  17. package/model/src/lib/notification/notification.module.d.ts +11 -0
  18. package/model/src/lib/notification/notification.send.d.ts +8 -1
  19. package/model/src/lib/notification/notification.send.service.d.ts +7 -1
  20. package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +32 -2
  21. package/model/src/lib/notification/notification.send.service.text.d.ts +11 -3
  22. package/model/src/lib/notification/notification.task.service.d.ts +13 -1
  23. package/model/src/lib/notification/notification.task.service.handler.d.ts +27 -3
  24. package/model/src/lib/notification/notification.task.service.util.d.ts +16 -4
  25. package/model/src/lib/notification/notification.task.subtask.handler.d.ts +31 -1
  26. package/model/src/lib/notification/notification.util.d.ts +70 -0
  27. package/model/src/lib/storagefile/storagefile.action.init.service.d.ts +62 -1
  28. package/model/src/lib/storagefile/storagefile.action.server.d.ts +124 -2
  29. package/model/src/lib/storagefile/storagefile.error.d.ts +44 -0
  30. package/model/src/lib/storagefile/storagefile.module.d.ts +11 -0
  31. package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +4 -1
  32. package/model/src/lib/storagefile/storagefile.upload.service.d.ts +13 -1
  33. package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +43 -1
  34. package/model/src/lib/storagefile/storagefile.util.d.ts +8 -0
  35. package/oidc/index.cjs.default.js +1 -0
  36. package/oidc/index.cjs.js +5607 -0
  37. package/oidc/index.cjs.mjs +2 -0
  38. package/oidc/index.d.ts +1 -0
  39. package/oidc/index.esm.js +5560 -0
  40. package/oidc/package.json +26 -0
  41. package/oidc/src/index.d.ts +1 -0
  42. package/oidc/src/lib/controller/index.d.ts +3 -0
  43. package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +54 -0
  44. package/oidc/src/lib/controller/oidc.provider.controller.d.ts +18 -0
  45. package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +36 -0
  46. package/oidc/src/lib/index.d.ts +6 -0
  47. package/oidc/src/lib/middleware/index.d.ts +3 -0
  48. package/oidc/src/lib/middleware/oauth-auth.decorator.d.ts +14 -0
  49. package/oidc/src/lib/middleware/oauth-auth.middleware.d.ts +21 -0
  50. package/oidc/src/lib/middleware/oauth-auth.module.d.ts +50 -0
  51. package/oidc/src/lib/model/index.d.ts +3 -0
  52. package/oidc/src/lib/model/jwks/index.d.ts +3 -0
  53. package/oidc/src/lib/model/jwks/jwks.d.ts +107 -0
  54. package/oidc/src/lib/model/jwks/jwks.id.d.ts +9 -0
  55. package/oidc/src/lib/model/jwks/jwks.query.d.ts +18 -0
  56. package/oidc/src/lib/model/model.d.ts +12 -0
  57. package/oidc/src/lib/model/oidc/index.d.ts +2 -0
  58. package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +62 -0
  59. package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +23 -0
  60. package/oidc/src/lib/oidc.config.d.ts +175 -0
  61. package/oidc/src/lib/oidc.module.d.ts +100 -0
  62. package/oidc/src/lib/service/index.d.ts +10 -0
  63. package/oidc/src/lib/service/oidc.account.d.ts +36 -0
  64. package/oidc/src/lib/service/oidc.account.service.d.ts +104 -0
  65. package/oidc/src/lib/service/oidc.adapter.service.d.ts +20 -0
  66. package/oidc/src/lib/service/oidc.auth.d.ts +26 -0
  67. package/oidc/src/lib/service/oidc.client.service.d.ts +57 -0
  68. package/oidc/src/lib/service/oidc.config.service.d.ts +100 -0
  69. package/oidc/src/lib/service/oidc.encryption.service.d.ts +53 -0
  70. package/oidc/src/lib/service/oidc.interaction.service.d.ts +44 -0
  71. package/oidc/src/lib/service/oidc.jwks.service.d.ts +105 -0
  72. package/oidc/src/lib/service/oidc.service.d.ts +55 -0
  73. package/package.json +21 -14
  74. package/src/lib/auth/auth.context.d.ts +22 -2
  75. package/src/lib/auth/auth.service.d.ts +5 -0
  76. package/src/lib/auth/auth.service.error.d.ts +2 -1
  77. package/src/lib/auth/auth.util.d.ts +15 -3
  78. package/src/lib/env/env.config.d.ts +42 -0
  79. package/src/lib/env/env.service.d.ts +17 -0
  80. package/src/lib/env/index.d.ts +1 -0
  81. package/src/lib/firestore/array.d.ts +11 -3
  82. package/src/lib/firestore/driver.accessor.batch.d.ts +27 -4
  83. package/src/lib/firestore/driver.accessor.d.ts +43 -0
  84. package/src/lib/firestore/driver.accessor.default.d.ts +20 -0
  85. package/src/lib/firestore/driver.accessor.transaction.d.ts +28 -4
  86. package/src/lib/firestore/driver.d.ts +14 -0
  87. package/src/lib/firestore/driver.query.d.ts +25 -0
  88. package/src/lib/firestore/increment.d.ts +13 -3
  89. package/src/lib/firestore/snapshot/index.d.ts +1 -1
  90. package/src/lib/firestore/snapshot/{snapshot.field.d.ts → snapshot.field.encrypt.d.ts} +13 -27
  91. package/src/lib/function/assert.d.ts +32 -16
  92. package/src/lib/function/context.d.ts +26 -0
  93. package/src/lib/function/error.auth.d.ts +15 -0
  94. package/src/lib/function/error.d.ts +68 -4
  95. package/src/lib/nest/app.d.ts +53 -9
  96. package/src/lib/nest/app.module.d.ts +90 -0
  97. package/src/lib/nest/auth/auth.module.d.ts +30 -4
  98. package/src/lib/nest/auth/auth.util.d.ts +38 -0
  99. package/src/lib/nest/controller/auth.context.server.d.ts +27 -0
  100. package/src/lib/nest/controller/index.d.ts +1 -0
  101. package/src/lib/nest/development/development.app.function.d.ts +45 -0
  102. package/src/lib/nest/development/development.assert.function.d.ts +19 -1
  103. package/src/lib/nest/development/development.function.d.ts +42 -3
  104. package/src/lib/nest/development/development.schedule.function.d.ts +29 -0
  105. package/src/lib/nest/development/development.schedule.function.error.d.ts +21 -0
  106. package/src/lib/nest/env/env.service.d.ts +9 -0
  107. package/src/lib/nest/env/env.util.d.ts +16 -0
  108. package/src/lib/nest/firebase/firebase.module.d.ts +13 -1
  109. package/src/lib/nest/firestore/firestore.module.d.ts +24 -8
  110. package/src/lib/nest/function/call.d.ts +75 -6
  111. package/src/lib/nest/function/context.d.ts +85 -2
  112. package/src/lib/nest/function/nest.d.ts +46 -0
  113. package/src/lib/nest/function/schedule.d.ts +49 -0
  114. package/src/lib/nest/function/v2/blocking.d.ts +92 -8
  115. package/src/lib/nest/function/v2/call.d.ts +38 -8
  116. package/src/lib/nest/function/v2/event.d.ts +67 -4
  117. package/src/lib/nest/function/v2/schedule.d.ts +36 -5
  118. package/src/lib/nest/index.d.ts +3 -0
  119. package/src/lib/nest/middleware/appcheck.d.ts +5 -0
  120. package/src/lib/nest/middleware/appcheck.middleware.d.ts +44 -14
  121. package/src/lib/nest/middleware/appcheck.module.d.ts +10 -1
  122. package/src/lib/nest/middleware/globalprefix.d.ts +31 -3
  123. package/src/lib/nest/middleware/index.d.ts +2 -1
  124. package/src/lib/nest/middleware/rawbody.middleware.d.ts +6 -0
  125. package/src/lib/nest/model/call.model.function.d.ts +69 -3
  126. package/src/lib/nest/model/create.model.function.d.ts +66 -0
  127. package/src/lib/nest/model/crud.assert.function.d.ts +27 -1
  128. package/src/lib/nest/model/delete.model.function.d.ts +55 -0
  129. package/src/lib/nest/model/permission.error.d.ts +15 -0
  130. package/src/lib/nest/model/read.model.function.d.ts +57 -0
  131. package/src/lib/nest/model/specifier.function.d.ts +58 -1
  132. package/src/lib/nest/model/update.model.function.d.ts +58 -0
  133. package/src/lib/nest/nest.provider.d.ts +24 -11
  134. package/src/lib/nest/nest.provider.server.d.ts +12 -0
  135. package/src/lib/nest/storage/storage.module.d.ts +30 -4
  136. package/src/lib/storage/driver.accessor.d.ts +33 -0
  137. package/src/lib/storage/driver.d.ts +14 -0
  138. package/src/lib/storage/storage.d.ts +11 -4
  139. package/src/lib/storage/storage.service.d.ts +10 -1
  140. package/src/lib/type.d.ts +7 -2
  141. package/test/index.cjs.js +4072 -757
  142. package/test/index.esm.js +4073 -761
  143. package/test/package.json +10 -10
  144. package/test/src/lib/firebase/firebase.admin.auth.d.ts +82 -1
  145. package/test/src/lib/firebase/firebase.admin.collection.d.ts +55 -3
  146. package/test/src/lib/firebase/firebase.admin.d.ts +64 -0
  147. package/test/src/lib/firebase/firebase.admin.function.d.ts +84 -0
  148. package/test/src/lib/firebase/firebase.admin.nest.d.ts +125 -17
  149. package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.d.ts +44 -0
  150. package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.d.ts +41 -0
  151. package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +98 -0
  152. package/test/src/lib/firebase/firebase.admin.test.server.d.ts +26 -0
  153. package/test/src/lib/firebase/firebase.d.ts +57 -2
  154. package/test/src/lib/firebase/firebase.function.d.ts +138 -0
  155. package/test/src/lib/firestore/firestore.admin.d.ts +6 -0
  156. package/test/src/lib/firestore/firestore.d.ts +30 -0
  157. package/test/src/lib/storage/storage.admin.d.ts +9 -3
  158. package/test/src/lib/storage/storage.d.ts +30 -0
  159. package/zoho/index.cjs.js +406 -73
  160. package/zoho/index.esm.js +406 -73
  161. package/zoho/package.json +8 -8
  162. package/zoho/src/lib/zoho.accounts.firebase.d.ts +13 -2
  163. package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +29 -6
  164. package/index.cjs.js.map +0 -1
  165. package/index.esm.js.map +0 -1
  166. /package/src/lib/nest/middleware/{webhook.d.ts → webhook.module.d.ts} +0 -0
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@dereekb/firebase-server/oidc",
3
+ "version": "13.3.1",
4
+ "peerDependencies": {
5
+ "@dereekb/date": "13.3.1",
6
+ "@dereekb/model": "13.3.1",
7
+ "@dereekb/nestjs": "13.3.1",
8
+ "@dereekb/rxjs": "13.3.1",
9
+ "@dereekb/firebase": "13.3.1",
10
+ "@dereekb/util": "13.3.1",
11
+ "@dereekb/zoho": "13.3.1",
12
+ "oidc-provider": "^9.7.0"
13
+ },
14
+ "exports": {
15
+ "./package.json": "./package.json",
16
+ ".": {
17
+ "module": "./index.esm.js",
18
+ "types": "./index.d.ts",
19
+ "import": "./index.cjs.mjs",
20
+ "default": "./index.cjs.js"
21
+ }
22
+ },
23
+ "module": "./index.esm.js",
24
+ "main": "./index.cjs.js",
25
+ "types": "./index.d.ts"
26
+ }
@@ -0,0 +1 @@
1
+ export * from './lib';
@@ -0,0 +1,3 @@
1
+ export * from './oidc.interaction.controller';
2
+ export * from './oidc.provider.controller';
3
+ export * from './oidc.wellknown.controller';
@@ -0,0 +1,54 @@
1
+ import { type Request, type Response } from 'express';
2
+ import { OidcProviderConfigService } from '../service';
3
+ import { type OAuthInteractionConsentRequest, type OAuthInteractionLoginRequest, type OidcInteractionUid } from '@dereekb/firebase';
4
+ import { OidcAccountService } from '../service/oidc.account.service';
5
+ import { OidcInteractionService } from '../service/oidc.interaction.service';
6
+ /**
7
+ * Controller for OIDC interaction endpoints (login/consent).
8
+ *
9
+ * The GET endpoint is accessed via browser redirect from the oidc-provider
10
+ * and must be excluded from AppCheck middleware.
11
+ *
12
+ * The POST endpoints are called by the frontend app. They verify the user's
13
+ * Firebase Auth ID token and bypass the oidc-provider interaction cookie
14
+ * (which is scoped to the frontend path set by `interactions.url`).
15
+ */
16
+ export declare class OidcInteractionController {
17
+ private readonly oidcInteractionService;
18
+ private readonly oidcProviderConfigService;
19
+ private readonly accountService;
20
+ constructor(oidcInteractionService: OidcInteractionService, oidcProviderConfigService: OidcProviderConfigService, accountService: OidcAccountService);
21
+ /**
22
+ * GET /interaction/:uid
23
+ *
24
+ * Detects the interaction type and redirects to the appropriate frontend page.
25
+ *
26
+ * @throws {HttpException} 404 when the interaction UID is not found or has expired.
27
+ */
28
+ getInteraction(uid: OidcInteractionUid, req: Request, res: Response): Promise<void>;
29
+ /**
30
+ * POST /interaction/:uid/login
31
+ *
32
+ * Verifies the Firebase Auth ID token sent by the frontend, extracts the
33
+ * user's UID, and completes the oidc-provider login interaction.
34
+ *
35
+ * @throws {HttpException} 401 when the Firebase ID token is invalid.
36
+ * @throws {HttpException} 400 when the login interaction cannot be completed.
37
+ */
38
+ postLogin(uid: OidcInteractionUid, body: OAuthInteractionLoginRequest, res: Response): Promise<void>;
39
+ /**
40
+ * POST /interaction/:uid/consent
41
+ *
42
+ * Receives consent decision from frontend. Grants missing OIDC scopes and claims
43
+ * when approved, or returns `access_denied` when rejected.
44
+ *
45
+ * @throws {HttpException} 400 when the consent interaction cannot be completed.
46
+ */
47
+ postConsent(uid: OidcInteractionUid, body: OAuthInteractionConsentRequest, res: Response): Promise<void>;
48
+ /**
49
+ * Verifies a Firebase Auth ID token and returns the user's UID.
50
+ *
51
+ * @throws {HttpException} 401 when the token is invalid or expired.
52
+ */
53
+ private _verifyIdToken;
54
+ }
@@ -0,0 +1,18 @@
1
+ import { type Request, type Response } from 'express';
2
+ import { OidcService } from '../service/oidc.service';
3
+ /**
4
+ * Catch-all controller that proxies requests to the oidc-provider callback.
5
+ *
6
+ * Mounted at the issuer path (`/oidc` by default). The oidc-provider instance
7
+ * handles all core OAuth/OIDC endpoints internally (authorization, token,
8
+ * userinfo, registration, JWKS, etc.).
9
+ *
10
+ * The provider's callback strips the controller prefix from the URL so that
11
+ * the provider sees paths relative to its issuer (e.g., `/auth` instead of `/oidc/auth`).
12
+ */
13
+ export declare class OidcProviderController {
14
+ private readonly oidcService;
15
+ private _callback;
16
+ constructor(oidcService: OidcService);
17
+ handleOidcRequest(req: Request, res: Response): Promise<void>;
18
+ }
@@ -0,0 +1,36 @@
1
+ import { JwksService } from '../service/oidc.jwks.service';
2
+ import { OidcModuleConfig } from '../oidc.config';
3
+ import { OidcProviderConfigService, type OidcDiscoveryMetadata } from '../service/oidc.config.service';
4
+ /**
5
+ * Controller for OAuth/OIDC discovery and metadata endpoints.
6
+ */
7
+ export declare class OidcWellKnownController {
8
+ private readonly config;
9
+ private readonly providerConfigService;
10
+ private readonly jwksService;
11
+ constructor(config: OidcModuleConfig, providerConfigService: OidcProviderConfigService, jwksService: JwksService);
12
+ /**
13
+ * OpenID Connect Discovery endpoint (RFC 8414 / OpenID Connect Discovery 1.0).
14
+ *
15
+ * Returns the provider metadata so clients can auto-discover endpoints,
16
+ * supported scopes, signing algorithms, etc.
17
+ */
18
+ getOpenIdConfiguration(): Promise<OidcDiscoveryMetadata>;
19
+ /**
20
+ * JWKS endpoint. Returns the public JSON Web Key Set for token verification.
21
+ *
22
+ * This endpoint is typically skipped if the JwksServiceStorageConfig is provided.
23
+ */
24
+ getJwks(): Promise<{
25
+ keys: import("..").JsonWebKeyWithKid[];
26
+ }>;
27
+ /**
28
+ * OAuth Protected Resource discovery endpoint (RFC 8707).
29
+ *
30
+ * Returns the authorization server(s) that protect this resource,
31
+ * allowing clients to discover which authorization server to use.
32
+ */
33
+ getProtectedResource(): {
34
+ authorization_servers: string[];
35
+ };
36
+ }
@@ -0,0 +1,6 @@
1
+ export * from './middleware';
2
+ export * from './model';
3
+ export * from './oidc.config';
4
+ export * from './controller';
5
+ export * from './oidc.module';
6
+ export * from './service';
@@ -0,0 +1,3 @@
1
+ export * from './oauth-auth.decorator';
2
+ export * from './oauth-auth.middleware';
3
+ export * from './oauth-auth.module';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * NestJS parameter decorator that extracts the {@link OidcAuthData} from the request.
3
+ *
4
+ * Returns `undefined` if the middleware has not run or the request is unauthenticated.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * @Get('me')
9
+ * getMe(@OidcAuth() auth: OidcAuthData) {
10
+ * return { uid: auth.uid };
11
+ * }
12
+ * ```
13
+ */
14
+ export declare const OidcAuth: (...dataOrPipes: unknown[]) => ParameterDecorator;
@@ -0,0 +1,21 @@
1
+ import { type NestMiddleware } from '@nestjs/common';
2
+ import { type Response, type NextFunction } from 'express';
3
+ import { OidcService } from '../service/oidc.service';
4
+ import { type OidcAuthenticatedRequest } from '../service/oidc.auth';
5
+ /**
6
+ * NestJS middleware that verifies OAuth bearer tokens issued by our OIDC provider.
7
+ *
8
+ * Extracts `Authorization: Bearer <token>` from the request header,
9
+ * verifies it via the provider's AccessToken model, and attaches the
10
+ * auth context to the request as {@link OidcAuthData}.
11
+ *
12
+ * Applied to routes via {@link ConfigureOidcAuthMiddlewareModule}.
13
+ *
14
+ * @throws {UnauthorizedException} When the Authorization header is missing, malformed, or the token is invalid/expired.
15
+ */
16
+ export declare class OidcAuthBearerTokenMiddleware implements NestMiddleware {
17
+ private readonly oidcService;
18
+ private readonly logger;
19
+ constructor(oidcService: OidcService);
20
+ use(req: OidcAuthenticatedRequest, _res: Response, next: NextFunction): Promise<void>;
21
+ }
@@ -0,0 +1,50 @@
1
+ import { type MiddlewareConsumer } from '@nestjs/common';
2
+ import { type SlashPath } from '@dereekb/util';
3
+ /**
4
+ * Configuration for `OidcAuthBearerTokenMiddleware` route protection.
5
+ *
6
+ * Works in reverse of `FirebaseAppCheckMiddlewareConfig`: instead of protecting
7
+ * all routes and ignoring some, this only protects explicitly specified paths.
8
+ * Routes under the global API prefix (protected by AppCheck) are excluded.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * // Provide in your module:
13
+ * { provide: OidcAuthMiddlewareConfig, useValue: { protectedPaths: ['/mcp'] } }
14
+ * ```
15
+ */
16
+ export declare abstract class OidcAuthMiddlewareConfig {
17
+ /**
18
+ * Path prefixes that require OAuth bearer token verification.
19
+ *
20
+ * Only requests matching one of these prefixes will be checked.
21
+ * Paths under the global API route prefix should not be included
22
+ * since those are protected by AppCheck.
23
+ */
24
+ readonly protectedPaths: SlashPath[];
25
+ }
26
+ /**
27
+ * Middleware module that applies OAuth bearer token verification
28
+ * to paths specified in `OidcAuthMiddlewareConfig`.
29
+ *
30
+ * Only protects explicitly listed paths — all other routes pass through.
31
+ * This is the inverse of `ConfigureFirebaseAppCheckMiddlewareModule`, which
32
+ * protects everything and ignores specific paths.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * @Module({
37
+ * imports: [ConfigureOidcAuthMiddlewareModule],
38
+ * providers: [
39
+ * { provide: OidcAuthMiddlewareConfig, useValue: { protectedPaths: ['/mcp'] } }
40
+ * ]
41
+ * })
42
+ * export class AppModule {}
43
+ * ```
44
+ */
45
+ export declare class ConfigureOidcAuthMiddlewareModule {
46
+ private readonly config?;
47
+ private readonly logger;
48
+ constructor(config?: OidcAuthMiddlewareConfig | undefined);
49
+ configure(consumer: MiddlewareConsumer): void;
50
+ }
@@ -0,0 +1,3 @@
1
+ export * from './jwks';
2
+ export * from './oidc';
3
+ export * from './model';
@@ -0,0 +1,3 @@
1
+ export * from './jwks';
2
+ export * from './jwks.id';
3
+ export * from './jwks.query';
@@ -0,0 +1,107 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type GrantedReadRole } from '@dereekb/model';
3
+ import { AbstractFirestoreDocument, type FirestoreCollection, type FirestoreContext, type CollectionReference } from '@dereekb/firebase';
4
+ import { type AES256GCMEncryptionSecretSource } from '@dereekb/nestjs';
5
+ /**
6
+ * Abstract class providing access to all JWKS-related Firestore collections.
7
+ *
8
+ * Implementations provide concrete collection instances wired to a specific {@link FirestoreContext}.
9
+ */
10
+ export declare abstract class JwksFirestoreCollections {
11
+ abstract readonly jwksKeyCollection: JwksKeyFirestoreCollection;
12
+ }
13
+ /**
14
+ * Firestore model identity for {@link JwksKey} documents.
15
+ *
16
+ * This is a server-side only model. It has no provisions for client-side access.
17
+ */
18
+ export declare const jwksKeyIdentity: import("@dereekb/firebase").RootFirestoreModelIdentity<"oidcJwksKey", "oidc_jwks">;
19
+ /**
20
+ * Lifecycle status of a JWKS signing key.
21
+ *
22
+ * - `active` — currently used for signing new tokens
23
+ * - `rotated` — replaced by a newer key but still valid for verification until expiry
24
+ * - `retired` — fully expired and excluded from the public JWKS
25
+ */
26
+ export type JwksKeyStatus = 'active' | 'rotated' | 'retired';
27
+ /**
28
+ * JWK with a required kid field.
29
+ */
30
+ export interface JsonWebKeyWithKid extends JsonWebKey {
31
+ readonly kid: string;
32
+ readonly kty: string;
33
+ readonly alg?: string;
34
+ readonly use?: string;
35
+ }
36
+ /**
37
+ * Firestore document representing a JWKS signing key.
38
+ */
39
+ export interface JwksKey {
40
+ /**
41
+ * Private key in JWK format, encrypted at rest.
42
+ */
43
+ privateKey: string;
44
+ /**
45
+ * Public key in JWK format (plain text for JWKS endpoint).
46
+ */
47
+ publicKey: JsonWebKeyWithKid;
48
+ /**
49
+ * Current lifecycle status.
50
+ */
51
+ status: JwksKeyStatus;
52
+ /**
53
+ * When this key was created.
54
+ */
55
+ createdAt: Date;
56
+ /**
57
+ * When this key was rotated (status changed from active to rotated).
58
+ */
59
+ rotatedAt?: Maybe<Date>;
60
+ /**
61
+ * When tokens signed with this key will all have expired.
62
+ */
63
+ expiresAt?: Maybe<Date>;
64
+ }
65
+ /**
66
+ * Role type for JWKS key documents. Read-only since keys are managed by the {@link JwksService}.
67
+ */
68
+ export type JwksKeyRoles = GrantedReadRole;
69
+ /**
70
+ * Firestore document wrapper for {@link JwksKey}.
71
+ */
72
+ export declare class JwksKeyDocument extends AbstractFirestoreDocument<JwksKey, JwksKeyDocument, typeof jwksKeyIdentity> {
73
+ get modelIdentity(): import("@dereekb/firebase").RootFirestoreModelIdentity<"oidcJwksKey", "oidc_jwks">;
74
+ }
75
+ /**
76
+ * Configuration for creating a {@link JwksKey} snapshot converter.
77
+ */
78
+ export interface JwksKeyConverterConfig {
79
+ /**
80
+ * Encryption secret source for the private key field.
81
+ */
82
+ readonly encryptionSecret: AES256GCMEncryptionSecretSource;
83
+ }
84
+ /**
85
+ * Creates a snapshot converter for {@link JwksKey} documents.
86
+ *
87
+ * Requires runtime encryption config since the private key field is encrypted at rest.
88
+ */
89
+ export declare function jwksKeyConverter(config: JwksKeyConverterConfig): import("@dereekb/firebase").SnapshotConverterFunctions<JwksKey, Partial<import("@dereekb/util").ReplaceType<JwksKey, import("@dereekb/util").MaybeMap<object>, any>>>;
90
+ /**
91
+ * Returns the Firestore {@link CollectionReference} for {@link JwksKey} documents.
92
+ */
93
+ export declare function jwksKeyCollectionReference(context: FirestoreContext): CollectionReference<JwksKey>;
94
+ /**
95
+ * Typed Firestore collection for {@link JwksKey} documents.
96
+ */
97
+ export type JwksKeyFirestoreCollection = FirestoreCollection<JwksKey, JwksKeyDocument>;
98
+ /**
99
+ * Configuration for creating a {@link JwksKeyFirestoreCollection}.
100
+ */
101
+ export interface JwksKeyFirestoreCollectionConfig extends JwksKeyConverterConfig {
102
+ readonly firestoreContext: FirestoreContext;
103
+ }
104
+ /**
105
+ * Creates a {@link JwksKeyFirestoreCollection} with encrypted private key field support.
106
+ */
107
+ export declare function jwksKeyFirestoreCollection(config: JwksKeyFirestoreCollectionConfig): JwksKeyFirestoreCollection;
@@ -0,0 +1,9 @@
1
+ import { type FirestoreModelId, type FirestoreModelKey } from '@dereekb/firebase';
2
+ /**
3
+ * Document ID for a JwksKey. The kid (key identifier) string.
4
+ */
5
+ export type JwksKeyId = FirestoreModelId;
6
+ /**
7
+ * Full Firestore model key path for a JwksKey document.
8
+ */
9
+ export type JwksKeyKey = FirestoreModelKey;
@@ -0,0 +1,18 @@
1
+ import { type FirestoreQueryConstraint } from '@dereekb/firebase';
2
+ import { type JwksKeyStatus } from './jwks';
3
+ /**
4
+ * Query for JwksKey documents with a specific status.
5
+ */
6
+ export declare function jwksKeysWithStatusQuery(status: JwksKeyStatus): FirestoreQueryConstraint[];
7
+ /**
8
+ * Query for active JwksKey documents.
9
+ */
10
+ export declare function activeJwksKeysQuery(): FirestoreQueryConstraint[];
11
+ /**
12
+ * Query for non-retired JwksKey documents (active + rotated).
13
+ */
14
+ export declare function nonRetiredJwksKeysQuery(): FirestoreQueryConstraint[];
15
+ /**
16
+ * Query for rotated JwksKey documents.
17
+ */
18
+ export declare function rotatedJwksKeysQuery(): FirestoreQueryConstraint[];
@@ -0,0 +1,12 @@
1
+ import { type JwksFirestoreCollections, type JwksKeyFirestoreCollection } from './jwks';
2
+ import { type OidcModelFirestoreCollections, type OidcEntryFirestoreCollection } from '@dereekb/firebase';
3
+ /**
4
+ * Abstract class providing access to all OIDC-related Firestore collections.
5
+ *
6
+ * Extends both {@link JwksFirestoreCollections} (server-only JWKS keys) and
7
+ * {@link OidcModelFirestoreCollections} (shared adapter entries).
8
+ */
9
+ export declare abstract class OidcServerFirestoreCollections implements JwksFirestoreCollections, OidcModelFirestoreCollections {
10
+ abstract readonly jwksKeyCollection: JwksKeyFirestoreCollection;
11
+ abstract readonly oidcEntryCollection: OidcEntryFirestoreCollection;
12
+ }
@@ -0,0 +1,2 @@
1
+ export * from './oidcmodel.action.server';
2
+ export * from './oidcmodel.module';
@@ -0,0 +1,62 @@
1
+ import { type AsyncFirebaseFunctionCreateAction, type AsyncOidcEntryUpdateAction, type AsyncOidcEntryDeleteAction, type CreateOidcClientParams, type CreateOidcClientResult, type UpdateOidcClientParams, type DeleteOidcClientParams, type RotateOidcClientSecretParams, type RotateOidcClientSecretResult, type OidcEntryDocument } from '@dereekb/firebase';
2
+ import { type FirebaseServerActionsContext } from '@dereekb/firebase-server';
3
+ import { type OidcClientService } from '../../service/oidc.client.service';
4
+ /**
5
+ * Context providing the OIDC client service and server action utilities needed by OIDC model server actions.
6
+ */
7
+ export interface OidcModelServerActionsContext extends FirebaseServerActionsContext {
8
+ /**
9
+ * Service for managing OIDC client adapter entries.
10
+ */
11
+ readonly oidcClientService: OidcClientService;
12
+ }
13
+ /**
14
+ * Abstract service class defining all server-side OIDC client CRUD actions.
15
+ *
16
+ * @see {@link oidcModelServerActions} for the concrete implementation factory.
17
+ */
18
+ export declare abstract class OidcModelServerActions {
19
+ abstract createOidcClient(params: CreateOidcClientParams): AsyncFirebaseFunctionCreateAction<CreateOidcClientParams, CreateOidcClientResult>;
20
+ abstract updateOidcClient(params: UpdateOidcClientParams): AsyncOidcEntryUpdateAction<UpdateOidcClientParams>;
21
+ abstract rotateOidcClientSecret(params: RotateOidcClientSecretParams): AsyncFirebaseFunctionCreateAction<RotateOidcClientSecretParams, RotateOidcClientSecretResult, OidcEntryDocument>;
22
+ abstract deleteOidcClient(params: DeleteOidcClientParams): AsyncOidcEntryDeleteAction<DeleteOidcClientParams>;
23
+ }
24
+ /**
25
+ * Creates a concrete {@link OidcModelServerActions} implementation wired to the provided context.
26
+ *
27
+ * @param context - the fully assembled OIDC model server actions context
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const actions = oidcModelServerActions(context);
32
+ * const createFn = await actions.createOidcClient({ client_name: 'My App', redirect_uris: ['...'] });
33
+ * const result = await createFn();
34
+ * ```
35
+ */
36
+ export declare function oidcModelServerActions(context: OidcModelServerActionsContext): OidcModelServerActions;
37
+ /**
38
+ * Factory for the `createOidcClient` action.
39
+ *
40
+ * Delegates to {@link OidcClientService.createClient} to generate a `client_id` and `client_secret`,
41
+ * create the adapter entry, and return the secret in plaintext (only returned once).
42
+ */
43
+ export declare function createOidcClientFactory(context: OidcModelServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<CreateOidcClientParams, () => Promise<CreateOidcClientResult>, object, unknown>;
44
+ /**
45
+ * Factory for the `updateOidcClient` action.
46
+ *
47
+ * Delegates to {@link OidcClientService.updateClient} to apply plaintext field updates.
48
+ */
49
+ export declare function updateOidcClientFactory(context: OidcModelServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<UpdateOidcClientParams, (document: OidcEntryDocument) => Promise<OidcEntryDocument>, object, unknown>;
50
+ /**
51
+ * Factory for the `rotateOidcClientSecret` action.
52
+ *
53
+ * Delegates to {@link OidcClientService.rotateClientSecret} to generate a new secret
54
+ * and return it in plaintext (only returned once).
55
+ */
56
+ export declare function rotateOidcClientSecretFactory(context: OidcModelServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<import("@dereekb/firebase").TargetModelParams, (document: OidcEntryDocument) => Promise<RotateOidcClientSecretResult>, object, unknown>;
57
+ /**
58
+ * Factory for the `deleteOidcClient` action.
59
+ *
60
+ * Delegates to {@link OidcClientService.deleteClient}.
61
+ */
62
+ export declare function deleteOidcClientFactory(context: OidcModelServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<import("@dereekb/firebase").TargetModelParams, (document: OidcEntryDocument) => Promise<void>, object, unknown>;
@@ -0,0 +1,23 @@
1
+ import { type ModuleMetadata } from '@nestjs/common';
2
+ import { OidcModelServerActions } from './oidcmodel.action.server';
3
+ import { OidcClientService } from '../../service/oidc.client.service';
4
+ /**
5
+ * Factory that creates an {@link OidcModelServerActions} instance from the injected {@link OidcClientService}.
6
+ */
7
+ export declare function oidcModelServerActionsFactory(oidcClientService: OidcClientService): OidcModelServerActions;
8
+ export interface ProvideAppOidcModelMetadataConfig {
9
+ /**
10
+ * The OidcModule that exports the required OIDC dependencies:
11
+ * - {@link OidcClientService}
12
+ */
13
+ readonly oidcModule: Required<ModuleMetadata>['imports']['0'];
14
+ }
15
+ /**
16
+ * Convenience function used to generate ModuleMetadata for an app's OidcModelModule.
17
+ *
18
+ * By default this module exports:
19
+ * - OidcModelServerActions
20
+ *
21
+ * @param config
22
+ */
23
+ export declare function appOidcModelModuleMetadata(config: ProvideAppOidcModelMetadataConfig): ModuleMetadata;