@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
package/oidc/index.cjs.js CHANGED
@@ -177,6 +177,7 @@ function _define_property$f(obj, key, value) {
177
177
  *
178
178
  * Called by {@link oidcModuleConfigFactory} after building the config from environment variables.
179
179
  *
180
+ * @param config - the config object to validate
180
181
  * @throws {Error} When any required field (`issuer`, `appInteractionPath`, `appLoginUrlPart`, `appConsentUrlPart`, `jwksServiceConfig`, `jwksKeyConverterConfig`) is missing.
181
182
  */ function assertValidConfig(config) {
182
183
  if (!config.issuer) {
@@ -206,6 +207,9 @@ function _define_property$f(obj, key, value) {
206
207
 
207
208
  /**
208
209
  * Query for JwksKey documents with a specific status.
210
+ *
211
+ * @param status - the lifecycle status to filter by
212
+ * @returns Firestore query constraints filtering by the given status
209
213
  */ function jwksKeysWithStatusQuery(status) {
210
214
  return [
211
215
  firebase.where('status', '==', status)
@@ -213,11 +217,15 @@ function _define_property$f(obj, key, value) {
213
217
  }
214
218
  /**
215
219
  * Query for active JwksKey documents.
220
+ *
221
+ * @returns Firestore query constraints filtering for active keys
216
222
  */ function activeJwksKeysQuery() {
217
223
  return jwksKeysWithStatusQuery('active');
218
224
  }
219
225
  /**
220
226
  * Query for non-retired JwksKey documents (active + rotated).
227
+ *
228
+ * @returns Firestore query constraints filtering for non-retired keys
221
229
  */ function nonRetiredJwksKeysQuery() {
222
230
  return [
223
231
  firebase.where('status', 'in', [
@@ -228,6 +236,8 @@ function _define_property$f(obj, key, value) {
228
236
  }
229
237
  /**
230
238
  * Query for rotated JwksKey documents.
239
+ *
240
+ * @returns Firestore query constraints filtering for rotated keys
231
241
  */ function rotatedJwksKeysQuery() {
232
242
  return jwksKeysWithStatusQuery('rotated');
233
243
  }
@@ -539,13 +549,15 @@ exports.JwksService = /*#__PURE__*/ function() {
539
549
  *
540
550
  * Returns both the stored {@link JwksKey} and the unencrypted private JWK
541
551
  * so callers can use the signing key immediately without a decryption round-trip.
552
+ *
553
+ * @returns the generated key pair result containing the stored JwksKey and signing key
542
554
  */ function generateKeyPair() {
543
555
  return _async_to_generator$a(function() {
544
556
  var _generateKeyPairSync, publicKey, privateKey, kid, publicJwk, privateJwk, getKey, encryptedPrivateKey, data, doc;
545
557
  return _ts_generator$a(this, function(_state) {
546
558
  switch(_state.label){
547
559
  case 0:
548
- _generateKeyPairSync = crypto.generateKeyPairSync('rsa', {
560
+ /* eslint-disable @typescript-eslint/no-explicit-any -- Node.js crypto types do not include JWK format overloads */ _generateKeyPairSync = crypto.generateKeyPairSync('rsa', {
549
561
  modulusLength: 2048,
550
562
  publicKeyEncoding: {
551
563
  type: 'spki',
@@ -556,7 +568,7 @@ exports.JwksService = /*#__PURE__*/ function() {
556
568
  format: 'jwk'
557
569
  }
558
570
  }), publicKey = _generateKeyPairSync.publicKey, privateKey = _generateKeyPairSync.privateKey;
559
- kid = crypto.randomBytes(16).toString('hex');
571
+ /* eslint-enable @typescript-eslint/no-explicit-any */ kid = crypto.randomBytes(16).toString('hex');
560
572
  publicJwk = _object_spread_props$3(_object_spread$6({}, publicKey), {
561
573
  kid: kid,
562
574
  kty: 'RSA',
@@ -600,6 +612,8 @@ exports.JwksService = /*#__PURE__*/ function() {
600
612
  key: "getActiveSigningKey",
601
613
  value: /**
602
614
  * Returns the currently active signing key's private JWK.
615
+ *
616
+ * @returns the active signing key's private JWK, or undefined if no active key exists
603
617
  */ function getActiveSigningKey() {
604
618
  return _async_to_generator$a(function() {
605
619
  var results, result, data, getKey;
@@ -636,6 +650,8 @@ exports.JwksService = /*#__PURE__*/ function() {
636
650
  *
637
651
  * Returns undefined if storage is not configured or `serveJwksFromStorage` is false.
638
652
  * Returns null if an error occured while trying to setup.
653
+ *
654
+ * @returns the public URL, or null/undefined if unavailable
639
655
  */ function getJwksStoragePublicUrl() {
640
656
  return _async_to_generator$a(function() {
641
657
  return _ts_generator$a(this, function(_state) {
@@ -651,6 +667,8 @@ exports.JwksService = /*#__PURE__*/ function() {
651
667
  key: "getLatestPublicJwks",
652
668
  value: /**
653
669
  * Returns the public JWKS (all non-retired keys) by querying Firestore.
670
+ *
671
+ * @returns the public JWKS containing all non-retired signing keys
654
672
  */ function getLatestPublicJwks() {
655
673
  return _async_to_generator$a(function() {
656
674
  var keys;
@@ -695,6 +713,8 @@ exports.JwksService = /*#__PURE__*/ function() {
695
713
  key: "rotateKeys",
696
714
  value: /**
697
715
  * Rotates keys: marks the current active key as rotated and generates a new active key.
716
+ *
717
+ * @returns the newly generated active JwksKey
698
718
  */ function rotateKeys() {
699
719
  return _async_to_generator$a(function() {
700
720
  var now, expiresAt, _ref, newKey;
@@ -873,6 +893,8 @@ exports.JwksService = /*#__PURE__*/ function() {
873
893
  key: "retireExpiredKeys",
874
894
  value: /**
875
895
  * Retires rotated keys whose expiresAt has passed.
896
+ *
897
+ * @returns the number of keys retired
876
898
  */ function retireExpiredKeys() {
877
899
  return _async_to_generator$a(function() {
878
900
  var now, count;
@@ -1181,6 +1203,8 @@ function _ts_generator$9(thisArg, body) {
1181
1203
  *
1182
1204
  * Returns an {@link OidcAccount} compatible with oidc-provider's `findAccount` interface,
1183
1205
  * or `undefined` if the user does not exist in Firebase Auth.
1206
+ *
1207
+ * @returns the OIDC account for this user, or undefined if the user does not exist
1184
1208
  */ function findAccount() {
1185
1209
  return _async_to_generator$9(function() {
1186
1210
  var authUserContext, exists, delegate;
@@ -1248,6 +1272,8 @@ function _ts_generator$9(thisArg, body) {
1248
1272
  key: "providerConfig",
1249
1273
  get: /**
1250
1274
  * The provider config from the delegate.
1275
+ *
1276
+ * @returns the OIDC provider configuration from the delegate
1251
1277
  */ function get() {
1252
1278
  return this.delegate.providerConfig;
1253
1279
  }
@@ -1255,6 +1281,9 @@ function _ts_generator$9(thisArg, body) {
1255
1281
  {
1256
1282
  /**
1257
1283
  * Creates a user context for the given user ID.
1284
+ *
1285
+ * @param uid - the Firebase Auth user ID
1286
+ * @returns a new user context bound to the given user
1258
1287
  */ key: "userContext",
1259
1288
  value: function userContext(uid) {
1260
1289
  return new OidcAccountServiceUserContext(this, uid);
@@ -1373,6 +1402,9 @@ function _is_native_reflect_construct() {
1373
1402
  * Creates a snapshot converter for {@link JwksKey} documents.
1374
1403
  *
1375
1404
  * Requires runtime encryption config since the private key field is encrypted at rest.
1405
+ *
1406
+ * @param config - encryption configuration for the private key field
1407
+ * @returns snapshot converter functions for JwksKey documents
1376
1408
  */ function jwksKeyConverter(config) {
1377
1409
  return firebase.snapshotConverterFunctions({
1378
1410
  fields: {
@@ -1395,11 +1427,17 @@ function _is_native_reflect_construct() {
1395
1427
  // MARK: Collection
1396
1428
  /**
1397
1429
  * Returns the Firestore {@link CollectionReference} for {@link JwksKey} documents.
1430
+ *
1431
+ * @param context - the Firestore context to create the collection reference from
1432
+ * @returns the typed collection reference for JwksKey documents
1398
1433
  */ function jwksKeyCollectionReference(context) {
1399
1434
  return context.collection(jwksKeyIdentity.collectionName);
1400
1435
  }
1401
1436
  /**
1402
1437
  * Creates a {@link JwksKeyFirestoreCollection} with encrypted private key field support.
1438
+ *
1439
+ * @param config - configuration including the Firestore context and encryption settings
1440
+ * @returns the configured JwksKey Firestore collection
1403
1441
  */ function jwksKeyFirestoreCollection(config) {
1404
1442
  var firestoreContext = config.firestoreContext;
1405
1443
  return firestoreContext.firestoreCollection({
@@ -1558,6 +1596,7 @@ function _ts_generator$8(thisArg, body) {
1558
1596
  * Creates a concrete {@link OidcModelServerActions} implementation wired to the provided context.
1559
1597
  *
1560
1598
  * @param context - the fully assembled OIDC model server actions context
1599
+ * @returns the concrete OidcModelServerActions instance
1561
1600
  *
1562
1601
  * @example
1563
1602
  * ```ts
@@ -1579,6 +1618,9 @@ function _ts_generator$8(thisArg, body) {
1579
1618
  *
1580
1619
  * Delegates to {@link OidcClientService.createClient} to generate a `client_id` and `client_secret`,
1581
1620
  * create the adapter entry, and return the secret in plaintext (only returned once).
1621
+ *
1622
+ * @param context - the OIDC model server actions context
1623
+ * @returns a transform function factory for creating OIDC clients
1582
1624
  */ function createOidcClientFactory(context) {
1583
1625
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1584
1626
  return firebaseServerActionTransformFunctionFactory(firebase.createOidcClientParamsType, function(params) {
@@ -1605,6 +1647,9 @@ function _ts_generator$8(thisArg, body) {
1605
1647
  * Factory for the `updateOidcClient` action.
1606
1648
  *
1607
1649
  * Delegates to {@link OidcClientService.updateClient} to apply plaintext field updates.
1650
+ *
1651
+ * @param context - the OIDC model server actions context
1652
+ * @returns a transform function factory for updating OIDC clients
1608
1653
  */ function updateOidcClientFactory(context) {
1609
1654
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1610
1655
  return firebaseServerActionTransformFunctionFactory(firebase.updateOidcClientParamsType, function(params) {
@@ -1641,6 +1686,9 @@ function _ts_generator$8(thisArg, body) {
1641
1686
  *
1642
1687
  * Delegates to {@link OidcClientService.rotateClientSecret} to generate a new secret
1643
1688
  * and return it in plaintext (only returned once).
1689
+ *
1690
+ * @param context - the OIDC model server actions context
1691
+ * @returns a transform function factory for rotating OIDC client secrets
1644
1692
  */ function rotateOidcClientSecretFactory(context) {
1645
1693
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1646
1694
  return firebaseServerActionTransformFunctionFactory(firebase.rotateOidcClientSecretParamsType, function(_params) {
@@ -1667,9 +1715,12 @@ function _ts_generator$8(thisArg, body) {
1667
1715
  * Factory for the `deleteOidcClient` action.
1668
1716
  *
1669
1717
  * Delegates to {@link OidcClientService.deleteClient}.
1718
+ *
1719
+ * @param context - the OIDC model server actions context
1720
+ * @returns a transform function factory for deleting OIDC clients
1670
1721
  */ function deleteOidcClientFactory(context) {
1671
1722
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1672
- return firebaseServerActionTransformFunctionFactory(firebase.deleteOidcClientParamsType, function(params) {
1723
+ return firebaseServerActionTransformFunctionFactory(firebase.deleteOidcClientParamsType, function(_params) {
1673
1724
  return _async_to_generator$8(function() {
1674
1725
  return _ts_generator$8(this, function(_state) {
1675
1726
  return [
@@ -1929,6 +1980,7 @@ function _ts_generator$7(thisArg, body) {
1929
1980
  ];
1930
1981
  case 1:
1931
1982
  provider = _state.sent();
1983
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
1932
1984
  ProviderClient = provider.Client;
1933
1985
  // Mirrors oidc-provider's default idFactory from lib/helpers/defaults.js
1934
1986
  clientId = nanoid.nanoid();
@@ -1990,7 +2042,7 @@ function _ts_generator$7(thisArg, body) {
1990
2042
  {
1991
2043
  modelKeys: firebase.firestoreModelKey(firebase.oidcEntryIdentity, clientId),
1992
2044
  client_id: clientId,
1993
- client_secret: clientSecret
2045
+ client_secret: clientSecret !== null && clientSecret !== void 0 ? clientSecret : ''
1994
2046
  }
1995
2047
  ];
1996
2048
  }
@@ -2013,7 +2065,7 @@ function _ts_generator$7(thisArg, body) {
2013
2065
  * @throws When the client is not found.
2014
2066
  */ function updateClient(clientId, params) {
2015
2067
  return _async_to_generator$7(function() {
2016
- var provider, ProviderClient, existing, updatedMetadata, client;
2068
+ var provider, ProviderClient, existing, updatedMetadata, _params_logo_uri, _params_client_uri, client;
2017
2069
  return _ts_generator$7(this, function(_state) {
2018
2070
  switch(_state.label){
2019
2071
  case 0:
@@ -2023,6 +2075,7 @@ function _ts_generator$7(thisArg, body) {
2023
2075
  ];
2024
2076
  case 1:
2025
2077
  provider = _state.sent();
2078
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
2026
2079
  ProviderClient = provider.Client;
2027
2080
  return [
2028
2081
  4,
@@ -2034,17 +2087,13 @@ function _ts_generator$7(thisArg, body) {
2034
2087
  throw new Error('Client not found.');
2035
2088
  }
2036
2089
  updatedMetadata = _object_spread$5({}, existing);
2037
- if (params.client_name !== undefined && params.client_name !== null) {
2038
- updatedMetadata.client_name = params.client_name;
2039
- }
2040
- if (params.redirect_uris !== undefined && params.redirect_uris !== null) {
2041
- updatedMetadata.redirect_uris = params.redirect_uris;
2042
- }
2090
+ updatedMetadata.client_name = params.client_name;
2091
+ updatedMetadata.redirect_uris = params.redirect_uris;
2043
2092
  if (params.logo_uri !== undefined) {
2044
- updatedMetadata.logo_uri = params.logo_uri || undefined;
2093
+ updatedMetadata.logo_uri = (_params_logo_uri = params.logo_uri) !== null && _params_logo_uri !== void 0 ? _params_logo_uri : undefined;
2045
2094
  }
2046
2095
  if (params.client_uri !== undefined) {
2047
- updatedMetadata.client_uri = params.client_uri || undefined;
2096
+ updatedMetadata.client_uri = (_params_client_uri = params.client_uri) !== null && _params_client_uri !== void 0 ? _params_client_uri : undefined;
2048
2097
  }
2049
2098
  // Mirrors oidc-provider's lib/helpers/add_client.js: re-validates and persists.
2050
2099
  return [
@@ -2091,6 +2140,7 @@ function _ts_generator$7(thisArg, body) {
2091
2140
  ];
2092
2141
  case 1:
2093
2142
  provider = _state.sent();
2143
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
2094
2144
  ProviderClient = provider.Client;
2095
2145
  return [
2096
2146
  4,
@@ -2150,6 +2200,7 @@ function _ts_generator$7(thisArg, body) {
2150
2200
  ];
2151
2201
  case 1:
2152
2202
  provider = _state.sent();
2203
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
2153
2204
  ProviderClient = provider.Client;
2154
2205
  return [
2155
2206
  4,
@@ -2229,6 +2280,9 @@ function _object_spread_props$1(target, source) {
2229
2280
  // MARK: Provider Factories
2230
2281
  /**
2231
2282
  * Factory that creates an {@link OidcModelServerActions} instance from the injected {@link OidcClientService}.
2283
+ *
2284
+ * @param oidcClientService - the OIDC client service to wire into the server actions
2285
+ * @returns the configured OidcModelServerActions instance
2232
2286
  */ function oidcModelServerActionsFactory(oidcClientService) {
2233
2287
  var context = _object_spread_props$1(_object_spread$4({}, firebaseServer.firebaseServerActionsContext()), {
2234
2288
  oidcClientService: oidcClientService
@@ -2241,7 +2295,8 @@ function _object_spread_props$1(target, source) {
2241
2295
  * By default this module exports:
2242
2296
  * - OidcModelServerActions
2243
2297
  *
2244
- * @param config
2298
+ * @param config - the configuration specifying the OIDC module dependency
2299
+ * @returns the NestJS module metadata for the OidcModel module
2245
2300
  */ function appOidcModelModuleMetadata(config) {
2246
2301
  var oidcModule = config.oidcModule;
2247
2302
  return {
@@ -2469,6 +2524,7 @@ function _ts_generator$6(thisArg, body) {
2469
2524
  *
2470
2525
  * @param collections - Firestore collection access for adapter entries.
2471
2526
  * @param encryptionService - Encryption service for sensitive payload fields.
2527
+ * @returns an oidc-provider adapter constructor backed by Firestore
2472
2528
  */ function createAdapterFactory(collections, encryptionService) {
2473
2529
  var FirestoreAdapter = /*#__PURE__*/ function() {
2474
2530
  function FirestoreAdapter(name) {
@@ -2536,7 +2592,7 @@ function _ts_generator$6(thisArg, body) {
2536
2592
  data = snapshot.data();
2537
2593
  return [
2538
2594
  2,
2539
- data && data.type === this.name ? this._toPayload(data) : undefined
2595
+ (data === null || data === void 0 ? void 0 : data.type) === this.name ? this._toPayload(data) : undefined
2540
2596
  ];
2541
2597
  }
2542
2598
  });
@@ -2702,6 +2758,9 @@ function _ts_generator$6(thisArg, body) {
2702
2758
  /**
2703
2759
  * Converts a Firestore document into an oidc-provider payload,
2704
2760
  * returning `undefined` if the entry has expired.
2761
+ *
2762
+ * @param data - the Firestore document data to convert
2763
+ * @returns the decrypted adapter payload, or undefined if the entry has expired
2705
2764
  */ key: "_toPayload",
2706
2765
  value: function _toPayload(data) {
2707
2766
  var expiresDate = data.expiresAt ? _instanceof$1(data.expiresAt, Date) ? data.expiresAt : data.expiresAt.toDate() : undefined;
@@ -2805,6 +2864,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2805
2864
  /**
2806
2865
  * Encrypts sensitive fields in an adapter payload and returns it as a {@link JsonSerializableObject}
2807
2866
  * suitable for storing directly in Firestore.
2867
+ *
2868
+ * @param payload - the adapter payload to encrypt
2869
+ * @returns the encrypted payload as a JSON-serializable object
2808
2870
  */ key: "encryptAdapterPayload",
2809
2871
  value: function encryptAdapterPayload(payload) {
2810
2872
  var filtered = util.filterUndefinedValues(payload);
@@ -2814,8 +2876,12 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2814
2876
  {
2815
2877
  /**
2816
2878
  * Decrypts sensitive fields in a Firestore-stored payload object back to an {@link AdapterPayload}.
2879
+ *
2880
+ * @param payload - the encrypted Firestore-stored payload
2881
+ * @returns the decrypted adapter payload
2817
2882
  */ key: "decryptAdapterPayload",
2818
2883
  value: function decryptAdapterPayload(payload) {
2884
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2819
2885
  return this.adapterPayloadEncryptor.decrypt(payload);
2820
2886
  }
2821
2887
  }
@@ -2977,6 +3043,7 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
2977
3043
  *
2978
3044
  * @param jwksUri - Optional override for the JWKS URI (e.g., from cloud storage).
2979
3045
  * Falls back to `{issuer}{routes.jwks}`.
3046
+ * @returns the fully constructed OIDC discovery metadata
2980
3047
  */ key: "buildDiscoveryMetadata",
2981
3048
  value: function buildDiscoveryMetadata(jwksUri) {
2982
3049
  var issuer = this.config.issuer;
@@ -3259,6 +3326,8 @@ function _ts_generator$5(thisArg, body) {
3259
3326
  {
3260
3327
  /**
3261
3328
  * Returns the oidc-provider instance, initializing it on first access.
3329
+ *
3330
+ * @returns the lazily-initialized oidc-provider instance
3262
3331
  */ key: "getProvider",
3263
3332
  value: function getProvider() {
3264
3333
  return this._getProvider();
@@ -3273,11 +3342,11 @@ function _ts_generator$5(thisArg, body) {
3273
3342
  * Uses the provider's `AccessToken` model to look up the token and extract
3274
3343
  * the account ID, scope, and client ID.
3275
3344
  *
3276
- * @param token - The opaque access token string.
3345
+ * @param rawToken - The opaque access token string.
3277
3346
  * @returns The auth context, or `undefined` if the token is invalid or expired.
3278
3347
  */ function verifyAccessToken(rawToken) {
3279
3348
  return _async_to_generator$5(function() {
3280
- var _firstValue, _accessToken_exp, provider, accessToken, token;
3349
+ var _accessToken_exp, provider, accessToken, token;
3281
3350
  return _ts_generator$5(this, function(_state) {
3282
3351
  switch(_state.label){
3283
3352
  case 0:
@@ -3301,7 +3370,7 @@ function _ts_generator$5(thisArg, body) {
3301
3370
  }
3302
3371
  token = {
3303
3372
  // Standard JWT claims — sourced from the access token
3304
- aud: (_firstValue = util.firstValue(accessToken.aud)) !== null && _firstValue !== void 0 ? _firstValue : accessToken.clientId,
3373
+ aud: util.firstValue(accessToken.aud),
3305
3374
  iss: this.config.issuer,
3306
3375
  sub: accessToken.accountId,
3307
3376
  iat: accessToken.iat,
@@ -3355,6 +3424,7 @@ function _ts_generator$5(thisArg, body) {
3355
3424
  ];
3356
3425
  case 1:
3357
3426
  provider = _state.sent();
3427
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
3358
3428
  ProviderClient = provider.Client;
3359
3429
  return [
3360
3430
  4,
@@ -3391,6 +3461,9 @@ function _ts_generator$5(thisArg, body) {
3391
3461
  *
3392
3462
  * Does NOT include `adapter`, `findAccount`, or `jwks` — those require async
3393
3463
  * setup and are handled by {@link OidcService}.
3464
+ *
3465
+ * @param cookieKeys - the signing keys for oidc-provider session cookies
3466
+ * @returns the oidc-provider configuration options
3394
3467
  */ key: "buildProviderConfiguration",
3395
3468
  value: function buildProviderConfiguration(cookieKeys) {
3396
3469
  var _this = this;
@@ -3429,7 +3502,7 @@ function _ts_generator$5(thisArg, body) {
3429
3502
  interactions: {
3430
3503
  url: function url(_ctx, interaction) {
3431
3504
  return _async_to_generator$5(function() {
3432
- var baseUrl, client_id, paramsToEncode, client, scopes, interactionLoginDetails, paramsString, redirectUrl;
3505
+ var baseUrl, client_id, paramsToEncode, client, scopes, interactionLoginDetails, paramsString;
3433
3506
  return _ts_generator$5(this, function(_state) {
3434
3507
  switch(_state.label){
3435
3508
  case 0:
@@ -3471,10 +3544,9 @@ function _ts_generator$5(thisArg, body) {
3471
3544
  paramsString = fetch.makeUrlSearchParamsString(paramsToEncode, {
3472
3545
  useUrlSearchSpaceHandling: true
3473
3546
  });
3474
- redirectUrl = "".concat(baseUrl, "?").concat(paramsString);
3475
3547
  return [
3476
3548
  2,
3477
- redirectUrl
3549
+ "".concat(baseUrl, "?").concat(paramsString)
3478
3550
  ];
3479
3551
  }
3480
3552
  });
@@ -3538,7 +3610,9 @@ function _ts_generator$5(thisArg, body) {
3538
3610
  _ref = _state.sent(), ProviderClass = _ref.default;
3539
3611
  provider = new ProviderClass(config.issuer, _object_spread_props(_object_spread$2({}, providerConfiguration), {
3540
3612
  adapter: adapterFactory,
3613
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider findAccount signature is more specific than our wrapper
3541
3614
  findAccount: findAccount,
3615
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider expects JOSE JWK type which differs from Node.js JsonWebKey
3542
3616
  jwks: {
3543
3617
  keys: [
3544
3618
  signingKey
@@ -3762,7 +3836,7 @@ function _ts_generator$4(thisArg, body) {
3762
3836
  switch(_state.label){
3763
3837
  case 0:
3764
3838
  authHeader = req.headers.authorization;
3765
- if (!authHeader || !authHeader.startsWith('Bearer ')) {
3839
+ if (!(authHeader === null || authHeader === void 0 ? void 0 : authHeader.startsWith('Bearer '))) {
3766
3840
  throw new common.UnauthorizedException('Missing or invalid Authorization header');
3767
3841
  }
3768
3842
  token = authHeader.slice(7);
@@ -4136,6 +4210,10 @@ function _ts_generator$3(thisArg, body) {
4136
4210
  * Loads the interaction details for a given request/response pair.
4137
4211
  *
4138
4212
  * Requires the oidc-provider interaction cookie to be present on the request.
4213
+ *
4214
+ * @param req - the Express request containing the interaction cookie
4215
+ * @param res - the Express response
4216
+ * @returns the oidc-provider interaction details
4139
4217
  */ function getInteractionDetails(req, res) {
4140
4218
  return _async_to_generator$3(function() {
4141
4219
  var provider;
@@ -4166,6 +4244,8 @@ function _ts_generator$3(thisArg, body) {
4166
4244
  * This is necessary when the interaction cookie is scoped to a different path
4167
4245
  * (e.g., the frontend) and is not sent with backend API requests.
4168
4246
  *
4247
+ * @param uid - the interaction UID to look up
4248
+ * @returns the interaction details for the given UID
4169
4249
  * @throws {Error} When the interaction is not found or has expired.
4170
4250
  */ function findInteractionByUid(uid) {
4171
4251
  return _async_to_generator$3(function() {
@@ -4205,6 +4285,10 @@ function _ts_generator$3(thisArg, body) {
4205
4285
  * Looks up the interaction directly by UID, applies the result, saves it,
4206
4286
  * and returns the `returnTo` URL for the client to redirect to.
4207
4287
  *
4288
+ * @param uid - the interaction UID to complete
4289
+ * @param result - the interaction results to apply
4290
+ * @param options - optional settings for merging with the last submission
4291
+ * @param options.mergeWithLastSubmission - whether to merge with the last submission (defaults to true)
4208
4292
  * @returns The `returnTo` URL that the client should redirect to.
4209
4293
  */ function finishInteractionByUid(uid, result, options) {
4210
4294
  return _async_to_generator$3(function() {
@@ -4243,9 +4327,14 @@ function _ts_generator$3(thisArg, body) {
4243
4327
  key: "findOrCreateGrant",
4244
4328
  value: /**
4245
4329
  * Finds an existing grant by ID, or creates a new one.
4330
+ *
4331
+ * @param grantId - the existing grant ID to look up, or undefined to create a new grant
4332
+ * @param accountId - the account ID for creating a new grant
4333
+ * @param clientId - the client ID for creating a new grant
4334
+ * @returns the found or newly created grant
4246
4335
  */ function findOrCreateGrant(grantId, accountId, clientId) {
4247
4336
  return _async_to_generator$3(function() {
4248
- var provider, grant;
4337
+ var provider, grant, found;
4249
4338
  return _ts_generator$3(this, function(_state) {
4250
4339
  switch(_state.label){
4251
4340
  case 0:
@@ -4264,7 +4353,11 @@ function _ts_generator$3(thisArg, body) {
4264
4353
  provider.Grant.find(grantId)
4265
4354
  ];
4266
4355
  case 2:
4267
- grant = _state.sent();
4356
+ found = _state.sent();
4357
+ if (!found) {
4358
+ throw new Error("Grant not found for grantId: ".concat(grantId));
4359
+ }
4360
+ grant = found;
4268
4361
  return [
4269
4362
  3,
4270
4363
  4
@@ -4527,6 +4620,10 @@ function _ts_generator$2(thisArg, body) {
4527
4620
  *
4528
4621
  * Detects the interaction type and redirects to the appropriate frontend page.
4529
4622
  *
4623
+ * @param uid - the interaction UID from the URL path
4624
+ * @param req - the incoming Express request
4625
+ * @param res - the Express response used for redirecting
4626
+ * @returns a redirect response to the appropriate frontend page
4530
4627
  * @throws {HttpException} 404 when the interaction UID is not found or has expired.
4531
4628
  */ function getInteraction(uid, req, res) {
4532
4629
  return _async_to_generator$2(function() {
@@ -4577,6 +4674,9 @@ function _ts_generator$2(thisArg, body) {
4577
4674
  * Verifies the Firebase Auth ID token sent by the frontend, extracts the
4578
4675
  * user's UID, and completes the oidc-provider login interaction.
4579
4676
  *
4677
+ * @param uid - the interaction UID from the URL path
4678
+ * @param body - the login request containing the Firebase ID token
4679
+ * @param res - the Express response used for sending JSON
4580
4680
  * @throws {HttpException} 401 when the Firebase ID token is invalid.
4581
4681
  * @throws {HttpException} 400 when the login interaction cannot be completed.
4582
4682
  */ function postLogin(uid, body, res) {
@@ -4638,10 +4738,13 @@ function _ts_generator$2(thisArg, body) {
4638
4738
  * Receives consent decision from frontend. Grants missing OIDC scopes and claims
4639
4739
  * when approved, or returns `access_denied` when rejected.
4640
4740
  *
4741
+ * @param uid - the interaction UID from the URL path
4742
+ * @param body - the consent request containing approval decision and Firebase ID token
4743
+ * @param res - the Express response used for sending JSON
4641
4744
  * @throws {HttpException} 400 when the consent interaction cannot be completed.
4642
4745
  */ function postConsent(uid, body, res) {
4643
4746
  return _async_to_generator$2(function() {
4644
- var _ref, _prompt_details, _prompt_details1, _prompt_details2, redirectTo, interaction, prompt, params, session, grant, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, indicator, scopes, grantId, redirectTo1;
4747
+ var _ref, redirectTo, interaction, prompt, params, session, grant, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, indicator, scopes, grantId, redirectTo1;
4645
4748
  return _ts_generator$2(this, function(_state) {
4646
4749
  switch(_state.label){
4647
4750
  case 0:
@@ -4694,13 +4797,13 @@ function _ts_generator$2(thisArg, body) {
4694
4797
  ];
4695
4798
  case 6:
4696
4799
  grant = _state.sent();
4697
- if ((_prompt_details = prompt.details) === null || _prompt_details === void 0 ? void 0 : _prompt_details.missingOIDCScope) {
4800
+ if (prompt.details.missingOIDCScope) {
4698
4801
  grant.addOIDCScope(prompt.details.missingOIDCScope.join(' '));
4699
4802
  }
4700
- if ((_prompt_details1 = prompt.details) === null || _prompt_details1 === void 0 ? void 0 : _prompt_details1.missingOIDCClaims) {
4803
+ if (prompt.details.missingOIDCClaims) {
4701
4804
  grant.addOIDCClaims(prompt.details.missingOIDCClaims);
4702
4805
  }
4703
- if ((_prompt_details2 = prompt.details) === null || _prompt_details2 === void 0 ? void 0 : _prompt_details2.missingResourceScopes) {
4806
+ if (prompt.details.missingResourceScopes) {
4704
4807
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4705
4808
  try {
4706
4809
  for(_iterator = Object.entries(prompt.details.missingResourceScopes)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
@@ -4765,6 +4868,8 @@ function _ts_generator$2(thisArg, body) {
4765
4868
  /**
4766
4869
  * Verifies a Firebase Auth ID token and returns the user's UID.
4767
4870
  *
4871
+ * @param idToken - the Firebase Auth ID token to verify
4872
+ * @returns the user's UID extracted from the decoded token
4768
4873
  * @throws {HttpException} 401 when the token is invalid or expired.
4769
4874
  */ function _verifyIdToken(idToken) {
4770
4875
  return _async_to_generator$2(function() {
@@ -5228,6 +5333,8 @@ function _ts_generator(thisArg, body) {
5228
5333
  *
5229
5334
  * Returns the provider metadata so clients can auto-discover endpoints,
5230
5335
  * supported scopes, signing algorithms, etc.
5336
+ *
5337
+ * @returns the OIDC discovery metadata document
5231
5338
  */ function getOpenIdConfiguration() {
5232
5339
  return _async_to_generator(function() {
5233
5340
  var _ref, jwksUri;
@@ -5255,6 +5362,8 @@ function _ts_generator(thisArg, body) {
5255
5362
  * JWKS endpoint. Returns the public JSON Web Key Set for token verification.
5256
5363
  *
5257
5364
  * This endpoint is typically skipped if the JwksServiceStorageConfig is provided.
5365
+ *
5366
+ * @returns the public JWKS containing all non-retired signing keys
5258
5367
  */ function getJwks() {
5259
5368
  return _async_to_generator(function() {
5260
5369
  return _ts_generator(this, function(_state) {
@@ -5272,6 +5381,8 @@ function _ts_generator(thisArg, body) {
5272
5381
  *
5273
5382
  * Returns the authorization server(s) that protect this resource,
5274
5383
  * allowing clients to discover which authorization server to use.
5384
+ *
5385
+ * @returns the protected resource metadata with authorization server URLs
5275
5386
  */ key: "getProtectedResource",
5276
5387
  value: function getProtectedResource() {
5277
5388
  return {
@@ -5414,6 +5525,9 @@ function _unsupported_iterable_to_array(o, minLen) {
5414
5525
  * Reads the JWKS encryption secret from `OIDC_JWKS_ENCRYPTION_SECRET`; in test environments,
5415
5526
  * a deterministic fallback is used.
5416
5527
  *
5528
+ * @param configService - the NestJS ConfigService for reading environment variables
5529
+ * @param envService - the Firebase server environment service for app URL and env detection
5530
+ * @returns the constructed OidcModuleConfig
5417
5531
  * @throws {Error} When `appUrl` is missing, lacks an HTTP prefix, or the encryption secret is invalid.
5418
5532
  */ function oidcModuleConfigFactory(configService, envService) {
5419
5533
  var _configService_get;
@@ -5453,6 +5567,10 @@ function _unsupported_iterable_to_array(o, minLen) {
5453
5567
  /**
5454
5568
  * Factory that creates {@link OidcServerFirestoreCollections} using the provided Firestore context
5455
5569
  * and JWKS encryption config from {@link OidcModuleConfig}.
5570
+ *
5571
+ * @param firestoreContext - the Firestore context for collection creation
5572
+ * @param oidcModuleConfig - the OIDC module config containing JWKS encryption settings
5573
+ * @returns the configured OidcServerFirestoreCollections
5456
5574
  */ function oidcFirestoreCollectionsFactory(firestoreContext, oidcModuleConfig) {
5457
5575
  return {
5458
5576
  jwksKeyCollection: jwksKeyFirestoreCollection(_object_spread({
@@ -5473,13 +5591,13 @@ function _unsupported_iterable_to_array(o, minLen) {
5473
5591
  * Additionally, the following may be optionally provided:
5474
5592
  * - JwksServiceStorageConfig
5475
5593
  *
5476
- * @param metadataConfig
5477
- * @returns
5594
+ * @param metadataConfig - the configuration for generating the OIDC module metadata
5595
+ * @returns the NestJS module metadata for the OIDC module
5478
5596
  */ function oidcModuleMetadata(metadataConfig) {
5479
5597
  var dependencyModule = metadataConfig.dependencyModule, config$1 = metadataConfig.config, imports = metadataConfig.imports, exports$1 = metadataConfig.exports, providers = metadataConfig.providers;
5480
- var dependencyModuleImport = dependencyModule ? [
5598
+ var dependencyModuleImport = [
5481
5599
  dependencyModule
5482
- ] : [];
5600
+ ];
5483
5601
  return {
5484
5602
  imports: [
5485
5603
  config.ConfigModule,