@dereekb/firebase-server 13.4.1 → 13.5.0

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 (101) hide show
  1. package/index.cjs.js +405 -93
  2. package/index.esm.js +406 -94
  3. package/mailgun/package.json +9 -9
  4. package/model/index.cjs.js +639 -348
  5. package/model/index.esm.js +640 -349
  6. package/model/package.json +10 -10
  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 +141 -31
  30. package/oidc/index.esm.js +141 -31
  31. package/oidc/package.json +11 -11
  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 +13 -13
  48. package/src/lib/auth/auth.context.d.ts +1 -0
  49. package/src/lib/auth/auth.service.d.ts +13 -0
  50. package/src/lib/env/env.config.d.ts +2 -0
  51. package/src/lib/env/env.service.d.ts +21 -7
  52. package/src/lib/firestore/array.d.ts +1 -0
  53. package/src/lib/firestore/driver.accessor.batch.d.ts +4 -0
  54. package/src/lib/firestore/driver.accessor.d.ts +4 -0
  55. package/src/lib/firestore/driver.accessor.default.d.ts +5 -1
  56. package/src/lib/firestore/driver.accessor.transaction.d.ts +4 -0
  57. package/src/lib/firestore/driver.d.ts +2 -0
  58. package/src/lib/firestore/driver.query.d.ts +4 -0
  59. package/src/lib/firestore/increment.d.ts +1 -0
  60. package/src/lib/function/assert.d.ts +7 -0
  61. package/src/lib/function/context.d.ts +4 -0
  62. package/src/lib/function/error.auth.d.ts +2 -0
  63. package/src/lib/function/error.d.ts +86 -11
  64. package/src/lib/index.d.ts +0 -1
  65. package/src/lib/nest/analytics/analytics.service.listener.d.ts +2 -0
  66. package/src/lib/nest/app.d.ts +6 -3
  67. package/src/lib/nest/auth/auth.module.d.ts +6 -0
  68. package/src/lib/nest/auth/auth.util.d.ts +19 -1
  69. package/src/lib/nest/development/development.app.function.d.ts +12 -4
  70. package/src/lib/nest/development/development.assert.function.d.ts +6 -2
  71. package/src/lib/nest/development/development.function.d.ts +6 -1
  72. package/src/lib/nest/development/development.schedule.function.d.ts +3 -1
  73. package/src/lib/nest/development/development.schedule.function.error.d.ts +8 -0
  74. package/src/lib/nest/env/env.service.d.ts +2 -0
  75. package/src/lib/nest/env/env.util.d.ts +6 -0
  76. package/src/lib/nest/firebase/firebase.module.d.ts +1 -0
  77. package/src/lib/nest/firestore/firestore.module.d.ts +8 -0
  78. package/src/lib/nest/function/context.d.ts +2 -0
  79. package/src/lib/nest/model/analytics.details.d.ts +21 -7
  80. package/src/lib/nest/model/analytics.emit.d.ts +3 -0
  81. package/src/lib/nest/model/analytics.handler.d.ts +30 -10
  82. package/src/lib/nest/model/api.details.d.ts +34 -1
  83. package/src/lib/nest/model/call.model.function.d.ts +20 -4
  84. package/src/lib/nest/model/create.model.function.d.ts +6 -1
  85. package/src/lib/nest/model/crud.assert.function.d.ts +12 -4
  86. package/src/lib/nest/model/delete.model.function.d.ts +6 -1
  87. package/src/lib/nest/model/permission.error.d.ts +7 -0
  88. package/src/lib/nest/model/read.model.function.d.ts +6 -1
  89. package/src/lib/nest/model/specifier.function.d.ts +3 -0
  90. package/src/lib/nest/model/update.model.function.d.ts +6 -1
  91. package/src/lib/nest/nest.provider.d.ts +10 -0
  92. package/src/lib/nest/storage/storage.module.d.ts +9 -0
  93. package/src/lib/storage/driver.accessor.d.ts +22 -0
  94. package/src/lib/storage/driver.d.ts +2 -0
  95. package/src/lib/storage/storage.d.ts +1 -0
  96. package/test/package.json +11 -11
  97. package/zoho/index.cjs.js +8 -6
  98. package/zoho/index.esm.js +8 -6
  99. package/zoho/package.json +9 -9
  100. package/zoho/src/lib/zoho.accounts.firebase.d.ts +2 -1
  101. package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +2 -1
package/oidc/index.esm.js CHANGED
@@ -175,6 +175,7 @@ function _define_property$f(obj, key, value) {
175
175
  *
176
176
  * Called by {@link oidcModuleConfigFactory} after building the config from environment variables.
177
177
  *
178
+ * @param config - the config object to validate
178
179
  * @throws {Error} When any required field (`issuer`, `appInteractionPath`, `appLoginUrlPart`, `appConsentUrlPart`, `jwksServiceConfig`, `jwksKeyConverterConfig`) is missing.
179
180
  */ function assertValidConfig(config) {
180
181
  if (!config.issuer) {
@@ -204,6 +205,9 @@ function _define_property$f(obj, key, value) {
204
205
 
205
206
  /**
206
207
  * Query for JwksKey documents with a specific status.
208
+ *
209
+ * @param status - the lifecycle status to filter by
210
+ * @returns Firestore query constraints filtering by the given status
207
211
  */ function jwksKeysWithStatusQuery(status) {
208
212
  return [
209
213
  where('status', '==', status)
@@ -211,11 +215,15 @@ function _define_property$f(obj, key, value) {
211
215
  }
212
216
  /**
213
217
  * Query for active JwksKey documents.
218
+ *
219
+ * @returns Firestore query constraints filtering for active keys
214
220
  */ function activeJwksKeysQuery() {
215
221
  return jwksKeysWithStatusQuery('active');
216
222
  }
217
223
  /**
218
224
  * Query for non-retired JwksKey documents (active + rotated).
225
+ *
226
+ * @returns Firestore query constraints filtering for non-retired keys
219
227
  */ function nonRetiredJwksKeysQuery() {
220
228
  return [
221
229
  where('status', 'in', [
@@ -226,6 +234,8 @@ function _define_property$f(obj, key, value) {
226
234
  }
227
235
  /**
228
236
  * Query for rotated JwksKey documents.
237
+ *
238
+ * @returns Firestore query constraints filtering for rotated keys
229
239
  */ function rotatedJwksKeysQuery() {
230
240
  return jwksKeysWithStatusQuery('rotated');
231
241
  }
@@ -537,13 +547,15 @@ var JwksService = /*#__PURE__*/ function() {
537
547
  *
538
548
  * Returns both the stored {@link JwksKey} and the unencrypted private JWK
539
549
  * so callers can use the signing key immediately without a decryption round-trip.
550
+ *
551
+ * @returns the generated key pair result containing the stored JwksKey and signing key
540
552
  */ function generateKeyPair() {
541
553
  return _async_to_generator$a(function() {
542
554
  var _generateKeyPairSync, publicKey, privateKey, kid, publicJwk, privateJwk, getKey, encryptedPrivateKey, data, doc;
543
555
  return _ts_generator$a(this, function(_state) {
544
556
  switch(_state.label){
545
557
  case 0:
546
- _generateKeyPairSync = generateKeyPairSync('rsa', {
558
+ /* eslint-disable @typescript-eslint/no-explicit-any -- Node.js crypto types do not include JWK format overloads */ _generateKeyPairSync = generateKeyPairSync('rsa', {
547
559
  modulusLength: 2048,
548
560
  publicKeyEncoding: {
549
561
  type: 'spki',
@@ -554,7 +566,7 @@ var JwksService = /*#__PURE__*/ function() {
554
566
  format: 'jwk'
555
567
  }
556
568
  }), publicKey = _generateKeyPairSync.publicKey, privateKey = _generateKeyPairSync.privateKey;
557
- kid = randomBytes(16).toString('hex');
569
+ /* eslint-enable @typescript-eslint/no-explicit-any */ kid = randomBytes(16).toString('hex');
558
570
  publicJwk = _object_spread_props$3(_object_spread$6({}, publicKey), {
559
571
  kid: kid,
560
572
  kty: 'RSA',
@@ -598,6 +610,8 @@ var JwksService = /*#__PURE__*/ function() {
598
610
  key: "getActiveSigningKey",
599
611
  value: /**
600
612
  * Returns the currently active signing key's private JWK.
613
+ *
614
+ * @returns the active signing key's private JWK, or undefined if no active key exists
601
615
  */ function getActiveSigningKey() {
602
616
  return _async_to_generator$a(function() {
603
617
  var results, result, data, getKey;
@@ -634,6 +648,8 @@ var JwksService = /*#__PURE__*/ function() {
634
648
  *
635
649
  * Returns undefined if storage is not configured or `serveJwksFromStorage` is false.
636
650
  * Returns null if an error occured while trying to setup.
651
+ *
652
+ * @returns the public URL, or null/undefined if unavailable
637
653
  */ function getJwksStoragePublicUrl() {
638
654
  return _async_to_generator$a(function() {
639
655
  return _ts_generator$a(this, function(_state) {
@@ -649,6 +665,8 @@ var JwksService = /*#__PURE__*/ function() {
649
665
  key: "getLatestPublicJwks",
650
666
  value: /**
651
667
  * Returns the public JWKS (all non-retired keys) by querying Firestore.
668
+ *
669
+ * @returns the public JWKS containing all non-retired signing keys
652
670
  */ function getLatestPublicJwks() {
653
671
  return _async_to_generator$a(function() {
654
672
  var keys;
@@ -693,6 +711,8 @@ var JwksService = /*#__PURE__*/ function() {
693
711
  key: "rotateKeys",
694
712
  value: /**
695
713
  * Rotates keys: marks the current active key as rotated and generates a new active key.
714
+ *
715
+ * @returns the newly generated active JwksKey
696
716
  */ function rotateKeys() {
697
717
  return _async_to_generator$a(function() {
698
718
  var now, expiresAt, _ref, newKey;
@@ -871,6 +891,8 @@ var JwksService = /*#__PURE__*/ function() {
871
891
  key: "retireExpiredKeys",
872
892
  value: /**
873
893
  * Retires rotated keys whose expiresAt has passed.
894
+ *
895
+ * @returns the number of keys retired
874
896
  */ function retireExpiredKeys() {
875
897
  return _async_to_generator$a(function() {
876
898
  var now, count;
@@ -1179,6 +1201,8 @@ function _ts_generator$9(thisArg, body) {
1179
1201
  *
1180
1202
  * Returns an {@link OidcAccount} compatible with oidc-provider's `findAccount` interface,
1181
1203
  * or `undefined` if the user does not exist in Firebase Auth.
1204
+ *
1205
+ * @returns the OIDC account for this user, or undefined if the user does not exist
1182
1206
  */ function findAccount() {
1183
1207
  return _async_to_generator$9(function() {
1184
1208
  var authUserContext, exists, delegate;
@@ -1246,6 +1270,8 @@ function _ts_generator$9(thisArg, body) {
1246
1270
  key: "providerConfig",
1247
1271
  get: /**
1248
1272
  * The provider config from the delegate.
1273
+ *
1274
+ * @returns the OIDC provider configuration from the delegate
1249
1275
  */ function get() {
1250
1276
  return this.delegate.providerConfig;
1251
1277
  }
@@ -1253,6 +1279,9 @@ function _ts_generator$9(thisArg, body) {
1253
1279
  {
1254
1280
  /**
1255
1281
  * Creates a user context for the given user ID.
1282
+ *
1283
+ * @param uid - the Firebase Auth user ID
1284
+ * @returns a new user context bound to the given user
1256
1285
  */ key: "userContext",
1257
1286
  value: function userContext(uid) {
1258
1287
  return new OidcAccountServiceUserContext(this, uid);
@@ -1371,6 +1400,9 @@ function _is_native_reflect_construct() {
1371
1400
  * Creates a snapshot converter for {@link JwksKey} documents.
1372
1401
  *
1373
1402
  * Requires runtime encryption config since the private key field is encrypted at rest.
1403
+ *
1404
+ * @param config - encryption configuration for the private key field
1405
+ * @returns snapshot converter functions for JwksKey documents
1374
1406
  */ function jwksKeyConverter(config) {
1375
1407
  return snapshotConverterFunctions({
1376
1408
  fields: {
@@ -1393,11 +1425,17 @@ function _is_native_reflect_construct() {
1393
1425
  // MARK: Collection
1394
1426
  /**
1395
1427
  * Returns the Firestore {@link CollectionReference} for {@link JwksKey} documents.
1428
+ *
1429
+ * @param context - the Firestore context to create the collection reference from
1430
+ * @returns the typed collection reference for JwksKey documents
1396
1431
  */ function jwksKeyCollectionReference(context) {
1397
1432
  return context.collection(jwksKeyIdentity.collectionName);
1398
1433
  }
1399
1434
  /**
1400
1435
  * Creates a {@link JwksKeyFirestoreCollection} with encrypted private key field support.
1436
+ *
1437
+ * @param config - configuration including the Firestore context and encryption settings
1438
+ * @returns the configured JwksKey Firestore collection
1401
1439
  */ function jwksKeyFirestoreCollection(config) {
1402
1440
  var firestoreContext = config.firestoreContext;
1403
1441
  return firestoreContext.firestoreCollection({
@@ -1556,6 +1594,7 @@ function _ts_generator$8(thisArg, body) {
1556
1594
  * Creates a concrete {@link OidcModelServerActions} implementation wired to the provided context.
1557
1595
  *
1558
1596
  * @param context - the fully assembled OIDC model server actions context
1597
+ * @returns the concrete OidcModelServerActions instance
1559
1598
  *
1560
1599
  * @example
1561
1600
  * ```ts
@@ -1577,6 +1616,9 @@ function _ts_generator$8(thisArg, body) {
1577
1616
  *
1578
1617
  * Delegates to {@link OidcClientService.createClient} to generate a `client_id` and `client_secret`,
1579
1618
  * create the adapter entry, and return the secret in plaintext (only returned once).
1619
+ *
1620
+ * @param context - the OIDC model server actions context
1621
+ * @returns a transform function factory for creating OIDC clients
1580
1622
  */ function createOidcClientFactory(context) {
1581
1623
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1582
1624
  return firebaseServerActionTransformFunctionFactory(createOidcClientParamsType, function(params) {
@@ -1603,6 +1645,9 @@ function _ts_generator$8(thisArg, body) {
1603
1645
  * Factory for the `updateOidcClient` action.
1604
1646
  *
1605
1647
  * Delegates to {@link OidcClientService.updateClient} to apply plaintext field updates.
1648
+ *
1649
+ * @param context - the OIDC model server actions context
1650
+ * @returns a transform function factory for updating OIDC clients
1606
1651
  */ function updateOidcClientFactory(context) {
1607
1652
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1608
1653
  return firebaseServerActionTransformFunctionFactory(updateOidcClientParamsType, function(params) {
@@ -1639,6 +1684,9 @@ function _ts_generator$8(thisArg, body) {
1639
1684
  *
1640
1685
  * Delegates to {@link OidcClientService.rotateClientSecret} to generate a new secret
1641
1686
  * and return it in plaintext (only returned once).
1687
+ *
1688
+ * @param context - the OIDC model server actions context
1689
+ * @returns a transform function factory for rotating OIDC client secrets
1642
1690
  */ function rotateOidcClientSecretFactory(context) {
1643
1691
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1644
1692
  return firebaseServerActionTransformFunctionFactory(rotateOidcClientSecretParamsType, function(_params) {
@@ -1665,9 +1713,12 @@ function _ts_generator$8(thisArg, body) {
1665
1713
  * Factory for the `deleteOidcClient` action.
1666
1714
  *
1667
1715
  * Delegates to {@link OidcClientService.deleteClient}.
1716
+ *
1717
+ * @param context - the OIDC model server actions context
1718
+ * @returns a transform function factory for deleting OIDC clients
1668
1719
  */ function deleteOidcClientFactory(context) {
1669
1720
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1670
- return firebaseServerActionTransformFunctionFactory(deleteOidcClientParamsType, function(params) {
1721
+ return firebaseServerActionTransformFunctionFactory(deleteOidcClientParamsType, function(_params) {
1671
1722
  return _async_to_generator$8(function() {
1672
1723
  return _ts_generator$8(this, function(_state) {
1673
1724
  return [
@@ -2011,7 +2062,7 @@ function _ts_generator$7(thisArg, body) {
2011
2062
  * @throws When the client is not found.
2012
2063
  */ function updateClient(clientId, params) {
2013
2064
  return _async_to_generator$7(function() {
2014
- var provider, ProviderClient, existing, updatedMetadata, client;
2065
+ var provider, ProviderClient, existing, updatedMetadata, _params_logo_uri, _params_client_uri, client;
2015
2066
  return _ts_generator$7(this, function(_state) {
2016
2067
  switch(_state.label){
2017
2068
  case 0:
@@ -2032,17 +2083,13 @@ function _ts_generator$7(thisArg, body) {
2032
2083
  throw new Error('Client not found.');
2033
2084
  }
2034
2085
  updatedMetadata = _object_spread$5({}, existing);
2035
- if (params.client_name !== undefined && params.client_name !== null) {
2036
- updatedMetadata.client_name = params.client_name;
2037
- }
2038
- if (params.redirect_uris !== undefined && params.redirect_uris !== null) {
2039
- updatedMetadata.redirect_uris = params.redirect_uris;
2040
- }
2086
+ updatedMetadata.client_name = params.client_name;
2087
+ updatedMetadata.redirect_uris = params.redirect_uris;
2041
2088
  if (params.logo_uri !== undefined) {
2042
- updatedMetadata.logo_uri = params.logo_uri || undefined;
2089
+ updatedMetadata.logo_uri = (_params_logo_uri = params.logo_uri) !== null && _params_logo_uri !== void 0 ? _params_logo_uri : undefined;
2043
2090
  }
2044
2091
  if (params.client_uri !== undefined) {
2045
- updatedMetadata.client_uri = params.client_uri || undefined;
2092
+ updatedMetadata.client_uri = (_params_client_uri = params.client_uri) !== null && _params_client_uri !== void 0 ? _params_client_uri : undefined;
2046
2093
  }
2047
2094
  // Mirrors oidc-provider's lib/helpers/add_client.js: re-validates and persists.
2048
2095
  return [
@@ -2227,6 +2274,9 @@ function _object_spread_props$1(target, source) {
2227
2274
  // MARK: Provider Factories
2228
2275
  /**
2229
2276
  * Factory that creates an {@link OidcModelServerActions} instance from the injected {@link OidcClientService}.
2277
+ *
2278
+ * @param oidcClientService - the OIDC client service to wire into the server actions
2279
+ * @returns the configured OidcModelServerActions instance
2230
2280
  */ function oidcModelServerActionsFactory(oidcClientService) {
2231
2281
  var context = _object_spread_props$1(_object_spread$4({}, firebaseServerActionsContext()), {
2232
2282
  oidcClientService: oidcClientService
@@ -2239,7 +2289,8 @@ function _object_spread_props$1(target, source) {
2239
2289
  * By default this module exports:
2240
2290
  * - OidcModelServerActions
2241
2291
  *
2242
- * @param config
2292
+ * @param config - the configuration specifying the OIDC module dependency
2293
+ * @returns the NestJS module metadata for the OidcModel module
2243
2294
  */ function appOidcModelModuleMetadata(config) {
2244
2295
  var oidcModule = config.oidcModule;
2245
2296
  return {
@@ -2467,6 +2518,7 @@ function _ts_generator$6(thisArg, body) {
2467
2518
  *
2468
2519
  * @param collections - Firestore collection access for adapter entries.
2469
2520
  * @param encryptionService - Encryption service for sensitive payload fields.
2521
+ * @returns an oidc-provider adapter constructor backed by Firestore
2470
2522
  */ function createAdapterFactory(collections, encryptionService) {
2471
2523
  var FirestoreAdapter = /*#__PURE__*/ function() {
2472
2524
  function FirestoreAdapter(name) {
@@ -2534,7 +2586,7 @@ function _ts_generator$6(thisArg, body) {
2534
2586
  data = snapshot.data();
2535
2587
  return [
2536
2588
  2,
2537
- data && data.type === this.name ? this._toPayload(data) : undefined
2589
+ (data === null || data === void 0 ? void 0 : data.type) === this.name ? this._toPayload(data) : undefined
2538
2590
  ];
2539
2591
  }
2540
2592
  });
@@ -2700,6 +2752,9 @@ function _ts_generator$6(thisArg, body) {
2700
2752
  /**
2701
2753
  * Converts a Firestore document into an oidc-provider payload,
2702
2754
  * returning `undefined` if the entry has expired.
2755
+ *
2756
+ * @param data - the Firestore document data to convert
2757
+ * @returns the decrypted adapter payload, or undefined if the entry has expired
2703
2758
  */ key: "_toPayload",
2704
2759
  value: function _toPayload(data) {
2705
2760
  var expiresDate = data.expiresAt ? _instanceof$1(data.expiresAt, Date) ? data.expiresAt : data.expiresAt.toDate() : undefined;
@@ -2803,6 +2858,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2803
2858
  /**
2804
2859
  * Encrypts sensitive fields in an adapter payload and returns it as a {@link JsonSerializableObject}
2805
2860
  * suitable for storing directly in Firestore.
2861
+ *
2862
+ * @param payload - the adapter payload to encrypt
2863
+ * @returns the encrypted payload as a JSON-serializable object
2806
2864
  */ key: "encryptAdapterPayload",
2807
2865
  value: function encryptAdapterPayload(payload) {
2808
2866
  var filtered = filterUndefinedValues(payload);
@@ -2812,6 +2870,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2812
2870
  {
2813
2871
  /**
2814
2872
  * Decrypts sensitive fields in a Firestore-stored payload object back to an {@link AdapterPayload}.
2873
+ *
2874
+ * @param payload - the encrypted Firestore-stored payload
2875
+ * @returns the decrypted adapter payload
2815
2876
  */ key: "decryptAdapterPayload",
2816
2877
  value: function decryptAdapterPayload(payload) {
2817
2878
  return this.adapterPayloadEncryptor.decrypt(payload);
@@ -2975,6 +3036,7 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
2975
3036
  *
2976
3037
  * @param jwksUri - Optional override for the JWKS URI (e.g., from cloud storage).
2977
3038
  * Falls back to `{issuer}{routes.jwks}`.
3039
+ * @returns the fully constructed OIDC discovery metadata
2978
3040
  */ key: "buildDiscoveryMetadata",
2979
3041
  value: function buildDiscoveryMetadata(jwksUri) {
2980
3042
  var issuer = this.config.issuer;
@@ -3257,6 +3319,8 @@ function _ts_generator$5(thisArg, body) {
3257
3319
  {
3258
3320
  /**
3259
3321
  * Returns the oidc-provider instance, initializing it on first access.
3322
+ *
3323
+ * @returns the lazily-initialized oidc-provider instance
3260
3324
  */ key: "getProvider",
3261
3325
  value: function getProvider() {
3262
3326
  return this._getProvider();
@@ -3271,11 +3335,11 @@ function _ts_generator$5(thisArg, body) {
3271
3335
  * Uses the provider's `AccessToken` model to look up the token and extract
3272
3336
  * the account ID, scope, and client ID.
3273
3337
  *
3274
- * @param token - The opaque access token string.
3338
+ * @param rawToken - The opaque access token string.
3275
3339
  * @returns The auth context, or `undefined` if the token is invalid or expired.
3276
3340
  */ function verifyAccessToken(rawToken) {
3277
3341
  return _async_to_generator$5(function() {
3278
- var _firstValue, _accessToken_exp, provider, accessToken, token;
3342
+ var _accessToken_exp, provider, accessToken, token;
3279
3343
  return _ts_generator$5(this, function(_state) {
3280
3344
  switch(_state.label){
3281
3345
  case 0:
@@ -3299,7 +3363,7 @@ function _ts_generator$5(thisArg, body) {
3299
3363
  }
3300
3364
  token = {
3301
3365
  // Standard JWT claims — sourced from the access token
3302
- aud: (_firstValue = firstValue(accessToken.aud)) !== null && _firstValue !== void 0 ? _firstValue : accessToken.clientId,
3366
+ aud: firstValue(accessToken.aud),
3303
3367
  iss: this.config.issuer,
3304
3368
  sub: accessToken.accountId,
3305
3369
  iat: accessToken.iat,
@@ -3389,6 +3453,9 @@ function _ts_generator$5(thisArg, body) {
3389
3453
  *
3390
3454
  * Does NOT include `adapter`, `findAccount`, or `jwks` — those require async
3391
3455
  * setup and are handled by {@link OidcService}.
3456
+ *
3457
+ * @param cookieKeys - the signing keys for oidc-provider session cookies
3458
+ * @returns the oidc-provider configuration options
3392
3459
  */ key: "buildProviderConfiguration",
3393
3460
  value: function buildProviderConfiguration(cookieKeys) {
3394
3461
  var _this = this;
@@ -3427,7 +3494,7 @@ function _ts_generator$5(thisArg, body) {
3427
3494
  interactions: {
3428
3495
  url: function url(_ctx, interaction) {
3429
3496
  return _async_to_generator$5(function() {
3430
- var baseUrl, client_id, paramsToEncode, client, scopes, interactionLoginDetails, paramsString, redirectUrl;
3497
+ var baseUrl, client_id, paramsToEncode, client, scopes, interactionLoginDetails, paramsString;
3431
3498
  return _ts_generator$5(this, function(_state) {
3432
3499
  switch(_state.label){
3433
3500
  case 0:
@@ -3469,10 +3536,9 @@ function _ts_generator$5(thisArg, body) {
3469
3536
  paramsString = makeUrlSearchParamsString(paramsToEncode, {
3470
3537
  useUrlSearchSpaceHandling: true
3471
3538
  });
3472
- redirectUrl = "".concat(baseUrl, "?").concat(paramsString);
3473
3539
  return [
3474
3540
  2,
3475
- redirectUrl
3541
+ "".concat(baseUrl, "?").concat(paramsString)
3476
3542
  ];
3477
3543
  }
3478
3544
  });
@@ -3760,7 +3826,7 @@ function _ts_generator$4(thisArg, body) {
3760
3826
  switch(_state.label){
3761
3827
  case 0:
3762
3828
  authHeader = req.headers.authorization;
3763
- if (!authHeader || !authHeader.startsWith('Bearer ')) {
3829
+ if (!(authHeader === null || authHeader === void 0 ? void 0 : authHeader.startsWith('Bearer '))) {
3764
3830
  throw new UnauthorizedException('Missing or invalid Authorization header');
3765
3831
  }
3766
3832
  token = authHeader.slice(7);
@@ -4134,6 +4200,10 @@ function _ts_generator$3(thisArg, body) {
4134
4200
  * Loads the interaction details for a given request/response pair.
4135
4201
  *
4136
4202
  * Requires the oidc-provider interaction cookie to be present on the request.
4203
+ *
4204
+ * @param req - the Express request containing the interaction cookie
4205
+ * @param res - the Express response
4206
+ * @returns the oidc-provider interaction details
4137
4207
  */ function getInteractionDetails(req, res) {
4138
4208
  return _async_to_generator$3(function() {
4139
4209
  var provider;
@@ -4164,6 +4234,8 @@ function _ts_generator$3(thisArg, body) {
4164
4234
  * This is necessary when the interaction cookie is scoped to a different path
4165
4235
  * (e.g., the frontend) and is not sent with backend API requests.
4166
4236
  *
4237
+ * @param uid - the interaction UID to look up
4238
+ * @returns the interaction details for the given UID
4167
4239
  * @throws {Error} When the interaction is not found or has expired.
4168
4240
  */ function findInteractionByUid(uid) {
4169
4241
  return _async_to_generator$3(function() {
@@ -4203,6 +4275,10 @@ function _ts_generator$3(thisArg, body) {
4203
4275
  * Looks up the interaction directly by UID, applies the result, saves it,
4204
4276
  * and returns the `returnTo` URL for the client to redirect to.
4205
4277
  *
4278
+ * @param uid - the interaction UID to complete
4279
+ * @param result - the interaction results to apply
4280
+ * @param options - optional settings for merging with the last submission
4281
+ * @param options.mergeWithLastSubmission - whether to merge with the last submission (defaults to true)
4206
4282
  * @returns The `returnTo` URL that the client should redirect to.
4207
4283
  */ function finishInteractionByUid(uid, result, options) {
4208
4284
  return _async_to_generator$3(function() {
@@ -4241,9 +4317,14 @@ function _ts_generator$3(thisArg, body) {
4241
4317
  key: "findOrCreateGrant",
4242
4318
  value: /**
4243
4319
  * Finds an existing grant by ID, or creates a new one.
4320
+ *
4321
+ * @param grantId - the existing grant ID to look up, or undefined to create a new grant
4322
+ * @param accountId - the account ID for creating a new grant
4323
+ * @param clientId - the client ID for creating a new grant
4324
+ * @returns the found or newly created grant
4244
4325
  */ function findOrCreateGrant(grantId, accountId, clientId) {
4245
4326
  return _async_to_generator$3(function() {
4246
- var provider, grant;
4327
+ var provider, grant, found;
4247
4328
  return _ts_generator$3(this, function(_state) {
4248
4329
  switch(_state.label){
4249
4330
  case 0:
@@ -4262,7 +4343,11 @@ function _ts_generator$3(thisArg, body) {
4262
4343
  provider.Grant.find(grantId)
4263
4344
  ];
4264
4345
  case 2:
4265
- grant = _state.sent();
4346
+ found = _state.sent();
4347
+ if (!found) {
4348
+ throw new Error("Grant not found for grantId: ".concat(grantId));
4349
+ }
4350
+ grant = found;
4266
4351
  return [
4267
4352
  3,
4268
4353
  4
@@ -4525,6 +4610,10 @@ function _ts_generator$2(thisArg, body) {
4525
4610
  *
4526
4611
  * Detects the interaction type and redirects to the appropriate frontend page.
4527
4612
  *
4613
+ * @param uid - the interaction UID from the URL path
4614
+ * @param req - the incoming Express request
4615
+ * @param res - the Express response used for redirecting
4616
+ * @returns a redirect response to the appropriate frontend page
4528
4617
  * @throws {HttpException} 404 when the interaction UID is not found or has expired.
4529
4618
  */ function getInteraction(uid, req, res) {
4530
4619
  return _async_to_generator$2(function() {
@@ -4575,6 +4664,9 @@ function _ts_generator$2(thisArg, body) {
4575
4664
  * Verifies the Firebase Auth ID token sent by the frontend, extracts the
4576
4665
  * user's UID, and completes the oidc-provider login interaction.
4577
4666
  *
4667
+ * @param uid - the interaction UID from the URL path
4668
+ * @param body - the login request containing the Firebase ID token
4669
+ * @param res - the Express response used for sending JSON
4578
4670
  * @throws {HttpException} 401 when the Firebase ID token is invalid.
4579
4671
  * @throws {HttpException} 400 when the login interaction cannot be completed.
4580
4672
  */ function postLogin(uid, body, res) {
@@ -4636,10 +4728,13 @@ function _ts_generator$2(thisArg, body) {
4636
4728
  * Receives consent decision from frontend. Grants missing OIDC scopes and claims
4637
4729
  * when approved, or returns `access_denied` when rejected.
4638
4730
  *
4731
+ * @param uid - the interaction UID from the URL path
4732
+ * @param body - the consent request containing approval decision and Firebase ID token
4733
+ * @param res - the Express response used for sending JSON
4639
4734
  * @throws {HttpException} 400 when the consent interaction cannot be completed.
4640
4735
  */ function postConsent(uid, body, res) {
4641
4736
  return _async_to_generator$2(function() {
4642
- 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;
4737
+ var _ref, redirectTo, interaction, prompt, params, session, grant, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, indicator, scopes, grantId, redirectTo1;
4643
4738
  return _ts_generator$2(this, function(_state) {
4644
4739
  switch(_state.label){
4645
4740
  case 0:
@@ -4692,13 +4787,13 @@ function _ts_generator$2(thisArg, body) {
4692
4787
  ];
4693
4788
  case 6:
4694
4789
  grant = _state.sent();
4695
- if ((_prompt_details = prompt.details) === null || _prompt_details === void 0 ? void 0 : _prompt_details.missingOIDCScope) {
4790
+ if (prompt.details.missingOIDCScope) {
4696
4791
  grant.addOIDCScope(prompt.details.missingOIDCScope.join(' '));
4697
4792
  }
4698
- if ((_prompt_details1 = prompt.details) === null || _prompt_details1 === void 0 ? void 0 : _prompt_details1.missingOIDCClaims) {
4793
+ if (prompt.details.missingOIDCClaims) {
4699
4794
  grant.addOIDCClaims(prompt.details.missingOIDCClaims);
4700
4795
  }
4701
- if ((_prompt_details2 = prompt.details) === null || _prompt_details2 === void 0 ? void 0 : _prompt_details2.missingResourceScopes) {
4796
+ if (prompt.details.missingResourceScopes) {
4702
4797
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4703
4798
  try {
4704
4799
  for(_iterator = Object.entries(prompt.details.missingResourceScopes)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
@@ -4763,6 +4858,8 @@ function _ts_generator$2(thisArg, body) {
4763
4858
  /**
4764
4859
  * Verifies a Firebase Auth ID token and returns the user's UID.
4765
4860
  *
4861
+ * @param idToken - the Firebase Auth ID token to verify
4862
+ * @returns the user's UID extracted from the decoded token
4766
4863
  * @throws {HttpException} 401 when the token is invalid or expired.
4767
4864
  */ function _verifyIdToken(idToken) {
4768
4865
  return _async_to_generator$2(function() {
@@ -5226,6 +5323,8 @@ function _ts_generator(thisArg, body) {
5226
5323
  *
5227
5324
  * Returns the provider metadata so clients can auto-discover endpoints,
5228
5325
  * supported scopes, signing algorithms, etc.
5326
+ *
5327
+ * @returns the OIDC discovery metadata document
5229
5328
  */ function getOpenIdConfiguration() {
5230
5329
  return _async_to_generator(function() {
5231
5330
  var _ref, jwksUri;
@@ -5253,6 +5352,8 @@ function _ts_generator(thisArg, body) {
5253
5352
  * JWKS endpoint. Returns the public JSON Web Key Set for token verification.
5254
5353
  *
5255
5354
  * This endpoint is typically skipped if the JwksServiceStorageConfig is provided.
5355
+ *
5356
+ * @returns the public JWKS containing all non-retired signing keys
5256
5357
  */ function getJwks() {
5257
5358
  return _async_to_generator(function() {
5258
5359
  return _ts_generator(this, function(_state) {
@@ -5270,6 +5371,8 @@ function _ts_generator(thisArg, body) {
5270
5371
  *
5271
5372
  * Returns the authorization server(s) that protect this resource,
5272
5373
  * allowing clients to discover which authorization server to use.
5374
+ *
5375
+ * @returns the protected resource metadata with authorization server URLs
5273
5376
  */ key: "getProtectedResource",
5274
5377
  value: function getProtectedResource() {
5275
5378
  return {
@@ -5412,6 +5515,9 @@ function _unsupported_iterable_to_array(o, minLen) {
5412
5515
  * Reads the JWKS encryption secret from `OIDC_JWKS_ENCRYPTION_SECRET`; in test environments,
5413
5516
  * a deterministic fallback is used.
5414
5517
  *
5518
+ * @param configService - the NestJS ConfigService for reading environment variables
5519
+ * @param envService - the Firebase server environment service for app URL and env detection
5520
+ * @returns the constructed OidcModuleConfig
5415
5521
  * @throws {Error} When `appUrl` is missing, lacks an HTTP prefix, or the encryption secret is invalid.
5416
5522
  */ function oidcModuleConfigFactory(configService, envService) {
5417
5523
  var _configService_get;
@@ -5451,6 +5557,10 @@ function _unsupported_iterable_to_array(o, minLen) {
5451
5557
  /**
5452
5558
  * Factory that creates {@link OidcServerFirestoreCollections} using the provided Firestore context
5453
5559
  * and JWKS encryption config from {@link OidcModuleConfig}.
5560
+ *
5561
+ * @param firestoreContext - the Firestore context for collection creation
5562
+ * @param oidcModuleConfig - the OIDC module config containing JWKS encryption settings
5563
+ * @returns the configured OidcServerFirestoreCollections
5454
5564
  */ function oidcFirestoreCollectionsFactory(firestoreContext, oidcModuleConfig) {
5455
5565
  return {
5456
5566
  jwksKeyCollection: jwksKeyFirestoreCollection(_object_spread({
@@ -5471,13 +5581,13 @@ function _unsupported_iterable_to_array(o, minLen) {
5471
5581
  * Additionally, the following may be optionally provided:
5472
5582
  * - JwksServiceStorageConfig
5473
5583
  *
5474
- * @param metadataConfig
5475
- * @returns
5584
+ * @param metadataConfig - the configuration for generating the OIDC module metadata
5585
+ * @returns the NestJS module metadata for the OIDC module
5476
5586
  */ function oidcModuleMetadata(metadataConfig) {
5477
5587
  var dependencyModule = metadataConfig.dependencyModule, config = metadataConfig.config, imports = metadataConfig.imports, exports$1 = metadataConfig.exports, providers = metadataConfig.providers;
5478
- var dependencyModuleImport = dependencyModule ? [
5588
+ var dependencyModuleImport = [
5479
5589
  dependencyModule
5480
- ] : [];
5590
+ ];
5481
5591
  return {
5482
5592
  imports: [
5483
5593
  ConfigModule,
package/oidc/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/oidc",
3
- "version": "13.4.1",
3
+ "version": "13.5.0",
4
4
  "peerDependencies": {
5
- "@dereekb/analytics": "13.4.1",
6
- "@dereekb/date": "13.4.1",
7
- "@dereekb/firebase": "13.4.1",
8
- "@dereekb/firebase-server": "13.4.1",
9
- "@dereekb/model": "13.4.1",
10
- "@dereekb/nestjs": "13.4.1",
11
- "@dereekb/rxjs": "13.4.1",
12
- "@dereekb/util": "13.4.1",
13
- "@dereekb/zoho": "13.4.1",
14
- "@nestjs/common": "^11.1.16",
5
+ "@dereekb/analytics": "13.5.0",
6
+ "@dereekb/date": "13.5.0",
7
+ "@dereekb/firebase": "13.5.0",
8
+ "@dereekb/firebase-server": "13.5.0",
9
+ "@dereekb/model": "13.5.0",
10
+ "@dereekb/nestjs": "13.5.0",
11
+ "@dereekb/rxjs": "13.5.0",
12
+ "@dereekb/util": "13.5.0",
13
+ "@dereekb/zoho": "13.5.0",
14
+ "@nestjs/common": "^11.1.17",
15
15
  "@nestjs/config": "^4.0.3",
16
16
  "express": "^5.0.0",
17
17
  "firebase-admin": "^13.0.0",
@@ -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[];