@dereekb/firebase-server 13.4.0 → 13.4.2

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 (102) hide show
  1. package/index.cjs.js +553 -119
  2. package/index.esm.js +553 -121
  3. package/mailgun/package.json +9 -9
  4. package/model/index.cjs.js +645 -350
  5. package/model/index.esm.js +646 -351
  6. package/model/package.json +9 -9
  7. package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +1 -0
  8. package/model/src/lib/notification/index.d.ts +2 -2
  9. package/model/src/lib/notification/{notification.action.service.d.ts → notification.action.server.d.ts} +53 -1
  10. package/model/src/lib/notification/{notification.action.init.service.d.ts → notification.action.server.init.d.ts} +20 -0
  11. package/model/src/lib/notification/notification.config.service.d.ts +2 -0
  12. package/model/src/lib/notification/notification.create.run.d.ts +1 -0
  13. package/model/src/lib/notification/notification.error.d.ts +16 -0
  14. package/model/src/lib/notification/notification.expedite.service.d.ts +11 -3
  15. package/model/src/lib/notification/notification.module.d.ts +19 -6
  16. package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +1 -0
  17. package/model/src/lib/notification/notification.send.service.text.d.ts +2 -0
  18. package/model/src/lib/notification/notification.task.service.handler.d.ts +1 -0
  19. package/model/src/lib/notification/notification.task.service.util.d.ts +1 -0
  20. package/model/src/lib/notification/notification.task.subtask.handler.d.ts +3 -0
  21. package/model/src/lib/notification/notification.util.d.ts +4 -2
  22. package/model/src/lib/storagefile/index.d.ts +1 -1
  23. package/model/src/lib/storagefile/storagefile.action.server.d.ts +98 -1
  24. package/model/src/lib/storagefile/{storagefile.action.init.service.d.ts → storagefile.action.server.init.d.ts} +13 -2
  25. package/model/src/lib/storagefile/storagefile.error.d.ts +27 -0
  26. package/model/src/lib/storagefile/storagefile.module.d.ts +14 -4
  27. package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +29 -7
  28. package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +2 -0
  29. package/oidc/index.cjs.js +150 -32
  30. package/oidc/index.esm.js +150 -32
  31. package/oidc/package.json +10 -10
  32. package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +12 -0
  33. package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +6 -0
  34. package/oidc/src/lib/model/jwks/jwks.d.ts +9 -0
  35. package/oidc/src/lib/model/jwks/jwks.query.d.ts +9 -0
  36. package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +13 -0
  37. package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +5 -1
  38. package/oidc/src/lib/oidc.config.d.ts +2 -1
  39. package/oidc/src/lib/oidc.module.d.ts +9 -2
  40. package/oidc/src/lib/service/oidc.account.service.d.ts +7 -0
  41. package/oidc/src/lib/service/oidc.adapter.service.d.ts +1 -0
  42. package/oidc/src/lib/service/oidc.config.service.d.ts +1 -0
  43. package/oidc/src/lib/service/oidc.encryption.service.d.ts +6 -0
  44. package/oidc/src/lib/service/oidc.interaction.service.d.ts +15 -0
  45. package/oidc/src/lib/service/oidc.jwks.service.d.ts +18 -2
  46. package/oidc/src/lib/service/oidc.service.d.ts +7 -3
  47. package/package.json +10 -10
  48. package/src/lib/auth/auth.context.d.ts +1 -0
  49. package/src/lib/auth/auth.service.d.ts +17 -1
  50. package/src/lib/auth/auth.service.error.d.ts +46 -0
  51. package/src/lib/env/env.config.d.ts +2 -0
  52. package/src/lib/env/env.service.d.ts +21 -7
  53. package/src/lib/firestore/array.d.ts +1 -0
  54. package/src/lib/firestore/driver.accessor.batch.d.ts +4 -0
  55. package/src/lib/firestore/driver.accessor.d.ts +4 -0
  56. package/src/lib/firestore/driver.accessor.default.d.ts +5 -1
  57. package/src/lib/firestore/driver.accessor.transaction.d.ts +4 -0
  58. package/src/lib/firestore/driver.d.ts +2 -0
  59. package/src/lib/firestore/driver.query.d.ts +4 -0
  60. package/src/lib/firestore/increment.d.ts +1 -0
  61. package/src/lib/function/assert.d.ts +7 -0
  62. package/src/lib/function/context.d.ts +4 -0
  63. package/src/lib/function/error.auth.d.ts +2 -0
  64. package/src/lib/function/error.d.ts +86 -11
  65. package/src/lib/index.d.ts +0 -1
  66. package/src/lib/nest/analytics/analytics.service.listener.d.ts +2 -0
  67. package/src/lib/nest/app.d.ts +6 -3
  68. package/src/lib/nest/auth/auth.module.d.ts +6 -0
  69. package/src/lib/nest/auth/auth.util.d.ts +19 -1
  70. package/src/lib/nest/development/development.app.function.d.ts +12 -4
  71. package/src/lib/nest/development/development.assert.function.d.ts +6 -2
  72. package/src/lib/nest/development/development.function.d.ts +6 -1
  73. package/src/lib/nest/development/development.schedule.function.d.ts +3 -1
  74. package/src/lib/nest/development/development.schedule.function.error.d.ts +8 -0
  75. package/src/lib/nest/env/env.service.d.ts +2 -0
  76. package/src/lib/nest/env/env.util.d.ts +6 -0
  77. package/src/lib/nest/firebase/firebase.module.d.ts +1 -0
  78. package/src/lib/nest/firestore/firestore.module.d.ts +8 -0
  79. package/src/lib/nest/function/context.d.ts +2 -0
  80. package/src/lib/nest/model/analytics.details.d.ts +21 -7
  81. package/src/lib/nest/model/analytics.emit.d.ts +3 -0
  82. package/src/lib/nest/model/analytics.handler.d.ts +30 -10
  83. package/src/lib/nest/model/api.details.d.ts +34 -1
  84. package/src/lib/nest/model/call.model.function.d.ts +20 -4
  85. package/src/lib/nest/model/create.model.function.d.ts +6 -1
  86. package/src/lib/nest/model/crud.assert.function.d.ts +12 -4
  87. package/src/lib/nest/model/delete.model.function.d.ts +6 -1
  88. package/src/lib/nest/model/permission.error.d.ts +7 -0
  89. package/src/lib/nest/model/read.model.function.d.ts +6 -1
  90. package/src/lib/nest/model/specifier.function.d.ts +3 -0
  91. package/src/lib/nest/model/update.model.function.d.ts +6 -1
  92. package/src/lib/nest/nest.provider.d.ts +16 -2
  93. package/src/lib/nest/storage/storage.module.d.ts +9 -0
  94. package/src/lib/storage/driver.accessor.d.ts +22 -0
  95. package/src/lib/storage/driver.d.ts +2 -0
  96. package/src/lib/storage/storage.d.ts +1 -0
  97. package/test/package.json +10 -10
  98. package/zoho/index.cjs.js +8 -6
  99. package/zoho/index.esm.js +8 -6
  100. package/zoho/package.json +9 -9
  101. package/zoho/src/lib/zoho.accounts.firebase.d.ts +2 -1
  102. package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +2 -1
@@ -23,6 +23,10 @@ export declare class OidcInteractionController {
23
23
  *
24
24
  * Detects the interaction type and redirects to the appropriate frontend page.
25
25
  *
26
+ * @param uid - the interaction UID from the URL path
27
+ * @param req - the incoming Express request
28
+ * @param res - the Express response used for redirecting
29
+ * @returns a redirect response to the appropriate frontend page
26
30
  * @throws {HttpException} 404 when the interaction UID is not found or has expired.
27
31
  */
28
32
  getInteraction(uid: OidcInteractionUid, req: Request, res: Response): Promise<void>;
@@ -32,6 +36,9 @@ export declare class OidcInteractionController {
32
36
  * Verifies the Firebase Auth ID token sent by the frontend, extracts the
33
37
  * user's UID, and completes the oidc-provider login interaction.
34
38
  *
39
+ * @param uid - the interaction UID from the URL path
40
+ * @param body - the login request containing the Firebase ID token
41
+ * @param res - the Express response used for sending JSON
35
42
  * @throws {HttpException} 401 when the Firebase ID token is invalid.
36
43
  * @throws {HttpException} 400 when the login interaction cannot be completed.
37
44
  */
@@ -42,12 +49,17 @@ export declare class OidcInteractionController {
42
49
  * Receives consent decision from frontend. Grants missing OIDC scopes and claims
43
50
  * when approved, or returns `access_denied` when rejected.
44
51
  *
52
+ * @param uid - the interaction UID from the URL path
53
+ * @param body - the consent request containing approval decision and Firebase ID token
54
+ * @param res - the Express response used for sending JSON
45
55
  * @throws {HttpException} 400 when the consent interaction cannot be completed.
46
56
  */
47
57
  postConsent(uid: OidcInteractionUid, body: OAuthInteractionConsentRequest, res: Response): Promise<void>;
48
58
  /**
49
59
  * Verifies a Firebase Auth ID token and returns the user's UID.
50
60
  *
61
+ * @param idToken - the Firebase Auth ID token to verify
62
+ * @returns the user's UID extracted from the decoded token
51
63
  * @throws {HttpException} 401 when the token is invalid or expired.
52
64
  */
53
65
  private _verifyIdToken;
@@ -14,12 +14,16 @@ export declare class OidcWellKnownController {
14
14
  *
15
15
  * Returns the provider metadata so clients can auto-discover endpoints,
16
16
  * supported scopes, signing algorithms, etc.
17
+ *
18
+ * @returns the OIDC discovery metadata document
17
19
  */
18
20
  getOpenIdConfiguration(): Promise<OidcDiscoveryMetadata>;
19
21
  /**
20
22
  * JWKS endpoint. Returns the public JSON Web Key Set for token verification.
21
23
  *
22
24
  * This endpoint is typically skipped if the JwksServiceStorageConfig is provided.
25
+ *
26
+ * @returns the public JWKS containing all non-retired signing keys
23
27
  */
24
28
  getJwks(): Promise<{
25
29
  keys: import("..").JsonWebKeyWithKid[];
@@ -29,6 +33,8 @@ export declare class OidcWellKnownController {
29
33
  *
30
34
  * Returns the authorization server(s) that protect this resource,
31
35
  * allowing clients to discover which authorization server to use.
36
+ *
37
+ * @returns the protected resource metadata with authorization server URLs
32
38
  */
33
39
  getProtectedResource(): {
34
40
  authorization_servers: string[];
@@ -85,10 +85,16 @@ export interface JwksKeyConverterConfig {
85
85
  * Creates a snapshot converter for {@link JwksKey} documents.
86
86
  *
87
87
  * Requires runtime encryption config since the private key field is encrypted at rest.
88
+ *
89
+ * @param config - encryption configuration for the private key field
90
+ * @returns snapshot converter functions for JwksKey documents
88
91
  */
89
92
  export declare function jwksKeyConverter(config: JwksKeyConverterConfig): import("@dereekb/firebase").SnapshotConverterFunctions<JwksKey, Partial<import("@dereekb/util").ReplaceType<JwksKey, import("@dereekb/util").MaybeMap<object>, any>>>;
90
93
  /**
91
94
  * Returns the Firestore {@link CollectionReference} for {@link JwksKey} documents.
95
+ *
96
+ * @param context - the Firestore context to create the collection reference from
97
+ * @returns the typed collection reference for JwksKey documents
92
98
  */
93
99
  export declare function jwksKeyCollectionReference(context: FirestoreContext): CollectionReference<JwksKey>;
94
100
  /**
@@ -103,5 +109,8 @@ export interface JwksKeyFirestoreCollectionConfig extends JwksKeyConverterConfig
103
109
  }
104
110
  /**
105
111
  * Creates a {@link JwksKeyFirestoreCollection} with encrypted private key field support.
112
+ *
113
+ * @param config - configuration including the Firestore context and encryption settings
114
+ * @returns the configured JwksKey Firestore collection
106
115
  */
107
116
  export declare function jwksKeyFirestoreCollection(config: JwksKeyFirestoreCollectionConfig): JwksKeyFirestoreCollection;
@@ -2,17 +2,26 @@ import { type FirestoreQueryConstraint } from '@dereekb/firebase';
2
2
  import { type JwksKeyStatus } from './jwks';
3
3
  /**
4
4
  * Query for JwksKey documents with a specific status.
5
+ *
6
+ * @param status - the lifecycle status to filter by
7
+ * @returns Firestore query constraints filtering by the given status
5
8
  */
6
9
  export declare function jwksKeysWithStatusQuery(status: JwksKeyStatus): FirestoreQueryConstraint[];
7
10
  /**
8
11
  * Query for active JwksKey documents.
12
+ *
13
+ * @returns Firestore query constraints filtering for active keys
9
14
  */
10
15
  export declare function activeJwksKeysQuery(): FirestoreQueryConstraint[];
11
16
  /**
12
17
  * Query for non-retired JwksKey documents (active + rotated).
18
+ *
19
+ * @returns Firestore query constraints filtering for non-retired keys
13
20
  */
14
21
  export declare function nonRetiredJwksKeysQuery(): FirestoreQueryConstraint[];
15
22
  /**
16
23
  * Query for rotated JwksKey documents.
24
+ *
25
+ * @returns Firestore query constraints filtering for rotated keys
17
26
  */
18
27
  export declare function rotatedJwksKeysQuery(): FirestoreQueryConstraint[];
@@ -25,6 +25,7 @@ export declare abstract class OidcModelServerActions {
25
25
  * Creates a concrete {@link OidcModelServerActions} implementation wired to the provided context.
26
26
  *
27
27
  * @param context - the fully assembled OIDC model server actions context
28
+ * @returns the concrete OidcModelServerActions instance
28
29
  *
29
30
  * @example
30
31
  * ```ts
@@ -39,12 +40,18 @@ export declare function oidcModelServerActions(context: OidcModelServerActionsCo
39
40
  *
40
41
  * Delegates to {@link OidcClientService.createClient} to generate a `client_id` and `client_secret`,
41
42
  * create the adapter entry, and return the secret in plaintext (only returned once).
43
+ *
44
+ * @param context - the OIDC model server actions context
45
+ * @returns a transform function factory for creating OIDC clients
42
46
  */
43
47
  export declare function createOidcClientFactory(context: OidcModelServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<CreateOidcClientParams, () => Promise<CreateOidcClientResult>, object, unknown>;
44
48
  /**
45
49
  * Factory for the `updateOidcClient` action.
46
50
  *
47
51
  * Delegates to {@link OidcClientService.updateClient} to apply plaintext field updates.
52
+ *
53
+ * @param context - the OIDC model server actions context
54
+ * @returns a transform function factory for updating OIDC clients
48
55
  */
49
56
  export declare function updateOidcClientFactory(context: OidcModelServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<UpdateOidcClientParams, (document: OidcEntryDocument) => Promise<OidcEntryDocument>, object, unknown>;
50
57
  /**
@@ -52,11 +59,17 @@ export declare function updateOidcClientFactory(context: OidcModelServerActionsC
52
59
  *
53
60
  * Delegates to {@link OidcClientService.rotateClientSecret} to generate a new secret
54
61
  * and return it in plaintext (only returned once).
62
+ *
63
+ * @param context - the OIDC model server actions context
64
+ * @returns a transform function factory for rotating OIDC client secrets
55
65
  */
56
66
  export declare function rotateOidcClientSecretFactory(context: OidcModelServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<import("@dereekb/firebase").TargetModelParams, (document: OidcEntryDocument) => Promise<RotateOidcClientSecretResult>, object, unknown>;
57
67
  /**
58
68
  * Factory for the `deleteOidcClient` action.
59
69
  *
60
70
  * Delegates to {@link OidcClientService.deleteClient}.
71
+ *
72
+ * @param context - the OIDC model server actions context
73
+ * @returns a transform function factory for deleting OIDC clients
61
74
  */
62
75
  export declare function deleteOidcClientFactory(context: OidcModelServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<import("@dereekb/firebase").TargetModelParams, (document: OidcEntryDocument) => Promise<void>, object, unknown>;
@@ -3,6 +3,9 @@ import { OidcModelServerActions } from './oidcmodel.action.server';
3
3
  import { OidcClientService } from '../../service/oidc.client.service';
4
4
  /**
5
5
  * Factory that creates an {@link OidcModelServerActions} instance from the injected {@link OidcClientService}.
6
+ *
7
+ * @param oidcClientService - the OIDC client service to wire into the server actions
8
+ * @returns the configured OidcModelServerActions instance
6
9
  */
7
10
  export declare function oidcModelServerActionsFactory(oidcClientService: OidcClientService): OidcModelServerActions;
8
11
  export interface ProvideAppOidcModelMetadataConfig {
@@ -18,6 +21,7 @@ export interface ProvideAppOidcModelMetadataConfig {
18
21
  * By default this module exports:
19
22
  * - OidcModelServerActions
20
23
  *
21
- * @param config
24
+ * @param config - the configuration specifying the OIDC module dependency
25
+ * @returns the NestJS module metadata for the OidcModel module
22
26
  */
23
27
  export declare function appOidcModelModuleMetadata(config: ProvideAppOidcModelMetadataConfig): ModuleMetadata;
@@ -169,7 +169,8 @@ export declare abstract class OidcModuleConfig {
169
169
  *
170
170
  * Called by {@link oidcModuleConfigFactory} after building the config from environment variables.
171
171
  *
172
+ * @param config - the config object to validate
172
173
  * @throws {Error} When any required field (`issuer`, `appInteractionPath`, `appLoginUrlPart`, `appConsentUrlPart`, `jwksServiceConfig`, `jwksKeyConverterConfig`) is missing.
173
174
  */
174
- static assertValidConfig(config: OidcModuleConfig): void;
175
+ static assertValidConfig(config: Partial<OidcModuleConfig>): void;
175
176
  }
@@ -65,12 +65,19 @@ export declare const FIREBASE_SERVER_OIDC_ROUTES_FOR_GLOBAL_ROUTE_EXCLUDE: strin
65
65
  * Reads the JWKS encryption secret from `OIDC_JWKS_ENCRYPTION_SECRET`; in test environments,
66
66
  * a deterministic fallback is used.
67
67
  *
68
+ * @param configService - the NestJS ConfigService for reading environment variables
69
+ * @param envService - the Firebase server environment service for app URL and env detection
70
+ * @returns the constructed OidcModuleConfig
68
71
  * @throws {Error} When `appUrl` is missing, lacks an HTTP prefix, or the encryption secret is invalid.
69
72
  */
70
73
  export declare function oidcModuleConfigFactory(configService: ConfigService, envService: FirebaseServerEnvService): OidcModuleConfig;
71
74
  /**
72
75
  * Factory that creates {@link OidcServerFirestoreCollections} using the provided Firestore context
73
76
  * and JWKS encryption config from {@link OidcModuleConfig}.
77
+ *
78
+ * @param firestoreContext - the Firestore context for collection creation
79
+ * @param oidcModuleConfig - the OIDC module config containing JWKS encryption settings
80
+ * @returns the configured OidcServerFirestoreCollections
74
81
  */
75
82
  export declare function oidcFirestoreCollectionsFactory(firestoreContext: FirestoreContext, oidcModuleConfig: OidcModuleConfig): OidcServerFirestoreCollections;
76
83
  export interface ProvideAppOidcModuleMetadataConfig extends Pick<ModuleMetadata, 'imports' | 'exports' | 'providers'> {
@@ -94,7 +101,7 @@ export interface ProvideAppOidcModuleMetadataConfig extends Pick<ModuleMetadata,
94
101
  * Additionally, the following may be optionally provided:
95
102
  * - JwksServiceStorageConfig
96
103
  *
97
- * @param metadataConfig
98
- * @returns
104
+ * @param metadataConfig - the configuration for generating the OIDC module metadata
105
+ * @returns the NestJS module metadata for the OIDC module
99
106
  */
100
107
  export declare function oidcModuleMetadata(metadataConfig: ProvideAppOidcModuleMetadataConfig): ModuleMetadata;
@@ -78,6 +78,8 @@ export declare class OidcAccountServiceUserContext<S extends OidcScope = OidcSco
78
78
  *
79
79
  * Returns an {@link OidcAccount} compatible with oidc-provider's `findAccount` interface,
80
80
  * or `undefined` if the user does not exist in Firebase Auth.
81
+ *
82
+ * @returns the OIDC account for this user, or undefined if the user does not exist
81
83
  */
82
84
  findAccount(): Promise<OidcAccount | undefined>;
83
85
  }
@@ -95,10 +97,15 @@ export declare class OidcAccountService<S extends OidcScope = OidcScope, U exten
95
97
  constructor(authService: FirebaseServerAuthService<U>, delegate: OidcAccountServiceDelegate<S, U>);
96
98
  /**
97
99
  * The provider config from the delegate.
100
+ *
101
+ * @returns the OIDC provider configuration from the delegate
98
102
  */
99
103
  get providerConfig(): OidcProviderConfig<S>;
100
104
  /**
101
105
  * Creates a user context for the given user ID.
106
+ *
107
+ * @param uid - the Firebase Auth user ID
108
+ * @returns a new user context bound to the given user
102
109
  */
103
110
  userContext(uid: string): OidcAccountServiceUserContext<S, U>;
104
111
  }
@@ -16,5 +16,6 @@ import { type OidcEncryptionService } from './oidc.encryption.service';
16
16
  *
17
17
  * @param collections - Firestore collection access for adapter entries.
18
18
  * @param encryptionService - Encryption service for sensitive payload fields.
19
+ * @returns an oidc-provider adapter constructor backed by Firestore
19
20
  */
20
21
  export declare function createAdapterFactory(collections: OidcServerFirestoreCollections, encryptionService: OidcEncryptionService): AdapterConstructor;
@@ -95,6 +95,7 @@ export declare class OidcProviderConfigService {
95
95
  *
96
96
  * @param jwksUri - Optional override for the JWKS URI (e.g., from cloud storage).
97
97
  * Falls back to `{issuer}{routes.jwks}`.
98
+ * @returns the fully constructed OIDC discovery metadata
98
99
  */
99
100
  buildDiscoveryMetadata(jwksUri?: string): OidcDiscoveryMetadata;
100
101
  }
@@ -44,10 +44,16 @@ export declare class OidcEncryptionService {
44
44
  /**
45
45
  * Encrypts sensitive fields in an adapter payload and returns it as a {@link JsonSerializableObject}
46
46
  * suitable for storing directly in Firestore.
47
+ *
48
+ * @param payload - the adapter payload to encrypt
49
+ * @returns the encrypted payload as a JSON-serializable object
47
50
  */
48
51
  encryptAdapterPayload(payload: AdapterPayload): JsonSerializableObject;
49
52
  /**
50
53
  * Decrypts sensitive fields in a Firestore-stored payload object back to an {@link AdapterPayload}.
54
+ *
55
+ * @param payload - the encrypted Firestore-stored payload
56
+ * @returns the decrypted adapter payload
51
57
  */
52
58
  decryptAdapterPayload(payload: JsonSerializableObject): AdapterPayload;
53
59
  }
@@ -14,6 +14,10 @@ export declare class OidcInteractionService {
14
14
  * Loads the interaction details for a given request/response pair.
15
15
  *
16
16
  * Requires the oidc-provider interaction cookie to be present on the request.
17
+ *
18
+ * @param req - the Express request containing the interaction cookie
19
+ * @param res - the Express response
20
+ * @returns the oidc-provider interaction details
17
21
  */
18
22
  getInteractionDetails(req: Request, res: Response): Promise<Interaction>;
19
23
  /**
@@ -23,6 +27,8 @@ export declare class OidcInteractionService {
23
27
  * This is necessary when the interaction cookie is scoped to a different path
24
28
  * (e.g., the frontend) and is not sent with backend API requests.
25
29
  *
30
+ * @param uid - the interaction UID to look up
31
+ * @returns the interaction details for the given UID
26
32
  * @throws {Error} When the interaction is not found or has expired.
27
33
  */
28
34
  findInteractionByUid(uid: OidcInteractionUid): Promise<Interaction>;
@@ -32,6 +38,10 @@ export declare class OidcInteractionService {
32
38
  * Looks up the interaction directly by UID, applies the result, saves it,
33
39
  * and returns the `returnTo` URL for the client to redirect to.
34
40
  *
41
+ * @param uid - the interaction UID to complete
42
+ * @param result - the interaction results to apply
43
+ * @param options - optional settings for merging with the last submission
44
+ * @param options.mergeWithLastSubmission - whether to merge with the last submission (defaults to true)
35
45
  * @returns The `returnTo` URL that the client should redirect to.
36
46
  */
37
47
  finishInteractionByUid(uid: OidcInteractionUid, result: InteractionResults, options?: {
@@ -39,6 +49,11 @@ export declare class OidcInteractionService {
39
49
  }): Promise<string>;
40
50
  /**
41
51
  * Finds an existing grant by ID, or creates a new one.
52
+ *
53
+ * @param grantId - the existing grant ID to look up, or undefined to create a new grant
54
+ * @param accountId - the account ID for creating a new grant
55
+ * @param clientId - the client ID for creating a new grant
56
+ * @returns the found or newly created grant
42
57
  */
43
58
  findOrCreateGrant(grantId: string | undefined, accountId: string, clientId: string): Promise<Grant>;
44
59
  }
@@ -7,9 +7,13 @@ import { OidcServerFirestoreCollections } from '../model/model';
7
7
  * Result of {@link JwksService.generateKeyPair}.
8
8
  */
9
9
  export interface GenerateKeyPairResult {
10
- /** The stored Firestore document data (private key is encrypted). */
10
+ /**
11
+ * The stored Firestore document data (private key is encrypted).
12
+ */
11
13
  readonly jwksKey: JwksKey;
12
- /** The unencrypted private JWK, ready for use as a signing key. */
14
+ /**
15
+ * The unencrypted private JWK, ready for use as a signing key.
16
+ */
13
17
  readonly signingKey: JsonWebKeyWithKid;
14
18
  }
15
19
  export declare abstract class JwksServiceConfig {
@@ -70,10 +74,14 @@ export declare class JwksService {
70
74
  *
71
75
  * Returns both the stored {@link JwksKey} and the unencrypted private JWK
72
76
  * so callers can use the signing key immediately without a decryption round-trip.
77
+ *
78
+ * @returns the generated key pair result containing the stored JwksKey and signing key
73
79
  */
74
80
  generateKeyPair(): Promise<GenerateKeyPairResult>;
75
81
  /**
76
82
  * Returns the currently active signing key's private JWK.
83
+ *
84
+ * @returns the active signing key's private JWK, or undefined if no active key exists
77
85
  */
78
86
  getActiveSigningKey(): Promise<JsonWebKeyWithKid | undefined>;
79
87
  /**
@@ -84,22 +92,30 @@ export declare class JwksService {
84
92
  *
85
93
  * Returns undefined if storage is not configured or `serveJwksFromStorage` is false.
86
94
  * Returns null if an error occured while trying to setup.
95
+ *
96
+ * @returns the public URL, or null/undefined if unavailable
87
97
  */
88
98
  getJwksStoragePublicUrl(): Promise<Maybe<WebsiteUrlWithPrefix>>;
89
99
  /**
90
100
  * Returns the public JWKS (all non-retired keys) by querying Firestore.
101
+ *
102
+ * @returns the public JWKS containing all non-retired signing keys
91
103
  */
92
104
  getLatestPublicJwks(): Promise<{
93
105
  keys: JsonWebKeyWithKid[];
94
106
  }>;
95
107
  /**
96
108
  * Rotates keys: marks the current active key as rotated and generates a new active key.
109
+ *
110
+ * @returns the newly generated active JwksKey
97
111
  */
98
112
  rotateKeys(): Promise<JwksKey>;
99
113
  private _initializeKeysAndCloud;
100
114
  private _syncKeysToCloud;
101
115
  /**
102
116
  * Retires rotated keys whose expiresAt has passed.
117
+ *
118
+ * @returns the number of keys retired
103
119
  */
104
120
  retireExpiredKeys(): Promise<number>;
105
121
  }
@@ -1,5 +1,4 @@
1
- import type Provider from 'oidc-provider';
2
- import { type Configuration } from 'oidc-provider';
1
+ import type { default as Provider, Configuration } from 'oidc-provider';
3
2
  import { OidcModuleConfig } from '../oidc.config';
4
3
  import { JwksService } from './oidc.jwks.service';
5
4
  import { OidcAccountService } from './oidc.account.service';
@@ -24,6 +23,8 @@ export declare class OidcService {
24
23
  constructor(config: OidcModuleConfig, providerConfigService: OidcProviderConfigService, jwksService: JwksService, accountService: OidcAccountService, collections: OidcServerFirestoreCollections, encryptionService: OidcEncryptionService);
25
24
  /**
26
25
  * Returns the oidc-provider instance, initializing it on first access.
26
+ *
27
+ * @returns the lazily-initialized oidc-provider instance
27
28
  */
28
29
  getProvider(): Promise<Provider>;
29
30
  /**
@@ -32,7 +33,7 @@ export declare class OidcService {
32
33
  * Uses the provider's `AccessToken` model to look up the token and extract
33
34
  * the account ID, scope, and client ID.
34
35
  *
35
- * @param token - The opaque access token string.
36
+ * @param rawToken - The opaque access token string.
36
37
  * @returns The auth context, or `undefined` if the token is invalid or expired.
37
38
  */
38
39
  verifyAccessToken(rawToken: string): Promise<OidcAuthData | undefined>;
@@ -49,6 +50,9 @@ export declare class OidcService {
49
50
  *
50
51
  * Does NOT include `adapter`, `findAccount`, or `jwks` — those require async
51
52
  * setup and are handled by {@link OidcService}.
53
+ *
54
+ * @param cookieKeys - the signing keys for oidc-provider session cookies
55
+ * @returns the oidc-provider configuration options
52
56
  */
53
57
  buildProviderConfiguration(cookieKeys: string[]): Configuration;
54
58
  private _buildProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
4
4
  "exports": {
5
5
  "./test": {
6
6
  "module": "./test/index.esm.js",
@@ -43,15 +43,15 @@
43
43
  "main": "./index.cjs.js",
44
44
  "types": "./src/index.d.ts",
45
45
  "peerDependencies": {
46
- "@dereekb/analytics": "13.4.0",
47
- "@dereekb/date": "13.4.0",
48
- "@dereekb/dbx-core": "13.4.0",
49
- "@dereekb/firebase": "13.4.0",
50
- "@dereekb/model": "13.4.0",
51
- "@dereekb/nestjs": "13.4.0",
52
- "@dereekb/rxjs": "13.4.0",
53
- "@dereekb/util": "13.4.0",
54
- "@dereekb/zoho": "13.4.0",
46
+ "@dereekb/analytics": "13.4.2",
47
+ "@dereekb/date": "13.4.2",
48
+ "@dereekb/dbx-core": "13.4.2",
49
+ "@dereekb/firebase": "13.4.2",
50
+ "@dereekb/model": "13.4.2",
51
+ "@dereekb/nestjs": "13.4.2",
52
+ "@dereekb/rxjs": "13.4.2",
53
+ "@dereekb/util": "13.4.2",
54
+ "@dereekb/zoho": "13.4.2",
55
55
  "@google-cloud/firestore": "^7.11.6",
56
56
  "@google-cloud/storage": "^7.19.0",
57
57
  "@nestjs/common": "^11.1.16",
@@ -17,6 +17,7 @@ export interface AuthDataRef<T extends AuthData = AuthData> {
17
17
  * including email, phone, and sign-in timestamps.
18
18
  *
19
19
  * @param token - The decoded ID token from Firebase Admin Auth.
20
+ * @returns A normalized {@link FirebaseAuthToken} with camelCase fields.
20
21
  *
21
22
  * @example
22
23
  * ```typescript
@@ -175,6 +175,8 @@ export declare abstract class AbstractFirebaseServerAuthUserContext<S extends Fi
175
175
  loadDetails(): Promise<FirebaseAuthDetails>;
176
176
  /**
177
177
  * Generates a random numeric string for use as a temporary reset password.
178
+ *
179
+ * @returns A random numeric string suitable as a temporary password.
178
180
  */
179
181
  protected _generateResetPasswordKey(): string;
180
182
  beginResetPassword(): Promise<FirebaseServerAuthResetUserPasswordClaims>;
@@ -192,6 +194,7 @@ export declare abstract class AbstractFirebaseServerAuthUserContext<S extends Fi
192
194
  *
193
195
  * @param roles - The complete set of roles to assign.
194
196
  * @param claimsToRetain - Additional claims to merge in alongside the role-derived claims.
197
+ * @returns Resolves when the claims have been replaced.
195
198
  *
196
199
  * @example
197
200
  * ```typescript
@@ -203,6 +206,9 @@ export declare abstract class AbstractFirebaseServerAuthUserContext<S extends Fi
203
206
  /**
204
207
  * Converts roles to their corresponding claim keys, filtering out null/undefined entries
205
208
  * that represent unrelated claims in the service's {@link FirebaseServerAuthService.claimsForRoles} output.
209
+ *
210
+ * @param roles - The roles to convert to claims.
211
+ * @returns Filtered claims object with only the relevant role-based entries.
206
212
  */
207
213
  protected _claimsForRolesChange(roles: ArrayOrValue<AuthRole>): Partial<{
208
214
  [x: string]: import("@dereekb/util").AuthClaimValue | null;
@@ -322,7 +328,10 @@ export interface FirebaseServerAuthInitializeNewUser<D = unknown> {
322
328
  */
323
329
  readonly email?: EmailAddress;
324
330
  /**
325
- * Phone for the new user, if applicable.
331
+ * Phone for the new user, if applicable. Must be a valid {@link E164PhoneNumber} (e.g. `'+17206620850'`).
332
+ *
333
+ * Firebase Auth requires E.164 format. If the value is not valid, {@link FirebaseServerAuthUserBadInputError}
334
+ * is thrown with code `auth/invalid-phone-number`.
326
335
  */
327
336
  readonly phone?: E164PhoneNumber;
328
337
  /**
@@ -494,6 +503,7 @@ export type UserContextOrUid<U extends FirebaseServerAuthUserContext = FirebaseS
494
503
  *
495
504
  * @param authService - The auth service to create a context from if needed.
496
505
  * @param userContextOrUid - A user context or UID string.
506
+ * @returns The resolved user context instance.
497
507
  *
498
508
  * @example
499
509
  * ```typescript
@@ -534,6 +544,8 @@ export declare abstract class AbstractFirebaseServerNewUserService<U extends Fir
534
544
  loadSetupDetailsForUserContext(userContext: U, config?: FirebaseServerAuthNewUserSendSetupDetailsConfig<D>): Promise<Maybe<FirebaseServerAuthNewUserSetupDetails<U, D>>>;
535
545
  /**
536
546
  * Records the current timestamp as the last setup content communication date in the user's claims.
547
+ *
548
+ * @param details - The user's setup details containing the user context.
537
549
  */
538
550
  protected updateSetupContentSentTime(details: FirebaseServerAuthNewUserSetupDetails<U, D>): Promise<void>;
539
551
  markUserSetupAsComplete(uid: FirebaseAuthUserId): Promise<boolean>;
@@ -542,6 +554,8 @@ export declare abstract class AbstractFirebaseServerNewUserService<U extends Fir
542
554
  *
543
555
  * Generates a random setup password if none is provided. Override to customize user creation behavior.
544
556
  *
557
+ * @param input - The initialization configuration for the new user.
558
+ * @returns The created user record and the setup password used.
545
559
  * @throws Throws if the Firebase Admin SDK rejects the user creation.
546
560
  */
547
561
  protected createNewUser(input: FirebaseServerAuthInitializeNewUser<D>): Promise<FirebaseServerAuthCreateNewUserResult>;
@@ -556,6 +570,8 @@ export declare abstract class AbstractFirebaseServerNewUserService<U extends Fir
556
570
  protected abstract sendSetupContentToUser(details: FirebaseServerAuthNewUserSetupDetails<U, D>): Promise<void>;
557
571
  /**
558
572
  * Clears setup-related claims (setup password and last communication date) from the user.
573
+ *
574
+ * @param userContext - The user context to clear setup claims from.
559
575
  */
560
576
  protected updateClaimsToClearUser(userContext: U): Promise<void>;
561
577
  }
@@ -1,4 +1,50 @@
1
+ import { type FirebaseErrorCode } from '@dereekb/firebase';
1
2
  import { BaseError } from 'make-error';
3
+ /**
4
+ * The type of identifier that caused the user-already-exists conflict.
5
+ */
6
+ export type FirebaseServerAuthUserExistsErrorIdentifierType = 'phone' | 'email';
7
+ /**
8
+ * Thrown by {@link AbstractFirebaseServerNewUserService.createNewUser} when Firebase Auth rejects
9
+ * user creation because the provided phone number or email is already associated with another account.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * try {
14
+ * await newUserService.initializeNewUser({ email, phone });
15
+ * } catch (e) {
16
+ * if (e instanceof FirebaseServerAuthUserExistsError && e.identifierType === 'phone') {
17
+ * const existingUser = await auth.getUserByPhoneNumber(e.identifierValue);
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ export declare class FirebaseServerAuthUserExistsError extends BaseError {
23
+ readonly code: FirebaseErrorCode;
24
+ readonly identifierType: FirebaseServerAuthUserExistsErrorIdentifierType;
25
+ readonly identifierValue: string;
26
+ constructor(code: FirebaseErrorCode, identifierType: FirebaseServerAuthUserExistsErrorIdentifierType, identifierValue: string);
27
+ }
28
+ /**
29
+ * Thrown by {@link AbstractFirebaseServerNewUserService.createNewUser} when Firebase Auth rejects
30
+ * user creation due to invalid input (e.g., a malformed phone number).
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * try {
35
+ * await newUserService.initializeNewUser({ email, phone: 'not-e164' });
36
+ * } catch (e) {
37
+ * if (e instanceof FirebaseServerAuthUserBadInputError) {
38
+ * console.log(`Bad input (${e.code}): ${e.inputValue}`);
39
+ * }
40
+ * }
41
+ * ```
42
+ */
43
+ export declare class FirebaseServerAuthUserBadInputError extends BaseError {
44
+ readonly code: FirebaseErrorCode;
45
+ readonly inputValue: string;
46
+ constructor(code: FirebaseErrorCode, inputValue: string, message?: string);
47
+ }
2
48
  /**
3
49
  * Thrown by sendSetupDetails() if the user has no setup configuration available, meaning they probably already have accepted their invite or is in an invalid state.
4
50
  */
@@ -17,6 +17,7 @@ export declare const FIREBASE_SERVER_ENV_TOKEN: InjectionToken;
17
17
  * Creates a NestJS provider that binds the given config to the {@link FIREBASE_SERVER_ENV_TOKEN} injection token.
18
18
  *
19
19
  * @param env - The Firebase server environment configuration.
20
+ * @returns A NestJS provider binding the config to the {@link FIREBASE_SERVER_ENV_TOKEN} token.
20
21
  *
21
22
  * @example
22
23
  * ```typescript
@@ -31,6 +32,7 @@ export declare function firebaseServerEnvTokenProvider<T extends FirebaseServerE
31
32
  * Use this when the NestJS app needs the config accessible via either token.
32
33
  *
33
34
  * @param env - The Firebase server environment configuration.
35
+ * @returns An array of providers binding the config to both Firebase and base server env tokens.
34
36
  *
35
37
  * @example
36
38
  * ```typescript
@@ -13,18 +13,32 @@ export interface FirebaseServerEnvServiceRef<S extends FirebaseServerEnvService
13
13
  * backed by a {@link FirebaseServerEnvironmentConfig}.
14
14
  */
15
15
  export declare abstract class FirebaseServerEnvService {
16
- /** Whether the server is running in a test/CI environment. */
16
+ /**
17
+ * Whether the server is running in a test/CI environment.
18
+ */
17
19
  abstract readonly isTestingEnv: boolean;
18
- /** Whether the server is running in production. */
20
+ /**
21
+ * Whether the server is running in production.
22
+ */
19
23
  abstract readonly isProduction: boolean;
20
- /** Whether the server is running in a staging environment. */
24
+ /**
25
+ * Whether the server is running in a staging environment.
26
+ */
21
27
  abstract readonly isStaging: boolean;
22
- /** Whether developer/debug tools are enabled for this environment. */
28
+ /**
29
+ * Whether developer/debug tools are enabled for this environment.
30
+ */
23
31
  abstract readonly developerToolsEnabled: boolean;
24
- /** Whether the development scheduler (for cron-like tasks) is enabled. */
32
+ /**
33
+ * Whether the development scheduler (for cron-like tasks) is enabled.
34
+ */
25
35
  abstract readonly developmentSchedulerEnabled: boolean;
26
- /** The application's public URL, if configured. */
36
+ /**
37
+ * The application's public URL, if configured.
38
+ */
27
39
  abstract readonly appUrl: Maybe<string>;
28
- /** Parsed URL details for the application URL. */
40
+ /**
41
+ * Parsed URL details for the application URL.
42
+ */
29
43
  abstract readonly appUrlDetails: Maybe<WebsiteUrlDetails>;
30
44
  }