@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.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 [
@@ -1927,6 +1978,7 @@ function _ts_generator$7(thisArg, body) {
1927
1978
  ];
1928
1979
  case 1:
1929
1980
  provider = _state.sent();
1981
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
1930
1982
  ProviderClient = provider.Client;
1931
1983
  // Mirrors oidc-provider's default idFactory from lib/helpers/defaults.js
1932
1984
  clientId = nanoid();
@@ -1988,7 +2040,7 @@ function _ts_generator$7(thisArg, body) {
1988
2040
  {
1989
2041
  modelKeys: firestoreModelKey(oidcEntryIdentity, clientId),
1990
2042
  client_id: clientId,
1991
- client_secret: clientSecret
2043
+ client_secret: clientSecret !== null && clientSecret !== void 0 ? clientSecret : ''
1992
2044
  }
1993
2045
  ];
1994
2046
  }
@@ -2011,7 +2063,7 @@ function _ts_generator$7(thisArg, body) {
2011
2063
  * @throws When the client is not found.
2012
2064
  */ function updateClient(clientId, params) {
2013
2065
  return _async_to_generator$7(function() {
2014
- var provider, ProviderClient, existing, updatedMetadata, client;
2066
+ var provider, ProviderClient, existing, updatedMetadata, _params_logo_uri, _params_client_uri, client;
2015
2067
  return _ts_generator$7(this, function(_state) {
2016
2068
  switch(_state.label){
2017
2069
  case 0:
@@ -2021,6 +2073,7 @@ function _ts_generator$7(thisArg, body) {
2021
2073
  ];
2022
2074
  case 1:
2023
2075
  provider = _state.sent();
2076
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
2024
2077
  ProviderClient = provider.Client;
2025
2078
  return [
2026
2079
  4,
@@ -2032,17 +2085,13 @@ function _ts_generator$7(thisArg, body) {
2032
2085
  throw new Error('Client not found.');
2033
2086
  }
2034
2087
  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
- }
2088
+ updatedMetadata.client_name = params.client_name;
2089
+ updatedMetadata.redirect_uris = params.redirect_uris;
2041
2090
  if (params.logo_uri !== undefined) {
2042
- updatedMetadata.logo_uri = params.logo_uri || undefined;
2091
+ updatedMetadata.logo_uri = (_params_logo_uri = params.logo_uri) !== null && _params_logo_uri !== void 0 ? _params_logo_uri : undefined;
2043
2092
  }
2044
2093
  if (params.client_uri !== undefined) {
2045
- updatedMetadata.client_uri = params.client_uri || undefined;
2094
+ updatedMetadata.client_uri = (_params_client_uri = params.client_uri) !== null && _params_client_uri !== void 0 ? _params_client_uri : undefined;
2046
2095
  }
2047
2096
  // Mirrors oidc-provider's lib/helpers/add_client.js: re-validates and persists.
2048
2097
  return [
@@ -2089,6 +2138,7 @@ function _ts_generator$7(thisArg, body) {
2089
2138
  ];
2090
2139
  case 1:
2091
2140
  provider = _state.sent();
2141
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
2092
2142
  ProviderClient = provider.Client;
2093
2143
  return [
2094
2144
  4,
@@ -2148,6 +2198,7 @@ function _ts_generator$7(thisArg, body) {
2148
2198
  ];
2149
2199
  case 1:
2150
2200
  provider = _state.sent();
2201
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
2151
2202
  ProviderClient = provider.Client;
2152
2203
  return [
2153
2204
  4,
@@ -2227,6 +2278,9 @@ function _object_spread_props$1(target, source) {
2227
2278
  // MARK: Provider Factories
2228
2279
  /**
2229
2280
  * Factory that creates an {@link OidcModelServerActions} instance from the injected {@link OidcClientService}.
2281
+ *
2282
+ * @param oidcClientService - the OIDC client service to wire into the server actions
2283
+ * @returns the configured OidcModelServerActions instance
2230
2284
  */ function oidcModelServerActionsFactory(oidcClientService) {
2231
2285
  var context = _object_spread_props$1(_object_spread$4({}, firebaseServerActionsContext()), {
2232
2286
  oidcClientService: oidcClientService
@@ -2239,7 +2293,8 @@ function _object_spread_props$1(target, source) {
2239
2293
  * By default this module exports:
2240
2294
  * - OidcModelServerActions
2241
2295
  *
2242
- * @param config
2296
+ * @param config - the configuration specifying the OIDC module dependency
2297
+ * @returns the NestJS module metadata for the OidcModel module
2243
2298
  */ function appOidcModelModuleMetadata(config) {
2244
2299
  var oidcModule = config.oidcModule;
2245
2300
  return {
@@ -2467,6 +2522,7 @@ function _ts_generator$6(thisArg, body) {
2467
2522
  *
2468
2523
  * @param collections - Firestore collection access for adapter entries.
2469
2524
  * @param encryptionService - Encryption service for sensitive payload fields.
2525
+ * @returns an oidc-provider adapter constructor backed by Firestore
2470
2526
  */ function createAdapterFactory(collections, encryptionService) {
2471
2527
  var FirestoreAdapter = /*#__PURE__*/ function() {
2472
2528
  function FirestoreAdapter(name) {
@@ -2534,7 +2590,7 @@ function _ts_generator$6(thisArg, body) {
2534
2590
  data = snapshot.data();
2535
2591
  return [
2536
2592
  2,
2537
- data && data.type === this.name ? this._toPayload(data) : undefined
2593
+ (data === null || data === void 0 ? void 0 : data.type) === this.name ? this._toPayload(data) : undefined
2538
2594
  ];
2539
2595
  }
2540
2596
  });
@@ -2700,6 +2756,9 @@ function _ts_generator$6(thisArg, body) {
2700
2756
  /**
2701
2757
  * Converts a Firestore document into an oidc-provider payload,
2702
2758
  * returning `undefined` if the entry has expired.
2759
+ *
2760
+ * @param data - the Firestore document data to convert
2761
+ * @returns the decrypted adapter payload, or undefined if the entry has expired
2703
2762
  */ key: "_toPayload",
2704
2763
  value: function _toPayload(data) {
2705
2764
  var expiresDate = data.expiresAt ? _instanceof$1(data.expiresAt, Date) ? data.expiresAt : data.expiresAt.toDate() : undefined;
@@ -2803,6 +2862,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2803
2862
  /**
2804
2863
  * Encrypts sensitive fields in an adapter payload and returns it as a {@link JsonSerializableObject}
2805
2864
  * suitable for storing directly in Firestore.
2865
+ *
2866
+ * @param payload - the adapter payload to encrypt
2867
+ * @returns the encrypted payload as a JSON-serializable object
2806
2868
  */ key: "encryptAdapterPayload",
2807
2869
  value: function encryptAdapterPayload(payload) {
2808
2870
  var filtered = filterUndefinedValues(payload);
@@ -2812,8 +2874,12 @@ function _unsupported_iterable_to_array$5(o, minLen) {
2812
2874
  {
2813
2875
  /**
2814
2876
  * Decrypts sensitive fields in a Firestore-stored payload object back to an {@link AdapterPayload}.
2877
+ *
2878
+ * @param payload - the encrypted Firestore-stored payload
2879
+ * @returns the decrypted adapter payload
2815
2880
  */ key: "decryptAdapterPayload",
2816
2881
  value: function decryptAdapterPayload(payload) {
2882
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2817
2883
  return this.adapterPayloadEncryptor.decrypt(payload);
2818
2884
  }
2819
2885
  }
@@ -2975,6 +3041,7 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
2975
3041
  *
2976
3042
  * @param jwksUri - Optional override for the JWKS URI (e.g., from cloud storage).
2977
3043
  * Falls back to `{issuer}{routes.jwks}`.
3044
+ * @returns the fully constructed OIDC discovery metadata
2978
3045
  */ key: "buildDiscoveryMetadata",
2979
3046
  value: function buildDiscoveryMetadata(jwksUri) {
2980
3047
  var issuer = this.config.issuer;
@@ -3257,6 +3324,8 @@ function _ts_generator$5(thisArg, body) {
3257
3324
  {
3258
3325
  /**
3259
3326
  * Returns the oidc-provider instance, initializing it on first access.
3327
+ *
3328
+ * @returns the lazily-initialized oidc-provider instance
3260
3329
  */ key: "getProvider",
3261
3330
  value: function getProvider() {
3262
3331
  return this._getProvider();
@@ -3271,11 +3340,11 @@ function _ts_generator$5(thisArg, body) {
3271
3340
  * Uses the provider's `AccessToken` model to look up the token and extract
3272
3341
  * the account ID, scope, and client ID.
3273
3342
  *
3274
- * @param token - The opaque access token string.
3343
+ * @param rawToken - The opaque access token string.
3275
3344
  * @returns The auth context, or `undefined` if the token is invalid or expired.
3276
3345
  */ function verifyAccessToken(rawToken) {
3277
3346
  return _async_to_generator$5(function() {
3278
- var _firstValue, _accessToken_exp, provider, accessToken, token;
3347
+ var _accessToken_exp, provider, accessToken, token;
3279
3348
  return _ts_generator$5(this, function(_state) {
3280
3349
  switch(_state.label){
3281
3350
  case 0:
@@ -3299,7 +3368,7 @@ function _ts_generator$5(thisArg, body) {
3299
3368
  }
3300
3369
  token = {
3301
3370
  // Standard JWT claims — sourced from the access token
3302
- aud: (_firstValue = firstValue(accessToken.aud)) !== null && _firstValue !== void 0 ? _firstValue : accessToken.clientId,
3371
+ aud: firstValue(accessToken.aud),
3303
3372
  iss: this.config.issuer,
3304
3373
  sub: accessToken.accountId,
3305
3374
  iat: accessToken.iat,
@@ -3353,6 +3422,7 @@ function _ts_generator$5(thisArg, body) {
3353
3422
  ];
3354
3423
  case 1:
3355
3424
  provider = _state.sent();
3425
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider Client has static methods not exposed in types
3356
3426
  ProviderClient = provider.Client;
3357
3427
  return [
3358
3428
  4,
@@ -3389,6 +3459,9 @@ function _ts_generator$5(thisArg, body) {
3389
3459
  *
3390
3460
  * Does NOT include `adapter`, `findAccount`, or `jwks` — those require async
3391
3461
  * setup and are handled by {@link OidcService}.
3462
+ *
3463
+ * @param cookieKeys - the signing keys for oidc-provider session cookies
3464
+ * @returns the oidc-provider configuration options
3392
3465
  */ key: "buildProviderConfiguration",
3393
3466
  value: function buildProviderConfiguration(cookieKeys) {
3394
3467
  var _this = this;
@@ -3427,7 +3500,7 @@ function _ts_generator$5(thisArg, body) {
3427
3500
  interactions: {
3428
3501
  url: function url(_ctx, interaction) {
3429
3502
  return _async_to_generator$5(function() {
3430
- var baseUrl, client_id, paramsToEncode, client, scopes, interactionLoginDetails, paramsString, redirectUrl;
3503
+ var baseUrl, client_id, paramsToEncode, client, scopes, interactionLoginDetails, paramsString;
3431
3504
  return _ts_generator$5(this, function(_state) {
3432
3505
  switch(_state.label){
3433
3506
  case 0:
@@ -3469,10 +3542,9 @@ function _ts_generator$5(thisArg, body) {
3469
3542
  paramsString = makeUrlSearchParamsString(paramsToEncode, {
3470
3543
  useUrlSearchSpaceHandling: true
3471
3544
  });
3472
- redirectUrl = "".concat(baseUrl, "?").concat(paramsString);
3473
3545
  return [
3474
3546
  2,
3475
- redirectUrl
3547
+ "".concat(baseUrl, "?").concat(paramsString)
3476
3548
  ];
3477
3549
  }
3478
3550
  });
@@ -3536,7 +3608,9 @@ function _ts_generator$5(thisArg, body) {
3536
3608
  _ref = _state.sent(), ProviderClass = _ref.default;
3537
3609
  provider = new ProviderClass(config.issuer, _object_spread_props(_object_spread$2({}, providerConfiguration), {
3538
3610
  adapter: adapterFactory,
3611
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider findAccount signature is more specific than our wrapper
3539
3612
  findAccount: findAccount,
3613
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oidc-provider expects JOSE JWK type which differs from Node.js JsonWebKey
3540
3614
  jwks: {
3541
3615
  keys: [
3542
3616
  signingKey
@@ -3760,7 +3834,7 @@ function _ts_generator$4(thisArg, body) {
3760
3834
  switch(_state.label){
3761
3835
  case 0:
3762
3836
  authHeader = req.headers.authorization;
3763
- if (!authHeader || !authHeader.startsWith('Bearer ')) {
3837
+ if (!(authHeader === null || authHeader === void 0 ? void 0 : authHeader.startsWith('Bearer '))) {
3764
3838
  throw new UnauthorizedException('Missing or invalid Authorization header');
3765
3839
  }
3766
3840
  token = authHeader.slice(7);
@@ -4134,6 +4208,10 @@ function _ts_generator$3(thisArg, body) {
4134
4208
  * Loads the interaction details for a given request/response pair.
4135
4209
  *
4136
4210
  * Requires the oidc-provider interaction cookie to be present on the request.
4211
+ *
4212
+ * @param req - the Express request containing the interaction cookie
4213
+ * @param res - the Express response
4214
+ * @returns the oidc-provider interaction details
4137
4215
  */ function getInteractionDetails(req, res) {
4138
4216
  return _async_to_generator$3(function() {
4139
4217
  var provider;
@@ -4164,6 +4242,8 @@ function _ts_generator$3(thisArg, body) {
4164
4242
  * This is necessary when the interaction cookie is scoped to a different path
4165
4243
  * (e.g., the frontend) and is not sent with backend API requests.
4166
4244
  *
4245
+ * @param uid - the interaction UID to look up
4246
+ * @returns the interaction details for the given UID
4167
4247
  * @throws {Error} When the interaction is not found or has expired.
4168
4248
  */ function findInteractionByUid(uid) {
4169
4249
  return _async_to_generator$3(function() {
@@ -4203,6 +4283,10 @@ function _ts_generator$3(thisArg, body) {
4203
4283
  * Looks up the interaction directly by UID, applies the result, saves it,
4204
4284
  * and returns the `returnTo` URL for the client to redirect to.
4205
4285
  *
4286
+ * @param uid - the interaction UID to complete
4287
+ * @param result - the interaction results to apply
4288
+ * @param options - optional settings for merging with the last submission
4289
+ * @param options.mergeWithLastSubmission - whether to merge with the last submission (defaults to true)
4206
4290
  * @returns The `returnTo` URL that the client should redirect to.
4207
4291
  */ function finishInteractionByUid(uid, result, options) {
4208
4292
  return _async_to_generator$3(function() {
@@ -4241,9 +4325,14 @@ function _ts_generator$3(thisArg, body) {
4241
4325
  key: "findOrCreateGrant",
4242
4326
  value: /**
4243
4327
  * Finds an existing grant by ID, or creates a new one.
4328
+ *
4329
+ * @param grantId - the existing grant ID to look up, or undefined to create a new grant
4330
+ * @param accountId - the account ID for creating a new grant
4331
+ * @param clientId - the client ID for creating a new grant
4332
+ * @returns the found or newly created grant
4244
4333
  */ function findOrCreateGrant(grantId, accountId, clientId) {
4245
4334
  return _async_to_generator$3(function() {
4246
- var provider, grant;
4335
+ var provider, grant, found;
4247
4336
  return _ts_generator$3(this, function(_state) {
4248
4337
  switch(_state.label){
4249
4338
  case 0:
@@ -4262,7 +4351,11 @@ function _ts_generator$3(thisArg, body) {
4262
4351
  provider.Grant.find(grantId)
4263
4352
  ];
4264
4353
  case 2:
4265
- grant = _state.sent();
4354
+ found = _state.sent();
4355
+ if (!found) {
4356
+ throw new Error("Grant not found for grantId: ".concat(grantId));
4357
+ }
4358
+ grant = found;
4266
4359
  return [
4267
4360
  3,
4268
4361
  4
@@ -4525,6 +4618,10 @@ function _ts_generator$2(thisArg, body) {
4525
4618
  *
4526
4619
  * Detects the interaction type and redirects to the appropriate frontend page.
4527
4620
  *
4621
+ * @param uid - the interaction UID from the URL path
4622
+ * @param req - the incoming Express request
4623
+ * @param res - the Express response used for redirecting
4624
+ * @returns a redirect response to the appropriate frontend page
4528
4625
  * @throws {HttpException} 404 when the interaction UID is not found or has expired.
4529
4626
  */ function getInteraction(uid, req, res) {
4530
4627
  return _async_to_generator$2(function() {
@@ -4575,6 +4672,9 @@ function _ts_generator$2(thisArg, body) {
4575
4672
  * Verifies the Firebase Auth ID token sent by the frontend, extracts the
4576
4673
  * user's UID, and completes the oidc-provider login interaction.
4577
4674
  *
4675
+ * @param uid - the interaction UID from the URL path
4676
+ * @param body - the login request containing the Firebase ID token
4677
+ * @param res - the Express response used for sending JSON
4578
4678
  * @throws {HttpException} 401 when the Firebase ID token is invalid.
4579
4679
  * @throws {HttpException} 400 when the login interaction cannot be completed.
4580
4680
  */ function postLogin(uid, body, res) {
@@ -4636,10 +4736,13 @@ function _ts_generator$2(thisArg, body) {
4636
4736
  * Receives consent decision from frontend. Grants missing OIDC scopes and claims
4637
4737
  * when approved, or returns `access_denied` when rejected.
4638
4738
  *
4739
+ * @param uid - the interaction UID from the URL path
4740
+ * @param body - the consent request containing approval decision and Firebase ID token
4741
+ * @param res - the Express response used for sending JSON
4639
4742
  * @throws {HttpException} 400 when the consent interaction cannot be completed.
4640
4743
  */ function postConsent(uid, body, res) {
4641
4744
  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;
4745
+ var _ref, redirectTo, interaction, prompt, params, session, grant, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, indicator, scopes, grantId, redirectTo1;
4643
4746
  return _ts_generator$2(this, function(_state) {
4644
4747
  switch(_state.label){
4645
4748
  case 0:
@@ -4692,13 +4795,13 @@ function _ts_generator$2(thisArg, body) {
4692
4795
  ];
4693
4796
  case 6:
4694
4797
  grant = _state.sent();
4695
- if ((_prompt_details = prompt.details) === null || _prompt_details === void 0 ? void 0 : _prompt_details.missingOIDCScope) {
4798
+ if (prompt.details.missingOIDCScope) {
4696
4799
  grant.addOIDCScope(prompt.details.missingOIDCScope.join(' '));
4697
4800
  }
4698
- if ((_prompt_details1 = prompt.details) === null || _prompt_details1 === void 0 ? void 0 : _prompt_details1.missingOIDCClaims) {
4801
+ if (prompt.details.missingOIDCClaims) {
4699
4802
  grant.addOIDCClaims(prompt.details.missingOIDCClaims);
4700
4803
  }
4701
- if ((_prompt_details2 = prompt.details) === null || _prompt_details2 === void 0 ? void 0 : _prompt_details2.missingResourceScopes) {
4804
+ if (prompt.details.missingResourceScopes) {
4702
4805
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4703
4806
  try {
4704
4807
  for(_iterator = Object.entries(prompt.details.missingResourceScopes)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
@@ -4763,6 +4866,8 @@ function _ts_generator$2(thisArg, body) {
4763
4866
  /**
4764
4867
  * Verifies a Firebase Auth ID token and returns the user's UID.
4765
4868
  *
4869
+ * @param idToken - the Firebase Auth ID token to verify
4870
+ * @returns the user's UID extracted from the decoded token
4766
4871
  * @throws {HttpException} 401 when the token is invalid or expired.
4767
4872
  */ function _verifyIdToken(idToken) {
4768
4873
  return _async_to_generator$2(function() {
@@ -5226,6 +5331,8 @@ function _ts_generator(thisArg, body) {
5226
5331
  *
5227
5332
  * Returns the provider metadata so clients can auto-discover endpoints,
5228
5333
  * supported scopes, signing algorithms, etc.
5334
+ *
5335
+ * @returns the OIDC discovery metadata document
5229
5336
  */ function getOpenIdConfiguration() {
5230
5337
  return _async_to_generator(function() {
5231
5338
  var _ref, jwksUri;
@@ -5253,6 +5360,8 @@ function _ts_generator(thisArg, body) {
5253
5360
  * JWKS endpoint. Returns the public JSON Web Key Set for token verification.
5254
5361
  *
5255
5362
  * This endpoint is typically skipped if the JwksServiceStorageConfig is provided.
5363
+ *
5364
+ * @returns the public JWKS containing all non-retired signing keys
5256
5365
  */ function getJwks() {
5257
5366
  return _async_to_generator(function() {
5258
5367
  return _ts_generator(this, function(_state) {
@@ -5270,6 +5379,8 @@ function _ts_generator(thisArg, body) {
5270
5379
  *
5271
5380
  * Returns the authorization server(s) that protect this resource,
5272
5381
  * allowing clients to discover which authorization server to use.
5382
+ *
5383
+ * @returns the protected resource metadata with authorization server URLs
5273
5384
  */ key: "getProtectedResource",
5274
5385
  value: function getProtectedResource() {
5275
5386
  return {
@@ -5412,6 +5523,9 @@ function _unsupported_iterable_to_array(o, minLen) {
5412
5523
  * Reads the JWKS encryption secret from `OIDC_JWKS_ENCRYPTION_SECRET`; in test environments,
5413
5524
  * a deterministic fallback is used.
5414
5525
  *
5526
+ * @param configService - the NestJS ConfigService for reading environment variables
5527
+ * @param envService - the Firebase server environment service for app URL and env detection
5528
+ * @returns the constructed OidcModuleConfig
5415
5529
  * @throws {Error} When `appUrl` is missing, lacks an HTTP prefix, or the encryption secret is invalid.
5416
5530
  */ function oidcModuleConfigFactory(configService, envService) {
5417
5531
  var _configService_get;
@@ -5451,6 +5565,10 @@ function _unsupported_iterable_to_array(o, minLen) {
5451
5565
  /**
5452
5566
  * Factory that creates {@link OidcServerFirestoreCollections} using the provided Firestore context
5453
5567
  * and JWKS encryption config from {@link OidcModuleConfig}.
5568
+ *
5569
+ * @param firestoreContext - the Firestore context for collection creation
5570
+ * @param oidcModuleConfig - the OIDC module config containing JWKS encryption settings
5571
+ * @returns the configured OidcServerFirestoreCollections
5454
5572
  */ function oidcFirestoreCollectionsFactory(firestoreContext, oidcModuleConfig) {
5455
5573
  return {
5456
5574
  jwksKeyCollection: jwksKeyFirestoreCollection(_object_spread({
@@ -5471,13 +5589,13 @@ function _unsupported_iterable_to_array(o, minLen) {
5471
5589
  * Additionally, the following may be optionally provided:
5472
5590
  * - JwksServiceStorageConfig
5473
5591
  *
5474
- * @param metadataConfig
5475
- * @returns
5592
+ * @param metadataConfig - the configuration for generating the OIDC module metadata
5593
+ * @returns the NestJS module metadata for the OIDC module
5476
5594
  */ function oidcModuleMetadata(metadataConfig) {
5477
5595
  var dependencyModule = metadataConfig.dependencyModule, config = metadataConfig.config, imports = metadataConfig.imports, exports$1 = metadataConfig.exports, providers = metadataConfig.providers;
5478
- var dependencyModuleImport = dependencyModule ? [
5596
+ var dependencyModuleImport = [
5479
5597
  dependencyModule
5480
- ] : [];
5598
+ ];
5481
5599
  return {
5482
5600
  imports: [
5483
5601
  ConfigModule,
package/oidc/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/oidc",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
4
4
  "peerDependencies": {
5
- "@dereekb/analytics": "13.4.0",
6
- "@dereekb/date": "13.4.0",
7
- "@dereekb/firebase": "13.4.0",
8
- "@dereekb/firebase-server": "13.4.0",
9
- "@dereekb/model": "13.4.0",
10
- "@dereekb/nestjs": "13.4.0",
11
- "@dereekb/rxjs": "13.4.0",
12
- "@dereekb/util": "13.4.0",
13
- "@dereekb/zoho": "13.4.0",
5
+ "@dereekb/analytics": "13.4.2",
6
+ "@dereekb/date": "13.4.2",
7
+ "@dereekb/firebase": "13.4.2",
8
+ "@dereekb/firebase-server": "13.4.2",
9
+ "@dereekb/model": "13.4.2",
10
+ "@dereekb/nestjs": "13.4.2",
11
+ "@dereekb/rxjs": "13.4.2",
12
+ "@dereekb/util": "13.4.2",
13
+ "@dereekb/zoho": "13.4.2",
14
14
  "@nestjs/common": "^11.1.16",
15
15
  "@nestjs/config": "^4.0.3",
16
16
  "express": "^5.0.0",