@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.
- package/index.cjs.js +405 -93
- package/index.esm.js +406 -94
- package/mailgun/package.json +9 -9
- package/model/index.cjs.js +639 -348
- package/model/index.esm.js +640 -349
- package/model/package.json +10 -10
- package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +1 -0
- package/model/src/lib/notification/index.d.ts +2 -2
- package/model/src/lib/notification/{notification.action.service.d.ts → notification.action.server.d.ts} +53 -1
- package/model/src/lib/notification/{notification.action.init.service.d.ts → notification.action.server.init.d.ts} +20 -0
- package/model/src/lib/notification/notification.config.service.d.ts +2 -0
- package/model/src/lib/notification/notification.create.run.d.ts +1 -0
- package/model/src/lib/notification/notification.error.d.ts +16 -0
- package/model/src/lib/notification/notification.expedite.service.d.ts +11 -3
- package/model/src/lib/notification/notification.module.d.ts +19 -6
- package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +1 -0
- package/model/src/lib/notification/notification.send.service.text.d.ts +2 -0
- package/model/src/lib/notification/notification.task.service.handler.d.ts +1 -0
- package/model/src/lib/notification/notification.task.service.util.d.ts +1 -0
- package/model/src/lib/notification/notification.task.subtask.handler.d.ts +3 -0
- package/model/src/lib/notification/notification.util.d.ts +4 -2
- package/model/src/lib/storagefile/index.d.ts +1 -1
- package/model/src/lib/storagefile/storagefile.action.server.d.ts +98 -1
- package/model/src/lib/storagefile/{storagefile.action.init.service.d.ts → storagefile.action.server.init.d.ts} +13 -2
- package/model/src/lib/storagefile/storagefile.error.d.ts +27 -0
- package/model/src/lib/storagefile/storagefile.module.d.ts +14 -4
- package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +29 -7
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +2 -0
- package/oidc/index.cjs.js +141 -31
- package/oidc/index.esm.js +141 -31
- package/oidc/package.json +11 -11
- package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +12 -0
- package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +6 -0
- package/oidc/src/lib/model/jwks/jwks.d.ts +9 -0
- package/oidc/src/lib/model/jwks/jwks.query.d.ts +9 -0
- package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +13 -0
- package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +5 -1
- package/oidc/src/lib/oidc.config.d.ts +2 -1
- package/oidc/src/lib/oidc.module.d.ts +9 -2
- package/oidc/src/lib/service/oidc.account.service.d.ts +7 -0
- package/oidc/src/lib/service/oidc.adapter.service.d.ts +1 -0
- package/oidc/src/lib/service/oidc.config.service.d.ts +1 -0
- package/oidc/src/lib/service/oidc.encryption.service.d.ts +6 -0
- package/oidc/src/lib/service/oidc.interaction.service.d.ts +15 -0
- package/oidc/src/lib/service/oidc.jwks.service.d.ts +18 -2
- package/oidc/src/lib/service/oidc.service.d.ts +7 -3
- package/package.json +13 -13
- package/src/lib/auth/auth.context.d.ts +1 -0
- package/src/lib/auth/auth.service.d.ts +13 -0
- package/src/lib/env/env.config.d.ts +2 -0
- package/src/lib/env/env.service.d.ts +21 -7
- package/src/lib/firestore/array.d.ts +1 -0
- package/src/lib/firestore/driver.accessor.batch.d.ts +4 -0
- package/src/lib/firestore/driver.accessor.d.ts +4 -0
- package/src/lib/firestore/driver.accessor.default.d.ts +5 -1
- package/src/lib/firestore/driver.accessor.transaction.d.ts +4 -0
- package/src/lib/firestore/driver.d.ts +2 -0
- package/src/lib/firestore/driver.query.d.ts +4 -0
- package/src/lib/firestore/increment.d.ts +1 -0
- package/src/lib/function/assert.d.ts +7 -0
- package/src/lib/function/context.d.ts +4 -0
- package/src/lib/function/error.auth.d.ts +2 -0
- package/src/lib/function/error.d.ts +86 -11
- package/src/lib/index.d.ts +0 -1
- package/src/lib/nest/analytics/analytics.service.listener.d.ts +2 -0
- package/src/lib/nest/app.d.ts +6 -3
- package/src/lib/nest/auth/auth.module.d.ts +6 -0
- package/src/lib/nest/auth/auth.util.d.ts +19 -1
- package/src/lib/nest/development/development.app.function.d.ts +12 -4
- package/src/lib/nest/development/development.assert.function.d.ts +6 -2
- package/src/lib/nest/development/development.function.d.ts +6 -1
- package/src/lib/nest/development/development.schedule.function.d.ts +3 -1
- package/src/lib/nest/development/development.schedule.function.error.d.ts +8 -0
- package/src/lib/nest/env/env.service.d.ts +2 -0
- package/src/lib/nest/env/env.util.d.ts +6 -0
- package/src/lib/nest/firebase/firebase.module.d.ts +1 -0
- package/src/lib/nest/firestore/firestore.module.d.ts +8 -0
- package/src/lib/nest/function/context.d.ts +2 -0
- package/src/lib/nest/model/analytics.details.d.ts +21 -7
- package/src/lib/nest/model/analytics.emit.d.ts +3 -0
- package/src/lib/nest/model/analytics.handler.d.ts +30 -10
- package/src/lib/nest/model/api.details.d.ts +34 -1
- package/src/lib/nest/model/call.model.function.d.ts +20 -4
- package/src/lib/nest/model/create.model.function.d.ts +6 -1
- package/src/lib/nest/model/crud.assert.function.d.ts +12 -4
- package/src/lib/nest/model/delete.model.function.d.ts +6 -1
- package/src/lib/nest/model/permission.error.d.ts +7 -0
- package/src/lib/nest/model/read.model.function.d.ts +6 -1
- package/src/lib/nest/model/specifier.function.d.ts +3 -0
- package/src/lib/nest/model/update.model.function.d.ts +6 -1
- package/src/lib/nest/nest.provider.d.ts +10 -0
- package/src/lib/nest/storage/storage.module.d.ts +9 -0
- package/src/lib/storage/driver.accessor.d.ts +22 -0
- package/src/lib/storage/driver.d.ts +2 -0
- package/src/lib/storage/storage.d.ts +1 -0
- package/test/package.json +11 -11
- package/zoho/index.cjs.js +8 -6
- package/zoho/index.esm.js +8 -6
- package/zoho/package.json +9 -9
- package/zoho/src/lib/zoho.accounts.firebase.d.ts +2 -1
- 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(
|
|
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 [
|
|
@@ -2013,7 +2064,7 @@ function _ts_generator$7(thisArg, body) {
|
|
|
2013
2064
|
* @throws When the client is not found.
|
|
2014
2065
|
*/ function updateClient(clientId, params) {
|
|
2015
2066
|
return _async_to_generator$7(function() {
|
|
2016
|
-
var provider, ProviderClient, existing, updatedMetadata, client;
|
|
2067
|
+
var provider, ProviderClient, existing, updatedMetadata, _params_logo_uri, _params_client_uri, client;
|
|
2017
2068
|
return _ts_generator$7(this, function(_state) {
|
|
2018
2069
|
switch(_state.label){
|
|
2019
2070
|
case 0:
|
|
@@ -2034,17 +2085,13 @@ function _ts_generator$7(thisArg, body) {
|
|
|
2034
2085
|
throw new Error('Client not found.');
|
|
2035
2086
|
}
|
|
2036
2087
|
updatedMetadata = _object_spread$5({}, existing);
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
}
|
|
2040
|
-
if (params.redirect_uris !== undefined && params.redirect_uris !== null) {
|
|
2041
|
-
updatedMetadata.redirect_uris = params.redirect_uris;
|
|
2042
|
-
}
|
|
2088
|
+
updatedMetadata.client_name = params.client_name;
|
|
2089
|
+
updatedMetadata.redirect_uris = params.redirect_uris;
|
|
2043
2090
|
if (params.logo_uri !== undefined) {
|
|
2044
|
-
updatedMetadata.logo_uri = params.logo_uri
|
|
2091
|
+
updatedMetadata.logo_uri = (_params_logo_uri = params.logo_uri) !== null && _params_logo_uri !== void 0 ? _params_logo_uri : undefined;
|
|
2045
2092
|
}
|
|
2046
2093
|
if (params.client_uri !== undefined) {
|
|
2047
|
-
updatedMetadata.client_uri = params.client_uri
|
|
2094
|
+
updatedMetadata.client_uri = (_params_client_uri = params.client_uri) !== null && _params_client_uri !== void 0 ? _params_client_uri : undefined;
|
|
2048
2095
|
}
|
|
2049
2096
|
// Mirrors oidc-provider's lib/helpers/add_client.js: re-validates and persists.
|
|
2050
2097
|
return [
|
|
@@ -2229,6 +2276,9 @@ function _object_spread_props$1(target, source) {
|
|
|
2229
2276
|
// MARK: Provider Factories
|
|
2230
2277
|
/**
|
|
2231
2278
|
* Factory that creates an {@link OidcModelServerActions} instance from the injected {@link OidcClientService}.
|
|
2279
|
+
*
|
|
2280
|
+
* @param oidcClientService - the OIDC client service to wire into the server actions
|
|
2281
|
+
* @returns the configured OidcModelServerActions instance
|
|
2232
2282
|
*/ function oidcModelServerActionsFactory(oidcClientService) {
|
|
2233
2283
|
var context = _object_spread_props$1(_object_spread$4({}, firebaseServer.firebaseServerActionsContext()), {
|
|
2234
2284
|
oidcClientService: oidcClientService
|
|
@@ -2241,7 +2291,8 @@ function _object_spread_props$1(target, source) {
|
|
|
2241
2291
|
* By default this module exports:
|
|
2242
2292
|
* - OidcModelServerActions
|
|
2243
2293
|
*
|
|
2244
|
-
* @param config
|
|
2294
|
+
* @param config - the configuration specifying the OIDC module dependency
|
|
2295
|
+
* @returns the NestJS module metadata for the OidcModel module
|
|
2245
2296
|
*/ function appOidcModelModuleMetadata(config) {
|
|
2246
2297
|
var oidcModule = config.oidcModule;
|
|
2247
2298
|
return {
|
|
@@ -2469,6 +2520,7 @@ function _ts_generator$6(thisArg, body) {
|
|
|
2469
2520
|
*
|
|
2470
2521
|
* @param collections - Firestore collection access for adapter entries.
|
|
2471
2522
|
* @param encryptionService - Encryption service for sensitive payload fields.
|
|
2523
|
+
* @returns an oidc-provider adapter constructor backed by Firestore
|
|
2472
2524
|
*/ function createAdapterFactory(collections, encryptionService) {
|
|
2473
2525
|
var FirestoreAdapter = /*#__PURE__*/ function() {
|
|
2474
2526
|
function FirestoreAdapter(name) {
|
|
@@ -2536,7 +2588,7 @@ function _ts_generator$6(thisArg, body) {
|
|
|
2536
2588
|
data = snapshot.data();
|
|
2537
2589
|
return [
|
|
2538
2590
|
2,
|
|
2539
|
-
data
|
|
2591
|
+
(data === null || data === void 0 ? void 0 : data.type) === this.name ? this._toPayload(data) : undefined
|
|
2540
2592
|
];
|
|
2541
2593
|
}
|
|
2542
2594
|
});
|
|
@@ -2702,6 +2754,9 @@ function _ts_generator$6(thisArg, body) {
|
|
|
2702
2754
|
/**
|
|
2703
2755
|
* Converts a Firestore document into an oidc-provider payload,
|
|
2704
2756
|
* returning `undefined` if the entry has expired.
|
|
2757
|
+
*
|
|
2758
|
+
* @param data - the Firestore document data to convert
|
|
2759
|
+
* @returns the decrypted adapter payload, or undefined if the entry has expired
|
|
2705
2760
|
*/ key: "_toPayload",
|
|
2706
2761
|
value: function _toPayload(data) {
|
|
2707
2762
|
var expiresDate = data.expiresAt ? _instanceof$1(data.expiresAt, Date) ? data.expiresAt : data.expiresAt.toDate() : undefined;
|
|
@@ -2805,6 +2860,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2805
2860
|
/**
|
|
2806
2861
|
* Encrypts sensitive fields in an adapter payload and returns it as a {@link JsonSerializableObject}
|
|
2807
2862
|
* suitable for storing directly in Firestore.
|
|
2863
|
+
*
|
|
2864
|
+
* @param payload - the adapter payload to encrypt
|
|
2865
|
+
* @returns the encrypted payload as a JSON-serializable object
|
|
2808
2866
|
*/ key: "encryptAdapterPayload",
|
|
2809
2867
|
value: function encryptAdapterPayload(payload) {
|
|
2810
2868
|
var filtered = util.filterUndefinedValues(payload);
|
|
@@ -2814,6 +2872,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
2814
2872
|
{
|
|
2815
2873
|
/**
|
|
2816
2874
|
* Decrypts sensitive fields in a Firestore-stored payload object back to an {@link AdapterPayload}.
|
|
2875
|
+
*
|
|
2876
|
+
* @param payload - the encrypted Firestore-stored payload
|
|
2877
|
+
* @returns the decrypted adapter payload
|
|
2817
2878
|
*/ key: "decryptAdapterPayload",
|
|
2818
2879
|
value: function decryptAdapterPayload(payload) {
|
|
2819
2880
|
return this.adapterPayloadEncryptor.decrypt(payload);
|
|
@@ -2977,6 +3038,7 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
|
|
|
2977
3038
|
*
|
|
2978
3039
|
* @param jwksUri - Optional override for the JWKS URI (e.g., from cloud storage).
|
|
2979
3040
|
* Falls back to `{issuer}{routes.jwks}`.
|
|
3041
|
+
* @returns the fully constructed OIDC discovery metadata
|
|
2980
3042
|
*/ key: "buildDiscoveryMetadata",
|
|
2981
3043
|
value: function buildDiscoveryMetadata(jwksUri) {
|
|
2982
3044
|
var issuer = this.config.issuer;
|
|
@@ -3259,6 +3321,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
3259
3321
|
{
|
|
3260
3322
|
/**
|
|
3261
3323
|
* Returns the oidc-provider instance, initializing it on first access.
|
|
3324
|
+
*
|
|
3325
|
+
* @returns the lazily-initialized oidc-provider instance
|
|
3262
3326
|
*/ key: "getProvider",
|
|
3263
3327
|
value: function getProvider() {
|
|
3264
3328
|
return this._getProvider();
|
|
@@ -3273,11 +3337,11 @@ function _ts_generator$5(thisArg, body) {
|
|
|
3273
3337
|
* Uses the provider's `AccessToken` model to look up the token and extract
|
|
3274
3338
|
* the account ID, scope, and client ID.
|
|
3275
3339
|
*
|
|
3276
|
-
* @param
|
|
3340
|
+
* @param rawToken - The opaque access token string.
|
|
3277
3341
|
* @returns The auth context, or `undefined` if the token is invalid or expired.
|
|
3278
3342
|
*/ function verifyAccessToken(rawToken) {
|
|
3279
3343
|
return _async_to_generator$5(function() {
|
|
3280
|
-
var
|
|
3344
|
+
var _accessToken_exp, provider, accessToken, token;
|
|
3281
3345
|
return _ts_generator$5(this, function(_state) {
|
|
3282
3346
|
switch(_state.label){
|
|
3283
3347
|
case 0:
|
|
@@ -3301,7 +3365,7 @@ function _ts_generator$5(thisArg, body) {
|
|
|
3301
3365
|
}
|
|
3302
3366
|
token = {
|
|
3303
3367
|
// Standard JWT claims — sourced from the access token
|
|
3304
|
-
aud:
|
|
3368
|
+
aud: util.firstValue(accessToken.aud),
|
|
3305
3369
|
iss: this.config.issuer,
|
|
3306
3370
|
sub: accessToken.accountId,
|
|
3307
3371
|
iat: accessToken.iat,
|
|
@@ -3391,6 +3455,9 @@ function _ts_generator$5(thisArg, body) {
|
|
|
3391
3455
|
*
|
|
3392
3456
|
* Does NOT include `adapter`, `findAccount`, or `jwks` — those require async
|
|
3393
3457
|
* setup and are handled by {@link OidcService}.
|
|
3458
|
+
*
|
|
3459
|
+
* @param cookieKeys - the signing keys for oidc-provider session cookies
|
|
3460
|
+
* @returns the oidc-provider configuration options
|
|
3394
3461
|
*/ key: "buildProviderConfiguration",
|
|
3395
3462
|
value: function buildProviderConfiguration(cookieKeys) {
|
|
3396
3463
|
var _this = this;
|
|
@@ -3429,7 +3496,7 @@ function _ts_generator$5(thisArg, body) {
|
|
|
3429
3496
|
interactions: {
|
|
3430
3497
|
url: function url(_ctx, interaction) {
|
|
3431
3498
|
return _async_to_generator$5(function() {
|
|
3432
|
-
var baseUrl, client_id, paramsToEncode, client, scopes, interactionLoginDetails, paramsString
|
|
3499
|
+
var baseUrl, client_id, paramsToEncode, client, scopes, interactionLoginDetails, paramsString;
|
|
3433
3500
|
return _ts_generator$5(this, function(_state) {
|
|
3434
3501
|
switch(_state.label){
|
|
3435
3502
|
case 0:
|
|
@@ -3471,10 +3538,9 @@ function _ts_generator$5(thisArg, body) {
|
|
|
3471
3538
|
paramsString = fetch.makeUrlSearchParamsString(paramsToEncode, {
|
|
3472
3539
|
useUrlSearchSpaceHandling: true
|
|
3473
3540
|
});
|
|
3474
|
-
redirectUrl = "".concat(baseUrl, "?").concat(paramsString);
|
|
3475
3541
|
return [
|
|
3476
3542
|
2,
|
|
3477
|
-
|
|
3543
|
+
"".concat(baseUrl, "?").concat(paramsString)
|
|
3478
3544
|
];
|
|
3479
3545
|
}
|
|
3480
3546
|
});
|
|
@@ -3762,7 +3828,7 @@ function _ts_generator$4(thisArg, body) {
|
|
|
3762
3828
|
switch(_state.label){
|
|
3763
3829
|
case 0:
|
|
3764
3830
|
authHeader = req.headers.authorization;
|
|
3765
|
-
if (!authHeader ||
|
|
3831
|
+
if (!(authHeader === null || authHeader === void 0 ? void 0 : authHeader.startsWith('Bearer '))) {
|
|
3766
3832
|
throw new common.UnauthorizedException('Missing or invalid Authorization header');
|
|
3767
3833
|
}
|
|
3768
3834
|
token = authHeader.slice(7);
|
|
@@ -4136,6 +4202,10 @@ function _ts_generator$3(thisArg, body) {
|
|
|
4136
4202
|
* Loads the interaction details for a given request/response pair.
|
|
4137
4203
|
*
|
|
4138
4204
|
* Requires the oidc-provider interaction cookie to be present on the request.
|
|
4205
|
+
*
|
|
4206
|
+
* @param req - the Express request containing the interaction cookie
|
|
4207
|
+
* @param res - the Express response
|
|
4208
|
+
* @returns the oidc-provider interaction details
|
|
4139
4209
|
*/ function getInteractionDetails(req, res) {
|
|
4140
4210
|
return _async_to_generator$3(function() {
|
|
4141
4211
|
var provider;
|
|
@@ -4166,6 +4236,8 @@ function _ts_generator$3(thisArg, body) {
|
|
|
4166
4236
|
* This is necessary when the interaction cookie is scoped to a different path
|
|
4167
4237
|
* (e.g., the frontend) and is not sent with backend API requests.
|
|
4168
4238
|
*
|
|
4239
|
+
* @param uid - the interaction UID to look up
|
|
4240
|
+
* @returns the interaction details for the given UID
|
|
4169
4241
|
* @throws {Error} When the interaction is not found or has expired.
|
|
4170
4242
|
*/ function findInteractionByUid(uid) {
|
|
4171
4243
|
return _async_to_generator$3(function() {
|
|
@@ -4205,6 +4277,10 @@ function _ts_generator$3(thisArg, body) {
|
|
|
4205
4277
|
* Looks up the interaction directly by UID, applies the result, saves it,
|
|
4206
4278
|
* and returns the `returnTo` URL for the client to redirect to.
|
|
4207
4279
|
*
|
|
4280
|
+
* @param uid - the interaction UID to complete
|
|
4281
|
+
* @param result - the interaction results to apply
|
|
4282
|
+
* @param options - optional settings for merging with the last submission
|
|
4283
|
+
* @param options.mergeWithLastSubmission - whether to merge with the last submission (defaults to true)
|
|
4208
4284
|
* @returns The `returnTo` URL that the client should redirect to.
|
|
4209
4285
|
*/ function finishInteractionByUid(uid, result, options) {
|
|
4210
4286
|
return _async_to_generator$3(function() {
|
|
@@ -4243,9 +4319,14 @@ function _ts_generator$3(thisArg, body) {
|
|
|
4243
4319
|
key: "findOrCreateGrant",
|
|
4244
4320
|
value: /**
|
|
4245
4321
|
* Finds an existing grant by ID, or creates a new one.
|
|
4322
|
+
*
|
|
4323
|
+
* @param grantId - the existing grant ID to look up, or undefined to create a new grant
|
|
4324
|
+
* @param accountId - the account ID for creating a new grant
|
|
4325
|
+
* @param clientId - the client ID for creating a new grant
|
|
4326
|
+
* @returns the found or newly created grant
|
|
4246
4327
|
*/ function findOrCreateGrant(grantId, accountId, clientId) {
|
|
4247
4328
|
return _async_to_generator$3(function() {
|
|
4248
|
-
var provider, grant;
|
|
4329
|
+
var provider, grant, found;
|
|
4249
4330
|
return _ts_generator$3(this, function(_state) {
|
|
4250
4331
|
switch(_state.label){
|
|
4251
4332
|
case 0:
|
|
@@ -4264,7 +4345,11 @@ function _ts_generator$3(thisArg, body) {
|
|
|
4264
4345
|
provider.Grant.find(grantId)
|
|
4265
4346
|
];
|
|
4266
4347
|
case 2:
|
|
4267
|
-
|
|
4348
|
+
found = _state.sent();
|
|
4349
|
+
if (!found) {
|
|
4350
|
+
throw new Error("Grant not found for grantId: ".concat(grantId));
|
|
4351
|
+
}
|
|
4352
|
+
grant = found;
|
|
4268
4353
|
return [
|
|
4269
4354
|
3,
|
|
4270
4355
|
4
|
|
@@ -4527,6 +4612,10 @@ function _ts_generator$2(thisArg, body) {
|
|
|
4527
4612
|
*
|
|
4528
4613
|
* Detects the interaction type and redirects to the appropriate frontend page.
|
|
4529
4614
|
*
|
|
4615
|
+
* @param uid - the interaction UID from the URL path
|
|
4616
|
+
* @param req - the incoming Express request
|
|
4617
|
+
* @param res - the Express response used for redirecting
|
|
4618
|
+
* @returns a redirect response to the appropriate frontend page
|
|
4530
4619
|
* @throws {HttpException} 404 when the interaction UID is not found or has expired.
|
|
4531
4620
|
*/ function getInteraction(uid, req, res) {
|
|
4532
4621
|
return _async_to_generator$2(function() {
|
|
@@ -4577,6 +4666,9 @@ function _ts_generator$2(thisArg, body) {
|
|
|
4577
4666
|
* Verifies the Firebase Auth ID token sent by the frontend, extracts the
|
|
4578
4667
|
* user's UID, and completes the oidc-provider login interaction.
|
|
4579
4668
|
*
|
|
4669
|
+
* @param uid - the interaction UID from the URL path
|
|
4670
|
+
* @param body - the login request containing the Firebase ID token
|
|
4671
|
+
* @param res - the Express response used for sending JSON
|
|
4580
4672
|
* @throws {HttpException} 401 when the Firebase ID token is invalid.
|
|
4581
4673
|
* @throws {HttpException} 400 when the login interaction cannot be completed.
|
|
4582
4674
|
*/ function postLogin(uid, body, res) {
|
|
@@ -4638,10 +4730,13 @@ function _ts_generator$2(thisArg, body) {
|
|
|
4638
4730
|
* Receives consent decision from frontend. Grants missing OIDC scopes and claims
|
|
4639
4731
|
* when approved, or returns `access_denied` when rejected.
|
|
4640
4732
|
*
|
|
4733
|
+
* @param uid - the interaction UID from the URL path
|
|
4734
|
+
* @param body - the consent request containing approval decision and Firebase ID token
|
|
4735
|
+
* @param res - the Express response used for sending JSON
|
|
4641
4736
|
* @throws {HttpException} 400 when the consent interaction cannot be completed.
|
|
4642
4737
|
*/ function postConsent(uid, body, res) {
|
|
4643
4738
|
return _async_to_generator$2(function() {
|
|
4644
|
-
var _ref,
|
|
4739
|
+
var _ref, redirectTo, interaction, prompt, params, session, grant, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, indicator, scopes, grantId, redirectTo1;
|
|
4645
4740
|
return _ts_generator$2(this, function(_state) {
|
|
4646
4741
|
switch(_state.label){
|
|
4647
4742
|
case 0:
|
|
@@ -4694,13 +4789,13 @@ function _ts_generator$2(thisArg, body) {
|
|
|
4694
4789
|
];
|
|
4695
4790
|
case 6:
|
|
4696
4791
|
grant = _state.sent();
|
|
4697
|
-
if (
|
|
4792
|
+
if (prompt.details.missingOIDCScope) {
|
|
4698
4793
|
grant.addOIDCScope(prompt.details.missingOIDCScope.join(' '));
|
|
4699
4794
|
}
|
|
4700
|
-
if (
|
|
4795
|
+
if (prompt.details.missingOIDCClaims) {
|
|
4701
4796
|
grant.addOIDCClaims(prompt.details.missingOIDCClaims);
|
|
4702
4797
|
}
|
|
4703
|
-
if (
|
|
4798
|
+
if (prompt.details.missingResourceScopes) {
|
|
4704
4799
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4705
4800
|
try {
|
|
4706
4801
|
for(_iterator = Object.entries(prompt.details.missingResourceScopes)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
@@ -4765,6 +4860,8 @@ function _ts_generator$2(thisArg, body) {
|
|
|
4765
4860
|
/**
|
|
4766
4861
|
* Verifies a Firebase Auth ID token and returns the user's UID.
|
|
4767
4862
|
*
|
|
4863
|
+
* @param idToken - the Firebase Auth ID token to verify
|
|
4864
|
+
* @returns the user's UID extracted from the decoded token
|
|
4768
4865
|
* @throws {HttpException} 401 when the token is invalid or expired.
|
|
4769
4866
|
*/ function _verifyIdToken(idToken) {
|
|
4770
4867
|
return _async_to_generator$2(function() {
|
|
@@ -5228,6 +5325,8 @@ function _ts_generator(thisArg, body) {
|
|
|
5228
5325
|
*
|
|
5229
5326
|
* Returns the provider metadata so clients can auto-discover endpoints,
|
|
5230
5327
|
* supported scopes, signing algorithms, etc.
|
|
5328
|
+
*
|
|
5329
|
+
* @returns the OIDC discovery metadata document
|
|
5231
5330
|
*/ function getOpenIdConfiguration() {
|
|
5232
5331
|
return _async_to_generator(function() {
|
|
5233
5332
|
var _ref, jwksUri;
|
|
@@ -5255,6 +5354,8 @@ function _ts_generator(thisArg, body) {
|
|
|
5255
5354
|
* JWKS endpoint. Returns the public JSON Web Key Set for token verification.
|
|
5256
5355
|
*
|
|
5257
5356
|
* This endpoint is typically skipped if the JwksServiceStorageConfig is provided.
|
|
5357
|
+
*
|
|
5358
|
+
* @returns the public JWKS containing all non-retired signing keys
|
|
5258
5359
|
*/ function getJwks() {
|
|
5259
5360
|
return _async_to_generator(function() {
|
|
5260
5361
|
return _ts_generator(this, function(_state) {
|
|
@@ -5272,6 +5373,8 @@ function _ts_generator(thisArg, body) {
|
|
|
5272
5373
|
*
|
|
5273
5374
|
* Returns the authorization server(s) that protect this resource,
|
|
5274
5375
|
* allowing clients to discover which authorization server to use.
|
|
5376
|
+
*
|
|
5377
|
+
* @returns the protected resource metadata with authorization server URLs
|
|
5275
5378
|
*/ key: "getProtectedResource",
|
|
5276
5379
|
value: function getProtectedResource() {
|
|
5277
5380
|
return {
|
|
@@ -5414,6 +5517,9 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
5414
5517
|
* Reads the JWKS encryption secret from `OIDC_JWKS_ENCRYPTION_SECRET`; in test environments,
|
|
5415
5518
|
* a deterministic fallback is used.
|
|
5416
5519
|
*
|
|
5520
|
+
* @param configService - the NestJS ConfigService for reading environment variables
|
|
5521
|
+
* @param envService - the Firebase server environment service for app URL and env detection
|
|
5522
|
+
* @returns the constructed OidcModuleConfig
|
|
5417
5523
|
* @throws {Error} When `appUrl` is missing, lacks an HTTP prefix, or the encryption secret is invalid.
|
|
5418
5524
|
*/ function oidcModuleConfigFactory(configService, envService) {
|
|
5419
5525
|
var _configService_get;
|
|
@@ -5453,6 +5559,10 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
5453
5559
|
/**
|
|
5454
5560
|
* Factory that creates {@link OidcServerFirestoreCollections} using the provided Firestore context
|
|
5455
5561
|
* and JWKS encryption config from {@link OidcModuleConfig}.
|
|
5562
|
+
*
|
|
5563
|
+
* @param firestoreContext - the Firestore context for collection creation
|
|
5564
|
+
* @param oidcModuleConfig - the OIDC module config containing JWKS encryption settings
|
|
5565
|
+
* @returns the configured OidcServerFirestoreCollections
|
|
5456
5566
|
*/ function oidcFirestoreCollectionsFactory(firestoreContext, oidcModuleConfig) {
|
|
5457
5567
|
return {
|
|
5458
5568
|
jwksKeyCollection: jwksKeyFirestoreCollection(_object_spread({
|
|
@@ -5473,13 +5583,13 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
5473
5583
|
* Additionally, the following may be optionally provided:
|
|
5474
5584
|
* - JwksServiceStorageConfig
|
|
5475
5585
|
*
|
|
5476
|
-
* @param metadataConfig
|
|
5477
|
-
* @returns
|
|
5586
|
+
* @param metadataConfig - the configuration for generating the OIDC module metadata
|
|
5587
|
+
* @returns the NestJS module metadata for the OIDC module
|
|
5478
5588
|
*/ function oidcModuleMetadata(metadataConfig) {
|
|
5479
5589
|
var dependencyModule = metadataConfig.dependencyModule, config$1 = metadataConfig.config, imports = metadataConfig.imports, exports$1 = metadataConfig.exports, providers = metadataConfig.providers;
|
|
5480
|
-
var dependencyModuleImport =
|
|
5590
|
+
var dependencyModuleImport = [
|
|
5481
5591
|
dependencyModule
|
|
5482
|
-
]
|
|
5592
|
+
];
|
|
5483
5593
|
return {
|
|
5484
5594
|
imports: [
|
|
5485
5595
|
config.ConfigModule,
|