@dereekb/firebase-server 14.2.0 → 14.4.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/oidc/index.esm.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import { createParamDecorator, Injectable, Inject, Optional, Logger, UnauthorizedException, Get, Param, Req, Res, Post, HttpCode, HttpStatus, Body, Controller, HttpException, All } from '@nestjs/common';
2
2
  import { errors } from 'oidc-provider';
3
- import { SECONDS_IN_MINUTE, SECONDS_IN_DAY, cachedGetter, unixDateTimeSecondsNumberToDate, unixDateTimeSecondsNumberForNow, selectiveFieldEncryptor, filterUndefinedValues, websiteUrlFromPaths, firstValue, hasHttpPrefix } from '@dereekb/util';
4
- import { generateKeyPairSync, randomBytes } from 'node:crypto';
3
+ import { SECONDS_IN_MINUTE, SECONDS_IN_DAY, cachedGetter, unixDateTimeSecondsNumberToDate, unixDateTimeSecondsNumberForNow, selectiveFieldEncryptor, filterUndefinedValues, websiteUrlFromPaths, unique, filterKeysOnPOJOFunction, firstValue, hasHttpPrefix } from '@dereekb/util';
4
+ import { generateKeyPairSync, randomBytes, randomUUID } from 'node:crypto';
5
5
  import { resolveEncryptionKey, encryptValue, decryptValue, createAesStringEncryptionProvider, isValidAES256GCMEncryptionSecret } from '@dereekb/nestjs';
6
6
  import { where, iterateFirestoreDocumentSnapshotPairs, firestoreModelIdentity, snapshotConverterFunctions, optionalFirestoreDate, firestoreDate, firestoreEnum, firestorePassThroughField, AbstractFirestoreDocument, createOidcClientParamsType, deleteOidcClientParamsType, deleteOidcTokenParamsType, rotateOidcClientSecretParamsType, updateOidcClientParamsType, firestoreModelKey, oidcEntryIdentity, PUBLIC_PKCE_TOKEN_ENDPOINT_AUTH_METHOD, OIDC_ENTRY_CLIENT_TYPE, oidcEntriesByUserCodeQuery, oidcEntriesByUidQuery, oidcEntriesByGrantIdQuery, assignmentOnlyScopesForOidcProviderProfiles, adminOnlyScopesForOidcProviderProfiles, oidcProviderProfilesForClient, requiredScopesForOidcProviderProfiles, scopesForOidcProviderProfiles, oidcScopesFromScopeClaim, oidcEntryFirestoreCollection } from '@dereekb/firebase';
7
7
  import { firestoreEncryptedField, firebaseServerActionsContext, FirebaseServerEnvService, FirebaseServerAnalyticsService, FIREBASE_FIRESTORE_CONTEXT_TOKEN, FirebaseServerFirestoreContextModule } from '@dereekb/firebase-server';
8
8
  import { nanoid } from 'nanoid';
9
9
  import { safeToJsDate } from '@dereekb/date';
10
10
  import { makeUrlSearchParamsString } from '@dereekb/util/fetch';
11
+ import { buildIssuerProfiles, verifyBearerJwt, buildBearerChallenge as buildBearerChallenge$1 } from '@dereekb/oauth-resource';
12
+ import { createLocalJWKSet, SignJWT, importJWK } from 'jose';
11
13
  import { ConfigService, ConfigModule } from '@nestjs/config';
12
14
 
13
15
  /**
@@ -27,13 +29,13 @@ import { ConfigService, ConfigModule } from '@nestjs/config';
27
29
  return req.auth;
28
30
  });
29
31
 
30
- function _type_of$2(obj) {
32
+ function _type_of$3(obj) {
31
33
  "@swc/helpers - typeof";
32
34
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
33
35
  }
34
36
  function __decorate(decorators, target, key, desc) {
35
37
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
36
- if ((typeof Reflect === "undefined" ? "undefined" : _type_of$2(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
38
+ if ((typeof Reflect === "undefined" ? "undefined" : _type_of$3(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
37
39
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
38
40
  return c > 3 && r && Object.defineProperty(target, key, r), r;
39
41
  }
@@ -47,10 +49,10 @@ typeof SuppressedError === "function" ? SuppressedError : function(error, suppre
47
49
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
48
50
  };
49
51
 
50
- function _class_call_check$i(instance, Constructor) {
52
+ function _class_call_check$j(instance, Constructor) {
51
53
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
52
54
  }
53
- function _defineProperties$e(target, props) {
55
+ function _defineProperties$f(target, props) {
54
56
  for(var i = 0; i < props.length; i++){
55
57
  var descriptor = props[i];
56
58
  descriptor.enumerable = descriptor.enumerable || false;
@@ -59,11 +61,11 @@ function _defineProperties$e(target, props) {
59
61
  Object.defineProperty(target, descriptor.key, descriptor);
60
62
  }
61
63
  }
62
- function _create_class$e(Constructor, protoProps, staticProps) {
63
- if (staticProps) _defineProperties$e(Constructor, staticProps);
64
+ function _create_class$f(Constructor, protoProps, staticProps) {
65
+ if (staticProps) _defineProperties$f(Constructor, staticProps);
64
66
  return Constructor;
65
67
  }
66
- function _define_property$g(obj, key, value) {
68
+ function _define_property$i(obj, key, value) {
67
69
  if (key in obj) {
68
70
  Object.defineProperty(obj, key, {
69
71
  value: value,
@@ -139,32 +141,32 @@ function _define_property$g(obj, key, value) {
139
141
  * Used as an abstract class so it can serve as both a type and a NestJS DI token.
140
142
  */ var OidcModuleConfig = /*#__PURE__*/ function() {
141
143
  function OidcModuleConfig() {
142
- _class_call_check$i(this, OidcModuleConfig);
144
+ _class_call_check$j(this, OidcModuleConfig);
143
145
  /**
144
146
  * The OIDC issuer URL (e.g., 'https://accounts.example.com').
145
147
  * Must be the canonical URL where the OIDC provider is accessible.
146
- */ _define_property$g(this, "issuer", void 0);
148
+ */ _define_property$i(this, "issuer", void 0);
147
149
  /**
148
150
  * The path prefix used for OIDC interaction endpoints (login/consent).
149
151
  *
150
152
  * Appended to the base appUrl this is the base frontend interaction path.
151
153
  *
152
154
  * Defaults to '/oauth'.
153
- */ _define_property$g(this, "appOAuthInteractionPath", void 0);
155
+ */ _define_property$i(this, "appOAuthInteractionPath", void 0);
154
156
  /**
155
157
  * Frontend URL for the login interaction page.
156
158
  * The interaction uid will be appended as a query parameter.
157
159
  *
158
160
  * Defaults to `<appOAuthInteractionPath>/login`.
159
- */ _define_property$g(this, "appOAuthLoginUrlPart", void 0);
161
+ */ _define_property$i(this, "appOAuthLoginUrlPart", void 0);
160
162
  /**
161
163
  * Frontend URL for the consent interaction page.
162
164
  *
163
165
  * Defaults to `<appOAuthInteractionPath>/consent`.
164
- */ _define_property$g(this, "appOAuthConsentUrlPart", void 0);
166
+ */ _define_property$i(this, "appOAuthConsentUrlPart", void 0);
165
167
  /**
166
168
  * Token lifetime configuration.
167
- */ _define_property$g(this, "tokenLifetimes", void 0);
169
+ */ _define_property$i(this, "tokenLifetimes", void 0);
168
170
  /**
169
171
  * Maximum login duration (seconds) a client may request via the `dbx_session_ttl` auth-URL param.
170
172
  *
@@ -173,18 +175,18 @@ function _define_property$g(obj, key, value) {
173
175
  * `min(client.dbx_max_session_ttl, this)`.
174
176
  *
175
177
  * Defaults to {@link DEFAULT_MAX_REQUESTED_LOGIN_DURATION_SECONDS} (90 days).
176
- */ _define_property$g(this, "maxRequestedLoginDuration", void 0);
178
+ */ _define_property$i(this, "maxRequestedLoginDuration", void 0);
177
179
  /**
178
180
  * Minimum login duration (seconds) a client may request via the `dbx_session_ttl` auth-URL param.
179
181
  *
180
182
  * Requested values below this floor are clamped up. Prevents pathological 30-second sessions.
181
183
  *
182
184
  * Defaults to {@link DEFAULT_MIN_REQUESTED_LOGIN_DURATION_SECONDS} (1 hour).
183
- */ _define_property$g(this, "minRequestedLoginDuration", void 0);
185
+ */ _define_property$i(this, "minRequestedLoginDuration", void 0);
184
186
  /**
185
187
  * Default login duration (seconds) used when a client does NOT pass the `dbx_session_ttl`
186
188
  * auth-URL param. When undefined, falls back to {@link OidcTokenLifetimes.refreshToken}.
187
- */ _define_property$g(this, "defaultRequestedLoginDuration", void 0);
189
+ */ _define_property$i(this, "defaultRequestedLoginDuration", void 0);
188
190
  /**
189
191
  * Tiered ceiling (seconds) on the requested login duration for a non-admin user.
190
192
  *
@@ -193,23 +195,23 @@ function _define_property$g(obj, key, value) {
193
195
  * {@link maxRequestedLoginDuration}, since service-token tokens intentionally exceed it).
194
196
  *
195
197
  * Defaults to {@link DEFAULT_MAX_NONADMIN_LOGIN_DURATION_SECONDS} (45 days).
196
- */ _define_property$g(this, "maxRequestedLoginDurationNonAdmin", void 0);
198
+ */ _define_property$i(this, "maxRequestedLoginDurationNonAdmin", void 0);
197
199
  /**
198
200
  * Tiered ceiling (seconds) on a normal (non-service-token) requested login duration for an admin user.
199
201
  *
200
202
  * Defaults to {@link DEFAULT_MAX_ADMIN_LOGIN_DURATION_SECONDS} (90 days).
201
- */ _define_property$g(this, "maxRequestedLoginDurationAdmin", void 0);
203
+ */ _define_property$i(this, "maxRequestedLoginDurationAdmin", void 0);
202
204
  /**
203
205
  * Tiered ceiling (seconds) on a requested login duration carrying an admin-only service-token scope.
204
206
  *
205
207
  * Defaults to {@link DEFAULT_MAX_SERVICE_TOKEN_LOGIN_DURATION_SECONDS} (365 days).
206
- */ _define_property$g(this, "maxRequestedLoginDurationServiceToken", void 0);
208
+ */ _define_property$i(this, "maxRequestedLoginDurationServiceToken", void 0);
207
209
  /**
208
210
  * JWKS service configuration (encryption secret, rotated key max age).
209
- */ _define_property$g(this, "jwksServiceConfig", void 0);
211
+ */ _define_property$i(this, "jwksServiceConfig", void 0);
210
212
  /**
211
213
  * JWKS key converter configuration (encryption secret for Firestore field encryption).
212
- */ _define_property$g(this, "jwksKeyConverterConfig", void 0);
214
+ */ _define_property$i(this, "jwksKeyConverterConfig", void 0);
213
215
  /**
214
216
  * Custom error rendering function for the oidc-provider.
215
217
  *
@@ -219,7 +221,7 @@ function _define_property$g(obj, key, value) {
219
221
  * errors are presented (e.g. redirect to an error page).
220
222
  *
221
223
  * The function signature matches oidc-provider's `renderError` configuration option.
222
- */ _define_property$g(this, "renderError", void 0);
224
+ */ _define_property$i(this, "renderError", void 0);
223
225
  /**
224
226
  * Whether to suppress the oidc-provider "already parsed request body" warning.
225
227
  *
@@ -228,7 +230,7 @@ function _define_property$g(obj, key, value) {
228
230
  * this correctly by falling back to `req.body`, but emits a one-time warning.
229
231
  *
230
232
  * Defaults to `false`.
231
- */ _define_property$g(this, "suppressBodyParserWarning", void 0);
233
+ */ _define_property$i(this, "suppressBodyParserWarning", void 0);
232
234
  /**
233
235
  * Path prefixes that require OAuth bearer token verification.
234
236
  *
@@ -238,7 +240,7 @@ function _define_property$g(obj, key, value) {
238
240
  *
239
241
  * Paths under the global API route prefix should not be included
240
242
  * since those are typically protected by AppCheck.
241
- */ _define_property$g(this, "protectedPaths", void 0);
243
+ */ _define_property$i(this, "protectedPaths", void 0);
242
244
  /**
243
245
  * Map of recognized OAuth resource indicator URLs (RFC 8707) to their
244
246
  * {@link OidcResourceServerInfo}. When non-empty, oidc-provider's
@@ -260,7 +262,7 @@ function _define_property$g(obj, key, value) {
260
262
  * }
261
263
  * }
262
264
  * ```
263
- */ _define_property$g(this, "resourceServers", void 0);
265
+ */ _define_property$i(this, "resourceServers", void 0);
264
266
  /**
265
267
  * When `true`, {@link oidcModuleMetadata} automatically derives a resource-server
266
268
  * entry from `envService.appMcpUrl` and the registered {@link OidcAccountService}'s
@@ -276,7 +278,7 @@ function _define_property$g(obj, key, value) {
276
278
  * Defaults to `false`.
277
279
  *
278
280
  * @see buildFirebaseServerMcpResourceServer
279
- */ _define_property$g(this, "configureMcpResourceServer", void 0);
281
+ */ _define_property$i(this, "configureMcpResourceServer", void 0);
280
282
  /**
281
283
  * Absolute URL of the OAuth 2.0 Protected Resource Metadata document
282
284
  * (RFC 9728) for the resources guarded by {@link protectedPaths}.
@@ -294,7 +296,7 @@ function _define_property$g(obj, key, value) {
294
296
  *
295
297
  * @example
296
298
  * resourceMetadataUrl: 'http://localhost:9902/dereekb-components/us-central1/api/.well-known/oauth-protected-resource'
297
- */ _define_property$g(this, "resourceMetadataUrl", void 0);
299
+ */ _define_property$i(this, "resourceMetadataUrl", void 0);
298
300
  /**
299
301
  * Supported token endpoint authentication methods.
300
302
  *
@@ -302,7 +304,7 @@ function _define_property$g(obj, key, value) {
302
304
  * in the discovery metadata document.
303
305
  *
304
306
  * @see DEFAULT_OIDC_TOKEN_ENDPOINT_AUTH_METHODS
305
- */ _define_property$g(this, "tokenEndpointAuthMethods", void 0);
307
+ */ _define_property$i(this, "tokenEndpointAuthMethods", void 0);
306
308
  /**
307
309
  * Whether to enable the OIDC dynamic client registration endpoint (`/reg`).
308
310
  *
@@ -310,7 +312,7 @@ function _define_property$g(obj, key, value) {
310
312
  * and manage their registrations via the registration management feature.
311
313
  *
312
314
  * Defaults to `false`.
313
- */ _define_property$g(this, "registrationEnabled", void 0);
315
+ */ _define_property$i(this, "registrationEnabled", void 0);
314
316
  /**
315
317
  * Whether the oidc-provider should trust upstream proxy headers
316
318
  * (`X-Forwarded-Host`, `X-Forwarded-Proto`) when computing the request URL
@@ -329,7 +331,7 @@ function _define_property$g(obj, key, value) {
329
331
  * (which is the Koa `app.proxy` setting).
330
332
  *
331
333
  * Defaults to `'prod_only'` if the environment is `production`, otherwise `false`.
332
- */ _define_property$g(this, "trustProxy", void 0);
334
+ */ _define_property$i(this, "trustProxy", void 0);
333
335
  /**
334
336
  * Whether to trust proxy headers in a non-production environment, such as the local environment.
335
337
  *
@@ -337,7 +339,7 @@ function _define_property$g(obj, key, value) {
337
339
  * `true` will result in errors.
338
340
  *
339
341
  * Defaults to `false`.
340
- */ _define_property$g(this, "trustProxyInNonProduction", void 0);
342
+ */ _define_property$i(this, "trustProxyInNonProduction", void 0);
341
343
  /**
342
344
  * Unified CORS configuration for the cross-origin browser OIDC endpoints
343
345
  * (discovery GET, token POST). When unset, the Express CORS layer preserves the
@@ -345,9 +347,9 @@ function _define_property$g(obj, key, value) {
345
347
  * response, which pre-empts oidc-provider's own CORS handling.
346
348
  *
347
349
  * @see OidcCorsConfig
348
- */ _define_property$g(this, "cors", void 0);
350
+ */ _define_property$i(this, "cors", void 0);
349
351
  }
350
- _create_class$e(OidcModuleConfig, null, [
352
+ _create_class$f(OidcModuleConfig, null, [
351
353
  {
352
354
  key: "assertValidConfig",
353
355
  value: /**
@@ -597,7 +599,7 @@ function _define_property$g(obj, key, value) {
597
599
  return jwksKeysWithStatusQuery('rotated');
598
600
  }
599
601
 
600
- function _class_call_check$h(instance, Constructor) {
602
+ function _class_call_check$i(instance, Constructor) {
601
603
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
602
604
  }
603
605
  // MARK: Collections
@@ -607,11 +609,11 @@ function _class_call_check$h(instance, Constructor) {
607
609
  * Extends both {@link JwksFirestoreCollections} (server-only JWKS keys) and
608
610
  * {@link OidcModelFirestoreCollections} (shared adapter entries).
609
611
  */ var OidcServerFirestoreCollections = function OidcServerFirestoreCollections() {
610
- _class_call_check$h(this, OidcServerFirestoreCollections);
612
+ _class_call_check$i(this, OidcServerFirestoreCollections);
611
613
  }
612
614
  ;
613
615
 
614
- function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
616
+ function asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, key, arg) {
615
617
  try {
616
618
  var info = gen[key](arg);
617
619
  var value = info.value;
@@ -622,25 +624,25 @@ function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
622
624
  if (info.done) resolve(value);
623
625
  else Promise.resolve(value).then(_next, _throw);
624
626
  }
625
- function _async_to_generator$a(fn) {
627
+ function _async_to_generator$c(fn) {
626
628
  return function() {
627
629
  var self = this, args = arguments;
628
630
  return new Promise(function(resolve, reject) {
629
631
  var gen = fn.apply(self, args);
630
632
  function _next(value) {
631
- asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "next", value);
633
+ asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, "next", value);
632
634
  }
633
635
  function _throw(err) {
634
- asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "throw", err);
636
+ asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, "throw", err);
635
637
  }
636
638
  _next(undefined);
637
639
  });
638
640
  };
639
641
  }
640
- function _class_call_check$g(instance, Constructor) {
642
+ function _class_call_check$h(instance, Constructor) {
641
643
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
642
644
  }
643
- function _defineProperties$d(target, props) {
645
+ function _defineProperties$e(target, props) {
644
646
  for(var i = 0; i < props.length; i++){
645
647
  var descriptor = props[i];
646
648
  descriptor.enumerable = descriptor.enumerable || false;
@@ -649,11 +651,11 @@ function _defineProperties$d(target, props) {
649
651
  Object.defineProperty(target, descriptor.key, descriptor);
650
652
  }
651
653
  }
652
- function _create_class$d(Constructor, protoProps, staticProps) {
653
- if (protoProps) _defineProperties$d(Constructor.prototype, protoProps);
654
+ function _create_class$e(Constructor, protoProps, staticProps) {
655
+ if (protoProps) _defineProperties$e(Constructor.prototype, protoProps);
654
656
  return Constructor;
655
657
  }
656
- function _define_property$f(obj, key, value) {
658
+ function _define_property$h(obj, key, value) {
657
659
  if (key in obj) {
658
660
  Object.defineProperty(obj, key, {
659
661
  value: value,
@@ -664,7 +666,7 @@ function _define_property$f(obj, key, value) {
664
666
  } else obj[key] = value;
665
667
  return obj;
666
668
  }
667
- function _object_spread$7(target) {
669
+ function _object_spread$9(target) {
668
670
  for(var i = 1; i < arguments.length; i++){
669
671
  var source = arguments[i] != null ? arguments[i] : {};
670
672
  var ownKeys = Object.keys(source);
@@ -674,7 +676,7 @@ function _object_spread$7(target) {
674
676
  }));
675
677
  }
676
678
  ownKeys.forEach(function(key) {
677
- _define_property$f(target, key, source[key]);
679
+ _define_property$h(target, key, source[key]);
678
680
  });
679
681
  }
680
682
  return target;
@@ -697,7 +699,7 @@ function _object_spread_props$3(target, source) {
697
699
  }
698
700
  return target;
699
701
  }
700
- function _ts_generator$a(thisArg, body) {
702
+ function _ts_generator$c(thisArg, body) {
701
703
  var f, y, t, _ = {
702
704
  label: 0,
703
705
  sent: function() {
@@ -798,27 +800,27 @@ function _ts_generator$a(thisArg, body) {
798
800
  }
799
801
  // MARK: Config
800
802
  var JwksServiceConfig = function JwksServiceConfig() {
801
- _class_call_check$g(this, JwksServiceConfig);
803
+ _class_call_check$h(this, JwksServiceConfig);
802
804
  };
803
805
  /**
804
806
  * If provided, the JwksService will write the JWKS to this file when keys are rotated.
805
807
  */ var JwksServiceStorageConfig = function JwksServiceStorageConfig() {
806
- _class_call_check$g(this, JwksServiceStorageConfig);
808
+ _class_call_check$h(this, JwksServiceStorageConfig);
807
809
  };
808
810
  var DEFAULT_ROTATED_KEY_MAX_AGE = 30 * 24 * 60 * 60; // 30 days
809
811
  // MARK: Service
810
812
  var JwksService = /*#__PURE__*/ function() {
811
813
  function JwksService(config, collections, storageConfig) {
812
814
  var _this = this;
813
- _class_call_check$g(this, JwksService);
815
+ _class_call_check$h(this, JwksService);
814
816
  var _config_rotatedKeyMaxAge, _config_enableSaveJwksToStorage, _config_serveJwksFromStorage;
815
- _define_property$f(this, "config", void 0);
816
- _define_property$f(this, "collections", void 0);
817
- _define_property$f(this, "storageConfig", void 0);
818
- _define_property$f(this, "_jwksStoragePublicUrl", cachedGetter(function() {
819
- return _async_to_generator$a(function() {
817
+ _define_property$h(this, "config", void 0);
818
+ _define_property$h(this, "collections", void 0);
819
+ _define_property$h(this, "storageConfig", void 0);
820
+ _define_property$h(this, "_jwksStoragePublicUrl", cachedGetter(function() {
821
+ return _async_to_generator$c(function() {
820
822
  var _this, _this_storageConfig, result, _file;
821
- return _ts_generator$a(this, function(_state) {
823
+ return _ts_generator$c(this, function(_state) {
822
824
  switch(_state.label){
823
825
  case 0:
824
826
  _this = this;
@@ -830,8 +832,8 @@ var JwksService = /*#__PURE__*/ function() {
830
832
  return [
831
833
  4,
832
834
  _file.getDownloadUrl().catch(function() {
833
- return _async_to_generator$a(function() {
834
- return _ts_generator$a(this, function(_state) {
835
+ return _async_to_generator$c(function() {
836
+ return _ts_generator$c(this, function(_state) {
835
837
  switch(_state.label){
836
838
  case 0:
837
839
  return [
@@ -864,13 +866,13 @@ var JwksService = /*#__PURE__*/ function() {
864
866
  });
865
867
  }).call(_this);
866
868
  }));
867
- _define_property$f(this, "rotatedKeyMaxAge", void 0);
869
+ _define_property$h(this, "rotatedKeyMaxAge", void 0);
868
870
  /**
869
871
  * Whether the JWKS is served from a public storage URL rather than the built-in endpoint.
870
- */ _define_property$f(this, "serveJwksFromStorage", void 0);
872
+ */ _define_property$h(this, "serveJwksFromStorage", void 0);
871
873
  /**
872
874
  * Whether the JWKS should be saved to storage when keys are rotated.
873
- */ _define_property$f(this, "saveJwksToStorage", void 0);
875
+ */ _define_property$h(this, "saveJwksToStorage", void 0);
874
876
  this.config = config;
875
877
  this.collections = collections;
876
878
  this.storageConfig = storageConfig;
@@ -879,7 +881,7 @@ var JwksService = /*#__PURE__*/ function() {
879
881
  this.saveJwksToStorage = (_config_enableSaveJwksToStorage = config.enableSaveJwksToStorage) !== null && _config_enableSaveJwksToStorage !== void 0 ? _config_enableSaveJwksToStorage : hasStorageFile;
880
882
  this.serveJwksFromStorage = (_config_serveJwksFromStorage = config.serveJwksFromStorage) !== null && _config_serveJwksFromStorage !== void 0 ? _config_serveJwksFromStorage : this.saveJwksToStorage;
881
883
  }
882
- _create_class$d(JwksService, [
884
+ _create_class$e(JwksService, [
883
885
  {
884
886
  key: "jwksKeyCollection",
885
887
  get: function get() {
@@ -897,9 +899,9 @@ var JwksService = /*#__PURE__*/ function() {
897
899
  *
898
900
  * @returns The generated key pair result containing the stored JwksKey and signing key.
899
901
  */ function generateKeyPair() {
900
- return _async_to_generator$a(function() {
902
+ return _async_to_generator$c(function() {
901
903
  var _generateKeyPairSync, publicKey, privateKey, kid, publicJwk, privateJwk, getKey, encryptedPrivateKey, data, doc;
902
- return _ts_generator$a(this, function(_state) {
904
+ return _ts_generator$c(this, function(_state) {
903
905
  switch(_state.label){
904
906
  case 0:
905
907
  _generateKeyPairSync = generateKeyPairSync('rsa', {
@@ -914,13 +916,13 @@ var JwksService = /*#__PURE__*/ function() {
914
916
  }
915
917
  }), publicKey = _generateKeyPairSync.publicKey, privateKey = _generateKeyPairSync.privateKey;
916
918
  kid = randomBytes(16).toString('hex');
917
- publicJwk = _object_spread_props$3(_object_spread$7({}, publicKey), {
919
+ publicJwk = _object_spread_props$3(_object_spread$9({}, publicKey), {
918
920
  kid: kid,
919
921
  kty: 'RSA',
920
922
  alg: 'RS256',
921
923
  use: 'sig'
922
924
  });
923
- privateJwk = _object_spread_props$3(_object_spread$7({}, privateKey), {
925
+ privateJwk = _object_spread_props$3(_object_spread$9({}, privateKey), {
924
926
  kid: kid,
925
927
  kty: 'RSA',
926
928
  alg: 'RS256',
@@ -960,9 +962,9 @@ var JwksService = /*#__PURE__*/ function() {
960
962
  *
961
963
  * @returns The active signing key's private JWK, or undefined if no active key exists.
962
964
  */ function getActiveSigningKey() {
963
- return _async_to_generator$a(function() {
965
+ return _async_to_generator$c(function() {
964
966
  var results, result, data, getKey;
965
- return _ts_generator$a(this, function(_state) {
967
+ return _ts_generator$c(this, function(_state) {
966
968
  switch(_state.label){
967
969
  case 0:
968
970
  return [
@@ -998,8 +1000,8 @@ var JwksService = /*#__PURE__*/ function() {
998
1000
  *
999
1001
  * @returns The public URL, or null/undefined if unavailable.
1000
1002
  */ function getJwksStoragePublicUrl() {
1001
- return _async_to_generator$a(function() {
1002
- return _ts_generator$a(this, function(_state) {
1003
+ return _async_to_generator$c(function() {
1004
+ return _ts_generator$c(this, function(_state) {
1003
1005
  return [
1004
1006
  2,
1005
1007
  this._jwksStoragePublicUrl()
@@ -1015,9 +1017,9 @@ var JwksService = /*#__PURE__*/ function() {
1015
1017
  *
1016
1018
  * @returns The public JWKS containing all non-retired signing keys.
1017
1019
  */ function getLatestPublicJwks() {
1018
- return _async_to_generator$a(function() {
1020
+ return _async_to_generator$c(function() {
1019
1021
  var keys;
1020
- return _ts_generator$a(this, function(_state) {
1022
+ return _ts_generator$c(this, function(_state) {
1021
1023
  switch(_state.label){
1022
1024
  case 0:
1023
1025
  keys = [];
@@ -1030,8 +1032,8 @@ var JwksService = /*#__PURE__*/ function() {
1030
1032
  return nonRetiredJwksKeysQuery();
1031
1033
  },
1032
1034
  iterateSnapshotPair: function iterateSnapshotPair(pair) {
1033
- return _async_to_generator$a(function() {
1034
- return _ts_generator$a(this, function(_state) {
1035
+ return _async_to_generator$c(function() {
1036
+ return _ts_generator$c(this, function(_state) {
1035
1037
  keys.push(pair.data.publicKey);
1036
1038
  return [
1037
1039
  2
@@ -1061,9 +1063,9 @@ var JwksService = /*#__PURE__*/ function() {
1061
1063
  *
1062
1064
  * @returns The newly generated active JwksKey.
1063
1065
  */ function rotateKeys() {
1064
- return _async_to_generator$a(function() {
1066
+ return _async_to_generator$c(function() {
1065
1067
  var now, expiresAt, _ref, newKey;
1066
- return _ts_generator$a(this, function(_state) {
1068
+ return _ts_generator$c(this, function(_state) {
1067
1069
  switch(_state.label){
1068
1070
  case 0:
1069
1071
  now = new Date();
@@ -1077,8 +1079,8 @@ var JwksService = /*#__PURE__*/ function() {
1077
1079
  return activeJwksKeysQuery();
1078
1080
  },
1079
1081
  iterateSnapshotPair: function iterateSnapshotPair(pair) {
1080
- return _async_to_generator$a(function() {
1081
- return _ts_generator$a(this, function(_state) {
1082
+ return _async_to_generator$c(function() {
1083
+ return _ts_generator$c(this, function(_state) {
1082
1084
  switch(_state.label){
1083
1085
  case 0:
1084
1086
  return [
@@ -1128,9 +1130,9 @@ var JwksService = /*#__PURE__*/ function() {
1128
1130
  {
1129
1131
  key: "_initializeKeysAndCloud",
1130
1132
  value: function _initializeKeysAndCloud() {
1131
- return _async_to_generator$a(function() {
1133
+ return _async_to_generator$c(function() {
1132
1134
  var jwks;
1133
- return _ts_generator$a(this, function(_state) {
1135
+ return _ts_generator$c(this, function(_state) {
1134
1136
  switch(_state.label){
1135
1137
  case 0:
1136
1138
  return [
@@ -1173,9 +1175,9 @@ var JwksService = /*#__PURE__*/ function() {
1173
1175
  {
1174
1176
  key: "_syncKeysToCloud",
1175
1177
  value: function _syncKeysToCloud() {
1176
- return _async_to_generator$a(function() {
1178
+ return _async_to_generator$c(function() {
1177
1179
  var _this_storageConfig, jwks, data, _this_storageConfig_jwksStorageAccessorFile_makePublic, _this_storageConfig_jwksStorageAccessorFile, e;
1178
- return _ts_generator$a(this, function(_state) {
1180
+ return _ts_generator$c(this, function(_state) {
1179
1181
  switch(_state.label){
1180
1182
  case 0:
1181
1183
  if (!(this.saveJwksToStorage && ((_this_storageConfig = this.storageConfig) === null || _this_storageConfig === void 0 ? void 0 : _this_storageConfig.jwksStorageAccessorFile))) return [
@@ -1241,9 +1243,9 @@ var JwksService = /*#__PURE__*/ function() {
1241
1243
  *
1242
1244
  * @returns The number of keys retired.
1243
1245
  */ function retireExpiredKeys() {
1244
- return _async_to_generator$a(function() {
1246
+ return _async_to_generator$c(function() {
1245
1247
  var now, count;
1246
- return _ts_generator$a(this, function(_state) {
1248
+ return _ts_generator$c(this, function(_state) {
1247
1249
  switch(_state.label){
1248
1250
  case 0:
1249
1251
  now = new Date();
@@ -1257,8 +1259,8 @@ var JwksService = /*#__PURE__*/ function() {
1257
1259
  return rotatedJwksKeysQuery();
1258
1260
  },
1259
1261
  iterateSnapshotPair: function iterateSnapshotPair(pair) {
1260
- return _async_to_generator$a(function() {
1261
- return _ts_generator$a(this, function(_state) {
1262
+ return _async_to_generator$c(function() {
1263
+ return _ts_generator$c(this, function(_state) {
1262
1264
  switch(_state.label){
1263
1265
  case 0:
1264
1266
  if (!(pair.data.expiresAt && pair.data.expiresAt <= now)) return [
@@ -1309,7 +1311,7 @@ JwksService = __decorate([
1309
1311
  __param(2, Inject(JwksServiceStorageConfig))
1310
1312
  ], JwksService);
1311
1313
 
1312
- function asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, key, arg) {
1314
+ function asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, key, arg) {
1313
1315
  try {
1314
1316
  var info = gen[key](arg);
1315
1317
  var value = info.value;
@@ -1320,25 +1322,25 @@ function asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, key, arg) {
1320
1322
  if (info.done) resolve(value);
1321
1323
  else Promise.resolve(value).then(_next, _throw);
1322
1324
  }
1323
- function _async_to_generator$9(fn) {
1325
+ function _async_to_generator$b(fn) {
1324
1326
  return function() {
1325
1327
  var self = this, args = arguments;
1326
1328
  return new Promise(function(resolve, reject) {
1327
1329
  var gen = fn.apply(self, args);
1328
1330
  function _next(value) {
1329
- asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, "next", value);
1331
+ asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "next", value);
1330
1332
  }
1331
1333
  function _throw(err) {
1332
- asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, "throw", err);
1334
+ asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "throw", err);
1333
1335
  }
1334
1336
  _next(undefined);
1335
1337
  });
1336
1338
  };
1337
1339
  }
1338
- function _class_call_check$f(instance, Constructor) {
1340
+ function _class_call_check$g(instance, Constructor) {
1339
1341
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
1340
1342
  }
1341
- function _defineProperties$c(target, props) {
1343
+ function _defineProperties$d(target, props) {
1342
1344
  for(var i = 0; i < props.length; i++){
1343
1345
  var descriptor = props[i];
1344
1346
  descriptor.enumerable = descriptor.enumerable || false;
@@ -1347,11 +1349,11 @@ function _defineProperties$c(target, props) {
1347
1349
  Object.defineProperty(target, descriptor.key, descriptor);
1348
1350
  }
1349
1351
  }
1350
- function _create_class$c(Constructor, protoProps, staticProps) {
1351
- if (protoProps) _defineProperties$c(Constructor.prototype, protoProps);
1352
+ function _create_class$d(Constructor, protoProps, staticProps) {
1353
+ if (protoProps) _defineProperties$d(Constructor.prototype, protoProps);
1352
1354
  return Constructor;
1353
1355
  }
1354
- function _define_property$e(obj, key, value) {
1356
+ function _define_property$g(obj, key, value) {
1355
1357
  if (key in obj) {
1356
1358
  Object.defineProperty(obj, key, {
1357
1359
  value: value,
@@ -1362,7 +1364,7 @@ function _define_property$e(obj, key, value) {
1362
1364
  } else obj[key] = value;
1363
1365
  return obj;
1364
1366
  }
1365
- function _ts_generator$9(thisArg, body) {
1367
+ function _ts_generator$b(thisArg, body) {
1366
1368
  var f, y, t, _ = {
1367
1369
  label: 0,
1368
1370
  sent: function() {
@@ -1504,7 +1506,7 @@ function _ts_generator$9(thisArg, body) {
1504
1506
  * };
1505
1507
  * ```
1506
1508
  */ var OidcAccountServiceDelegate = function OidcAccountServiceDelegate() {
1507
- _class_call_check$f(this, OidcAccountServiceDelegate);
1509
+ _class_call_check$g(this, OidcAccountServiceDelegate);
1508
1510
  };
1509
1511
  // MARK: User Context
1510
1512
  /**
@@ -1513,15 +1515,15 @@ function _ts_generator$9(thisArg, body) {
1513
1515
  * Created by {@link OidcAccountService.userContext} for a specific user ID.
1514
1516
  */ var OidcAccountServiceUserContext = /*#__PURE__*/ function() {
1515
1517
  function OidcAccountServiceUserContext(_service, _uid) {
1516
- _class_call_check$f(this, OidcAccountServiceUserContext);
1517
- _define_property$e(this, "_service", void 0);
1518
- _define_property$e(this, "_uid", void 0);
1519
- _define_property$e(this, "authUserContext", void 0);
1518
+ _class_call_check$g(this, OidcAccountServiceUserContext);
1519
+ _define_property$g(this, "_service", void 0);
1520
+ _define_property$g(this, "_uid", void 0);
1521
+ _define_property$g(this, "authUserContext", void 0);
1520
1522
  this._service = _service;
1521
1523
  this._uid = _uid;
1522
1524
  this.authUserContext = this._service.authService.userContext(this._uid);
1523
1525
  }
1524
- _create_class$c(OidcAccountServiceUserContext, [
1526
+ _create_class$d(OidcAccountServiceUserContext, [
1525
1527
  {
1526
1528
  key: "uid",
1527
1529
  get: function get() {
@@ -1544,9 +1546,9 @@ function _ts_generator$9(thisArg, body) {
1544
1546
  *
1545
1547
  * @returns The OIDC account for this user, or undefined if the user does not exist.
1546
1548
  */ function findAccount() {
1547
- return _async_to_generator$9(function() {
1549
+ return _async_to_generator$b(function() {
1548
1550
  var authUserContext, exists, result, delegate;
1549
- return _ts_generator$9(this, function(_state) {
1551
+ return _ts_generator$b(this, function(_state) {
1550
1552
  switch(_state.label){
1551
1553
  case 0:
1552
1554
  authUserContext = this.authUserContext;
@@ -1561,9 +1563,9 @@ function _ts_generator$9(thisArg, body) {
1561
1563
  result = {
1562
1564
  accountId: this._uid,
1563
1565
  claims: function claims(_use, scope) {
1564
- return _async_to_generator$9(function() {
1566
+ return _async_to_generator$b(function() {
1565
1567
  var scopes;
1566
- return _ts_generator$9(this, function(_state) {
1568
+ return _ts_generator$b(this, function(_state) {
1567
1569
  scopes = new Set(scope.split(' '));
1568
1570
  return [
1569
1571
  2,
@@ -1596,13 +1598,13 @@ function _ts_generator$9(thisArg, body) {
1596
1598
  * Register it as a provider using the `OidcAccountService` class as the injection token.
1597
1599
  */ var OidcAccountService = /*#__PURE__*/ function() {
1598
1600
  function OidcAccountService(authService, delegate) {
1599
- _class_call_check$f(this, OidcAccountService);
1600
- _define_property$e(this, "authService", void 0);
1601
- _define_property$e(this, "delegate", void 0);
1601
+ _class_call_check$g(this, OidcAccountService);
1602
+ _define_property$g(this, "authService", void 0);
1603
+ _define_property$g(this, "delegate", void 0);
1602
1604
  this.authService = authService;
1603
1605
  this.delegate = delegate;
1604
1606
  }
1605
- _create_class$c(OidcAccountService, [
1607
+ _create_class$d(OidcAccountService, [
1606
1608
  {
1607
1609
  key: "providerConfig",
1608
1610
  get: /**
@@ -1637,10 +1639,10 @@ function _call_super$1(_this, derived, args) {
1637
1639
  derived = _get_prototype_of$1(derived);
1638
1640
  return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, args || [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
1639
1641
  }
1640
- function _class_call_check$e(instance, Constructor) {
1642
+ function _class_call_check$f(instance, Constructor) {
1641
1643
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
1642
1644
  }
1643
- function _defineProperties$b(target, props) {
1645
+ function _defineProperties$c(target, props) {
1644
1646
  for(var i = 0; i < props.length; i++){
1645
1647
  var descriptor = props[i];
1646
1648
  descriptor.enumerable = descriptor.enumerable || false;
@@ -1649,8 +1651,8 @@ function _defineProperties$b(target, props) {
1649
1651
  Object.defineProperty(target, descriptor.key, descriptor);
1650
1652
  }
1651
1653
  }
1652
- function _create_class$b(Constructor, protoProps, staticProps) {
1653
- if (protoProps) _defineProperties$b(Constructor.prototype, protoProps);
1654
+ function _create_class$c(Constructor, protoProps, staticProps) {
1655
+ if (protoProps) _defineProperties$c(Constructor.prototype, protoProps);
1654
1656
  return Constructor;
1655
1657
  }
1656
1658
  function _get_prototype_of$1(o) {
@@ -1681,7 +1683,7 @@ function _is_native_reflect_construct$1() {
1681
1683
  })();
1682
1684
  }
1683
1685
  function _possible_constructor_return$1(self, call) {
1684
- if (call && (_type_of$1(call) === "object" || typeof call === "function")) return call;
1686
+ if (call && (_type_of$2(call) === "object" || typeof call === "function")) return call;
1685
1687
  return _assert_this_initialized$1(self);
1686
1688
  }
1687
1689
  function _set_prototype_of$1(o, p) {
@@ -1691,7 +1693,7 @@ function _set_prototype_of$1(o, p) {
1691
1693
  };
1692
1694
  return _set_prototype_of$1(o, p);
1693
1695
  }
1694
- function _type_of$1(obj) {
1696
+ function _type_of$2(obj) {
1695
1697
  "@swc/helpers - typeof";
1696
1698
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1697
1699
  }
@@ -1701,7 +1703,7 @@ function _type_of$1(obj) {
1701
1703
  *
1702
1704
  * Implementations provide concrete collection instances wired to a specific {@link FirestoreContext}.
1703
1705
  */ var JwksFirestoreCollections = function JwksFirestoreCollections() {
1704
- _class_call_check$e(this, JwksFirestoreCollections);
1706
+ _class_call_check$f(this, JwksFirestoreCollections);
1705
1707
  };
1706
1708
  // MARK: Identity
1707
1709
  /**
@@ -1714,10 +1716,10 @@ function _type_of$1(obj) {
1714
1716
  */ var JwksKeyDocument = /*#__PURE__*/ function(AbstractFirestoreDocument) {
1715
1717
  _inherits$1(JwksKeyDocument, AbstractFirestoreDocument);
1716
1718
  function JwksKeyDocument() {
1717
- _class_call_check$e(this, JwksKeyDocument);
1719
+ _class_call_check$f(this, JwksKeyDocument);
1718
1720
  return _call_super$1(this, JwksKeyDocument, arguments);
1719
1721
  }
1720
- _create_class$b(JwksKeyDocument, [
1722
+ _create_class$c(JwksKeyDocument, [
1721
1723
  {
1722
1724
  key: "modelIdentity",
1723
1725
  get: function get() {
@@ -1780,7 +1782,7 @@ function _type_of$1(obj) {
1780
1782
  });
1781
1783
  }
1782
1784
 
1783
- function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
1785
+ function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
1784
1786
  try {
1785
1787
  var info = gen[key](arg);
1786
1788
  var value = info.value;
@@ -1791,25 +1793,25 @@ function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
1791
1793
  if (info.done) resolve(value);
1792
1794
  else Promise.resolve(value).then(_next, _throw);
1793
1795
  }
1794
- function _async_to_generator$8(fn) {
1796
+ function _async_to_generator$a(fn) {
1795
1797
  return function() {
1796
1798
  var self = this, args = arguments;
1797
1799
  return new Promise(function(resolve, reject) {
1798
1800
  var gen = fn.apply(self, args);
1799
1801
  function _next(value) {
1800
- asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "next", value);
1802
+ asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "next", value);
1801
1803
  }
1802
1804
  function _throw(err) {
1803
- asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "throw", err);
1805
+ asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "throw", err);
1804
1806
  }
1805
1807
  _next(undefined);
1806
1808
  });
1807
1809
  };
1808
1810
  }
1809
- function _class_call_check$d(instance, Constructor) {
1811
+ function _class_call_check$e(instance, Constructor) {
1810
1812
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
1811
1813
  }
1812
- function _ts_generator$8(thisArg, body) {
1814
+ function _ts_generator$a(thisArg, body) {
1813
1815
  var f, y, t, _ = {
1814
1816
  label: 0,
1815
1817
  sent: function() {
@@ -1914,7 +1916,7 @@ function _ts_generator$8(thisArg, body) {
1914
1916
  *
1915
1917
  * @see {@link oidcModelServerActions} for the concrete implementation factory.
1916
1918
  */ var OidcModelServerActions = function OidcModelServerActions() {
1917
- _class_call_check$d(this, OidcModelServerActions);
1919
+ _class_call_check$e(this, OidcModelServerActions);
1918
1920
  };
1919
1921
  /**
1920
1922
  * Creates a concrete {@link OidcModelServerActions} implementation wired to the provided context.
@@ -1949,13 +1951,13 @@ function _ts_generator$8(thisArg, body) {
1949
1951
  */ function createOidcClientFactory(context) {
1950
1952
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1951
1953
  return firebaseServerActionTransformFunctionFactory(createOidcClientParamsType, function(params) {
1952
- return _async_to_generator$8(function() {
1953
- return _ts_generator$8(this, function(_state) {
1954
+ return _async_to_generator$a(function() {
1955
+ return _ts_generator$a(this, function(_state) {
1954
1956
  return [
1955
1957
  2,
1956
1958
  function() {
1957
- return _async_to_generator$8(function() {
1958
- return _ts_generator$8(this, function(_state) {
1959
+ return _async_to_generator$a(function() {
1960
+ return _ts_generator$a(this, function(_state) {
1959
1961
  return [
1960
1962
  2,
1961
1963
  oidcClientService.createClient(params)
@@ -1978,13 +1980,13 @@ function _ts_generator$8(thisArg, body) {
1978
1980
  */ function updateOidcClientFactory(context) {
1979
1981
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
1980
1982
  return firebaseServerActionTransformFunctionFactory(updateOidcClientParamsType, function(params) {
1981
- return _async_to_generator$8(function() {
1982
- return _ts_generator$8(this, function(_state) {
1983
+ return _async_to_generator$a(function() {
1984
+ return _ts_generator$a(this, function(_state) {
1983
1985
  return [
1984
1986
  2,
1985
1987
  function(document) {
1986
- return _async_to_generator$8(function() {
1987
- return _ts_generator$8(this, function(_state) {
1988
+ return _async_to_generator$a(function() {
1989
+ return _ts_generator$a(this, function(_state) {
1988
1990
  switch(_state.label){
1989
1991
  case 0:
1990
1992
  return [
@@ -2017,13 +2019,13 @@ function _ts_generator$8(thisArg, body) {
2017
2019
  */ function rotateOidcClientSecretFactory(context) {
2018
2020
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
2019
2021
  return firebaseServerActionTransformFunctionFactory(rotateOidcClientSecretParamsType, function(_params) {
2020
- return _async_to_generator$8(function() {
2021
- return _ts_generator$8(this, function(_state) {
2022
+ return _async_to_generator$a(function() {
2023
+ return _ts_generator$a(this, function(_state) {
2022
2024
  return [
2023
2025
  2,
2024
2026
  function(document) {
2025
- return _async_to_generator$8(function() {
2026
- return _ts_generator$8(this, function(_state) {
2027
+ return _async_to_generator$a(function() {
2028
+ return _ts_generator$a(this, function(_state) {
2027
2029
  return [
2028
2030
  2,
2029
2031
  oidcClientService.rotateClientSecret(document.id)
@@ -2046,13 +2048,13 @@ function _ts_generator$8(thisArg, body) {
2046
2048
  */ function deleteOidcClientFactory(context) {
2047
2049
  var oidcClientService = context.oidcClientService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
2048
2050
  return firebaseServerActionTransformFunctionFactory(deleteOidcClientParamsType, function(_params) {
2049
- return _async_to_generator$8(function() {
2050
- return _ts_generator$8(this, function(_state) {
2051
+ return _async_to_generator$a(function() {
2052
+ return _ts_generator$a(this, function(_state) {
2051
2053
  return [
2052
2054
  2,
2053
2055
  function(document) {
2054
- return _async_to_generator$8(function() {
2055
- return _ts_generator$8(this, function(_state) {
2056
+ return _async_to_generator$a(function() {
2057
+ return _ts_generator$a(this, function(_state) {
2056
2058
  switch(_state.label){
2057
2059
  case 0:
2058
2060
  return [
@@ -2089,14 +2091,14 @@ function _ts_generator$8(thisArg, body) {
2089
2091
  */ function deleteOidcTokenFactory(context) {
2090
2092
  var oidcService = context.oidcService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
2091
2093
  return firebaseServerActionTransformFunctionFactory(deleteOidcTokenParamsType, function(_params) {
2092
- return _async_to_generator$8(function() {
2093
- return _ts_generator$8(this, function(_state) {
2094
+ return _async_to_generator$a(function() {
2095
+ return _ts_generator$a(this, function(_state) {
2094
2096
  return [
2095
2097
  2,
2096
2098
  function(document) {
2097
- return _async_to_generator$8(function() {
2099
+ return _async_to_generator$a(function() {
2098
2100
  var data;
2099
- return _ts_generator$8(this, function(_state) {
2101
+ return _ts_generator$a(this, function(_state) {
2100
2102
  switch(_state.label){
2101
2103
  case 0:
2102
2104
  return [
@@ -2127,7 +2129,7 @@ function _ts_generator$8(thisArg, body) {
2127
2129
  });
2128
2130
  }
2129
2131
 
2130
- function asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, key, arg) {
2132
+ function asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, key, arg) {
2131
2133
  try {
2132
2134
  var info = gen[key](arg);
2133
2135
  var value = info.value;
@@ -2138,25 +2140,25 @@ function asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, key, arg) {
2138
2140
  if (info.done) resolve(value);
2139
2141
  else Promise.resolve(value).then(_next, _throw);
2140
2142
  }
2141
- function _async_to_generator$7(fn) {
2143
+ function _async_to_generator$9(fn) {
2142
2144
  return function() {
2143
2145
  var self = this, args = arguments;
2144
2146
  return new Promise(function(resolve, reject) {
2145
2147
  var gen = fn.apply(self, args);
2146
2148
  function _next(value) {
2147
- asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "next", value);
2149
+ asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, "next", value);
2148
2150
  }
2149
2151
  function _throw(err) {
2150
- asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "throw", err);
2152
+ asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, "throw", err);
2151
2153
  }
2152
2154
  _next(undefined);
2153
2155
  });
2154
2156
  };
2155
2157
  }
2156
- function _class_call_check$c(instance, Constructor) {
2158
+ function _class_call_check$d(instance, Constructor) {
2157
2159
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
2158
2160
  }
2159
- function _defineProperties$a(target, props) {
2161
+ function _defineProperties$b(target, props) {
2160
2162
  for(var i = 0; i < props.length; i++){
2161
2163
  var descriptor = props[i];
2162
2164
  descriptor.enumerable = descriptor.enumerable || false;
@@ -2165,11 +2167,11 @@ function _defineProperties$a(target, props) {
2165
2167
  Object.defineProperty(target, descriptor.key, descriptor);
2166
2168
  }
2167
2169
  }
2168
- function _create_class$a(Constructor, protoProps, staticProps) {
2169
- if (protoProps) _defineProperties$a(Constructor.prototype, protoProps);
2170
+ function _create_class$b(Constructor, protoProps, staticProps) {
2171
+ if (protoProps) _defineProperties$b(Constructor.prototype, protoProps);
2170
2172
  return Constructor;
2171
2173
  }
2172
- function _define_property$d(obj, key, value) {
2174
+ function _define_property$f(obj, key, value) {
2173
2175
  if (key in obj) {
2174
2176
  Object.defineProperty(obj, key, {
2175
2177
  value: value,
@@ -2180,7 +2182,7 @@ function _define_property$d(obj, key, value) {
2180
2182
  } else obj[key] = value;
2181
2183
  return obj;
2182
2184
  }
2183
- function _object_spread$6(target) {
2185
+ function _object_spread$8(target) {
2184
2186
  for(var i = 1; i < arguments.length; i++){
2185
2187
  var source = arguments[i] != null ? arguments[i] : {};
2186
2188
  var ownKeys = Object.keys(source);
@@ -2190,7 +2192,7 @@ function _object_spread$6(target) {
2190
2192
  }));
2191
2193
  }
2192
2194
  ownKeys.forEach(function(key) {
2193
- _define_property$d(target, key, source[key]);
2195
+ _define_property$f(target, key, source[key]);
2194
2196
  });
2195
2197
  }
2196
2198
  return target;
@@ -2213,7 +2215,7 @@ function _object_spread_props$2(target, source) {
2213
2215
  }
2214
2216
  return target;
2215
2217
  }
2216
- function _ts_generator$7(thisArg, body) {
2218
+ function _ts_generator$9(thisArg, body) {
2217
2219
  var f, y, t, _ = {
2218
2220
  label: 0,
2219
2221
  sent: function() {
@@ -2324,11 +2326,11 @@ function _ts_generator$7(thisArg, body) {
2324
2326
  * with the acting user — not by the OIDC analytics service.
2325
2327
  */ var OidcClientService = /*#__PURE__*/ function() {
2326
2328
  function OidcClientService(oidcService) {
2327
- _class_call_check$c(this, OidcClientService);
2328
- _define_property$d(this, "oidcService", void 0);
2329
+ _class_call_check$d(this, OidcClientService);
2330
+ _define_property$f(this, "oidcService", void 0);
2329
2331
  this.oidcService = oidcService;
2330
2332
  }
2331
- _create_class$a(OidcClientService, [
2333
+ _create_class$b(OidcClientService, [
2332
2334
  {
2333
2335
  key: "createClient",
2334
2336
  value: /**
@@ -2348,9 +2350,9 @@ function _ts_generator$7(thisArg, body) {
2348
2350
  * and should not be exposed through the API params.
2349
2351
  * @returns The generated client ID and, for secret-based methods, the secret (plaintext, returned only once).
2350
2352
  */ function createClient(params, validatedMetadata) {
2351
- return _async_to_generator$7(function() {
2353
+ return _async_to_generator$9(function() {
2352
2354
  var provider, ProviderClient, clientId, firestoreOwnerKey, properties, clientSecret, client, payload;
2353
- return _ts_generator$7(this, function(_state) {
2355
+ return _ts_generator$9(this, function(_state) {
2354
2356
  switch(_state.label){
2355
2357
  case 0:
2356
2358
  return [
@@ -2448,9 +2450,9 @@ function _ts_generator$7(thisArg, body) {
2448
2450
  * @param params - The fields to update.
2449
2451
  * @throws {Error} When the client is not found.
2450
2452
  */ function updateClient(clientId, params) {
2451
- return _async_to_generator$7(function() {
2453
+ return _async_to_generator$9(function() {
2452
2454
  var provider, ProviderClient, existing, updatedMetadata, _params_logo_uri, _params_client_uri, _params_dbx_max_session_ttl, _params_dbx_provider_profiles, client;
2453
- return _ts_generator$7(this, function(_state) {
2455
+ return _ts_generator$9(this, function(_state) {
2454
2456
  switch(_state.label){
2455
2457
  case 0:
2456
2458
  return [
@@ -2469,7 +2471,7 @@ function _ts_generator$7(thisArg, body) {
2469
2471
  if (!existing) {
2470
2472
  throw new Error('Client not found.');
2471
2473
  }
2472
- updatedMetadata = _object_spread$6({}, existing);
2474
+ updatedMetadata = _object_spread$8({}, existing);
2473
2475
  updatedMetadata.client_name = params.client_name;
2474
2476
  updatedMetadata.redirect_uris = params.redirect_uris;
2475
2477
  if (params.logo_uri !== undefined) {
@@ -2524,9 +2526,9 @@ function _ts_generator$7(thisArg, body) {
2524
2526
  * @returns The client ID and new secret (plaintext, returned only once).
2525
2527
  * @throws {Error} When the client is not found, or is a public PKCE (`none`) client.
2526
2528
  */ function rotateClientSecret(clientId) {
2527
- return _async_to_generator$7(function() {
2529
+ return _async_to_generator$9(function() {
2528
2530
  var provider, ProviderClient, existing, newSecret, updatedMetadata, client;
2529
- return _ts_generator$7(this, function(_state) {
2531
+ return _ts_generator$9(this, function(_state) {
2530
2532
  switch(_state.label){
2531
2533
  case 0:
2532
2534
  return [
@@ -2549,7 +2551,7 @@ function _ts_generator$7(thisArg, body) {
2549
2551
  throw new Error('Cannot rotate a client secret for a public PKCE client (token_endpoint_auth_method "none"). Public clients have no secret.');
2550
2552
  }
2551
2553
  newSecret = randomBytes(64).toString('base64url');
2552
- updatedMetadata = _object_spread_props$2(_object_spread$6({}, existing), {
2554
+ updatedMetadata = _object_spread_props$2(_object_spread$8({}, existing), {
2553
2555
  client_secret: newSecret,
2554
2556
  client_secret_expires_at: 0
2555
2557
  });
@@ -2586,9 +2588,9 @@ function _ts_generator$7(thisArg, body) {
2586
2588
  * @param clientId - The client's document/adapter entry ID.
2587
2589
  * @throws {Error} When the client is not found.
2588
2590
  */ function deleteClient(clientId) {
2589
- return _async_to_generator$7(function() {
2591
+ return _async_to_generator$9(function() {
2590
2592
  var provider, ProviderClient, existing;
2591
- return _ts_generator$7(this, function(_state) {
2593
+ return _ts_generator$9(this, function(_state) {
2592
2594
  switch(_state.label){
2593
2595
  case 0:
2594
2596
  return [
@@ -2626,7 +2628,7 @@ function _ts_generator$7(thisArg, body) {
2626
2628
  }
2627
2629
  ();
2628
2630
 
2629
- function _define_property$c(obj, key, value) {
2631
+ function _define_property$e(obj, key, value) {
2630
2632
  if (key in obj) {
2631
2633
  Object.defineProperty(obj, key, {
2632
2634
  value: value,
@@ -2637,7 +2639,7 @@ function _define_property$c(obj, key, value) {
2637
2639
  } else obj[key] = value;
2638
2640
  return obj;
2639
2641
  }
2640
- function _object_spread$5(target) {
2642
+ function _object_spread$7(target) {
2641
2643
  for(var i = 1; i < arguments.length; i++){
2642
2644
  var source = arguments[i] != null ? arguments[i] : {};
2643
2645
  var ownKeys = Object.keys(source);
@@ -2647,7 +2649,7 @@ function _object_spread$5(target) {
2647
2649
  }));
2648
2650
  }
2649
2651
  ownKeys.forEach(function(key) {
2650
- _define_property$c(target, key, source[key]);
2652
+ _define_property$e(target, key, source[key]);
2651
2653
  });
2652
2654
  }
2653
2655
  return target;
@@ -2678,7 +2680,7 @@ function _object_spread_props$1(target, source) {
2678
2680
  * @param oidcService - The core OIDC service for grant revocation.
2679
2681
  * @returns The configured OidcModelServerActions instance.
2680
2682
  */ function oidcModelServerActionsFactory(oidcClientService, oidcService) {
2681
- var context = _object_spread_props$1(_object_spread$5({}, firebaseServerActionsContext()), {
2683
+ var context = _object_spread_props$1(_object_spread$7({}, firebaseServerActionsContext()), {
2682
2684
  oidcClientService: oidcClientService,
2683
2685
  oidcService: oidcService
2684
2686
  });
@@ -2714,7 +2716,7 @@ function _object_spread_props$1(target, source) {
2714
2716
  };
2715
2717
  }
2716
2718
 
2717
- function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
2719
+ function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
2718
2720
  try {
2719
2721
  var info = gen[key](arg);
2720
2722
  var value = info.value;
@@ -2725,25 +2727,25 @@ function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
2725
2727
  if (info.done) resolve(value);
2726
2728
  else Promise.resolve(value).then(_next, _throw);
2727
2729
  }
2728
- function _async_to_generator$6(fn) {
2730
+ function _async_to_generator$8(fn) {
2729
2731
  return function() {
2730
2732
  var self = this, args = arguments;
2731
2733
  return new Promise(function(resolve, reject) {
2732
2734
  var gen = fn.apply(self, args);
2733
2735
  function _next(value) {
2734
- asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "next", value);
2736
+ asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "next", value);
2735
2737
  }
2736
2738
  function _throw(err) {
2737
- asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "throw", err);
2739
+ asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, "throw", err);
2738
2740
  }
2739
2741
  _next(undefined);
2740
2742
  });
2741
2743
  };
2742
2744
  }
2743
- function _class_call_check$b(instance, Constructor) {
2745
+ function _class_call_check$c(instance, Constructor) {
2744
2746
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
2745
2747
  }
2746
- function _defineProperties$9(target, props) {
2748
+ function _defineProperties$a(target, props) {
2747
2749
  for(var i = 0; i < props.length; i++){
2748
2750
  var descriptor = props[i];
2749
2751
  descriptor.enumerable = descriptor.enumerable || false;
@@ -2752,11 +2754,11 @@ function _defineProperties$9(target, props) {
2752
2754
  Object.defineProperty(target, descriptor.key, descriptor);
2753
2755
  }
2754
2756
  }
2755
- function _create_class$9(Constructor, protoProps, staticProps) {
2756
- if (protoProps) _defineProperties$9(Constructor.prototype, protoProps);
2757
+ function _create_class$a(Constructor, protoProps, staticProps) {
2758
+ if (protoProps) _defineProperties$a(Constructor.prototype, protoProps);
2757
2759
  return Constructor;
2758
2760
  }
2759
- function _define_property$b(obj, key, value) {
2761
+ function _define_property$d(obj, key, value) {
2760
2762
  if (key in obj) {
2761
2763
  Object.defineProperty(obj, key, {
2762
2764
  value: value,
@@ -2773,7 +2775,7 @@ function _instanceof$3(left, right) {
2773
2775
  return !!right[Symbol.hasInstance](left);
2774
2776
  } else return left instanceof right;
2775
2777
  }
2776
- function _object_spread$4(target) {
2778
+ function _object_spread$6(target) {
2777
2779
  for(var i = 1; i < arguments.length; i++){
2778
2780
  var source = arguments[i] != null ? arguments[i] : {};
2779
2781
  var ownKeys = Object.keys(source);
@@ -2783,12 +2785,12 @@ function _object_spread$4(target) {
2783
2785
  }));
2784
2786
  }
2785
2787
  ownKeys.forEach(function(key) {
2786
- _define_property$b(target, key, source[key]);
2788
+ _define_property$d(target, key, source[key]);
2787
2789
  });
2788
2790
  }
2789
2791
  return target;
2790
2792
  }
2791
- function _ts_generator$6(thisArg, body) {
2793
+ function _ts_generator$8(thisArg, body) {
2792
2794
  var f, y, t, _ = {
2793
2795
  label: 0,
2794
2796
  sent: function() {
@@ -2917,19 +2919,19 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
2917
2919
  */ function createAdapterFactory(collections, encryptionService) {
2918
2920
  var FirestoreAdapter = /*#__PURE__*/ function() {
2919
2921
  function FirestoreAdapter(name) {
2920
- _class_call_check$b(this, FirestoreAdapter);
2921
- _define_property$b(this, "name", void 0);
2922
- _define_property$b(this, "collection", void 0);
2922
+ _class_call_check$c(this, FirestoreAdapter);
2923
+ _define_property$d(this, "name", void 0);
2924
+ _define_property$d(this, "collection", void 0);
2923
2925
  this.name = name;
2924
2926
  this.collection = collections.oidcEntryCollection;
2925
2927
  }
2926
- _create_class$9(FirestoreAdapter, [
2928
+ _create_class$a(FirestoreAdapter, [
2927
2929
  {
2928
2930
  key: "upsert",
2929
2931
  value: function upsert(id, payload, expiresIn) {
2930
- return _async_to_generator$6(function() {
2932
+ return _async_to_generator$8(function() {
2931
2933
  var _payload_uid, _payload_clientId, o, uid, clientId, iat, createdAtIso, createdAt, data, doc;
2932
- return _ts_generator$6(this, function(_state) {
2934
+ return _ts_generator$8(this, function(_state) {
2933
2935
  switch(_state.label){
2934
2936
  case 0:
2935
2937
  // Set ownership key for Client entries so firestore rules can restrict reads by owner.
@@ -2954,7 +2956,7 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
2954
2956
  } else if (createdAtIso) {
2955
2957
  createdAt = safeToJsDate(createdAtIso);
2956
2958
  }
2957
- data = _object_spread$4({
2959
+ data = _object_spread$6({
2958
2960
  type: this.name,
2959
2961
  payload: encryptionService.encryptAdapterPayload(payload),
2960
2962
  o: o,
@@ -2988,9 +2990,9 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
2988
2990
  {
2989
2991
  key: "find",
2990
2992
  value: function find(id) {
2991
- return _async_to_generator$6(function() {
2993
+ return _async_to_generator$8(function() {
2992
2994
  var doc, snapshot, data;
2993
- return _ts_generator$6(this, function(_state) {
2995
+ return _ts_generator$8(this, function(_state) {
2994
2996
  switch(_state.label){
2995
2997
  case 0:
2996
2998
  doc = this.collection.documentAccessor().loadDocumentForId(id);
@@ -3013,9 +3015,9 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
3013
3015
  {
3014
3016
  key: "findByUserCode",
3015
3017
  value: function findByUserCode(userCode) {
3016
- return _async_to_generator$6(function() {
3018
+ return _async_to_generator$8(function() {
3017
3019
  var results;
3018
- return _ts_generator$6(this, function(_state) {
3020
+ return _ts_generator$8(this, function(_state) {
3019
3021
  switch(_state.label){
3020
3022
  case 0:
3021
3023
  return [
@@ -3036,9 +3038,9 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
3036
3038
  {
3037
3039
  key: "findByUid",
3038
3040
  value: function findByUid(uid) {
3039
- return _async_to_generator$6(function() {
3041
+ return _async_to_generator$8(function() {
3040
3042
  var results;
3041
- return _ts_generator$6(this, function(_state) {
3043
+ return _ts_generator$8(this, function(_state) {
3042
3044
  switch(_state.label){
3043
3045
  case 0:
3044
3046
  return [
@@ -3059,9 +3061,9 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
3059
3061
  {
3060
3062
  key: "consume",
3061
3063
  value: function consume(id) {
3062
- return _async_to_generator$6(function() {
3064
+ return _async_to_generator$8(function() {
3063
3065
  var now, doc, snapshot, data, payload;
3064
- return _ts_generator$6(this, function(_state) {
3066
+ return _ts_generator$8(this, function(_state) {
3065
3067
  switch(_state.label){
3066
3068
  case 0:
3067
3069
  now = unixDateTimeSecondsNumberForNow();
@@ -3103,9 +3105,9 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
3103
3105
  {
3104
3106
  key: "destroy",
3105
3107
  value: function destroy(id) {
3106
- return _async_to_generator$6(function() {
3108
+ return _async_to_generator$8(function() {
3107
3109
  var doc;
3108
- return _ts_generator$6(this, function(_state) {
3110
+ return _ts_generator$8(this, function(_state) {
3109
3111
  switch(_state.label){
3110
3112
  case 0:
3111
3113
  doc = this.collection.documentAccessor().loadDocumentForId(id);
@@ -3126,9 +3128,9 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
3126
3128
  {
3127
3129
  key: "revokeByGrantId",
3128
3130
  value: function revokeByGrantId(grantId) {
3129
- return _async_to_generator$6(function() {
3131
+ return _async_to_generator$8(function() {
3130
3132
  var _this, results;
3131
- return _ts_generator$6(this, function(_state) {
3133
+ return _ts_generator$8(this, function(_state) {
3132
3134
  switch(_state.label){
3133
3135
  case 0:
3134
3136
  _this = this;
@@ -3188,18 +3190,18 @@ var GRANTABLE_MODELS = new Set(GRANTABLE_MODEL_NAMES);
3188
3190
  return FirestoreAdapter;
3189
3191
  }
3190
3192
 
3191
- function _array_like_to_array$7(arr, len) {
3193
+ function _array_like_to_array$a(arr, len) {
3192
3194
  if (len == null || len > arr.length) len = arr.length;
3193
3195
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3194
3196
  return arr2;
3195
3197
  }
3196
- function _array_without_holes$7(arr) {
3197
- if (Array.isArray(arr)) return _array_like_to_array$7(arr);
3198
+ function _array_without_holes$a(arr) {
3199
+ if (Array.isArray(arr)) return _array_like_to_array$a(arr);
3198
3200
  }
3199
- function _class_call_check$a(instance, Constructor) {
3201
+ function _class_call_check$b(instance, Constructor) {
3200
3202
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
3201
3203
  }
3202
- function _defineProperties$8(target, props) {
3204
+ function _defineProperties$9(target, props) {
3203
3205
  for(var i = 0; i < props.length; i++){
3204
3206
  var descriptor = props[i];
3205
3207
  descriptor.enumerable = descriptor.enumerable || false;
@@ -3208,11 +3210,11 @@ function _defineProperties$8(target, props) {
3208
3210
  Object.defineProperty(target, descriptor.key, descriptor);
3209
3211
  }
3210
3212
  }
3211
- function _create_class$8(Constructor, protoProps, staticProps) {
3212
- if (protoProps) _defineProperties$8(Constructor.prototype, protoProps);
3213
+ function _create_class$9(Constructor, protoProps, staticProps) {
3214
+ if (protoProps) _defineProperties$9(Constructor.prototype, protoProps);
3213
3215
  return Constructor;
3214
3216
  }
3215
- function _define_property$a(obj, key, value) {
3217
+ function _define_property$c(obj, key, value) {
3216
3218
  if (key in obj) {
3217
3219
  Object.defineProperty(obj, key, {
3218
3220
  value: value,
@@ -3223,24 +3225,24 @@ function _define_property$a(obj, key, value) {
3223
3225
  } else obj[key] = value;
3224
3226
  return obj;
3225
3227
  }
3226
- function _iterable_to_array$7(iter) {
3228
+ function _iterable_to_array$a(iter) {
3227
3229
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
3228
3230
  return Array.from(iter);
3229
3231
  }
3230
3232
  }
3231
- function _non_iterable_spread$7() {
3233
+ function _non_iterable_spread$a() {
3232
3234
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3233
3235
  }
3234
- function _to_consumable_array$7(arr) {
3235
- return _array_without_holes$7(arr) || _iterable_to_array$7(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$7();
3236
+ function _to_consumable_array$a(arr) {
3237
+ return _array_without_holes$a(arr) || _iterable_to_array$a(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$a();
3236
3238
  }
3237
- function _unsupported_iterable_to_array$7(o, minLen) {
3239
+ function _unsupported_iterable_to_array$a(o, minLen) {
3238
3240
  if (!o) return;
3239
- if (typeof o === "string") return _array_like_to_array$7(o, minLen);
3241
+ if (typeof o === "string") return _array_like_to_array$a(o, minLen);
3240
3242
  var n = Object.prototype.toString.call(o).slice(8, -1);
3241
3243
  if (n === "Object" && o.constructor) n = o.constructor.name;
3242
3244
  if (n === "Map" || n === "Set") return Array.from(n);
3243
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
3245
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
3244
3246
  }
3245
3247
  // MARK: Encrypted Fields
3246
3248
  /**
@@ -3262,16 +3264,16 @@ function _unsupported_iterable_to_array$7(o, minLen) {
3262
3264
  * the OIDC model server actions.
3263
3265
  */ var OidcEncryptionService = /*#__PURE__*/ function() {
3264
3266
  function OidcEncryptionService(config) {
3265
- _class_call_check$a(this, OidcEncryptionService);
3266
- _define_property$a(this, "provider", void 0);
3267
- _define_property$a(this, "adapterPayloadEncryptor", void 0);
3267
+ _class_call_check$b(this, OidcEncryptionService);
3268
+ _define_property$c(this, "provider", void 0);
3269
+ _define_property$c(this, "adapterPayloadEncryptor", void 0);
3268
3270
  this.provider = createAesStringEncryptionProvider(config.jwksKeyConverterConfig.encryptionSecret);
3269
3271
  this.adapterPayloadEncryptor = selectiveFieldEncryptor({
3270
3272
  provider: this.provider,
3271
- fields: _to_consumable_array$7(OIDC_ENCRYPTED_PAYLOAD_FIELDS)
3273
+ fields: _to_consumable_array$a(OIDC_ENCRYPTED_PAYLOAD_FIELDS)
3272
3274
  });
3273
3275
  }
3274
- _create_class$8(OidcEncryptionService, [
3276
+ _create_class$9(OidcEncryptionService, [
3275
3277
  {
3276
3278
  /**
3277
3279
  * Encrypts sensitive fields in an adapter payload and returns it as a {@link JsonSerializableObject}
@@ -3304,18 +3306,18 @@ OidcEncryptionService = __decorate([
3304
3306
  __param(0, Inject(OidcModuleConfig))
3305
3307
  ], OidcEncryptionService);
3306
3308
 
3307
- function _array_like_to_array$6(arr, len) {
3309
+ function _array_like_to_array$9(arr, len) {
3308
3310
  if (len == null || len > arr.length) len = arr.length;
3309
3311
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3310
3312
  return arr2;
3311
3313
  }
3312
- function _array_without_holes$6(arr) {
3313
- if (Array.isArray(arr)) return _array_like_to_array$6(arr);
3314
+ function _array_without_holes$9(arr) {
3315
+ if (Array.isArray(arr)) return _array_like_to_array$9(arr);
3314
3316
  }
3315
- function _class_call_check$9(instance, Constructor) {
3317
+ function _class_call_check$a(instance, Constructor) {
3316
3318
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
3317
3319
  }
3318
- function _defineProperties$7(target, props) {
3320
+ function _defineProperties$8(target, props) {
3319
3321
  for(var i = 0; i < props.length; i++){
3320
3322
  var descriptor = props[i];
3321
3323
  descriptor.enumerable = descriptor.enumerable || false;
@@ -3324,11 +3326,11 @@ function _defineProperties$7(target, props) {
3324
3326
  Object.defineProperty(target, descriptor.key, descriptor);
3325
3327
  }
3326
3328
  }
3327
- function _create_class$7(Constructor, protoProps, staticProps) {
3328
- if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);
3329
+ function _create_class$8(Constructor, protoProps, staticProps) {
3330
+ if (protoProps) _defineProperties$8(Constructor.prototype, protoProps);
3329
3331
  return Constructor;
3330
3332
  }
3331
- function _define_property$9(obj, key, value) {
3333
+ function _define_property$b(obj, key, value) {
3332
3334
  if (key in obj) {
3333
3335
  Object.defineProperty(obj, key, {
3334
3336
  value: value,
@@ -3339,24 +3341,24 @@ function _define_property$9(obj, key, value) {
3339
3341
  } else obj[key] = value;
3340
3342
  return obj;
3341
3343
  }
3342
- function _iterable_to_array$6(iter) {
3344
+ function _iterable_to_array$9(iter) {
3343
3345
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
3344
3346
  return Array.from(iter);
3345
3347
  }
3346
3348
  }
3347
- function _non_iterable_spread$6() {
3349
+ function _non_iterable_spread$9() {
3348
3350
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3349
3351
  }
3350
- function _to_consumable_array$6(arr) {
3351
- return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$6();
3352
+ function _to_consumable_array$9(arr) {
3353
+ return _array_without_holes$9(arr) || _iterable_to_array$9(arr) || _unsupported_iterable_to_array$9(arr) || _non_iterable_spread$9();
3352
3354
  }
3353
- function _unsupported_iterable_to_array$6(o, minLen) {
3355
+ function _unsupported_iterable_to_array$9(o, minLen) {
3354
3356
  if (!o) return;
3355
- if (typeof o === "string") return _array_like_to_array$6(o, minLen);
3357
+ if (typeof o === "string") return _array_like_to_array$9(o, minLen);
3356
3358
  var n = Object.prototype.toString.call(o).slice(8, -1);
3357
3359
  if (n === "Object" && o.constructor) n = o.constructor.name;
3358
3360
  if (n === "Map" || n === "Set") return Array.from(n);
3359
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
3361
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
3360
3362
  }
3361
3363
  // MARK: Routes
3362
3364
  /**
@@ -3404,25 +3406,25 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
3404
3406
  * Injected into {@link OidcService} and {@link OidcWellKnownController}.
3405
3407
  */ var OidcProviderConfigService = /*#__PURE__*/ function() {
3406
3408
  function OidcProviderConfigService(config, accountService, envService) {
3407
- _class_call_check$9(this, OidcProviderConfigService);
3409
+ _class_call_check$a(this, OidcProviderConfigService);
3408
3410
  var _this_providerConfig_providerProfiles, _this_config_tokenEndpointAuthMethods;
3409
- _define_property$9(this, "config", void 0);
3410
- _define_property$9(this, "routes", DEFAULT_OIDC_ROUTES);
3411
+ _define_property$b(this, "config", void 0);
3412
+ _define_property$b(this, "routes", DEFAULT_OIDC_ROUTES);
3411
3413
  /**
3412
3414
  * If the OIDC registration route is enabled.
3413
- */ _define_property$9(this, "oidcRegistrationRouteEnabled", void 0);
3415
+ */ _define_property$b(this, "oidcRegistrationRouteEnabled", void 0);
3414
3416
  /**
3415
3417
  * The url to the front-end login page.
3416
- */ _define_property$9(this, "appLoginUrl", void 0);
3418
+ */ _define_property$b(this, "appLoginUrl", void 0);
3417
3419
  /**
3418
3420
  * The url to the front-end consent page.
3419
- */ _define_property$9(this, "appConsentUrl", void 0);
3421
+ */ _define_property$b(this, "appConsentUrl", void 0);
3420
3422
  /**
3421
3423
  * The app-provided provider config from the delegate.
3422
- */ _define_property$9(this, "providerConfig", void 0);
3424
+ */ _define_property$b(this, "providerConfig", void 0);
3423
3425
  /**
3424
3426
  * Scopes derived from the claims configuration keys.
3425
- */ _define_property$9(this, "scopesSupported", void 0);
3427
+ */ _define_property$b(this, "scopesSupported", void 0);
3426
3428
  /**
3427
3429
  * {@link scopesSupported} minus the scopes only an admin-assigned {@link OidcProviderProfile}
3428
3430
  * unlocks — what an arbitrary client (a dynamically registered one included) may actually put in
@@ -3435,13 +3437,13 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
3435
3437
  * verbatim onto `/authorize`. An assignment-only scope advertised there ends the flow in
3436
3438
  * `access_denied`: the consent unlock gate judges the REQUEST, so unlike an admin-only scope
3437
3439
  * there is no deselect-at-consent way through.
3438
- */ _define_property$9(this, "clientRequestableScopesSupported", void 0);
3440
+ */ _define_property$b(this, "clientRequestableScopesSupported", void 0);
3439
3441
  /**
3440
3442
  * Flat list of all unique claim names from the claims configuration.
3441
- */ _define_property$9(this, "claimsSupported", void 0);
3443
+ */ _define_property$b(this, "claimsSupported", void 0);
3442
3444
  /**
3443
3445
  * Token endpoint authentication methods from config or defaults.
3444
- */ _define_property$9(this, "tokenEndpointAuthMethodsSupported", void 0);
3446
+ */ _define_property$b(this, "tokenEndpointAuthMethodsSupported", void 0);
3445
3447
  this.config = config;
3446
3448
  this.providerConfig = accountService.providerConfig;
3447
3449
  this.scopesSupported = Object.keys(this.providerConfig.claims);
@@ -3450,7 +3452,7 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
3450
3452
  return !assignmentOnlyScopes.has(scope);
3451
3453
  });
3452
3454
  this.claimsSupported = Array.from(new Set(Object.values(this.providerConfig.claims).flat()));
3453
- this.tokenEndpointAuthMethodsSupported = (_this_config_tokenEndpointAuthMethods = this.config.tokenEndpointAuthMethods) !== null && _this_config_tokenEndpointAuthMethods !== void 0 ? _this_config_tokenEndpointAuthMethods : _to_consumable_array$6(DEFAULT_OIDC_TOKEN_ENDPOINT_AUTH_METHODS);
3455
+ this.tokenEndpointAuthMethodsSupported = (_this_config_tokenEndpointAuthMethods = this.config.tokenEndpointAuthMethods) !== null && _this_config_tokenEndpointAuthMethods !== void 0 ? _this_config_tokenEndpointAuthMethods : _to_consumable_array$9(DEFAULT_OIDC_TOKEN_ENDPOINT_AUTH_METHODS);
3454
3456
  var appUrl = envService.appUrl;
3455
3457
  this.appLoginUrl = websiteUrlFromPaths(appUrl, [
3456
3458
  this.config.appOAuthInteractionPath,
@@ -3462,7 +3464,7 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
3462
3464
  ]);
3463
3465
  this.oidcRegistrationRouteEnabled = config.registrationEnabled === true;
3464
3466
  }
3465
- _create_class$7(OidcProviderConfigService, [
3467
+ _create_class$8(OidcProviderConfigService, [
3466
3468
  {
3467
3469
  /**
3468
3470
  * Builds the OpenID Connect Discovery metadata document.
@@ -3483,16 +3485,16 @@ var DEFAULT_OIDC_CODE_CHALLENGE_METHODS = [
3483
3485
  jwks_uri: jwksUri !== null && jwksUri !== void 0 ? jwksUri : "".concat(issuer).concat(routes.jwks),
3484
3486
  registration_endpoint: this.oidcRegistrationRouteEnabled ? "".concat(issuer).concat(routes.registration) : undefined,
3485
3487
  scopes_supported: this.scopesSupported,
3486
- response_types_supported: _to_consumable_array$6(providerConfig.responseTypes),
3488
+ response_types_supported: _to_consumable_array$9(providerConfig.responseTypes),
3487
3489
  response_modes_supported: [
3488
3490
  'query'
3489
3491
  ],
3490
- grant_types_supported: _to_consumable_array$6(providerConfig.grantTypes),
3491
- subject_types_supported: _to_consumable_array$6(DEFAULT_OIDC_SUBJECT_TYPES),
3492
- id_token_signing_alg_values_supported: _to_consumable_array$6(DEFAULT_OIDC_ID_TOKEN_SIGNING_ALG_VALUES),
3493
- token_endpoint_auth_methods_supported: _to_consumable_array$6(this.tokenEndpointAuthMethodsSupported),
3492
+ grant_types_supported: _to_consumable_array$9(providerConfig.grantTypes),
3493
+ subject_types_supported: _to_consumable_array$9(DEFAULT_OIDC_SUBJECT_TYPES),
3494
+ id_token_signing_alg_values_supported: _to_consumable_array$9(DEFAULT_OIDC_ID_TOKEN_SIGNING_ALG_VALUES),
3495
+ token_endpoint_auth_methods_supported: _to_consumable_array$9(this.tokenEndpointAuthMethodsSupported),
3494
3496
  claims_supported: this.claimsSupported,
3495
- code_challenge_methods_supported: _to_consumable_array$6(DEFAULT_OIDC_CODE_CHALLENGE_METHODS)
3497
+ code_challenge_methods_supported: _to_consumable_array$9(DEFAULT_OIDC_CODE_CHALLENGE_METHODS)
3496
3498
  };
3497
3499
  }
3498
3500
  }
@@ -3506,32 +3508,32 @@ OidcProviderConfigService = __decorate([
3506
3508
  __param(2, Inject(FirebaseServerEnvService))
3507
3509
  ], OidcProviderConfigService);
3508
3510
 
3509
- function _array_like_to_array$5(arr, len) {
3511
+ function _array_like_to_array$8(arr, len) {
3510
3512
  if (len == null || len > arr.length) len = arr.length;
3511
3513
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3512
3514
  return arr2;
3513
3515
  }
3514
- function _array_without_holes$5(arr) {
3515
- if (Array.isArray(arr)) return _array_like_to_array$5(arr);
3516
+ function _array_without_holes$8(arr) {
3517
+ if (Array.isArray(arr)) return _array_like_to_array$8(arr);
3516
3518
  }
3517
- function _iterable_to_array$5(iter) {
3519
+ function _iterable_to_array$8(iter) {
3518
3520
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
3519
3521
  return Array.from(iter);
3520
3522
  }
3521
3523
  }
3522
- function _non_iterable_spread$5() {
3524
+ function _non_iterable_spread$8() {
3523
3525
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3524
3526
  }
3525
- function _to_consumable_array$5(arr) {
3526
- return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$5();
3527
+ function _to_consumable_array$8(arr) {
3528
+ return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$8();
3527
3529
  }
3528
- function _unsupported_iterable_to_array$5(o, minLen) {
3530
+ function _unsupported_iterable_to_array$8(o, minLen) {
3529
3531
  if (!o) return;
3530
- if (typeof o === "string") return _array_like_to_array$5(o, minLen);
3532
+ if (typeof o === "string") return _array_like_to_array$8(o, minLen);
3531
3533
  var n = Object.prototype.toString.call(o).slice(8, -1);
3532
3534
  if (n === "Object" && o.constructor) n = o.constructor.name;
3533
3535
  if (n === "Map" || n === "Set") return Array.from(n);
3534
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
3536
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
3535
3537
  }
3536
3538
  /**
3537
3539
  * Custom oidc-provider client metadata field holding the {@link OidcProviderProfile} keys assigned
@@ -3571,7 +3573,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
3571
3573
  * @returns The union of config-level and profile-level admin-only scopes.
3572
3574
  */ function adminOnlyScopesForOidcProviderConfig(providerConfig) {
3573
3575
  var _providerConfig_adminOnlyScopes, _providerConfig_providerProfiles;
3574
- return new Set(_to_consumable_array$5((_providerConfig_adminOnlyScopes = providerConfig.adminOnlyScopes) !== null && _providerConfig_adminOnlyScopes !== void 0 ? _providerConfig_adminOnlyScopes : []).concat(_to_consumable_array$5(Array.from(adminOnlyScopesForOidcProviderProfiles((_providerConfig_providerProfiles = providerConfig.providerProfiles) !== null && _providerConfig_providerProfiles !== void 0 ? _providerConfig_providerProfiles : [])))));
3576
+ return new Set(_to_consumable_array$8((_providerConfig_adminOnlyScopes = providerConfig.adminOnlyScopes) !== null && _providerConfig_adminOnlyScopes !== void 0 ? _providerConfig_adminOnlyScopes : []).concat(_to_consumable_array$8(Array.from(adminOnlyScopesForOidcProviderProfiles((_providerConfig_providerProfiles = providerConfig.providerProfiles) !== null && _providerConfig_providerProfiles !== void 0 ? _providerConfig_providerProfiles : [])))));
3575
3577
  }
3576
3578
 
3577
3579
  /**
@@ -3614,57 +3616,18 @@ function _unsupported_iterable_to_array$5(o, minLen) {
3614
3616
  return policy;
3615
3617
  }
3616
3618
 
3617
- function _array_like_to_array$4(arr, len) {
3619
+ function _array_like_to_array$7(arr, len) {
3618
3620
  if (len == null || len > arr.length) len = arr.length;
3619
3621
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3620
3622
  return arr2;
3621
3623
  }
3622
- function _array_without_holes$4(arr) {
3623
- if (Array.isArray(arr)) return _array_like_to_array$4(arr);
3624
- }
3625
- function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
3626
- try {
3627
- var info = gen[key](arg);
3628
- var value = info.value;
3629
- } catch (error) {
3630
- reject(error);
3631
- return;
3632
- }
3633
- if (info.done) resolve(value);
3634
- else Promise.resolve(value).then(_next, _throw);
3635
- }
3636
- function _async_to_generator$5(fn) {
3637
- return function() {
3638
- var self = this, args = arguments;
3639
- return new Promise(function(resolve, reject) {
3640
- var gen = fn.apply(self, args);
3641
- function _next(value) {
3642
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
3643
- }
3644
- function _throw(err) {
3645
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
3646
- }
3647
- _next(undefined);
3648
- });
3649
- };
3650
- }
3651
- function _class_call_check$8(instance, Constructor) {
3652
- if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
3653
- }
3654
- function _defineProperties$6(target, props) {
3655
- for(var i = 0; i < props.length; i++){
3656
- var descriptor = props[i];
3657
- descriptor.enumerable = descriptor.enumerable || false;
3658
- descriptor.configurable = true;
3659
- if ("value" in descriptor) descriptor.writable = true;
3660
- Object.defineProperty(target, descriptor.key, descriptor);
3661
- }
3624
+ function _array_with_holes(arr) {
3625
+ if (Array.isArray(arr)) return arr;
3662
3626
  }
3663
- function _create_class$6(Constructor, protoProps, staticProps) {
3664
- if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
3665
- return Constructor;
3627
+ function _array_without_holes$7(arr) {
3628
+ if (Array.isArray(arr)) return _array_like_to_array$7(arr);
3666
3629
  }
3667
- function _define_property$8(obj, key, value) {
3630
+ function _define_property$a(obj, key, value) {
3668
3631
  if (key in obj) {
3669
3632
  Object.defineProperty(obj, key, {
3670
3633
  value: value,
@@ -3675,93 +3638,223 @@ function _define_property$8(obj, key, value) {
3675
3638
  } else obj[key] = value;
3676
3639
  return obj;
3677
3640
  }
3678
- function _instanceof$2(left, right) {
3679
- "@swc/helpers - instanceof";
3680
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
3681
- return !!right[Symbol.hasInstance](left);
3682
- } else return left instanceof right;
3683
- }
3684
- function _iterable_to_array$4(iter) {
3641
+ function _iterable_to_array$7(iter) {
3685
3642
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
3686
3643
  return Array.from(iter);
3687
3644
  }
3688
3645
  }
3689
- function _non_iterable_spread$4() {
3690
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3691
- }
3692
- function _object_spread$3(target) {
3693
- for(var i = 1; i < arguments.length; i++){
3694
- var source = arguments[i] != null ? arguments[i] : {};
3695
- var ownKeys = Object.keys(source);
3696
- if (typeof Object.getOwnPropertySymbols === "function") {
3697
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3698
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3699
- }));
3646
+ function _iterable_to_array_limit(arr, i) {
3647
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
3648
+ if (_i == null) return;
3649
+ var _arr = [];
3650
+ var _n = true;
3651
+ var _d = false;
3652
+ var _s, _e;
3653
+ try {
3654
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
3655
+ _arr.push(_s.value);
3656
+ if (i && _arr.length === i) break;
3657
+ }
3658
+ } catch (err) {
3659
+ _d = true;
3660
+ _e = err;
3661
+ } finally{
3662
+ try {
3663
+ if (!_n && _i["return"] != null) _i["return"]();
3664
+ } finally{
3665
+ if (_d) throw _e;
3700
3666
  }
3701
- ownKeys.forEach(function(key) {
3702
- _define_property$8(target, key, source[key]);
3703
- });
3704
- }
3705
- return target;
3706
- }
3707
- function ownKeys(object, enumerableOnly) {
3708
- var keys = Object.keys(object);
3709
- if (Object.getOwnPropertySymbols) {
3710
- var symbols = Object.getOwnPropertySymbols(object);
3711
- keys.push.apply(keys, symbols);
3712
3667
  }
3713
- return keys;
3668
+ return _arr;
3714
3669
  }
3715
- function _object_spread_props(target, source) {
3716
- source = source != null ? source : {};
3717
- if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3718
- else {
3719
- ownKeys(Object(source)).forEach(function(key) {
3720
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3670
+ function _non_iterable_rest() {
3671
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3672
+ }
3673
+ function _non_iterable_spread$7() {
3674
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3675
+ }
3676
+ function _object_spread$5(target) {
3677
+ for(var i = 1; i < arguments.length; i++){
3678
+ var source = arguments[i] != null ? arguments[i] : {};
3679
+ var ownKeys = Object.keys(source);
3680
+ if (typeof Object.getOwnPropertySymbols === "function") {
3681
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3682
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3683
+ }));
3684
+ }
3685
+ ownKeys.forEach(function(key) {
3686
+ _define_property$a(target, key, source[key]);
3721
3687
  });
3722
3688
  }
3723
3689
  return target;
3724
3690
  }
3725
- function _object_without_properties(source, excluded) {
3726
- if (source == null) return {};
3727
- var target = {}, sourceKeys, key, i;
3728
- if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
3729
- sourceKeys = Reflect.ownKeys(Object(source));
3730
- for(i = 0; i < sourceKeys.length; i++){
3731
- key = sourceKeys[i];
3732
- if (excluded.indexOf(key) >= 0) continue;
3733
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3734
- target[key] = source[key];
3735
- }
3736
- return target;
3737
- }
3738
- target = _object_without_properties_loose(source, excluded);
3739
- if (Object.getOwnPropertySymbols) {
3740
- sourceKeys = Object.getOwnPropertySymbols(source);
3741
- for(i = 0; i < sourceKeys.length; i++){
3742
- key = sourceKeys[i];
3743
- if (excluded.indexOf(key) >= 0) continue;
3744
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3745
- target[key] = source[key];
3746
- }
3691
+ function _sliced_to_array(arr, i) {
3692
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$7(arr, i) || _non_iterable_rest();
3693
+ }
3694
+ function _to_consumable_array$7(arr) {
3695
+ return _array_without_holes$7(arr) || _iterable_to_array$7(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$7();
3696
+ }
3697
+ function _unsupported_iterable_to_array$7(o, minLen) {
3698
+ if (!o) return;
3699
+ if (typeof o === "string") return _array_like_to_array$7(o, minLen);
3700
+ var n = Object.prototype.toString.call(o).slice(8, -1);
3701
+ if (n === "Object" && o.constructor) n = o.constructor.name;
3702
+ if (n === "Map" || n === "Set") return Array.from(n);
3703
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
3704
+ }
3705
+ /**
3706
+ * Builds a single-entry {@link OidcResourceServerInfo} map for an RFC 8707 resource indicator.
3707
+ *
3708
+ * This is the supported way to declare a resource server the provider issues tokens for —
3709
+ * including one that runs OFF-BOX (a Docker'd sidecar, a worker, a standalone MCP host), which is
3710
+ * what {@link BuildOidcResourceServerConfig.accessTokenFormat} `'jwt'` exists for.
3711
+ *
3712
+ * @param config - The resource indicator, its scopes, and the token shape to issue for it.
3713
+ * @returns A single-entry map keyed by the resource indicator.
3714
+ *
3715
+ * @example
3716
+ * ```ts
3717
+ * const DB_ORIGIN = 'https://db.example.com';
3718
+ *
3719
+ * oidcModuleMetadata({
3720
+ * dependencyModule: MyOidcDependencyModule,
3721
+ * config: {
3722
+ * resourceServers: buildOidcResourceServer({
3723
+ * url: `${DB_ORIGIN}/mcp`,
3724
+ * scope: 'openid profile email offline_access',
3725
+ * audience: DB_ORIGIN,
3726
+ * accessTokenFormat: 'jwt',
3727
+ * accessTokenTTL: 3600
3728
+ * })
3729
+ * }
3730
+ * })
3731
+ * ```
3732
+ */ function buildOidcResourceServer(config) {
3733
+ var _config_audience;
3734
+ var url = config.url.replace(/\/+$/, '');
3735
+ return _define_property$a({}, url, _object_spread$5({
3736
+ scope: config.scope,
3737
+ audience: (_config_audience = config.audience) !== null && _config_audience !== void 0 ? _config_audience : url
3738
+ }, config.accessTokenFormat == null ? {} : {
3739
+ accessTokenFormat: config.accessTokenFormat
3740
+ }, config.accessTokenTTL == null ? {} : {
3741
+ accessTokenTTL: config.accessTokenTTL
3742
+ }));
3743
+ }
3744
+ // COMPAT: superseded by the general-purpose buildOidcResourceServer().
3745
+ /**
3746
+ * Builds a single-entry {@link OidcResourceServerInfo} map for the MCP endpoint
3747
+ * declared on `envService.appMcpUrl`, with `scope` set to every scope declared
3748
+ * on `providerConfig.claims` (so any scope the provider issues is valid on the
3749
+ * resource server) and `audience` set to the MCP URL.
3750
+ *
3751
+ * Returns `undefined` when no `appMcpUrl` is configured.
3752
+ *
3753
+ * Used internally by `oidcModuleMetadata` when `OidcModuleConfig.configureMcpResourceServer`
3754
+ * is enabled.
3755
+ *
3756
+ * @param input - The environment service and provider config backing the entry.
3757
+ * @returns The single-entry map, or `undefined` when no MCP URL is configured.
3758
+ *
3759
+ * @deprecated Prefer {@link buildOidcResourceServer}, which takes the URL, scope, audience, and
3760
+ * token format explicitly instead of deriving a fixed shape from the environment.
3761
+ */ function buildFirebaseServerMcpResourceServer(input) {
3762
+ var envService = input.envService, providerConfig = input.providerConfig;
3763
+ var mcpUrl = envService.appMcpUrl;
3764
+ var result;
3765
+ if (mcpUrl) {
3766
+ result = buildOidcResourceServer({
3767
+ url: mcpUrl,
3768
+ scope: allOidcScopesStringForProviderConfig(providerConfig),
3769
+ audience: mcpUrl,
3770
+ accessTokenFormat: input.accessTokenFormat,
3771
+ accessTokenTTL: input.accessTokenTTL
3772
+ });
3747
3773
  }
3748
- return target;
3774
+ return result;
3749
3775
  }
3750
- function _object_without_properties_loose(source, excluded) {
3751
- if (source == null) return {};
3752
- var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
3753
- for(i = 0; i < sourceKeys.length; i++){
3754
- key = sourceKeys[i];
3755
- if (excluded.indexOf(key) >= 0) continue;
3756
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3757
- target[key] = source[key];
3776
+ /**
3777
+ * Emits the `@dereekb/oauth-resource` {@link BuildIssuerProfilesConfig} for THIS provider, so an
3778
+ * API and the satellite services it issues tokens for cannot drift on issuer / audience strings —
3779
+ * both sides read the same `OidcModuleConfig`.
3780
+ *
3781
+ * The type dependency points `firebase-server → oauth-resource` and never the reverse: the light
3782
+ * verify package must stay installable in a plain Express service with no Firebase, Nest, or
3783
+ * oidc-provider in its install graph.
3784
+ *
3785
+ * @param config - The provider's module config plus any extra trusted projects / audiences.
3786
+ * @returns The issuer-profile config to hand to `buildIssuerProfiles()`.
3787
+ *
3788
+ * @example
3789
+ * ```ts
3790
+ * // inside the API, to hand its satellites a config they cannot get wrong
3791
+ * const profilesConfig = firebaseServerIssuerProfiles({ oidcModuleConfig, firebaseProjectIds: [projectId] });
3792
+ * const profiles = buildIssuerProfiles(profilesConfig);
3793
+ * ```
3794
+ */ function firebaseServerIssuerProfiles(config) {
3795
+ var _config_audiences, _config_firebaseProjectIds;
3796
+ var _config_oidcModuleConfig = config.oidcModuleConfig, issuer = _config_oidcModuleConfig.issuer, resourceServers = _config_oidcModuleConfig.resourceServers;
3797
+ var audiences = unique(_to_consumable_array$7(oidcResourceServerAudiences(resourceServers)).concat(_to_consumable_array$7((_config_audiences = config.audiences) !== null && _config_audiences !== void 0 ? _config_audiences : [])));
3798
+ return {
3799
+ firebaseProjectIds: (_config_firebaseProjectIds = config.firebaseProjectIds) !== null && _config_firebaseProjectIds !== void 0 ? _config_firebaseProjectIds : [],
3800
+ oidcIssuers: [
3801
+ {
3802
+ issuer: issuer,
3803
+ audiences: audiences,
3804
+ getKey: config.getKey
3805
+ }
3806
+ ],
3807
+ audiences: audiences,
3808
+ fetch: config.fetch
3809
+ };
3810
+ }
3811
+ /**
3812
+ * Reads every audience a registered resource-server map can put on an access token: each entry's
3813
+ * key (the resource indicator, which oidc-provider uses as the audience by default) plus its
3814
+ * explicit `audience` when one is configured.
3815
+ *
3816
+ * @param resourceServers - The provider's registered resource servers, if any.
3817
+ * @returns The unique audience values.
3818
+ */ function oidcResourceServerAudiences(resourceServers) {
3819
+ var entries = Object.entries(resourceServers !== null && resourceServers !== void 0 ? resourceServers : {});
3820
+ return unique(entries.flatMap(function(param) {
3821
+ var _param = _sliced_to_array(param, 2), url = _param[0], info = _param[1];
3822
+ return info.audience == null ? [
3823
+ url
3824
+ ] : [
3825
+ url,
3826
+ info.audience
3827
+ ];
3828
+ }));
3829
+ }
3830
+
3831
+ function asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, key, arg) {
3832
+ try {
3833
+ var info = gen[key](arg);
3834
+ var value = info.value;
3835
+ } catch (error) {
3836
+ reject(error);
3837
+ return;
3758
3838
  }
3759
- return target;
3839
+ if (info.done) resolve(value);
3840
+ else Promise.resolve(value).then(_next, _throw);
3760
3841
  }
3761
- function _to_consumable_array$4(arr) {
3762
- return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$4();
3842
+ function _async_to_generator$7(fn) {
3843
+ return function() {
3844
+ var self = this, args = arguments;
3845
+ return new Promise(function(resolve, reject) {
3846
+ var gen = fn.apply(self, args);
3847
+ function _next(value) {
3848
+ asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "next", value);
3849
+ }
3850
+ function _throw(err) {
3851
+ asyncGeneratorStep$7(gen, resolve, reject, _next, _throw, "throw", err);
3852
+ }
3853
+ _next(undefined);
3854
+ });
3855
+ };
3763
3856
  }
3764
- function _ts_generator$5(thisArg, body) {
3857
+ function _ts_generator$7(thisArg, body) {
3765
3858
  var f, y, t, _ = {
3766
3859
  label: 0,
3767
3860
  sent: function() {
@@ -3860,62 +3953,459 @@ function _ts_generator$5(thisArg, body) {
3860
3953
  };
3861
3954
  }
3862
3955
  }
3863
- function _unsupported_iterable_to_array$4(o, minLen) {
3864
- if (!o) return;
3865
- if (typeof o === "string") return _array_like_to_array$4(o, minLen);
3866
- var n = Object.prototype.toString.call(o).slice(8, -1);
3867
- if (n === "Object" && o.constructor) n = o.constructor.name;
3868
- if (n === "Map" || n === "Set") return Array.from(n);
3869
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
3956
+ // MARK: Keys
3957
+ /**
3958
+ * Builds a jose {@link JWTVerifyGetKey} backed by the provider's OWN published JWKS, read directly
3959
+ * from {@link JwksService} rather than over HTTP.
3960
+ *
3961
+ * An in-process verifier must not `createRemoteJWKSet` against its own `/.well-known/jwks.json`:
3962
+ * that would make every bearer-authenticated request depend on the process being able to reach
3963
+ * itself over the network (which it may not be, behind a load balancer, in a Functions emulator,
3964
+ * or under supertest).
3965
+ *
3966
+ * The key set is cached and re-read only when a token presents a `kid` the cache does not hold —
3967
+ * so a freshly rotated key is picked up on its first use instead of after a fixed TTL.
3968
+ *
3969
+ * @param jwksService - The provider's JWKS service.
3970
+ * @returns The key resolver.
3971
+ */ function jwksServiceVerifyGetKey(jwksService) {
3972
+ var cached;
3973
+ function loadKeySet() {
3974
+ return _async_to_generator$7(function() {
3975
+ var jwks, next;
3976
+ return _ts_generator$7(this, function(_state) {
3977
+ switch(_state.label){
3978
+ case 0:
3979
+ return [
3980
+ 4,
3981
+ jwksService.getLatestPublicJwks()
3982
+ ];
3983
+ case 1:
3984
+ jwks = _state.sent();
3985
+ next = {
3986
+ kids: new Set(jwks.keys.map(function(key) {
3987
+ return key.kid;
3988
+ })),
3989
+ getKey: createLocalJWKSet({
3990
+ keys: jwks.keys
3991
+ })
3992
+ };
3993
+ cached = next;
3994
+ return [
3995
+ 2,
3996
+ next
3997
+ ];
3998
+ }
3999
+ });
4000
+ })();
4001
+ }
4002
+ return function(protectedHeader, token) {
4003
+ return _async_to_generator$7(function() {
4004
+ var keySet, _tmp, kid;
4005
+ return _ts_generator$7(this, function(_state) {
4006
+ switch(_state.label){
4007
+ case 0:
4008
+ if (!(cached !== null && cached !== void 0)) return [
4009
+ 3,
4010
+ 1
4011
+ ];
4012
+ _tmp = cached;
4013
+ return [
4014
+ 3,
4015
+ 3
4016
+ ];
4017
+ case 1:
4018
+ return [
4019
+ 4,
4020
+ loadKeySet()
4021
+ ];
4022
+ case 2:
4023
+ _tmp = _state.sent();
4024
+ _state.label = 3;
4025
+ case 3:
4026
+ keySet = _tmp;
4027
+ kid = protectedHeader === null || protectedHeader === void 0 ? void 0 : protectedHeader.kid;
4028
+ if (!(kid != null && !keySet.kids.has(kid))) return [
4029
+ 3,
4030
+ 5
4031
+ ];
4032
+ return [
4033
+ 4,
4034
+ loadKeySet()
4035
+ ];
4036
+ case 4:
4037
+ keySet = _state.sent();
4038
+ _state.label = 5;
4039
+ case 5:
4040
+ return [
4041
+ 2,
4042
+ keySet.getKey(protectedHeader, token)
4043
+ ];
4044
+ }
4045
+ });
4046
+ })();
4047
+ };
3870
4048
  }
3871
- var OidcService_1;
3872
- // MARK: Service
4049
+ // MARK: Profiles
3873
4050
  /**
3874
- * Core OIDC service that wraps the oidc-provider instance and exposes
3875
- * typed methods for interaction handling, provider initialization, and JWKS management.
3876
- */ var OidcService = OidcService_1 = /*#__PURE__*/ function() {
3877
- function OidcService(config, providerConfigService, jwksService, accountService, collections, encryptionService) {
3878
- var _this = this;
3879
- _class_call_check$8(this, OidcService);
3880
- _define_property$8(this, "config", void 0);
3881
- _define_property$8(this, "providerConfigService", void 0);
3882
- _define_property$8(this, "jwksService", void 0);
3883
- _define_property$8(this, "accountService", void 0);
3884
- _define_property$8(this, "collections", void 0);
3885
- _define_property$8(this, "encryptionService", void 0);
3886
- _define_property$8(this, "_logger", new Logger(OidcService_1.name));
3887
- _define_property$8(this, "_getProvider", cachedGetter(function() {
3888
- return _this._buildProvider();
3889
- }));
3890
- this.config = config;
3891
- this.providerConfigService = providerConfigService;
3892
- this.jwksService = jwksService;
3893
- this.accountService = accountService;
3894
- this.collections = collections;
3895
- this.encryptionService = encryptionService;
4051
+ * Builds the {@link IssuerProfiles} the provider uses to verify its OWN JWT-format access tokens
4052
+ * in-process.
4053
+ *
4054
+ * A JWT access token is issued for a specific `resource=`, so it carries THAT resource server's
4055
+ * audience — not the API's own identity. The accepted audiences are therefore every registered
4056
+ * `resourceServers` key and audience, plus the issuer itself. The trust decision that implies is
4057
+ * deliberate and narrow: a resource server the user consented to may present the token it was
4058
+ * given back to the API that issued it. Scope enforcement is unchanged and still does the real
4059
+ * authorization work (e.g. the admin-only `session.firestore` consent gate and the endpoint's own
4060
+ * admin predicate).
4061
+ *
4062
+ * @param config - The provider's module config.
4063
+ * @param jwksService - The provider's JWKS service, used for local key resolution.
4064
+ * @returns The issuer profiles, holding exactly this provider.
4065
+ */ function oidcProviderIssuerProfiles(config, jwksService) {
4066
+ var getKey = jwksServiceVerifyGetKey(jwksService);
4067
+ return buildIssuerProfiles(firebaseServerIssuerProfiles({
4068
+ oidcModuleConfig: config,
4069
+ audiences: [
4070
+ config.issuer
4071
+ ],
4072
+ getKey: function getKey1() {
4073
+ return _async_to_generator$7(function() {
4074
+ return _ts_generator$7(this, function(_state) {
4075
+ return [
4076
+ 2,
4077
+ getKey
4078
+ ];
4079
+ });
4080
+ })();
4081
+ }
4082
+ }));
4083
+ }
4084
+
4085
+ function _array_like_to_array$6(arr, len) {
4086
+ if (len == null || len > arr.length) len = arr.length;
4087
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4088
+ return arr2;
4089
+ }
4090
+ function _array_without_holes$6(arr) {
4091
+ if (Array.isArray(arr)) return _array_like_to_array$6(arr);
4092
+ }
4093
+ function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
4094
+ try {
4095
+ var info = gen[key](arg);
4096
+ var value = info.value;
4097
+ } catch (error) {
4098
+ reject(error);
4099
+ return;
3896
4100
  }
3897
- _create_class$6(OidcService, [
3898
- {
3899
- /**
3900
- * Returns the oidc-provider instance, initializing it on first access.
3901
- *
3902
- * @returns The lazily-initialized oidc-provider instance.
3903
- */ key: "getProvider",
3904
- value: function getProvider() {
3905
- return this._getProvider();
4101
+ if (info.done) resolve(value);
4102
+ else Promise.resolve(value).then(_next, _throw);
4103
+ }
4104
+ function _async_to_generator$6(fn) {
4105
+ return function() {
4106
+ var self = this, args = arguments;
4107
+ return new Promise(function(resolve, reject) {
4108
+ var gen = fn.apply(self, args);
4109
+ function _next(value) {
4110
+ asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "next", value);
3906
4111
  }
3907
- },
3908
- {
3909
- // MARK: Login Duration
3910
- /**
3911
- * Resolves the login-duration TTL (seconds) for a Grant being created from a fresh consent submission.
3912
- *
3913
- * The Grant TTL configured on the oidc-provider only fires when oidc-provider's koa middleware drives
3914
- * `grant.save()` (so `AsyncLocalStorage` carries the request context). Our consent flow saves grants
3915
- * from a NestJS controller, so we resolve the TTL up-front and pre-set `grant.expiresIn` before saving.
3916
- *
3917
- * Mirrors the resolution used by the `Grant`/`Session` TTL functions in {@link buildProviderConfiguration}.
3918
- *
4112
+ function _throw(err) {
4113
+ asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "throw", err);
4114
+ }
4115
+ _next(undefined);
4116
+ });
4117
+ };
4118
+ }
4119
+ function _class_call_check$9(instance, Constructor) {
4120
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
4121
+ }
4122
+ function _defineProperties$7(target, props) {
4123
+ for(var i = 0; i < props.length; i++){
4124
+ var descriptor = props[i];
4125
+ descriptor.enumerable = descriptor.enumerable || false;
4126
+ descriptor.configurable = true;
4127
+ if ("value" in descriptor) descriptor.writable = true;
4128
+ Object.defineProperty(target, descriptor.key, descriptor);
4129
+ }
4130
+ }
4131
+ function _create_class$7(Constructor, protoProps, staticProps) {
4132
+ if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);
4133
+ return Constructor;
4134
+ }
4135
+ function _define_property$9(obj, key, value) {
4136
+ if (key in obj) {
4137
+ Object.defineProperty(obj, key, {
4138
+ value: value,
4139
+ enumerable: true,
4140
+ configurable: true,
4141
+ writable: true
4142
+ });
4143
+ } else obj[key] = value;
4144
+ return obj;
4145
+ }
4146
+ function _instanceof$2(left, right) {
4147
+ "@swc/helpers - instanceof";
4148
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
4149
+ return !!right[Symbol.hasInstance](left);
4150
+ } else return left instanceof right;
4151
+ }
4152
+ function _iterable_to_array$6(iter) {
4153
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
4154
+ return Array.from(iter);
4155
+ }
4156
+ }
4157
+ function _non_iterable_spread$6() {
4158
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4159
+ }
4160
+ function _object_spread$4(target) {
4161
+ for(var i = 1; i < arguments.length; i++){
4162
+ var source = arguments[i] != null ? arguments[i] : {};
4163
+ var ownKeys = Object.keys(source);
4164
+ if (typeof Object.getOwnPropertySymbols === "function") {
4165
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4166
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4167
+ }));
4168
+ }
4169
+ ownKeys.forEach(function(key) {
4170
+ _define_property$9(target, key, source[key]);
4171
+ });
4172
+ }
4173
+ return target;
4174
+ }
4175
+ function ownKeys(object, enumerableOnly) {
4176
+ var keys = Object.keys(object);
4177
+ if (Object.getOwnPropertySymbols) {
4178
+ var symbols = Object.getOwnPropertySymbols(object);
4179
+ keys.push.apply(keys, symbols);
4180
+ }
4181
+ return keys;
4182
+ }
4183
+ function _object_spread_props(target, source) {
4184
+ source = source != null ? source : {};
4185
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4186
+ else {
4187
+ ownKeys(Object(source)).forEach(function(key) {
4188
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4189
+ });
4190
+ }
4191
+ return target;
4192
+ }
4193
+ function _object_without_properties(source, excluded) {
4194
+ if (source == null) return {};
4195
+ var target = {}, sourceKeys, key, i;
4196
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
4197
+ sourceKeys = Reflect.ownKeys(Object(source));
4198
+ for(i = 0; i < sourceKeys.length; i++){
4199
+ key = sourceKeys[i];
4200
+ if (excluded.indexOf(key) >= 0) continue;
4201
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
4202
+ target[key] = source[key];
4203
+ }
4204
+ return target;
4205
+ }
4206
+ target = _object_without_properties_loose(source, excluded);
4207
+ if (Object.getOwnPropertySymbols) {
4208
+ sourceKeys = Object.getOwnPropertySymbols(source);
4209
+ for(i = 0; i < sourceKeys.length; i++){
4210
+ key = sourceKeys[i];
4211
+ if (excluded.indexOf(key) >= 0) continue;
4212
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
4213
+ target[key] = source[key];
4214
+ }
4215
+ }
4216
+ return target;
4217
+ }
4218
+ function _object_without_properties_loose(source, excluded) {
4219
+ if (source == null) return {};
4220
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
4221
+ for(i = 0; i < sourceKeys.length; i++){
4222
+ key = sourceKeys[i];
4223
+ if (excluded.indexOf(key) >= 0) continue;
4224
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
4225
+ target[key] = source[key];
4226
+ }
4227
+ return target;
4228
+ }
4229
+ function _to_consumable_array$6(arr) {
4230
+ return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$6();
4231
+ }
4232
+ function _ts_generator$6(thisArg, body) {
4233
+ var f, y, t, _ = {
4234
+ label: 0,
4235
+ sent: function() {
4236
+ if (t[0] & 1) throw t[1];
4237
+ return t[1];
4238
+ },
4239
+ trys: [],
4240
+ ops: []
4241
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
4242
+ return d(g, "next", {
4243
+ value: verb(0)
4244
+ }), d(g, "throw", {
4245
+ value: verb(1)
4246
+ }), d(g, "return", {
4247
+ value: verb(2)
4248
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
4249
+ value: function() {
4250
+ return this;
4251
+ }
4252
+ }), g;
4253
+ function verb(n) {
4254
+ return function(v) {
4255
+ return step([
4256
+ n,
4257
+ v
4258
+ ]);
4259
+ };
4260
+ }
4261
+ function step(op) {
4262
+ if (f) throw new TypeError("Generator is already executing.");
4263
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
4264
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4265
+ if (y = 0, t) op = [
4266
+ op[0] & 2,
4267
+ t.value
4268
+ ];
4269
+ switch(op[0]){
4270
+ case 0:
4271
+ case 1:
4272
+ t = op;
4273
+ break;
4274
+ case 4:
4275
+ _.label++;
4276
+ return {
4277
+ value: op[1],
4278
+ done: false
4279
+ };
4280
+ case 5:
4281
+ _.label++;
4282
+ y = op[1];
4283
+ op = [
4284
+ 0
4285
+ ];
4286
+ continue;
4287
+ case 7:
4288
+ op = _.ops.pop();
4289
+ _.trys.pop();
4290
+ continue;
4291
+ default:
4292
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
4293
+ _ = 0;
4294
+ continue;
4295
+ }
4296
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
4297
+ _.label = op[1];
4298
+ break;
4299
+ }
4300
+ if (op[0] === 6 && _.label < t[1]) {
4301
+ _.label = t[1];
4302
+ t = op;
4303
+ break;
4304
+ }
4305
+ if (t && _.label < t[2]) {
4306
+ _.label = t[2];
4307
+ _.ops.push(op);
4308
+ break;
4309
+ }
4310
+ if (t[2]) _.ops.pop();
4311
+ _.trys.pop();
4312
+ continue;
4313
+ }
4314
+ op = body.call(thisArg, _);
4315
+ } catch (e) {
4316
+ op = [
4317
+ 6,
4318
+ e
4319
+ ];
4320
+ y = 0;
4321
+ } finally{
4322
+ f = t = 0;
4323
+ }
4324
+ if (op[0] & 5) throw op[1];
4325
+ return {
4326
+ value: op[0] ? op[1] : void 0,
4327
+ done: true
4328
+ };
4329
+ }
4330
+ }
4331
+ function _unsupported_iterable_to_array$6(o, minLen) {
4332
+ if (!o) return;
4333
+ if (typeof o === "string") return _array_like_to_array$6(o, minLen);
4334
+ var n = Object.prototype.toString.call(o).slice(8, -1);
4335
+ if (n === "Object" && o.constructor) n = o.constructor.name;
4336
+ if (n === "Map" || n === "Set") return Array.from(n);
4337
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
4338
+ }
4339
+ var OidcService_1;
4340
+ // MARK: JWT Access Tokens
4341
+ /**
4342
+ * Claims a JWT access token carries that the {@link OidcAuthData} shape sets explicitly, and that
4343
+ * are therefore NOT app account claims.
4344
+ */ var OIDC_JWT_ACCESS_TOKEN_RESERVED_CLAIMS = [
4345
+ 'iss',
4346
+ 'sub',
4347
+ 'aud',
4348
+ 'exp',
4349
+ 'iat',
4350
+ 'nbf',
4351
+ 'jti',
4352
+ 'auth_time',
4353
+ 'uid',
4354
+ 'scope',
4355
+ 'client_id',
4356
+ 'firebase'
4357
+ ];
4358
+ var filterReservedJwtAccessTokenClaims = filterKeysOnPOJOFunction(OIDC_JWT_ACCESS_TOKEN_RESERVED_CLAIMS, true);
4359
+ // MARK: Service
4360
+ /**
4361
+ * Core OIDC service that wraps the oidc-provider instance and exposes
4362
+ * typed methods for interaction handling, provider initialization, and JWKS management.
4363
+ */ var OidcService = OidcService_1 = /*#__PURE__*/ function() {
4364
+ function OidcService(config, providerConfigService, jwksService, accountService, collections, encryptionService) {
4365
+ var _this = this;
4366
+ _class_call_check$9(this, OidcService);
4367
+ _define_property$9(this, "config", void 0);
4368
+ _define_property$9(this, "providerConfigService", void 0);
4369
+ _define_property$9(this, "jwksService", void 0);
4370
+ _define_property$9(this, "accountService", void 0);
4371
+ _define_property$9(this, "collections", void 0);
4372
+ _define_property$9(this, "encryptionService", void 0);
4373
+ _define_property$9(this, "_logger", new Logger(OidcService_1.name));
4374
+ _define_property$9(this, "_getProvider", cachedGetter(function() {
4375
+ return _this._buildProvider();
4376
+ }));
4377
+ _define_property$9(this, "_getIssuerProfiles", cachedGetter(function() {
4378
+ return oidcProviderIssuerProfiles(_this.config, _this.jwksService);
4379
+ }));
4380
+ this.config = config;
4381
+ this.providerConfigService = providerConfigService;
4382
+ this.jwksService = jwksService;
4383
+ this.accountService = accountService;
4384
+ this.collections = collections;
4385
+ this.encryptionService = encryptionService;
4386
+ }
4387
+ _create_class$7(OidcService, [
4388
+ {
4389
+ /**
4390
+ * Returns the oidc-provider instance, initializing it on first access.
4391
+ *
4392
+ * @returns The lazily-initialized oidc-provider instance.
4393
+ */ key: "getProvider",
4394
+ value: function getProvider() {
4395
+ return this._getProvider();
4396
+ }
4397
+ },
4398
+ {
4399
+ // MARK: Login Duration
4400
+ /**
4401
+ * Resolves the login-duration TTL (seconds) for a Grant being created from a fresh consent submission.
4402
+ *
4403
+ * The Grant TTL configured on the oidc-provider only fires when oidc-provider's koa middleware drives
4404
+ * `grant.save()` (so `AsyncLocalStorage` carries the request context). Our consent flow saves grants
4405
+ * from a NestJS controller, so we resolve the TTL up-front and pre-set `grant.expiresIn` before saving.
4406
+ *
4407
+ * Mirrors the resolution used by the `Grant`/`Session` TTL functions in {@link buildProviderConfiguration}.
4408
+ *
3919
4409
  * The `serverMaxSeconds` ceiling is tiered by {@link resolveTieredServerMaxSeconds}: a non-admin
3920
4410
  * caps at the non-admin tier, an admin at the admin tier, and an admin whose grant carries a
3921
4411
  * service-token scope at the (highest) service-token tier. This tiered value replaces the flat
@@ -3952,17 +4442,30 @@ var OidcService_1;
3952
4442
  key: "verifyAccessToken",
3953
4443
  value: // MARK: Token Verification
3954
4444
  /**
3955
- * Verifies an opaque access token and returns the {@link OidcAuthData}.
4445
+ * Verifies an access token and returns the {@link OidcAuthData}.
4446
+ *
4447
+ * Two formats are accepted, because oidc-provider issues two:
3956
4448
  *
3957
- * Uses the provider's `AccessToken` model to look up the token and extract
3958
- * the account ID, scope, and client ID.
4449
+ * - **opaque** (the default) — a database key. Looked up through the provider's `AccessToken`
4450
+ * model, which reads the Firestore adapter record written at issuance.
4451
+ * - **JWT** (a resource server registered with `accessTokenFormat: 'jwt'`) — verified by
4452
+ * signature against this provider's own JWKS via `@dereekb/oauth-resource`. A JWT access token
4453
+ * is deliberately NOT persisted by oidc-provider (`lib/models/formats/jwt.js` returns no
4454
+ * payload, so `base_model.js` skips the `adapter.upsert`), which means `AccessToken.find()`
4455
+ * always misses for one and the store lookup alone would 401 every token the provider just
4456
+ * issued.
3959
4457
  *
3960
- * @param rawToken - The opaque access token string.
4458
+ * The same absence of an adapter record is why a JWT access token **cannot be revoked before
4459
+ * `exp`**: {@link revokeGrant} deletes the Grant and every persisted token referencing it, which
4460
+ * stops refresh and future issuance, but an outstanding JWT stays verifiable until it expires.
4461
+ * Keep `accessTokenTTL` short on any resource server that opts into the JWT format.
4462
+ *
4463
+ * @param rawToken - The access token string, opaque or JWT.
3961
4464
  * @returns The auth context, or `undefined` if the token is invalid or expired.
3962
4465
  */ function verifyAccessToken(rawToken) {
3963
- return _async_to_generator$5(function() {
4466
+ return _async_to_generator$6(function() {
3964
4467
  var provider, accessToken, result, _accessToken_extra, _accessToken_exp, accountClaims, token;
3965
- return _ts_generator$5(this, function(_state) {
4468
+ return _ts_generator$6(this, function(_state) {
3966
4469
  switch(_state.label){
3967
4470
  case 0:
3968
4471
  return [
@@ -3977,42 +4480,147 @@ var OidcService_1;
3977
4480
  ];
3978
4481
  case 2:
3979
4482
  accessToken = _state.sent();
3980
- if (accessToken) {
3981
- // Extract account claims baked into the access token at issuance time.
3982
- // These are the claims built by OidcAccountServiceDelegate.buildClaimsForUser()
3983
- // (e.g., `a` for admin, `o` for onboarded) based on the granted scopes.
3984
- // Read the account claims baked into the token at issuance time via extraAccessTokenClaims.
3985
- accountClaims = (_accessToken_extra = accessToken.extra) !== null && _accessToken_extra !== void 0 ? _accessToken_extra : {};
3986
- token = _object_spread_props(_object_spread$3({}, accountClaims), {
3987
- // Standard JWT claims — sourced from the access token
3988
- aud: firstValue(accessToken.aud),
3989
- iss: this.config.issuer,
4483
+ if (!accessToken) return [
4484
+ 3,
4485
+ 3
4486
+ ];
4487
+ // Extract account claims baked into the access token at issuance time.
4488
+ // These are the claims built by OidcAccountServiceDelegate.buildClaimsForUser()
4489
+ // (e.g., `a` for admin, `o` for onboarded) based on the granted scopes.
4490
+ // Read the account claims baked into the token at issuance time via extraAccessTokenClaims.
4491
+ accountClaims = (_accessToken_extra = accessToken.extra) !== null && _accessToken_extra !== void 0 ? _accessToken_extra : {};
4492
+ token = _object_spread_props(_object_spread$4({}, accountClaims), {
4493
+ // Standard JWT claims — sourced from the access token
4494
+ aud: firstValue(accessToken.aud),
4495
+ iss: this.config.issuer,
4496
+ sub: accessToken.accountId,
4497
+ iat: accessToken.iat,
4498
+ exp: (_accessToken_exp = accessToken.exp) !== null && _accessToken_exp !== void 0 ? _accessToken_exp : unixDateTimeSecondsNumberForNow() + accessToken.expiration,
4499
+ auth_time: accessToken.iat,
4500
+ // Firebase UID (copied from sub)
4501
+ uid: accessToken.accountId,
4502
+ // OIDC-specific claims carried on the token
4503
+ scope: accessToken.scope,
4504
+ client_id: accessToken.clientId,
4505
+ // Firebase sign-in info — marked as OIDC provider
4506
+ firebase: {
4507
+ identities: {},
4508
+ sign_in_provider: 'dbx_oidc'
4509
+ }
4510
+ });
4511
+ result = {
4512
+ uid: accessToken.accountId,
4513
+ token: token,
4514
+ rawToken: rawToken,
4515
+ oidcValidatedToken: _object_spread$4({
3990
4516
  sub: accessToken.accountId,
3991
- iat: accessToken.iat,
3992
- exp: (_accessToken_exp = accessToken.exp) !== null && _accessToken_exp !== void 0 ? _accessToken_exp : unixDateTimeSecondsNumberForNow() + accessToken.expiration,
3993
- auth_time: accessToken.iat,
3994
- // Firebase UID (copied from sub)
3995
- uid: accessToken.accountId,
3996
- // OIDC-specific claims carried on the token
3997
4517
  scope: accessToken.scope,
3998
- client_id: accessToken.clientId,
3999
- // Firebase sign-in info — marked as OIDC provider
4000
- firebase: {
4001
- identities: {},
4002
- sign_in_provider: 'dbx_oidc'
4003
- }
4004
- });
4005
- result = {
4006
- uid: accessToken.accountId,
4007
- token: token,
4008
- rawToken: rawToken,
4009
- oidcValidatedToken: _object_spread$3({
4010
- sub: accessToken.accountId,
4011
- scope: accessToken.scope,
4012
- client_id: accessToken.clientId
4013
- }, accountClaims)
4014
- };
4015
- }
4518
+ client_id: accessToken.clientId
4519
+ }, accountClaims)
4520
+ };
4521
+ return [
4522
+ 3,
4523
+ 5
4524
+ ];
4525
+ case 3:
4526
+ return [
4527
+ 4,
4528
+ this._verifyJwtAccessToken(rawToken)
4529
+ ];
4530
+ case 4:
4531
+ result = _state.sent();
4532
+ _state.label = 5;
4533
+ case 5:
4534
+ return [
4535
+ 2,
4536
+ result
4537
+ ];
4538
+ }
4539
+ });
4540
+ }).call(this);
4541
+ }
4542
+ },
4543
+ {
4544
+ key: "_verifyJwtAccessToken",
4545
+ value: /**
4546
+ * Verifies a JWT-format access token issued by THIS provider for one of its registered resource
4547
+ * servers, and builds the same {@link OidcAuthData} shape the opaque path produces.
4548
+ *
4549
+ * `sub` is the `accountId` oidc-provider stamped at issuance, which IS the Firebase uid (the
4550
+ * opaque path reads the identical value off `accessToken.accountId`), so no mapping table is
4551
+ * involved.
4552
+ *
4553
+ * @param rawToken - The raw token, which may not be a JWT at all.
4554
+ * @returns The auth context, or `undefined` when the token is not a verifiable JWT from this provider.
4555
+ */ function _verifyJwtAccessToken(rawToken) {
4556
+ return _async_to_generator$6(function() {
4557
+ var result, verified, claims, scope, clientId, accountClaims, token, e;
4558
+ return _ts_generator$6(this, function(_state) {
4559
+ switch(_state.label){
4560
+ case 0:
4561
+ _state.trys.push([
4562
+ 0,
4563
+ 2,
4564
+ ,
4565
+ 3
4566
+ ]);
4567
+ return [
4568
+ 4,
4569
+ verifyBearerJwt(rawToken, {
4570
+ profiles: this._getIssuerProfiles()
4571
+ })
4572
+ ];
4573
+ case 1:
4574
+ verified = _state.sent();
4575
+ claims = verified.claims;
4576
+ scope = typeof claims['scope'] === 'string' ? claims['scope'] : undefined;
4577
+ clientId = typeof claims['client_id'] === 'string' ? claims['client_id'] : undefined;
4578
+ // Account claims baked into the token at issuance time via extraAccessTokenClaims, minus the
4579
+ // standard JWT + OAuth claims the shape below sets explicitly.
4580
+ accountClaims = filterReservedJwtAccessTokenClaims(_object_spread$4({}, claims));
4581
+ token = _object_spread_props(_object_spread$4(_object_spread_props(_object_spread$4({}, accountClaims), {
4582
+ // `aud` is always present — jose rejected the token otherwise
4583
+ aud: firstValue(claims.aud),
4584
+ iss: this.config.issuer,
4585
+ sub: verified.subject,
4586
+ iat: claims.iat,
4587
+ exp: claims.exp,
4588
+ auth_time: claims.iat,
4589
+ uid: verified.subject
4590
+ }), scope == null ? {} : {
4591
+ scope: scope
4592
+ }, clientId == null ? {} : {
4593
+ client_id: clientId
4594
+ }), {
4595
+ firebase: {
4596
+ identities: {},
4597
+ sign_in_provider: 'dbx_oidc'
4598
+ }
4599
+ });
4600
+ result = {
4601
+ uid: verified.subject,
4602
+ token: token,
4603
+ rawToken: rawToken,
4604
+ oidcValidatedToken: _object_spread$4({
4605
+ sub: verified.subject,
4606
+ scope: scope,
4607
+ client_id: clientId
4608
+ }, accountClaims)
4609
+ };
4610
+ return [
4611
+ 3,
4612
+ 3
4613
+ ];
4614
+ case 2:
4615
+ e = _state.sent();
4616
+ // Not a verifiable JWT from this provider — indistinguishable from an unknown opaque token,
4617
+ // so report it the same way and let the caller emit the 401.
4618
+ this._logger.debug("verifyAccessToken: token is neither a known opaque token nor a verifiable JWT (".concat(e.message, ")."));
4619
+ return [
4620
+ 3,
4621
+ 3
4622
+ ];
4623
+ case 3:
4016
4624
  return [
4017
4625
  2,
4018
4626
  result
@@ -4038,9 +4646,9 @@ var OidcService_1;
4038
4646
  * @param grantId - The grant id (and Grant adapter entry id) to revoke.
4039
4647
  * @throws {Error} When the Grant entry does not exist.
4040
4648
  */ function revokeGrant(grantId) {
4041
- return _async_to_generator$5(function() {
4649
+ return _async_to_generator$6(function() {
4042
4650
  var provider, ProviderGrant, existing;
4043
- return _ts_generator$5(this, function(_state) {
4651
+ return _ts_generator$6(this, function(_state) {
4044
4652
  switch(_state.label){
4045
4653
  case 0:
4046
4654
  return [
@@ -4091,9 +4699,9 @@ var OidcService_1;
4091
4699
  * @param clientId - The client's document/adapter entry ID.
4092
4700
  * @returns The client payload data, or `undefined` if not found.
4093
4701
  */ function findClientPayload(clientId) {
4094
- return _async_to_generator$5(function() {
4702
+ return _async_to_generator$6(function() {
4095
4703
  var provider, ProviderClient, existing, result;
4096
- return _ts_generator$5(this, function(_state) {
4704
+ return _ts_generator$6(this, function(_state) {
4097
4705
  switch(_state.label){
4098
4706
  case 0:
4099
4707
  return [
@@ -4162,10 +4770,10 @@ var OidcService_1;
4162
4770
  defaultSeconds: overrideDefaultSeconds !== null && overrideDefaultSeconds !== void 0 ? overrideDefaultSeconds : perModelDefaultSeconds
4163
4771
  });
4164
4772
  };
4165
- return _object_spread_props(_object_spread$3({
4166
- routes: _object_spread$3({}, this.providerConfigService.routes),
4167
- claims: _object_spread$3({}, providerConfig.claims),
4168
- responseTypes: _to_consumable_array$4(providerConfig.responseTypes),
4773
+ return _object_spread_props(_object_spread$4({
4774
+ routes: _object_spread$4({}, this.providerConfigService.routes),
4775
+ claims: _object_spread$4({}, providerConfig.claims),
4776
+ responseTypes: _to_consumable_array$6(providerConfig.responseTypes),
4169
4777
  pkce: {
4170
4778
  required: function required() {
4171
4779
  return true;
@@ -4197,16 +4805,16 @@ var OidcService_1;
4197
4805
  return true;
4198
4806
  },
4199
4807
  getResourceServerInfo: function getResourceServerInfo(_ctx, resourceIndicator) {
4200
- return _async_to_generator$5(function() {
4808
+ return _async_to_generator$6(function() {
4201
4809
  var _config_resourceServers, info;
4202
- return _ts_generator$5(this, function(_state) {
4810
+ return _ts_generator$6(this, function(_state) {
4203
4811
  info = (_config_resourceServers = config.resourceServers) === null || _config_resourceServers === void 0 ? void 0 : _config_resourceServers[resourceIndicator];
4204
4812
  if (!info) {
4205
4813
  throw new errors.InvalidTarget("Unrecognized resource indicator: ".concat(resourceIndicator));
4206
4814
  }
4207
4815
  return [
4208
4816
  2,
4209
- _object_spread$3({
4817
+ _object_spread$4({
4210
4818
  scope: info.scope
4211
4819
  }, info.audience === undefined ? {} : {
4212
4820
  audience: info.audience
@@ -4283,9 +4891,9 @@ var OidcService_1;
4283
4891
  },
4284
4892
  interactions: {
4285
4893
  url: function url(_ctx, interaction) {
4286
- return _async_to_generator$5(function() {
4894
+ return _async_to_generator$6(function() {
4287
4895
  var baseUrl, client_id, paramsToEncode, client, _client_dbx_provider_profiles, requestedScopes, isAdmin, adminOnlyScopes, offeredScopes, scopes, requestedScopeSet, required, requiredScopes, interactionLoginDetails, paramsString;
4288
- return _ts_generator$5(this, function(_state) {
4896
+ return _ts_generator$6(this, function(_state) {
4289
4897
  switch(_state.label){
4290
4898
  case 0:
4291
4899
  client_id = interaction.params['client_id'];
@@ -4334,7 +4942,7 @@ var OidcService_1;
4334
4942
  requiredScopes = Array.from(required).filter(function(scope) {
4335
4943
  return requestedScopeSet.has(scope);
4336
4944
  });
4337
- interactionLoginDetails = _object_spread$3({
4945
+ interactionLoginDetails = _object_spread$4({
4338
4946
  client_id: client_id,
4339
4947
  client_name: client.client_name,
4340
4948
  client_uri: client.client_uri,
@@ -4343,7 +4951,7 @@ var OidcService_1;
4343
4951
  }, requiredScopes.length > 0 ? {
4344
4952
  requiredScopes: requiredScopes.join(' ')
4345
4953
  } : {});
4346
- paramsToEncode = _object_spread$3({}, paramsToEncode, interactionLoginDetails);
4954
+ paramsToEncode = _object_spread$4({}, paramsToEncode, interactionLoginDetails);
4347
4955
  _state.label = 4;
4348
4956
  case 4:
4349
4957
  paramsString = makeUrlSearchParamsString(paramsToEncode, {
@@ -4398,9 +5006,9 @@ var OidcService_1;
4398
5006
  // Bake account claims into the access token at issuance time so they're
4399
5007
  // available via `accessToken.extra` during verification without an extra DB call.
4400
5008
  extraTokenClaims: function extraTokenClaims(_ctx, token) {
4401
- return _async_to_generator$5(function() {
5009
+ return _async_to_generator$6(function() {
4402
5010
  var accountId, scope, result, account, claims, extraClaims, _providerConfig_nonRotatingScopes, nonRotatingScopes, scopeSet, provider, grant;
4403
- return _ts_generator$5(this, function(_state) {
5011
+ return _ts_generator$6(this, function(_state) {
4404
5012
  switch(_state.label){
4405
5013
  case 0:
4406
5014
  accountId = token.accountId;
@@ -4479,9 +5087,9 @@ var OidcService_1;
4479
5087
  key: "_buildProvider",
4480
5088
  value: // MARK: Internal
4481
5089
  function _buildProvider() {
4482
- return _async_to_generator$5(function() {
5090
+ return _async_to_generator$6(function() {
4483
5091
  var _this, _config_trustProxy, config, findAccount, signingKey, result, getEncryptionKey, cookieKey, adapterFactory, providerConfiguration, _ref, ProviderClass, interactionPolicy, provider;
4484
- return _ts_generator$5(this, function(_state) {
5092
+ return _ts_generator$6(this, function(_state) {
4485
5093
  switch(_state.label){
4486
5094
  case 0:
4487
5095
  _this = this;
@@ -4522,11 +5130,11 @@ var OidcService_1;
4522
5130
  ];
4523
5131
  case 4:
4524
5132
  _ref = _state.sent(), ProviderClass = _ref.default, interactionPolicy = _ref.interactionPolicy;
4525
- provider = new ProviderClass(config.issuer, _object_spread_props(_object_spread$3({}, providerConfiguration), {
5133
+ provider = new ProviderClass(config.issuer, _object_spread_props(_object_spread$4({}, providerConfiguration), {
4526
5134
  // The policy is applied here rather than in buildProviderConfiguration() because it needs the
4527
5135
  // `interactionPolicy` namespace off the dynamic (ESM-only) import, which that sync method has no
4528
5136
  // access to. Spread the configured `interactions` so its `url` builder survives.
4529
- interactions: _object_spread_props(_object_spread$3({}, providerConfiguration.interactions), {
5137
+ interactions: _object_spread_props(_object_spread$4({}, providerConfiguration.interactions), {
4530
5138
  policy: buildOidcInteractionPolicy(interactionPolicy)
4531
5139
  }),
4532
5140
  adapter: adapterFactory,
@@ -4567,9 +5175,9 @@ var OidcService_1;
4567
5175
  * @param interaction - The interaction whose session account should be checked.
4568
5176
  * @returns True when the interaction's account resolves to an admin user.
4569
5177
  */ function _isAdminInteractionUser(interaction) {
4570
- return _async_to_generator$5(function() {
5178
+ return _async_to_generator$6(function() {
4571
5179
  var _ref, _interaction_session, _this_accountService_delegate_isAdminUser, _this_accountService_delegate, accountId;
4572
- return _ts_generator$5(this, function(_state) {
5180
+ return _ts_generator$6(this, function(_state) {
4573
5181
  accountId = (_interaction_session = interaction.session) === null || _interaction_session === void 0 ? void 0 : _interaction_session.accountId;
4574
5182
  return [
4575
5183
  2,
@@ -4622,10 +5230,10 @@ OidcService = OidcService_1 = __decorate([
4622
5230
  __param(5, Inject(OidcEncryptionService))
4623
5231
  ], OidcService);
4624
5232
 
4625
- function _class_call_check$7(instance, Constructor) {
5233
+ function _class_call_check$8(instance, Constructor) {
4626
5234
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
4627
5235
  }
4628
- function _define_property$7(obj, key, value) {
5236
+ function _define_property$8(obj, key, value) {
4629
5237
  if (key in obj) {
4630
5238
  Object.defineProperty(obj, key, {
4631
5239
  value: value,
@@ -4661,14 +5269,14 @@ function _define_property$7(obj, key, value) {
4661
5269
  * export class MyApiModule {}
4662
5270
  * ```
4663
5271
  */ var OidcAuthMiddlewareConfig = function OidcAuthMiddlewareConfig() {
4664
- _class_call_check$7(this, OidcAuthMiddlewareConfig);
5272
+ _class_call_check$8(this, OidcAuthMiddlewareConfig);
4665
5273
  /**
4666
5274
  * Path prefixes that require OAuth bearer token verification.
4667
5275
  *
4668
5276
  * Only requests matching one of these prefixes will be checked.
4669
5277
  * Paths under the global API route prefix should not be included
4670
5278
  * since those are protected by AppCheck.
4671
- */ _define_property$7(this, "protectedPaths", void 0);
5279
+ */ _define_property$8(this, "protectedPaths", void 0);
4672
5280
  /**
4673
5281
  * Absolute URL of the OAuth 2.0 Protected Resource Metadata document
4674
5282
  * (RFC 9728). When set, included as the `resource_metadata` parameter
@@ -4676,7 +5284,7 @@ function _define_property$7(obj, key, value) {
4676
5284
  * clients can locate the discovery doc explicitly rather than relying on
4677
5285
  * origin-rooted path-walkback (which fails when the function isn't
4678
5286
  * mounted at `/` — e.g. behind the Firebase Functions emulator URL prefix).
4679
- */ _define_property$7(this, "resourceMetadataUrl", void 0);
5287
+ */ _define_property$8(this, "resourceMetadataUrl", void 0);
4680
5288
  };
4681
5289
  // MARK: WWW-Authenticate
4682
5290
  /**
@@ -4688,16 +5296,17 @@ function _define_property$7(obj, key, value) {
4688
5296
  * included as the RFC 9728 `resource_metadata` hint so clients can locate the
4689
5297
  * discovery doc directly instead of relying on origin-rooted path-walkback.
4690
5298
  *
5299
+ * Delegates to `@dereekb/oauth-resource`'s builder so the challenge an off-box resource server
5300
+ * emits and the one this API emits are produced by the same code.
5301
+ *
4691
5302
  * @param error - The RFC 6750 `error` token (e.g. `invalid_token`, `invalid_request`).
4692
5303
  * @param resourceMetadataUrl - Optional protected-resource metadata URL.
4693
5304
  * @returns Header value, e.g. `Bearer resource_metadata="…", error="invalid_token"`.
4694
5305
  */ function buildBearerChallenge(error, resourceMetadataUrl) {
4695
- var params = [];
4696
- if (resourceMetadataUrl) {
4697
- params.push('resource_metadata="'.concat(resourceMetadataUrl, '"'));
4698
- }
4699
- params.push('error="'.concat(error, '"'));
4700
- return "Bearer ".concat(params.join(', '));
5306
+ return buildBearerChallenge$1({
5307
+ error: error,
5308
+ resourceMetadataUrl: resourceMetadataUrl
5309
+ });
4701
5310
  }
4702
5311
  // MARK: Module
4703
5312
  var _logger = new Logger('applyOidcAuthMiddleware');
@@ -4787,7 +5396,7 @@ var _logger = new Logger('applyOidcAuthMiddleware');
4787
5396
  _logger.debug("Applied OAuth bearer token middleware for paths: ".concat(protectedPaths.join(', ')));
4788
5397
  }
4789
5398
 
4790
- function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
5399
+ function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
4791
5400
  try {
4792
5401
  var info = gen[key](arg);
4793
5402
  var value = info.value;
@@ -4798,25 +5407,25 @@ function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
4798
5407
  if (info.done) resolve(value);
4799
5408
  else Promise.resolve(value).then(_next, _throw);
4800
5409
  }
4801
- function _async_to_generator$4(fn) {
5410
+ function _async_to_generator$5(fn) {
4802
5411
  return function() {
4803
5412
  var self = this, args = arguments;
4804
5413
  return new Promise(function(resolve, reject) {
4805
5414
  var gen = fn.apply(self, args);
4806
5415
  function _next(value) {
4807
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
5416
+ asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
4808
5417
  }
4809
5418
  function _throw(err) {
4810
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
5419
+ asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
4811
5420
  }
4812
5421
  _next(undefined);
4813
5422
  });
4814
5423
  };
4815
5424
  }
4816
- function _class_call_check$6(instance, Constructor) {
5425
+ function _class_call_check$7(instance, Constructor) {
4817
5426
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
4818
5427
  }
4819
- function _defineProperties$5(target, props) {
5428
+ function _defineProperties$6(target, props) {
4820
5429
  for(var i = 0; i < props.length; i++){
4821
5430
  var descriptor = props[i];
4822
5431
  descriptor.enumerable = descriptor.enumerable || false;
@@ -4825,11 +5434,11 @@ function _defineProperties$5(target, props) {
4825
5434
  Object.defineProperty(target, descriptor.key, descriptor);
4826
5435
  }
4827
5436
  }
4828
- function _create_class$5(Constructor, protoProps, staticProps) {
4829
- if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
5437
+ function _create_class$6(Constructor, protoProps, staticProps) {
5438
+ if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
4830
5439
  return Constructor;
4831
5440
  }
4832
- function _define_property$6(obj, key, value) {
5441
+ function _define_property$7(obj, key, value) {
4833
5442
  if (key in obj) {
4834
5443
  Object.defineProperty(obj, key, {
4835
5444
  value: value,
@@ -4846,7 +5455,7 @@ function _instanceof$1(left, right) {
4846
5455
  return !!right[Symbol.hasInstance](left);
4847
5456
  } else return left instanceof right;
4848
5457
  }
4849
- function _ts_generator$4(thisArg, body) {
5458
+ function _ts_generator$5(thisArg, body) {
4850
5459
  var f, y, t, _ = {
4851
5460
  label: 0,
4852
5461
  sent: function() {
@@ -4975,20 +5584,20 @@ function _ts_generator$4(thisArg, body) {
4975
5584
  * @throws {UnauthorizedException} When the Authorization header is missing, malformed, or the token is invalid/expired.
4976
5585
  */ var OidcAuthBearerTokenMiddleware = /*#__PURE__*/ function() {
4977
5586
  function OidcAuthBearerTokenMiddleware(oidcService, config) {
4978
- _class_call_check$6(this, OidcAuthBearerTokenMiddleware);
4979
- _define_property$6(this, "oidcService", void 0);
4980
- _define_property$6(this, "config", void 0);
4981
- _define_property$6(this, "logger", new Logger('OidcAuthBearerTokenMiddleware'));
5587
+ _class_call_check$7(this, OidcAuthBearerTokenMiddleware);
5588
+ _define_property$7(this, "oidcService", void 0);
5589
+ _define_property$7(this, "config", void 0);
5590
+ _define_property$7(this, "logger", new Logger('OidcAuthBearerTokenMiddleware'));
4982
5591
  this.oidcService = oidcService;
4983
5592
  this.config = config;
4984
5593
  }
4985
- _create_class$5(OidcAuthBearerTokenMiddleware, [
5594
+ _create_class$6(OidcAuthBearerTokenMiddleware, [
4986
5595
  {
4987
5596
  key: "use",
4988
5597
  value: function use(req, res, next) {
4989
- return _async_to_generator$4(function() {
5598
+ return _async_to_generator$5(function() {
4990
5599
  var authHeader, token, oauthAuth, err;
4991
- return _ts_generator$4(this, function(_state) {
5600
+ return _ts_generator$5(this, function(_state) {
4992
5601
  switch(_state.label){
4993
5602
  case 0:
4994
5603
  authHeader = req.headers.authorization;
@@ -5054,32 +5663,32 @@ OidcAuthBearerTokenMiddleware = __decorate([
5054
5663
  __param(1, Inject(OidcAuthMiddlewareConfig))
5055
5664
  ], OidcAuthBearerTokenMiddleware);
5056
5665
 
5057
- function _array_like_to_array$3(arr, len) {
5666
+ function _array_like_to_array$5(arr, len) {
5058
5667
  if (len == null || len > arr.length) len = arr.length;
5059
5668
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5060
5669
  return arr2;
5061
5670
  }
5062
- function _array_without_holes$3(arr) {
5063
- if (Array.isArray(arr)) return _array_like_to_array$3(arr);
5671
+ function _array_without_holes$5(arr) {
5672
+ if (Array.isArray(arr)) return _array_like_to_array$5(arr);
5064
5673
  }
5065
- function _iterable_to_array$3(iter) {
5674
+ function _iterable_to_array$5(iter) {
5066
5675
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
5067
5676
  return Array.from(iter);
5068
5677
  }
5069
5678
  }
5070
- function _non_iterable_spread$3() {
5679
+ function _non_iterable_spread$5() {
5071
5680
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5072
5681
  }
5073
- function _to_consumable_array$3(arr) {
5074
- return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread$3();
5682
+ function _to_consumable_array$5(arr) {
5683
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$5();
5075
5684
  }
5076
- function _unsupported_iterable_to_array$3(o, minLen) {
5685
+ function _unsupported_iterable_to_array$5(o, minLen) {
5077
5686
  if (!o) return;
5078
- if (typeof o === "string") return _array_like_to_array$3(o, minLen);
5687
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
5079
5688
  var n = Object.prototype.toString.call(o).slice(8, -1);
5080
5689
  if (n === "Object" && o.constructor) n = o.constructor.name;
5081
5690
  if (n === "Map" || n === "Set") return Array.from(n);
5082
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
5691
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
5083
5692
  }
5084
5693
  /**
5085
5694
  * Builds the `cors`-package origin delegate implementing the composed OIDC CORS policy.
@@ -5102,7 +5711,7 @@ function _unsupported_iterable_to_array$3(o, minLen) {
5102
5711
  var clientBased = cors.clientBased === true;
5103
5712
  var allowlist = new Set([
5104
5713
  appUrl
5105
- ].concat(_to_consumable_array$3((_cors_allowOrigins = cors.allowOrigins) !== null && _cors_allowOrigins !== void 0 ? _cors_allowOrigins : [])));
5714
+ ].concat(_to_consumable_array$5((_cors_allowOrigins = cors.allowOrigins) !== null && _cors_allowOrigins !== void 0 ? _cors_allowOrigins : [])));
5106
5715
  return function(requestOrigin, callback) {
5107
5716
  var resolved;
5108
5717
  if (requestOrigin && allowlist.has(requestOrigin)) {
@@ -5214,7 +5823,7 @@ function _unsupported_iterable_to_array$3(o, minLen) {
5214
5823
  * ```
5215
5824
  */ var FIREBASE_SERVER_OIDC_ANALYTICS_CONFIG = 'FIREBASE_SERVER_OIDC_ANALYTICS_CONFIG';
5216
5825
 
5217
- function _class_call_check$5(instance, Constructor) {
5826
+ function _class_call_check$6(instance, Constructor) {
5218
5827
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
5219
5828
  }
5220
5829
  /**
@@ -5223,7 +5832,7 @@ function _class_call_check$5(instance, Constructor) {
5223
5832
  * Analogous to the MCP `McpAnalyticsService` but scoped to the OIDC/OAuth transport.
5224
5833
  * Apps extend this class and provide it via {@link OIDC_ANALYTICS_SERVICE}.
5225
5834
  */ var OidcAnalyticsService = function OidcAnalyticsService() {
5226
- _class_call_check$5(this, OidcAnalyticsService);
5835
+ _class_call_check$6(this, OidcAnalyticsService);
5227
5836
  };
5228
5837
  /**
5229
5838
  * Injection token for the OIDC analytics service.
@@ -5269,9 +5878,280 @@ function _assert_this_initialized(self) {
5269
5878
  if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5270
5879
  return self;
5271
5880
  }
5272
- function _call_super(_this, derived, args) {
5273
- derived = _get_prototype_of(derived);
5274
- return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
5881
+ function _call_super(_this, derived, args) {
5882
+ derived = _get_prototype_of(derived);
5883
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
5884
+ }
5885
+ function _class_call_check$5(instance, Constructor) {
5886
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
5887
+ }
5888
+ function _defineProperties$5(target, props) {
5889
+ for(var i = 0; i < props.length; i++){
5890
+ var descriptor = props[i];
5891
+ descriptor.enumerable = descriptor.enumerable || false;
5892
+ descriptor.configurable = true;
5893
+ if ("value" in descriptor) descriptor.writable = true;
5894
+ Object.defineProperty(target, descriptor.key, descriptor);
5895
+ }
5896
+ }
5897
+ function _create_class$5(Constructor, protoProps, staticProps) {
5898
+ if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
5899
+ return Constructor;
5900
+ }
5901
+ function _define_property$6(obj, key, value) {
5902
+ if (key in obj) {
5903
+ Object.defineProperty(obj, key, {
5904
+ value: value,
5905
+ enumerable: true,
5906
+ configurable: true,
5907
+ writable: true
5908
+ });
5909
+ } else obj[key] = value;
5910
+ return obj;
5911
+ }
5912
+ function _get_prototype_of(o) {
5913
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
5914
+ return o.__proto__ || Object.getPrototypeOf(o);
5915
+ };
5916
+ return _get_prototype_of(o);
5917
+ }
5918
+ function _inherits(subClass, superClass) {
5919
+ if (typeof superClass !== "function" && superClass !== null) {
5920
+ throw new TypeError("Super expression must either be null or a function");
5921
+ }
5922
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
5923
+ constructor: {
5924
+ value: subClass,
5925
+ writable: true,
5926
+ configurable: true
5927
+ }
5928
+ });
5929
+ if (superClass) _set_prototype_of(subClass, superClass);
5930
+ }
5931
+ function _is_native_reflect_construct() {
5932
+ try {
5933
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
5934
+ } catch (_) {}
5935
+ return (_is_native_reflect_construct = function() {
5936
+ return !!result;
5937
+ })();
5938
+ }
5939
+ function _object_spread$3(target) {
5940
+ for(var i = 1; i < arguments.length; i++){
5941
+ var source = arguments[i] != null ? arguments[i] : {};
5942
+ var ownKeys = Object.keys(source);
5943
+ if (typeof Object.getOwnPropertySymbols === "function") {
5944
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
5945
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
5946
+ }));
5947
+ }
5948
+ ownKeys.forEach(function(key) {
5949
+ _define_property$6(target, key, source[key]);
5950
+ });
5951
+ }
5952
+ return target;
5953
+ }
5954
+ function _possible_constructor_return(self, call) {
5955
+ if (call && (_type_of$1(call) === "object" || typeof call === "function")) return call;
5956
+ return _assert_this_initialized(self);
5957
+ }
5958
+ function _set_prototype_of(o, p) {
5959
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
5960
+ o.__proto__ = p;
5961
+ return o;
5962
+ };
5963
+ return _set_prototype_of(o, p);
5964
+ }
5965
+ function _type_of$1(obj) {
5966
+ "@swc/helpers - typeof";
5967
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
5968
+ }
5969
+ var FirebaseServerOidcAnalyticsService_1;
5970
+ /**
5971
+ * Reusable {@link OidcAnalyticsService} that forwards each high-level OIDC event to the app's
5972
+ * {@link FirebaseServerAnalyticsService}, so OIDC-transport analytics feed the same downstream
5973
+ * pipeline (e.g. Segment) as model and MCP analytics.
5974
+ *
5975
+ * Each {@link OidcAnalyticsEvent.type} resolves to a distinct downstream event name
5976
+ * (`eventNamePrefix` + per-type name, e.g. `'OIDC Login'`). Registered globally via
5977
+ * {@link appOidcAnalyticsModuleMetadata}; tuned via {@link FirebaseServerOidcAnalyticsConfig}.
5978
+ * When no analytics service is available the call is a no-op aside from the optional log line.
5979
+ */ var FirebaseServerOidcAnalyticsService = FirebaseServerOidcAnalyticsService_1 = /*#__PURE__*/ function(OidcAnalyticsService) {
5980
+ _inherits(FirebaseServerOidcAnalyticsService, OidcAnalyticsService);
5981
+ function FirebaseServerOidcAnalyticsService(firebaseServerEnvService, analyticsService, config) {
5982
+ _class_call_check$5(this, FirebaseServerOidcAnalyticsService);
5983
+ var _this;
5984
+ var _ref, _ref1;
5985
+ _this = _call_super(this, FirebaseServerOidcAnalyticsService), _define_property$6(_this, "firebaseServerEnvService", void 0), _define_property$6(_this, "analyticsService", void 0), _define_property$6(_this, "_logger", new Logger(FirebaseServerOidcAnalyticsService_1.name)), _define_property$6(_this, "_eventNamePrefix", void 0), _define_property$6(_this, "_eventNames", void 0), _define_property$6(_this, "_logEvents", void 0);
5986
+ _this.firebaseServerEnvService = firebaseServerEnvService;
5987
+ _this.analyticsService = analyticsService;
5988
+ _this._eventNamePrefix = (_ref = config === null || config === void 0 ? void 0 : config.eventNamePrefix) !== null && _ref !== void 0 ? _ref : DEFAULT_OIDC_ANALYTICS_EVENT_NAME_PREFIX;
5989
+ _this._eventNames = _object_spread$3({}, DEFAULT_OIDC_ANALYTICS_EVENT_NAMES, config === null || config === void 0 ? void 0 : config.eventNames);
5990
+ _this._logEvents = (_ref1 = config === null || config === void 0 ? void 0 : config.logEvents) !== null && _ref1 !== void 0 ? _ref1 : !_this.firebaseServerEnvService.isProduction;
5991
+ return _this;
5992
+ }
5993
+ _create_class$5(FirebaseServerOidcAnalyticsService, [
5994
+ {
5995
+ key: "handleOidcAnalyticsEvent",
5996
+ value: function handleOidcAnalyticsEvent(event) {
5997
+ var _this__eventNames_event_type;
5998
+ var name = "".concat(this._eventNamePrefix).concat((_this__eventNames_event_type = this._eventNames[event.type]) !== null && _this__eventNames_event_type !== void 0 ? _this__eventNames_event_type : event.type);
5999
+ if (this._logEvents) {
6000
+ var uidSuffix = event.uid ? " uid=".concat(event.uid) : '';
6001
+ var durationSuffix = event.durationMs == null ? '' : " (".concat(event.durationMs, "ms)");
6002
+ var outcome = event.isSuccessful ? 'Succeeded' : 'Failed';
6003
+ var reasonSuffix = event.reason ? " reason=".concat(event.reason) : '';
6004
+ this._logger.log("".concat(name, " ").concat(outcome).concat(uidSuffix).concat(reasonSuffix).concat(durationSuffix));
6005
+ }
6006
+ if (this.analyticsService != null) {
6007
+ var _event_clientId, _event_serviceToken, _event_isAdmin, _event_denied, _event_reason;
6008
+ // Drop undefined values so the downstream payload stays clean.
6009
+ var data = filterUndefinedValues({
6010
+ clientId: (_event_clientId = event.clientId) !== null && _event_clientId !== void 0 ? _event_clientId : undefined,
6011
+ scopes: event.scopes != null && event.scopes.length > 0 ? event.scopes.join(' ') : undefined,
6012
+ serviceToken: (_event_serviceToken = event.serviceToken) !== null && _event_serviceToken !== void 0 ? _event_serviceToken : undefined,
6013
+ isAdmin: (_event_isAdmin = event.isAdmin) !== null && _event_isAdmin !== void 0 ? _event_isAdmin : undefined,
6014
+ denied: (_event_denied = event.denied) !== null && _event_denied !== void 0 ? _event_denied : undefined,
6015
+ reason: (_event_reason = event.reason) !== null && _event_reason !== void 0 ? _event_reason : undefined,
6016
+ success: event.isSuccessful
6017
+ });
6018
+ this.analyticsService.sendEventData(event.uid, name, data);
6019
+ }
6020
+ }
6021
+ }
6022
+ ]);
6023
+ return FirebaseServerOidcAnalyticsService;
6024
+ }(OidcAnalyticsService);
6025
+ FirebaseServerOidcAnalyticsService = FirebaseServerOidcAnalyticsService_1 = __decorate([
6026
+ Injectable(),
6027
+ __param(0, Inject(FirebaseServerEnvService)),
6028
+ __param(1, Optional()),
6029
+ __param(1, Inject(FirebaseServerAnalyticsService)),
6030
+ __param(2, Optional()),
6031
+ __param(2, Inject(FIREBASE_SERVER_OIDC_ANALYTICS_CONFIG))
6032
+ ], FirebaseServerOidcAnalyticsService);
6033
+
6034
+ function _array_like_to_array$4(arr, len) {
6035
+ if (len == null || len > arr.length) len = arr.length;
6036
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6037
+ return arr2;
6038
+ }
6039
+ function _array_without_holes$4(arr) {
6040
+ if (Array.isArray(arr)) return _array_like_to_array$4(arr);
6041
+ }
6042
+ function _iterable_to_array$4(iter) {
6043
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
6044
+ return Array.from(iter);
6045
+ }
6046
+ }
6047
+ function _non_iterable_spread$4() {
6048
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6049
+ }
6050
+ function _to_consumable_array$4(arr) {
6051
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$4();
6052
+ }
6053
+ function _unsupported_iterable_to_array$4(o, minLen) {
6054
+ if (!o) return;
6055
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
6056
+ var n = Object.prototype.toString.call(o).slice(8, -1);
6057
+ if (n === "Object" && o.constructor) n = o.constructor.name;
6058
+ if (n === "Map" || n === "Set") return Array.from(n);
6059
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
6060
+ }
6061
+ /**
6062
+ * Generates NestJS module metadata that registers {@link FirebaseServerOidcAnalyticsService} as the
6063
+ * OIDC analytics consumer, aliased to {@link OIDC_ANALYTICS_SERVICE}.
6064
+ *
6065
+ * Mirrors the convention used by `appMcpAnalyticsModuleMetadata`. Requires no dependency module —
6066
+ * `FirebaseServerAnalyticsService` is resolved optionally and is expected to be supplied globally by
6067
+ * the app's analytics module.
6068
+ *
6069
+ * Decorate a `@Global()` module with the result so the `OIDC_ANALYTICS_SERVICE` token is visible to
6070
+ * the OIDC controllers and services provided by the app's OIDC module.
6071
+ *
6072
+ * @param config - Optional metadata + analytics config to merge in.
6073
+ * @returns NestJS module metadata providing + exporting the OIDC analytics service and token.
6074
+ *
6075
+ * @example
6076
+ * ```typescript
6077
+ * @Global()
6078
+ * @Module(appOidcAnalyticsModuleMetadata())
6079
+ * export class AppOidcAnalyticsModule {}
6080
+ * ```
6081
+ */ function appOidcAnalyticsModuleMetadata() {
6082
+ var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
6083
+ var oidcAnalyticsConfig = config.oidcAnalyticsConfig, imports = config.imports, exports = config.exports, providers = config.providers;
6084
+ var configProviders = oidcAnalyticsConfig ? [
6085
+ {
6086
+ provide: FIREBASE_SERVER_OIDC_ANALYTICS_CONFIG,
6087
+ useValue: oidcAnalyticsConfig
6088
+ }
6089
+ ] : [];
6090
+ return {
6091
+ imports: _to_consumable_array$4(imports !== null && imports !== void 0 ? imports : []),
6092
+ exports: [
6093
+ OIDC_ANALYTICS_SERVICE,
6094
+ FirebaseServerOidcAnalyticsService
6095
+ ].concat(_to_consumable_array$4(exports !== null && exports !== void 0 ? exports : [])),
6096
+ providers: [
6097
+ FirebaseServerOidcAnalyticsService,
6098
+ {
6099
+ provide: OIDC_ANALYTICS_SERVICE,
6100
+ useExisting: FirebaseServerOidcAnalyticsService
6101
+ }
6102
+ ].concat(_to_consumable_array$4(configProviders), _to_consumable_array$4(providers !== null && providers !== void 0 ? providers : []))
6103
+ };
6104
+ }
6105
+
6106
+ // MARK: Scopes
6107
+ /**
6108
+ * Reads the set of OIDC scopes carried by a callable request's bearer token.
6109
+ *
6110
+ * The `ModelApiCallModelDispatchService` builds a synthetic `CallableRequest` with
6111
+ * `auth.token = oidcValidatedToken ?? {}`, so the OIDC scope string lives at
6112
+ * `request.auth.token.scope` for OIDC callers and is `undefined` for non-OIDC
6113
+ * (regular Firebase ID-token) callers.
6114
+ *
6115
+ * Returning `undefined` for non-OIDC callers lets consumers (e.g. the MCP tool-visibility filter)
6116
+ * skip scope enforcement instead of falsely treating the missing claim as "no scopes granted".
6117
+ *
6118
+ * The parameter is intentionally typed as `unknown` because `DecodedIdToken` (Firebase
6119
+ * Auth's typed token shape) does not declare a `scope` field, while OIDC bearer-token
6120
+ * callers attach one at runtime. Reading is done defensively.
6121
+ *
6122
+ * @param request - The callable request as seen inside an `onCallModel` handler.
6123
+ * @returns A `Set<string>` of granted scopes, or `undefined` when the request carries no OIDC `scope` claim.
6124
+ */ function getOidcScopesFromRequest(request) {
6125
+ var _request_auth_token, _request_auth;
6126
+ var scope = request === null || request === void 0 ? void 0 : (_request_auth = request.auth) === null || _request_auth === void 0 ? void 0 : (_request_auth_token = _request_auth.token) === null || _request_auth_token === void 0 ? void 0 : _request_auth_token.scope;
6127
+ return oidcScopesFromScopeClaim(scope);
6128
+ }
6129
+
6130
+ function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
6131
+ try {
6132
+ var info = gen[key](arg);
6133
+ var value = info.value;
6134
+ } catch (error) {
6135
+ reject(error);
6136
+ return;
6137
+ }
6138
+ if (info.done) resolve(value);
6139
+ else Promise.resolve(value).then(_next, _throw);
6140
+ }
6141
+ function _async_to_generator$4(fn) {
6142
+ return function() {
6143
+ var self = this, args = arguments;
6144
+ return new Promise(function(resolve, reject) {
6145
+ var gen = fn.apply(self, args);
6146
+ function _next(value) {
6147
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
6148
+ }
6149
+ function _throw(err) {
6150
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
6151
+ }
6152
+ _next(undefined);
6153
+ });
6154
+ };
5275
6155
  }
5276
6156
  function _class_call_check$4(instance, Constructor) {
5277
6157
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
@@ -5300,33 +6180,6 @@ function _define_property$5(obj, key, value) {
5300
6180
  } else obj[key] = value;
5301
6181
  return obj;
5302
6182
  }
5303
- function _get_prototype_of(o) {
5304
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
5305
- return o.__proto__ || Object.getPrototypeOf(o);
5306
- };
5307
- return _get_prototype_of(o);
5308
- }
5309
- function _inherits(subClass, superClass) {
5310
- if (typeof superClass !== "function" && superClass !== null) {
5311
- throw new TypeError("Super expression must either be null or a function");
5312
- }
5313
- subClass.prototype = Object.create(superClass && superClass.prototype, {
5314
- constructor: {
5315
- value: subClass,
5316
- writable: true,
5317
- configurable: true
5318
- }
5319
- });
5320
- if (superClass) _set_prototype_of(subClass, superClass);
5321
- }
5322
- function _is_native_reflect_construct() {
5323
- try {
5324
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
5325
- } catch (_) {}
5326
- return (_is_native_reflect_construct = function() {
5327
- return !!result;
5328
- })();
5329
- }
5330
6183
  function _object_spread$2(target) {
5331
6184
  for(var i = 1; i < arguments.length; i++){
5332
6185
  var source = arguments[i] != null ? arguments[i] : {};
@@ -5342,182 +6195,519 @@ function _object_spread$2(target) {
5342
6195
  }
5343
6196
  return target;
5344
6197
  }
5345
- function _possible_constructor_return(self, call) {
5346
- if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
5347
- return _assert_this_initialized(self);
5348
- }
5349
- function _set_prototype_of(o, p) {
5350
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
5351
- o.__proto__ = p;
5352
- return o;
5353
- };
5354
- return _set_prototype_of(o, p);
5355
- }
5356
- function _type_of(obj) {
5357
- "@swc/helpers - typeof";
5358
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
6198
+ function _ts_generator$4(thisArg, body) {
6199
+ var f, y, t, _ = {
6200
+ label: 0,
6201
+ sent: function() {
6202
+ if (t[0] & 1) throw t[1];
6203
+ return t[1];
6204
+ },
6205
+ trys: [],
6206
+ ops: []
6207
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
6208
+ return d(g, "next", {
6209
+ value: verb(0)
6210
+ }), d(g, "throw", {
6211
+ value: verb(1)
6212
+ }), d(g, "return", {
6213
+ value: verb(2)
6214
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
6215
+ value: function() {
6216
+ return this;
6217
+ }
6218
+ }), g;
6219
+ function verb(n) {
6220
+ return function(v) {
6221
+ return step([
6222
+ n,
6223
+ v
6224
+ ]);
6225
+ };
6226
+ }
6227
+ function step(op) {
6228
+ if (f) throw new TypeError("Generator is already executing.");
6229
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
6230
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
6231
+ if (y = 0, t) op = [
6232
+ op[0] & 2,
6233
+ t.value
6234
+ ];
6235
+ switch(op[0]){
6236
+ case 0:
6237
+ case 1:
6238
+ t = op;
6239
+ break;
6240
+ case 4:
6241
+ _.label++;
6242
+ return {
6243
+ value: op[1],
6244
+ done: false
6245
+ };
6246
+ case 5:
6247
+ _.label++;
6248
+ y = op[1];
6249
+ op = [
6250
+ 0
6251
+ ];
6252
+ continue;
6253
+ case 7:
6254
+ op = _.ops.pop();
6255
+ _.trys.pop();
6256
+ continue;
6257
+ default:
6258
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
6259
+ _ = 0;
6260
+ continue;
6261
+ }
6262
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
6263
+ _.label = op[1];
6264
+ break;
6265
+ }
6266
+ if (op[0] === 6 && _.label < t[1]) {
6267
+ _.label = t[1];
6268
+ t = op;
6269
+ break;
6270
+ }
6271
+ if (t && _.label < t[2]) {
6272
+ _.label = t[2];
6273
+ _.ops.push(op);
6274
+ break;
6275
+ }
6276
+ if (t[2]) _.ops.pop();
6277
+ _.trys.pop();
6278
+ continue;
6279
+ }
6280
+ op = body.call(thisArg, _);
6281
+ } catch (e) {
6282
+ op = [
6283
+ 6,
6284
+ e
6285
+ ];
6286
+ y = 0;
6287
+ } finally{
6288
+ f = t = 0;
6289
+ }
6290
+ if (op[0] & 5) throw op[1];
6291
+ return {
6292
+ value: op[0] ? op[1] : void 0,
6293
+ done: true
6294
+ };
6295
+ }
5359
6296
  }
5360
- var FirebaseServerOidcAnalyticsService_1;
6297
+ // MARK: Service
5361
6298
  /**
5362
- * Reusable {@link OidcAnalyticsService} that forwards each high-level OIDC event to the app's
5363
- * {@link FirebaseServerAnalyticsService}, so OIDC-transport analytics feed the same downstream
5364
- * pipeline (e.g. Segment) as model and MCP analytics.
5365
- *
5366
- * Each {@link OidcAnalyticsEvent.type} resolves to a distinct downstream event name
5367
- * (`eventNamePrefix` + per-type name, e.g. `'OIDC Login'`). Registered globally via
5368
- * {@link appOidcAnalyticsModuleMetadata}; tuned via {@link FirebaseServerOidcAnalyticsConfig}.
5369
- * When no analytics service is available the call is a no-op aside from the optional log line.
5370
- */ var FirebaseServerOidcAnalyticsService = FirebaseServerOidcAnalyticsService_1 = /*#__PURE__*/ function(OidcAnalyticsService) {
5371
- _inherits(FirebaseServerOidcAnalyticsService, OidcAnalyticsService);
5372
- function FirebaseServerOidcAnalyticsService(firebaseServerEnvService, analyticsService, config) {
5373
- _class_call_check$4(this, FirebaseServerOidcAnalyticsService);
5374
- var _this;
5375
- var _ref, _ref1;
5376
- _this = _call_super(this, FirebaseServerOidcAnalyticsService), _define_property$5(_this, "firebaseServerEnvService", void 0), _define_property$5(_this, "analyticsService", void 0), _define_property$5(_this, "_logger", new Logger(FirebaseServerOidcAnalyticsService_1.name)), _define_property$5(_this, "_eventNamePrefix", void 0), _define_property$5(_this, "_eventNames", void 0), _define_property$5(_this, "_logEvents", void 0);
5377
- _this.firebaseServerEnvService = firebaseServerEnvService;
5378
- _this.analyticsService = analyticsService;
5379
- _this._eventNamePrefix = (_ref = config === null || config === void 0 ? void 0 : config.eventNamePrefix) !== null && _ref !== void 0 ? _ref : DEFAULT_OIDC_ANALYTICS_EVENT_NAME_PREFIX;
5380
- _this._eventNames = _object_spread$2({}, DEFAULT_OIDC_ANALYTICS_EVENT_NAMES, config === null || config === void 0 ? void 0 : config.eventNames);
5381
- _this._logEvents = (_ref1 = config === null || config === void 0 ? void 0 : config.logEvents) !== null && _ref1 !== void 0 ? _ref1 : !_this.firebaseServerEnvService.isProduction;
5382
- return _this;
6299
+ * Service for handling OIDC interactions.
6300
+ */ var OidcInteractionService = /*#__PURE__*/ function() {
6301
+ function OidcInteractionService(oidcService, clientService) {
6302
+ _class_call_check$4(this, OidcInteractionService);
6303
+ _define_property$5(this, "oidcService", void 0);
6304
+ _define_property$5(this, "clientService", void 0);
6305
+ this.oidcService = oidcService;
6306
+ this.clientService = clientService;
5383
6307
  }
5384
- _create_class$4(FirebaseServerOidcAnalyticsService, [
6308
+ _create_class$4(OidcInteractionService, [
6309
+ {
6310
+ key: "getInteractionDetails",
6311
+ value: /**
6312
+ * Loads the interaction details for a given request/response pair.
6313
+ *
6314
+ * Requires the oidc-provider interaction cookie to be present on the request.
6315
+ *
6316
+ * @param req - The Express request containing the interaction cookie.
6317
+ * @param res - The Express response.
6318
+ * @returns The oidc-provider interaction details.
6319
+ */ function getInteractionDetails(req, res) {
6320
+ return _async_to_generator$4(function() {
6321
+ var provider;
6322
+ return _ts_generator$4(this, function(_state) {
6323
+ switch(_state.label){
6324
+ case 0:
6325
+ return [
6326
+ 4,
6327
+ this.oidcService.getProvider()
6328
+ ];
6329
+ case 1:
6330
+ provider = _state.sent();
6331
+ return [
6332
+ 2,
6333
+ provider.interactionDetails(req, res)
6334
+ ];
6335
+ }
6336
+ });
6337
+ }).call(this);
6338
+ }
6339
+ },
6340
+ {
6341
+ key: "findInteractionByUid",
6342
+ value: /**
6343
+ * Finds an interaction by its UID directly from the adapter store.
6344
+ *
6345
+ * Bypasses the cookie-based lookup used by `provider.interactionDetails()`.
6346
+ * This is necessary when the interaction cookie is scoped to a different path
6347
+ * (e.g., the frontend) and is not sent with backend API requests.
6348
+ *
6349
+ * @param uid - The interaction UID to look up.
6350
+ * @returns The interaction details for the given UID.
6351
+ * @throws {Error} When the interaction is not found or has expired.
6352
+ */ function findInteractionByUid(uid) {
6353
+ return _async_to_generator$4(function() {
6354
+ var provider, interaction;
6355
+ return _ts_generator$4(this, function(_state) {
6356
+ switch(_state.label){
6357
+ case 0:
6358
+ return [
6359
+ 4,
6360
+ this.oidcService.getProvider()
6361
+ ];
6362
+ case 1:
6363
+ provider = _state.sent();
6364
+ return [
6365
+ 4,
6366
+ provider.Interaction.find(uid)
6367
+ ];
6368
+ case 2:
6369
+ interaction = _state.sent();
6370
+ if (!interaction) {
6371
+ throw new Error('Interaction not found');
6372
+ }
6373
+ return [
6374
+ 2,
6375
+ interaction
6376
+ ];
6377
+ }
6378
+ });
6379
+ }).call(this);
6380
+ }
6381
+ },
5385
6382
  {
5386
- key: "handleOidcAnalyticsEvent",
5387
- value: function handleOidcAnalyticsEvent(event) {
5388
- var _this__eventNames_event_type;
5389
- var name = "".concat(this._eventNamePrefix).concat((_this__eventNames_event_type = this._eventNames[event.type]) !== null && _this__eventNames_event_type !== void 0 ? _this__eventNames_event_type : event.type);
5390
- if (this._logEvents) {
5391
- var uidSuffix = event.uid ? " uid=".concat(event.uid) : '';
5392
- var durationSuffix = event.durationMs == null ? '' : " (".concat(event.durationMs, "ms)");
5393
- var outcome = event.isSuccessful ? 'Succeeded' : 'Failed';
5394
- var reasonSuffix = event.reason ? " reason=".concat(event.reason) : '';
5395
- this._logger.log("".concat(name, " ").concat(outcome).concat(uidSuffix).concat(reasonSuffix).concat(durationSuffix));
5396
- }
5397
- if (this.analyticsService != null) {
5398
- var _event_clientId, _event_serviceToken, _event_isAdmin, _event_denied, _event_reason;
5399
- // Drop undefined values so the downstream payload stays clean.
5400
- var data = filterUndefinedValues({
5401
- clientId: (_event_clientId = event.clientId) !== null && _event_clientId !== void 0 ? _event_clientId : undefined,
5402
- scopes: event.scopes != null && event.scopes.length > 0 ? event.scopes.join(' ') : undefined,
5403
- serviceToken: (_event_serviceToken = event.serviceToken) !== null && _event_serviceToken !== void 0 ? _event_serviceToken : undefined,
5404
- isAdmin: (_event_isAdmin = event.isAdmin) !== null && _event_isAdmin !== void 0 ? _event_isAdmin : undefined,
5405
- denied: (_event_denied = event.denied) !== null && _event_denied !== void 0 ? _event_denied : undefined,
5406
- reason: (_event_reason = event.reason) !== null && _event_reason !== void 0 ? _event_reason : undefined,
5407
- success: event.isSuccessful
6383
+ key: "finishInteractionByUid",
6384
+ value: /**
6385
+ * Completes an interaction by UID without requiring the interaction cookie.
6386
+ *
6387
+ * Looks up the interaction directly by UID, applies the result, saves it,
6388
+ * and returns the `returnTo` URL for the client to redirect to.
6389
+ *
6390
+ * @param uid - The interaction UID to complete.
6391
+ * @param result - The interaction results to apply.
6392
+ * @param options - Optional settings for merging with the last submission.
6393
+ * @param options.mergeWithLastSubmission - Whether to merge with the last submission (defaults to true)
6394
+ * @returns The interaction that was completed. It includes the returnTo property for the next step of the interaction.
6395
+ */ function finishInteractionByUid(uid, result, options) {
6396
+ return _async_to_generator$4(function() {
6397
+ var _ref, interaction, mergeWithLastSubmission;
6398
+ return _ts_generator$4(this, function(_state) {
6399
+ switch(_state.label){
6400
+ case 0:
6401
+ return [
6402
+ 4,
6403
+ this.findInteractionByUid(uid)
6404
+ ];
6405
+ case 1:
6406
+ interaction = _state.sent();
6407
+ mergeWithLastSubmission = (_ref = options === null || options === void 0 ? void 0 : options.mergeWithLastSubmission) !== null && _ref !== void 0 ? _ref : true;
6408
+ if (mergeWithLastSubmission && !('error' in result)) {
6409
+ interaction.result = _object_spread$2({}, interaction.lastSubmission, result);
6410
+ } else {
6411
+ interaction.result = result;
6412
+ }
6413
+ return [
6414
+ 4,
6415
+ interaction.save(interaction.exp - unixDateTimeSecondsNumberForNow())
6416
+ ];
6417
+ case 2:
6418
+ _state.sent();
6419
+ return [
6420
+ 2,
6421
+ interaction
6422
+ ];
6423
+ }
5408
6424
  });
5409
- this.analyticsService.sendEventData(event.uid, name, data);
5410
- }
6425
+ }).call(this);
6426
+ }
6427
+ },
6428
+ {
6429
+ key: "findOrCreateGrant",
6430
+ value: /**
6431
+ * Finds an existing grant by ID, or creates a new one.
6432
+ *
6433
+ * For new grants, optionally pre-set `expiresIn` so {@link Grant#save} writes the requested TTL
6434
+ * instead of falling through to the configured Grant TTL function (which cannot read the original
6435
+ * `dbx_session_ttl` request param when save is driven from a NestJS controller — see
6436
+ * {@link OidcService#resolveLoginDurationForGrant}).
6437
+ *
6438
+ * @param grantId - The existing grant ID to look up, or undefined to create a new grant.
6439
+ * @param accountId - The account ID for creating a new grant.
6440
+ * @param clientId - The client ID for creating a new grant.
6441
+ * @param expiresInSeconds - Optional TTL (seconds) to assign to a newly-created grant.
6442
+ * @returns The found or newly created grant.
6443
+ */ // eslint-disable-next-line @typescript-eslint/max-params -- positional args mirror the existing call sites
6444
+ function findOrCreateGrant(grantId, accountId, clientId, expiresInSeconds) {
6445
+ return _async_to_generator$4(function() {
6446
+ var provider, grant, found, grantInit;
6447
+ return _ts_generator$4(this, function(_state) {
6448
+ switch(_state.label){
6449
+ case 0:
6450
+ return [
6451
+ 4,
6452
+ this.oidcService.getProvider()
6453
+ ];
6454
+ case 1:
6455
+ provider = _state.sent();
6456
+ if (!grantId) return [
6457
+ 3,
6458
+ 3
6459
+ ];
6460
+ return [
6461
+ 4,
6462
+ provider.Grant.find(grantId)
6463
+ ];
6464
+ case 2:
6465
+ found = _state.sent();
6466
+ if (!found) {
6467
+ throw new Error("Grant not found for grantId: ".concat(grantId));
6468
+ }
6469
+ grant = found;
6470
+ return [
6471
+ 3,
6472
+ 4
6473
+ ];
6474
+ case 3:
6475
+ grantInit = {
6476
+ accountId: accountId,
6477
+ clientId: clientId
6478
+ };
6479
+ if (expiresInSeconds != null) {
6480
+ grantInit.expiresIn = expiresInSeconds;
6481
+ }
6482
+ grant = new provider.Grant(grantInit);
6483
+ _state.label = 4;
6484
+ case 4:
6485
+ return [
6486
+ 2,
6487
+ grant
6488
+ ];
6489
+ }
6490
+ });
6491
+ }).call(this);
5411
6492
  }
5412
6493
  }
5413
6494
  ]);
5414
- return FirebaseServerOidcAnalyticsService;
5415
- }(OidcAnalyticsService);
5416
- FirebaseServerOidcAnalyticsService = FirebaseServerOidcAnalyticsService_1 = __decorate([
6495
+ return OidcInteractionService;
6496
+ }();
6497
+ OidcInteractionService = __decorate([
5417
6498
  Injectable(),
5418
- __param(0, Inject(FirebaseServerEnvService)),
5419
- __param(1, Optional()),
5420
- __param(1, Inject(FirebaseServerAnalyticsService)),
5421
- __param(2, Optional()),
5422
- __param(2, Inject(FIREBASE_SERVER_OIDC_ANALYTICS_CONFIG))
5423
- ], FirebaseServerOidcAnalyticsService);
6499
+ __param(0, Inject(OidcService)),
6500
+ __param(1, Inject(OidcClientService))
6501
+ ], OidcInteractionService);
5424
6502
 
5425
- function _array_like_to_array$2(arr, len) {
6503
+ function _array_like_to_array$3(arr, len) {
5426
6504
  if (len == null || len > arr.length) len = arr.length;
5427
6505
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5428
6506
  return arr2;
5429
6507
  }
5430
- function _array_without_holes$2(arr) {
5431
- if (Array.isArray(arr)) return _array_like_to_array$2(arr);
6508
+ function _array_without_holes$3(arr) {
6509
+ if (Array.isArray(arr)) return _array_like_to_array$3(arr);
5432
6510
  }
5433
- function _iterable_to_array$2(iter) {
6511
+ function _iterable_to_array$3(iter) {
5434
6512
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
5435
6513
  return Array.from(iter);
5436
6514
  }
5437
6515
  }
5438
- function _non_iterable_spread$2() {
6516
+ function _non_iterable_spread$3() {
5439
6517
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5440
6518
  }
5441
- function _to_consumable_array$2(arr) {
5442
- return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$2();
6519
+ function _to_consumable_array$3(arr) {
6520
+ return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread$3();
5443
6521
  }
5444
- function _unsupported_iterable_to_array$2(o, minLen) {
6522
+ function _type_of(obj) {
6523
+ "@swc/helpers - typeof";
6524
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
6525
+ }
6526
+ function _unsupported_iterable_to_array$3(o, minLen) {
5445
6527
  if (!o) return;
5446
- if (typeof o === "string") return _array_like_to_array$2(o, minLen);
6528
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
5447
6529
  var n = Object.prototype.toString.call(o).slice(8, -1);
5448
6530
  if (n === "Object" && o.constructor) n = o.constructor.name;
5449
6531
  if (n === "Map" || n === "Set") return Array.from(n);
5450
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
6532
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
5451
6533
  }
5452
6534
  /**
5453
- * Generates NestJS module metadata that registers {@link FirebaseServerOidcAnalyticsService} as the
5454
- * OIDC analytics consumer, aliased to {@link OIDC_ANALYTICS_SERVICE}.
6535
+ * Splits a space-delimited scope string into its non-empty entries.
5455
6536
  *
5456
- * Mirrors the convention used by `appMcpAnalyticsModuleMetadata`. Requires no dependency module —
5457
- * `FirebaseServerAnalyticsService` is resolved optionally and is expected to be supplied globally by
5458
- * the app's analytics module.
6537
+ * @param scope - The space-delimited scope string.
6538
+ * @returns The scope entries.
6539
+ */ function splitScope(scope) {
6540
+ return (scope !== null && scope !== void 0 ? scope : '').split(' ').filter(Boolean);
6541
+ }
6542
+ /**
6543
+ * Removes previously-rejected OIDC scopes from a Grant's rejected set.
6544
+ *
6545
+ * oidc-provider exposes `rejectOIDCScope()` but no inverse, and a rejected scope is subtracted from
6546
+ * `getOIDCScope()` on every read — so `addOIDCScope()` alone cannot put a once-rejected scope back in
6547
+ * force. `rejected` is plain persisted data (`Pick<Grant, 'openid' | 'resources'>`), which is what
6548
+ * makes editing it directly the supported shape of an un-reject.
6549
+ *
6550
+ * @param grant - The grant to edit in place.
6551
+ * @param scopes - The scopes to un-reject. Scopes not currently rejected are ignored.
6552
+ */ function unrejectOIDCScopes(grant, scopes) {
6553
+ var _grant_rejected;
6554
+ var rejected = (_grant_rejected = grant.rejected) === null || _grant_rejected === void 0 ? void 0 : _grant_rejected.openid;
6555
+ if (rejected === null || rejected === void 0 ? void 0 : rejected.scope) {
6556
+ var remove = new Set(scopes);
6557
+ var remaining = splitScope(rejected.scope).filter(function(scope) {
6558
+ return !remove.has(scope);
6559
+ });
6560
+ rejected.scope = remaining.length > 0 ? remaining.join(' ') : undefined;
6561
+ }
6562
+ }
6563
+ /**
6564
+ * Removes previously-rejected OIDC claims from a Grant's rejected set.
6565
+ *
6566
+ * @param grant - The grant to edit in place.
6567
+ * @param claims - The claims to un-reject. Claims not currently rejected are ignored.
6568
+ * @see unrejectOIDCScopes
6569
+ */ function unrejectOIDCClaims(grant, claims) {
6570
+ var _grant_rejected, _rejected_claims;
6571
+ var rejected = (_grant_rejected = grant.rejected) === null || _grant_rejected === void 0 ? void 0 : _grant_rejected.openid;
6572
+ if (rejected === null || rejected === void 0 ? void 0 : (_rejected_claims = rejected.claims) === null || _rejected_claims === void 0 ? void 0 : _rejected_claims.length) {
6573
+ var remove = new Set(claims);
6574
+ var remaining = rejected.claims.filter(function(claim) {
6575
+ return !remove.has(claim);
6576
+ });
6577
+ rejected.claims = remaining.length > 0 ? remaining : undefined;
6578
+ }
6579
+ }
6580
+ /**
6581
+ * Removes previously-rejected resource scopes for one resource indicator from a Grant's rejected set.
6582
+ *
6583
+ * @param grant - The grant to edit in place.
6584
+ * @param resource - The resource indicator.
6585
+ * @param scopes - The scopes to un-reject. Scopes not currently rejected for the resource are ignored.
6586
+ * @see unrejectOIDCScopes
6587
+ */ function unrejectResourceScopes(grant, resource, scopes) {
6588
+ var _grant_rejected;
6589
+ var rejectedResources = (_grant_rejected = grant.rejected) === null || _grant_rejected === void 0 ? void 0 : _grant_rejected.resources;
6590
+ if (rejectedResources === null || rejectedResources === void 0 ? void 0 : rejectedResources[resource]) {
6591
+ var remove = new Set(scopes);
6592
+ var remaining = splitScope(rejectedResources[resource]).filter(function(scope) {
6593
+ return !remove.has(scope);
6594
+ });
6595
+ if (remaining.length > 0) {
6596
+ rejectedResources[resource] = remaining.join(' ');
6597
+ } else {
6598
+ delete rejectedResources[resource];
6599
+ }
6600
+ }
6601
+ }
6602
+ /**
6603
+ * Moves previously-rejected values the current request asks for again from the "encountered" set back into
6604
+ * the "missing" set, so a re-consent decides them afresh.
5459
6605
  *
5460
- * Decorate a `@Global()` module with the result so the `OIDC_ANALYTICS_SERVICE` token is visible to
5461
- * the OIDC controllers and services provided by the app's OIDC module.
6606
+ * oidc-provider counts a rejected value as encountered: it never reappears in the prompt's `missing*`
6607
+ * details, so without this a consent that names it again is a silent no-op and the value can never be
6608
+ * granted on that Grant — even when the user explicitly ticks it. Values the Grant has GRANTED are left in
6609
+ * `encountered`: they are already in force and need no re-application.
5462
6610
  *
5463
- * @param config - Optional metadata + analytics config to merge in.
5464
- * @returns NestJS module metadata providing + exporting the OIDC analytics service and token.
6611
+ * @param input - The missing, encountered, rejected, and requested sets.
6612
+ * @returns The adjusted missing/encountered sets plus the reconsidered values.
5465
6613
  *
5466
- * @example
5467
- * ```typescript
5468
- * @Global()
5469
- * @Module(appOidcAnalyticsModuleMetadata())
5470
- * export class AppOidcAnalyticsModule {}
5471
- * ```
5472
- */ function appOidcAnalyticsModuleMetadata() {
5473
- var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
5474
- var oidcAnalyticsConfig = config.oidcAnalyticsConfig, imports = config.imports, exports = config.exports, providers = config.providers;
5475
- var configProviders = oidcAnalyticsConfig ? [
5476
- {
5477
- provide: FIREBASE_SERVER_OIDC_ANALYTICS_CONFIG,
5478
- useValue: oidcAnalyticsConfig
5479
- }
5480
- ] : [];
6614
+ * @__NO_SIDE_EFFECTS__
6615
+ */ function reconsiderRejectedValues(input) {
6616
+ var missing = input.missing, encountered = input.encountered, rejected = input.rejected, requested = input.requested;
6617
+ var missingSet = new Set(missing);
6618
+ var reconsidered = rejected.filter(function(value) {
6619
+ return requested.has(value) && !missingSet.has(value);
6620
+ });
6621
+ var reconsideredSet = new Set(reconsidered);
5481
6622
  return {
5482
- imports: _to_consumable_array$2(imports !== null && imports !== void 0 ? imports : []),
5483
- exports: [
5484
- OIDC_ANALYTICS_SERVICE,
5485
- FirebaseServerOidcAnalyticsService
5486
- ].concat(_to_consumable_array$2(exports !== null && exports !== void 0 ? exports : [])),
5487
- providers: [
5488
- FirebaseServerOidcAnalyticsService,
5489
- {
5490
- provide: OIDC_ANALYTICS_SERVICE,
5491
- useExisting: FirebaseServerOidcAnalyticsService
5492
- }
5493
- ].concat(_to_consumable_array$2(configProviders), _to_consumable_array$2(providers !== null && providers !== void 0 ? providers : []))
6623
+ missing: _to_consumable_array$3(missing).concat(_to_consumable_array$3(reconsidered)),
6624
+ encountered: encountered.filter(function(value) {
6625
+ return !reconsideredSet.has(value);
6626
+ }),
6627
+ reconsidered: reconsidered
5494
6628
  };
5495
6629
  }
5496
-
5497
- // MARK: Scopes
5498
6630
  /**
5499
- * Reads the set of OIDC scopes carried by a callable request's bearer token.
5500
- *
5501
- * The `ModelApiCallModelDispatchService` builds a synthetic `CallableRequest` with
5502
- * `auth.token = oidcValidatedToken ?? {}`, so the OIDC scope string lives at
5503
- * `request.auth.token.scope` for OIDC callers and is `undefined` for non-OIDC
5504
- * (regular Firebase ID-token) callers.
5505
- *
5506
- * Returning `undefined` for non-OIDC callers lets consumers (e.g. the MCP tool-visibility filter)
5507
- * skip scope enforcement instead of falsely treating the missing claim as "no scopes granted".
6631
+ * Names every claim an authorization request's `claims` parameter asks for, across `id_token` and `userinfo`.
5508
6632
  *
5509
- * The parameter is intentionally typed as `unknown` because `DecodedIdToken` (Firebase
5510
- * Auth's typed token shape) does not declare a `scope` field, while OIDC bearer-token
5511
- * callers attach one at runtime. Reading is done defensively.
6633
+ * @param claimsParam - The raw `claims` request parameter (a JSON string), or undefined.
6634
+ * @returns The requested claim names; empty when the parameter is absent or malformed.
5512
6635
  *
5513
- * @param request - The callable request as seen inside an `onCallModel` handler.
5514
- * @returns A `Set<string>` of granted scopes, or `undefined` when the request carries no OIDC `scope` claim.
5515
- */ function getOidcScopesFromRequest(request) {
5516
- var _request_auth_token, _request_auth;
5517
- var scope = request === null || request === void 0 ? void 0 : (_request_auth = request.auth) === null || _request_auth === void 0 ? void 0 : (_request_auth_token = _request_auth.token) === null || _request_auth_token === void 0 ? void 0 : _request_auth_token.scope;
5518
- return oidcScopesFromScopeClaim(scope);
6636
+ * @__NO_SIDE_EFFECTS__
6637
+ */ function requestedOIDCClaimNames(claimsParam) {
6638
+ var names = new Set();
6639
+ if (typeof claimsParam === 'string' && claimsParam.length > 0) {
6640
+ var parsed;
6641
+ try {
6642
+ parsed = JSON.parse(claimsParam);
6643
+ } catch (unused) {
6644
+ parsed = undefined;
6645
+ }
6646
+ if (parsed != null && (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object') {
6647
+ for(var _i = 0, _iter = [
6648
+ 'id_token',
6649
+ 'userinfo'
6650
+ ]; _i < _iter.length; _i++){
6651
+ var key = _iter[_i];
6652
+ var section = parsed[key];
6653
+ if (section != null && (typeof section === "undefined" ? "undefined" : _type_of(section)) === 'object') {
6654
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6655
+ try {
6656
+ for(var _iterator = Object.keys(section)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6657
+ var claim = _step.value;
6658
+ names.add(claim);
6659
+ }
6660
+ } catch (err) {
6661
+ _didIteratorError = true;
6662
+ _iteratorError = err;
6663
+ } finally{
6664
+ try {
6665
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
6666
+ _iterator.return();
6667
+ }
6668
+ } finally{
6669
+ if (_didIteratorError) {
6670
+ throw _iteratorError;
6671
+ }
6672
+ }
6673
+ }
6674
+ }
6675
+ }
6676
+ }
6677
+ }
6678
+ return names;
6679
+ }
6680
+ /**
6681
+ * Normalizes an authorization request's `resource` parameter to its list of resource indicators.
6682
+ *
6683
+ * @param resourceParam - The raw `resource` request parameter (a string, an array of strings, or undefined).
6684
+ * @returns The resource indicators; empty when the parameter is absent.
6685
+ *
6686
+ * @__NO_SIDE_EFFECTS__
6687
+ */ function requestedResourceIndicators(resourceParam) {
6688
+ var indicators;
6689
+ if (typeof resourceParam === 'string') {
6690
+ indicators = [
6691
+ resourceParam
6692
+ ];
6693
+ } else if (Array.isArray(resourceParam)) {
6694
+ indicators = resourceParam.filter(function(value) {
6695
+ return typeof value === 'string';
6696
+ });
6697
+ } else {
6698
+ indicators = [];
6699
+ }
6700
+ return indicators;
5519
6701
  }
5520
6702
 
6703
+ function _array_like_to_array$2(arr, len) {
6704
+ if (len == null || len > arr.length) len = arr.length;
6705
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6706
+ return arr2;
6707
+ }
6708
+ function _array_without_holes$2(arr) {
6709
+ if (Array.isArray(arr)) return _array_like_to_array$2(arr);
6710
+ }
5521
6711
  function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
5522
6712
  try {
5523
6713
  var info = gen[key](arg);
@@ -5571,6 +6761,14 @@ function _define_property$4(obj, key, value) {
5571
6761
  } else obj[key] = value;
5572
6762
  return obj;
5573
6763
  }
6764
+ function _iterable_to_array$2(iter) {
6765
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
6766
+ return Array.from(iter);
6767
+ }
6768
+ }
6769
+ function _non_iterable_spread$2() {
6770
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6771
+ }
5574
6772
  function _object_spread$1(target) {
5575
6773
  for(var i = 1; i < arguments.length; i++){
5576
6774
  var source = arguments[i] != null ? arguments[i] : {};
@@ -5586,6 +6784,9 @@ function _object_spread$1(target) {
5586
6784
  }
5587
6785
  return target;
5588
6786
  }
6787
+ function _to_consumable_array$2(arr) {
6788
+ return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$2();
6789
+ }
5589
6790
  function _ts_generator$3(thisArg, body) {
5590
6791
  var f, y, t, _ = {
5591
6792
  label: 0,
@@ -5685,85 +6886,90 @@ function _ts_generator$3(thisArg, body) {
5685
6886
  };
5686
6887
  }
5687
6888
  }
6889
+ function _unsupported_iterable_to_array$2(o, minLen) {
6890
+ if (!o) return;
6891
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
6892
+ var n = Object.prototype.toString.call(o).slice(8, -1);
6893
+ if (n === "Object" && o.constructor) n = o.constructor.name;
6894
+ if (n === "Map" || n === "Set") return Array.from(n);
6895
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
6896
+ }
6897
+ // MARK: Constants
6898
+ /**
6899
+ * Default lifetime of a minted JWT, in seconds.
6900
+ */ var DEFAULT_OIDC_SIGNED_JWT_EXPIRES_IN_SECONDS = 600;
6901
+ /**
6902
+ * How long the active signing key is cached before it is re-read from the JWKS store.
6903
+ *
6904
+ * A rotation is picked up within this window; rotated keys stay in the public JWKS for 30 days, so
6905
+ * tokens signed with the previous key keep verifying in the meantime.
6906
+ */ var DEFAULT_OIDC_JWT_SIGNING_KEY_CACHE_MS = 5 * 60 * 1000;
6907
+ /**
6908
+ * Header `typ` for a minted JWT: an RFC 9068 JWT access token, matching the format oidc-provider
6909
+ * uses for the `accessTokenFormat: 'jwt'` resource-server tokens.
6910
+ */ var DEFAULT_OIDC_SIGNED_JWT_TYP = 'at+jwt';
5688
6911
  // MARK: Service
5689
6912
  /**
5690
- * Service for handling OIDC interactions.
5691
- */ var OidcInteractionService = /*#__PURE__*/ function() {
5692
- function OidcInteractionService(oidcService, clientService) {
5693
- _class_call_check$3(this, OidcInteractionService);
5694
- _define_property$4(this, "oidcService", void 0);
5695
- _define_property$4(this, "clientService", void 0);
5696
- this.oidcService = oidcService;
5697
- this.clientService = clientService;
6913
+ * Signs first-party JWTs with the OIDC provider's active JWKS signing key.
6914
+ *
6915
+ * The result is an RS256 token with `iss` = this provider's issuer, so any resource server that
6916
+ * already trusts the provider's JWKS for OAuth access tokens verifies it with no new secret or
6917
+ * trust anchor: "the API mints a token for the satellite service" is literally "sign with the
6918
+ * active key, `aud` = the satellite's origin". The counterpart on the resource server is
6919
+ * `verifyBearerJwt` from `@dereekb/oauth-resource`, whose `oidc` issuer profile discovers this
6920
+ * provider's `jwks_uri` from its own discovery document.
6921
+ *
6922
+ * Registered and exported by `oidcModuleMetadata`, so a downstream app injects it with no extra
6923
+ * wiring. Pair it with `createCachedTokenProvider` from `@dereekb/util/oidc` to hold a minted
6924
+ * token until it nears expiry instead of re-signing per call.
6925
+ */ var OidcJwtSigningService = /*#__PURE__*/ function() {
6926
+ function OidcJwtSigningService(_jwks, _config) {
6927
+ _class_call_check$3(this, OidcJwtSigningService);
6928
+ _define_property$4(this, "_jwks", void 0);
6929
+ _define_property$4(this, "_config", void 0);
6930
+ _define_property$4(this, "_cached", void 0);
6931
+ this._jwks = _jwks;
6932
+ this._config = _config;
5698
6933
  }
5699
- _create_class$3(OidcInteractionService, [
5700
- {
5701
- key: "getInteractionDetails",
5702
- value: /**
5703
- * Loads the interaction details for a given request/response pair.
5704
- *
5705
- * Requires the oidc-provider interaction cookie to be present on the request.
5706
- *
5707
- * @param req - The Express request containing the interaction cookie.
5708
- * @param res - The Express response.
5709
- * @returns The oidc-provider interaction details.
5710
- */ function getInteractionDetails(req, res) {
5711
- return _async_to_generator$3(function() {
5712
- var provider;
5713
- return _ts_generator$3(this, function(_state) {
5714
- switch(_state.label){
5715
- case 0:
5716
- return [
5717
- 4,
5718
- this.oidcService.getProvider()
5719
- ];
5720
- case 1:
5721
- provider = _state.sent();
5722
- return [
5723
- 2,
5724
- provider.interactionDetails(req, res)
5725
- ];
5726
- }
5727
- });
5728
- }).call(this);
5729
- }
5730
- },
6934
+ _create_class$3(OidcJwtSigningService, [
5731
6935
  {
5732
- key: "findInteractionByUid",
6936
+ key: "signJwt",
5733
6937
  value: /**
5734
- * Finds an interaction by its UID directly from the adapter store.
5735
- *
5736
- * Bypasses the cookie-based lookup used by `provider.interactionDetails()`.
5737
- * This is necessary when the interaction cookie is scoped to a different path
5738
- * (e.g., the frontend) and is not sent with backend API requests.
6938
+ * Mints a signed JWT.
5739
6939
  *
5740
- * @param uid - The interaction UID to look up.
5741
- * @returns The interaction details for the given UID.
5742
- * @throws {Error} When the interaction is not found or has expired.
5743
- */ function findInteractionByUid(uid) {
6940
+ * @param input - Audience, subject, lifetime, and extra claims.
6941
+ * @returns The compact token, its expiry, and the signing key id.
6942
+ */ function signJwt(input) {
5744
6943
  return _async_to_generator$3(function() {
5745
- var provider, interaction;
6944
+ var _input_expiresIn, _input_typ, _ref, kid, key, now, exp, token;
5746
6945
  return _ts_generator$3(this, function(_state) {
5747
6946
  switch(_state.label){
5748
6947
  case 0:
5749
6948
  return [
5750
6949
  4,
5751
- this.oidcService.getProvider()
6950
+ this._loadSigningKey()
5752
6951
  ];
5753
6952
  case 1:
5754
- provider = _state.sent();
6953
+ _ref = _state.sent(), kid = _ref.kid, key = _ref.key;
6954
+ now = Math.floor(Date.now() / 1000);
6955
+ exp = now + ((_input_expiresIn = input.expiresIn) !== null && _input_expiresIn !== void 0 ? _input_expiresIn : DEFAULT_OIDC_SIGNED_JWT_EXPIRES_IN_SECONDS);
5755
6956
  return [
5756
6957
  4,
5757
- provider.Interaction.find(uid)
6958
+ new SignJWT(_object_spread$1({}, input.claims)).setProtectedHeader({
6959
+ alg: 'RS256',
6960
+ kid: kid,
6961
+ typ: (_input_typ = input.typ) !== null && _input_typ !== void 0 ? _input_typ : DEFAULT_OIDC_SIGNED_JWT_TYP
6962
+ }).setIssuer(this._config.issuer).setAudience(typeof input.audience === 'string' ? input.audience : _to_consumable_array$2(input.audience)).setSubject(input.subject).setIssuedAt(now).setExpirationTime(exp).setJti(randomUUID()).sign(key)
5758
6963
  ];
5759
6964
  case 2:
5760
- interaction = _state.sent();
5761
- if (!interaction) {
5762
- throw new Error('Interaction not found');
5763
- }
6965
+ token = _state.sent();
5764
6966
  return [
5765
6967
  2,
5766
- interaction
6968
+ {
6969
+ token: token,
6970
+ kid: kid,
6971
+ expiresAt: new Date(exp * 1000)
6972
+ }
5767
6973
  ];
5768
6974
  }
5769
6975
  });
@@ -5771,111 +6977,57 @@ function _ts_generator$3(thisArg, body) {
5771
6977
  }
5772
6978
  },
5773
6979
  {
5774
- key: "finishInteractionByUid",
5775
- value: /**
5776
- * Completes an interaction by UID without requiring the interaction cookie.
5777
- *
5778
- * Looks up the interaction directly by UID, applies the result, saves it,
5779
- * and returns the `returnTo` URL for the client to redirect to.
5780
- *
5781
- * @param uid - The interaction UID to complete.
5782
- * @param result - The interaction results to apply.
5783
- * @param options - Optional settings for merging with the last submission.
5784
- * @param options.mergeWithLastSubmission - Whether to merge with the last submission (defaults to true)
5785
- * @returns The interaction that was completed. It includes the returnTo property for the next step of the interaction.
5786
- */ function finishInteractionByUid(uid, result, options) {
6980
+ key: "_loadSigningKey",
6981
+ value: function _loadSigningKey() {
5787
6982
  return _async_to_generator$3(function() {
5788
- var _ref, interaction, mergeWithLastSubmission;
6983
+ var stale, _ref, jwk, _tmp, _, _tmp1;
5789
6984
  return _ts_generator$3(this, function(_state) {
5790
6985
  switch(_state.label){
5791
6986
  case 0:
5792
- return [
5793
- 4,
5794
- this.findInteractionByUid(uid)
5795
- ];
5796
- case 1:
5797
- interaction = _state.sent();
5798
- mergeWithLastSubmission = (_ref = options === null || options === void 0 ? void 0 : options.mergeWithLastSubmission) !== null && _ref !== void 0 ? _ref : true;
5799
- if (mergeWithLastSubmission && !('error' in result)) {
5800
- interaction.result = _object_spread$1({}, interaction.lastSubmission, result);
5801
- } else {
5802
- interaction.result = result;
5803
- }
5804
- return [
5805
- 4,
5806
- interaction.save(interaction.exp - unixDateTimeSecondsNumberForNow())
5807
- ];
5808
- case 2:
5809
- _state.sent();
5810
- return [
5811
- 2,
5812
- interaction
6987
+ stale = !this._cached || Date.now() - this._cached.loadedAt > DEFAULT_OIDC_JWT_SIGNING_KEY_CACHE_MS;
6988
+ if (!stale) return [
6989
+ 3,
6990
+ 6
5813
6991
  ];
5814
- }
5815
- });
5816
- }).call(this);
5817
- }
5818
- },
5819
- {
5820
- key: "findOrCreateGrant",
5821
- value: /**
5822
- * Finds an existing grant by ID, or creates a new one.
5823
- *
5824
- * For new grants, optionally pre-set `expiresIn` so {@link Grant#save} writes the requested TTL
5825
- * instead of falling through to the configured Grant TTL function (which cannot read the original
5826
- * `dbx_session_ttl` request param when save is driven from a NestJS controller — see
5827
- * {@link OidcService#resolveLoginDurationForGrant}).
5828
- *
5829
- * @param grantId - The existing grant ID to look up, or undefined to create a new grant.
5830
- * @param accountId - The account ID for creating a new grant.
5831
- * @param clientId - The client ID for creating a new grant.
5832
- * @param expiresInSeconds - Optional TTL (seconds) to assign to a newly-created grant.
5833
- * @returns The found or newly created grant.
5834
- */ // eslint-disable-next-line @typescript-eslint/max-params -- positional args mirror the existing call sites
5835
- function findOrCreateGrant(grantId, accountId, clientId, expiresInSeconds) {
5836
- return _async_to_generator$3(function() {
5837
- var provider, grant, found, grantInit;
5838
- return _ts_generator$3(this, function(_state) {
5839
- switch(_state.label){
5840
- case 0:
5841
6992
  return [
5842
6993
  4,
5843
- this.oidcService.getProvider()
6994
+ this._jwks.getActiveSigningKey()
5844
6995
  ];
5845
6996
  case 1:
5846
- provider = _state.sent();
5847
- if (!grantId) return [
6997
+ if (!((_ref = _state.sent()) !== null && _ref !== void 0)) return [
5848
6998
  3,
5849
- 3
6999
+ 2
5850
7000
  ];
7001
+ _tmp = _ref;
5851
7002
  return [
5852
- 4,
5853
- provider.Grant.find(grantId)
7003
+ 3,
7004
+ 4
5854
7005
  ];
5855
7006
  case 2:
5856
- found = _state.sent();
5857
- if (!found) {
5858
- throw new Error("Grant not found for grantId: ".concat(grantId));
5859
- }
5860
- grant = found;
5861
7007
  return [
5862
- 3,
5863
- 4
7008
+ 4,
7009
+ this._jwks.generateKeyPair()
5864
7010
  ];
5865
7011
  case 3:
5866
- grantInit = {
5867
- accountId: accountId,
5868
- clientId: clientId
5869
- };
5870
- if (expiresInSeconds != null) {
5871
- grantInit.expiresIn = expiresInSeconds;
5872
- }
5873
- grant = new provider.Grant(grantInit);
7012
+ _tmp = _state.sent().signingKey;
5874
7013
  _state.label = 4;
5875
7014
  case 4:
7015
+ jwk = _tmp;
7016
+ _ = this;
7017
+ _tmp1 = {
7018
+ kid: jwk.kid
7019
+ };
7020
+ return [
7021
+ 4,
7022
+ importJWK(jwk, 'RS256')
7023
+ ];
7024
+ case 5:
7025
+ _._cached = (_tmp1.key = _state.sent(), _tmp1.loadedAt = Date.now(), _tmp1);
7026
+ _state.label = 6;
7027
+ case 6:
5876
7028
  return [
5877
7029
  2,
5878
- grant
7030
+ this._cached
5879
7031
  ];
5880
7032
  }
5881
7033
  });
@@ -5883,22 +7035,19 @@ function _ts_generator$3(thisArg, body) {
5883
7035
  }
5884
7036
  }
5885
7037
  ]);
5886
- return OidcInteractionService;
7038
+ return OidcJwtSigningService;
5887
7039
  }();
5888
- OidcInteractionService = __decorate([
7040
+ OidcJwtSigningService = __decorate([
5889
7041
  Injectable(),
5890
- __param(0, Inject(OidcService)),
5891
- __param(1, Inject(OidcClientService))
5892
- ], OidcInteractionService);
7042
+ __param(0, Inject(JwksService)),
7043
+ __param(1, Inject(OidcModuleConfig))
7044
+ ], OidcJwtSigningService);
5893
7045
 
5894
7046
  function _array_like_to_array$1(arr, len) {
5895
7047
  if (len == null || len > arr.length) len = arr.length;
5896
7048
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5897
7049
  return arr2;
5898
7050
  }
5899
- function _array_with_holes(arr) {
5900
- if (Array.isArray(arr)) return arr;
5901
- }
5902
7051
  function _array_without_holes$1(arr) {
5903
7052
  if (Array.isArray(arr)) return _array_like_to_array$1(arr);
5904
7053
  }
@@ -5966,39 +7115,9 @@ function _iterable_to_array$1(iter) {
5966
7115
  return Array.from(iter);
5967
7116
  }
5968
7117
  }
5969
- function _iterable_to_array_limit(arr, i) {
5970
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
5971
- if (_i == null) return;
5972
- var _arr = [];
5973
- var _n = true;
5974
- var _d = false;
5975
- var _s, _e;
5976
- try {
5977
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
5978
- _arr.push(_s.value);
5979
- if (i && _arr.length === i) break;
5980
- }
5981
- } catch (err) {
5982
- _d = true;
5983
- _e = err;
5984
- } finally{
5985
- try {
5986
- if (!_n && _i["return"] != null) _i["return"]();
5987
- } finally{
5988
- if (_d) throw _e;
5989
- }
5990
- }
5991
- return _arr;
5992
- }
5993
- function _non_iterable_rest() {
5994
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5995
- }
5996
7118
  function _non_iterable_spread$1() {
5997
7119
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5998
7120
  }
5999
- function _sliced_to_array(arr, i) {
6000
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest();
6001
- }
6002
7121
  function _to_consumable_array$1(arr) {
6003
7122
  return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread$1();
6004
7123
  }
@@ -6306,7 +7425,7 @@ var OidcInteractionController_1;
6306
7425
  * @throws {HttpException} HTTP 400 when the consent interaction cannot be completed.
6307
7426
  */ function postConsent(uid, body, res) {
6308
7427
  return _async_to_generator$2(function() {
6309
- var startedAt, clientId, accountId, _ref, _prompt_details_missingOIDCScope, _ref1, _this_accountService_providerConfig_adminOnlyScopes, _ref2, _ref3, _prompt_details_missingOIDCClaims, _prompt_details_missingResourceScopes, _this_accountService_delegate_isAdminUser, _this_accountService_delegate, _ref4, redirectTo, interaction, prompt, params, session, missingOIDCScope, existingGrant, _tmp, encounteredOIDCScopes, clientPayload, requestedOIDCScopeSet, providerProfiles, _oidcClientProviderProfileScopes, clientUnlockedScopes, clientRequiredScopes, profileGatedScopes, disallowedGatedScopes, _ref5, redirectTo1, missingRequiredScopes, _ref6, redirectTo2, effectiveOIDCScopes, heldOIDCScopes, consentedOIDCScopeSet, configAdminOnlyScopes, adminOnlyScopes, consentedAdminOnlyScopes, requestsServiceToken, isAdmin, _tmp1, _ref7, redirectTo3, requestedRawTtl, clientMaxSessionTtl, expiresInSeconds, grant, _tmp2, granted, rejected, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, encounteredOIDCClaims, missingOIDCClaims, _resolveEffectiveSubset, granted1, rejected1, missingResourceScopes, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, indicator, scopes, _ref8, _body_grantedResourceScopes, requestedSubset, encounteredResourceScopes, _resolveEffectiveSubset1, granted2, rejected2, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, value1, grantId, _ref9, redirectTo4, err;
7428
+ var startedAt, clientId, accountId, _ref, _params_scope, _prompt_details_missingOIDCScope, _ref1, _this_accountService_providerConfig_adminOnlyScopes, _ref2, _ref3, _prompt_details_missingOIDCClaims, _prompt_details_missingResourceScopes, _this_accountService_delegate_isAdminUser, _this_accountService_delegate, _ref4, redirectTo, interaction, prompt, params, session, existingGrant, _tmp, requestedScopeParam, oidcScopes, missingOIDCScope, encounteredOIDCScopes, clientPayload, requestedOIDCScopeSet, providerProfiles, _oidcClientProviderProfileScopes, clientUnlockedScopes, clientRequiredScopes, profileGatedScopes, disallowedGatedScopes, _ref5, redirectTo1, missingRequiredScopes, _ref6, redirectTo2, effectiveOIDCScopes, heldOIDCScopes, consentedOIDCScopeSet, configAdminOnlyScopes, adminOnlyScopes, consentedAdminOnlyScopes, requestsServiceToken, isAdmin, _tmp1, _ref7, redirectTo3, requestedRawTtl, clientMaxSessionTtl, expiresInSeconds, grant, _tmp2, granted, rejected, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, _reconsiderRejectedValues, missingOIDCClaims, encounteredOIDCClaims, _resolveEffectiveSubset, granted1, rejected1, missingResourceScopes, resourceIndicators, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, indicator, _missingResourceScopes_indicator, _ref8, _body_grantedResourceScopes, _reconsiderRejectedValues1, scopes, encounteredResourceScopes, requestedSubset, _resolveEffectiveSubset1, granted2, rejected2, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, value1, grantId, _ref9, redirectTo4, err;
6310
7429
  return _ts_generator$2(this, function(_state) {
6311
7430
  switch(_state.label){
6312
7431
  case 0:
@@ -6356,7 +7475,6 @@ var OidcInteractionController_1;
6356
7475
  prompt = interaction.prompt, params = interaction.params, session = interaction.session;
6357
7476
  clientId = params['client_id'];
6358
7477
  accountId = (_ref = session === null || session === void 0 ? void 0 : session.accountId) !== null && _ref !== void 0 ? _ref : '';
6359
- missingOIDCScope = (_prompt_details_missingOIDCScope = prompt.details['missingOIDCScope']) !== null && _prompt_details_missingOIDCScope !== void 0 ? _prompt_details_missingOIDCScope : [];
6360
7478
  if (!interaction.grantId) return [
6361
7479
  3,
6362
7480
  7
@@ -6381,7 +7499,20 @@ var OidcInteractionController_1;
6381
7499
  // but the consent UI sources its checkbox list from the auth URL's `scope=` param (the full request set)
6382
7500
  // and re-submits them all. We accept already-encountered values as silent no-ops so a re-consent on a
6383
7501
  // client the user has previously authorized doesn't fail validation.
6384
- encounteredOIDCScopes = existingGrant ? existingGrant.getOIDCScopeEncountered().split(' ').filter(Boolean) : [];
7502
+ //
7503
+ // A REJECTED value is the exception. oidc-provider counts it as encountered too, so it never comes back
7504
+ // in `missing*` — and a rejected scope is subtracted from `getOIDCScope()` on every read, so treating it
7505
+ // as a no-op would make it ungrantable on this Grant for good, even when the user explicitly ticks it
7506
+ // again. `reconsiderRejectedValues` moves the rejected values this request names back into `missing`
7507
+ // so this consent decides them afresh; a grant of one of those un-rejects it further down.
7508
+ requestedScopeParam = new Set(((_params_scope = params['scope']) !== null && _params_scope !== void 0 ? _params_scope : '').split(' ').filter(Boolean));
7509
+ oidcScopes = reconsiderRejectedValues({
7510
+ missing: (_prompt_details_missingOIDCScope = prompt.details['missingOIDCScope']) !== null && _prompt_details_missingOIDCScope !== void 0 ? _prompt_details_missingOIDCScope : [],
7511
+ encountered: existingGrant ? existingGrant.getOIDCScopeEncountered().split(' ').filter(Boolean) : [],
7512
+ rejected: existingGrant ? existingGrant.getRejectedOIDCScope().split(' ').filter(Boolean) : [],
7513
+ requested: requestedScopeParam
7514
+ });
7515
+ missingOIDCScope = oidcScopes.missing, encounteredOIDCScopes = oidcScopes.encountered;
6385
7516
  return [
6386
7517
  4,
6387
7518
  this.oidcService.findClientPayload(clientId)
@@ -6596,6 +7727,7 @@ var OidcInteractionController_1;
6596
7727
  if (missingOIDCScope.length > 0) {
6597
7728
  granted = effectiveOIDCScopes.granted, rejected = effectiveOIDCScopes.rejected;
6598
7729
  if (granted.length > 0) {
7730
+ unrejectOIDCScopes(grant, granted);
6599
7731
  grant.addOIDCScope(granted.join(' '));
6600
7732
  }
6601
7733
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -6619,8 +7751,14 @@ var OidcInteractionController_1;
6619
7751
  }
6620
7752
  }
6621
7753
  }
6622
- encounteredOIDCClaims = grant.getOIDCClaimsEncountered();
6623
- missingOIDCClaims = (_prompt_details_missingOIDCClaims = prompt.details['missingOIDCClaims']) !== null && _prompt_details_missingOIDCClaims !== void 0 ? _prompt_details_missingOIDCClaims : [];
7754
+ // Same reconsideration as the scopes above: a claim rejected on an earlier consent that this request's
7755
+ // `claims` parameter names again is decided afresh rather than silently kept rejected.
7756
+ _reconsiderRejectedValues = reconsiderRejectedValues({
7757
+ missing: (_prompt_details_missingOIDCClaims = prompt.details['missingOIDCClaims']) !== null && _prompt_details_missingOIDCClaims !== void 0 ? _prompt_details_missingOIDCClaims : [],
7758
+ encountered: grant.getOIDCClaimsEncountered(),
7759
+ rejected: grant.getRejectedOIDCClaims(),
7760
+ requested: requestedOIDCClaimNames(params['claims'])
7761
+ }), missingOIDCClaims = _reconsiderRejectedValues.missing, encounteredOIDCClaims = _reconsiderRejectedValues.encountered;
6624
7762
  if (missingOIDCClaims.length > 0) {
6625
7763
  _resolveEffectiveSubset = resolveEffectiveSubset({
6626
7764
  missing: missingOIDCClaims,
@@ -6628,6 +7766,7 @@ var OidcInteractionController_1;
6628
7766
  alreadyEncountered: encounteredOIDCClaims
6629
7767
  }), granted1 = _resolveEffectiveSubset.granted, rejected1 = _resolveEffectiveSubset.rejected;
6630
7768
  if (granted1.length > 0) {
7769
+ unrejectOIDCClaims(grant, granted1);
6631
7770
  grant.addOIDCClaims(granted1);
6632
7771
  }
6633
7772
  if (rejected1.length > 0) {
@@ -6635,12 +7774,25 @@ var OidcInteractionController_1;
6635
7774
  }
6636
7775
  }
6637
7776
  missingResourceScopes = (_prompt_details_missingResourceScopes = prompt.details['missingResourceScopes']) !== null && _prompt_details_missingResourceScopes !== void 0 ? _prompt_details_missingResourceScopes : {};
7777
+ // Resource indicators this consent decides: the ones oidc-provider reports as still undecided, plus any
7778
+ // the request names (`resource` param) that carry a rejection worth reconsidering. An indicator whose
7779
+ // every scope was rejected earlier is absent from `missingResourceScopes` entirely, which is exactly the
7780
+ // case that needs the second source.
7781
+ resourceIndicators = new Set(_to_consumable_array$1(Object.keys(missingResourceScopes)).concat(_to_consumable_array$1(requestedResourceIndicators(params['resource']).filter(function(indicator) {
7782
+ return grant.getRejectedResourceScope(indicator).length > 0;
7783
+ }))));
6638
7784
  _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6639
7785
  try {
6640
- for(_iterator1 = Object.entries(missingResourceScopes)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6641
- _step_value = _sliced_to_array(_step1.value, 2), indicator = _step_value[0], scopes = _step_value[1];
7786
+ for(_iterator1 = resourceIndicators[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
7787
+ indicator = _step1.value;
6642
7788
  ;
6643
7789
  ;
7790
+ _reconsiderRejectedValues1 = reconsiderRejectedValues({
7791
+ missing: (_missingResourceScopes_indicator = missingResourceScopes[indicator]) !== null && _missingResourceScopes_indicator !== void 0 ? _missingResourceScopes_indicator : [],
7792
+ encountered: grant.getResourceScopeEncountered(indicator).split(' ').filter(Boolean),
7793
+ rejected: grant.getRejectedResourceScope(indicator).split(' ').filter(Boolean),
7794
+ requested: requestedScopeParam
7795
+ }), scopes = _reconsiderRejectedValues1.missing, encounteredResourceScopes = _reconsiderRejectedValues1.encountered;
6644
7796
  // A submission with no explicit per-resource selection falls back to the OIDC scope selection
6645
7797
  // rather than granting everything the resource server declares. A resource server's scope list
6646
7798
  // is drawn from the same provider scopes the consent UI renders as one checkbox list, so a scope
@@ -6650,13 +7802,13 @@ var OidcInteractionController_1;
6650
7802
  requestedSubset = (_ref8 = (_body_grantedResourceScopes = body.grantedResourceScopes) === null || _body_grantedResourceScopes === void 0 ? void 0 : _body_grantedResourceScopes[indicator]) !== null && _ref8 !== void 0 ? _ref8 : body.grantedOIDCScopes ? scopes.filter(function(scope) {
6651
7803
  return consentedOIDCScopeSet.has(scope);
6652
7804
  }) : undefined;
6653
- encounteredResourceScopes = grant.getResourceScopeEncountered(indicator).split(' ').filter(Boolean);
6654
7805
  _resolveEffectiveSubset1 = resolveEffectiveSubset({
6655
7806
  missing: scopes,
6656
7807
  requestedSubset: requestedSubset,
6657
7808
  alreadyEncountered: encounteredResourceScopes
6658
7809
  }), granted2 = _resolveEffectiveSubset1.granted, rejected2 = _resolveEffectiveSubset1.rejected;
6659
7810
  if (granted2.length > 0) {
7811
+ unrejectResourceScopes(grant, indicator, granted2);
6660
7812
  grant.addResourceScope(indicator, granted2.join(' '));
6661
7813
  }
6662
7814
  _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
@@ -7726,40 +8878,6 @@ function _unsupported_iterable_to_array(o, minLen) {
7726
8878
  var trimmedPath = parsed.pathname.replace(/\/[^/]*\/?$/, '');
7727
8879
  return "".concat(parsed.origin).concat(trimmedPath, "/.well-known/oauth-protected-resource");
7728
8880
  }
7729
- /**
7730
- * Builds a single-entry {@link OidcResourceServerInfo} map for the MCP endpoint
7731
- * declared on `envService.appMcpUrl`, with `scope` set to every scope declared
7732
- * on `providerConfig.claims` (so any scope the provider issues is valid on the
7733
- * resource server) and `audience` set to the MCP URL.
7734
- *
7735
- * Returns `undefined` when no `appMcpUrl` is configured.
7736
- *
7737
- * Used internally by {@link oidcModuleMetadata} when {@link OidcModuleConfig.configureMcpResourceServer}
7738
- * is enabled, and exported for apps that need to combine the MCP resource server
7739
- * with additional app-specific entries:
7740
- *
7741
- * @example
7742
- * ```ts
7743
- * resourceServers: {
7744
- * ...(buildFirebaseServerMcpResourceServer({ envService, providerConfig: APP_PROVIDER_CONFIG }) ?? {}),
7745
- * 'https://api.example.com/extras': {
7746
- * scope: 'openid profile',
7747
- * audience: 'https://api.example.com/extras'
7748
- * }
7749
- * }
7750
- * ```
7751
- */ function buildFirebaseServerMcpResourceServer(input) {
7752
- var envService = input.envService, providerConfig = input.providerConfig;
7753
- var mcpUrl = envService.appMcpUrl;
7754
- var result;
7755
- if (mcpUrl) {
7756
- result = _define_property({}, mcpUrl, {
7757
- scope: allOidcScopesStringForProviderConfig(providerConfig),
7758
- audience: mcpUrl
7759
- });
7760
- }
7761
- return result;
7762
- }
7763
8881
  /**
7764
8882
  * Factory that creates {@link OidcServerFirestoreCollections} using the provided Firestore context
7765
8883
  * and JWKS encryption config from {@link OidcModuleConfig}.
@@ -7807,10 +8925,12 @@ function _unsupported_iterable_to_array(o, minLen) {
7807
8925
  exports: [
7808
8926
  OidcClientService,
7809
8927
  OidcService,
8928
+ OidcJwtSigningService,
7810
8929
  OidcProviderConfigService,
7811
8930
  OidcModuleConfig,
7812
8931
  OidcAuthMiddlewareConfig,
7813
- OidcServerFirestoreCollections
8932
+ OidcServerFirestoreCollections,
8933
+ JwksService
7814
8934
  ].concat(_to_consumable_array(exports !== null && exports !== void 0 ? exports : [])),
7815
8935
  providers: [
7816
8936
  {
@@ -7838,14 +8958,13 @@ function _unsupported_iterable_to_array(o, minLen) {
7838
8958
  // Auto-derive the MCP resource-server entry from envService.appMcpUrl and the
7839
8959
  // registered OidcAccountService's providerConfig. Any explicit resourceServers
7840
8960
  // entry from the consumer wins on key collisions.
7841
- if (result.configureMcpResourceServer) {
7842
- var mcpResourceServer = buildFirebaseServerMcpResourceServer({
7843
- envService: envService,
7844
- providerConfig: oidcAccountService.providerConfig
8961
+ if (result.configureMcpResourceServer && envService.appMcpUrl) {
8962
+ var mcpResourceServer = buildOidcResourceServer({
8963
+ url: envService.appMcpUrl,
8964
+ scope: allOidcScopesStringForProviderConfig(oidcAccountService.providerConfig),
8965
+ audience: envService.appMcpUrl
7845
8966
  });
7846
- if (mcpResourceServer) {
7847
- result.resourceServers = _object_spread({}, mcpResourceServer, result.resourceServers);
7848
- }
8967
+ result.resourceServers = _object_spread({}, mcpResourceServer, result.resourceServers);
7849
8968
  }
7850
8969
  return result;
7851
8970
  }
@@ -7884,6 +9003,7 @@ function _unsupported_iterable_to_array(o, minLen) {
7884
9003
  OidcProviderConfigService,
7885
9004
  OidcEncryptionService,
7886
9005
  OidcService,
9006
+ OidcJwtSigningService,
7887
9007
  JwksService,
7888
9008
  {
7889
9009
  provide: OidcClientService,
@@ -7898,4 +9018,4 @@ function _unsupported_iterable_to_array(o, minLen) {
7898
9018
  };
7899
9019
  }
7900
9020
 
7901
- export { DBX_FIREBASE_SERVER_OIDC_PROVIDER_PROFILES_CLIENT_METADATA, DEFAULT_APP_OAUTH_CONSENT_PATH_PART, DEFAULT_APP_OAUTH_INTERACTION_PATH, DEFAULT_APP_OAUTH_LOGIN_PATH_PART, DEFAULT_MAX_ADMIN_LOGIN_DURATION_SECONDS, DEFAULT_MAX_NONADMIN_LOGIN_DURATION_SECONDS, DEFAULT_MAX_REQUESTED_LOGIN_DURATION_SECONDS, DEFAULT_MAX_SERVICE_TOKEN_LOGIN_DURATION_SECONDS, DEFAULT_MIN_REQUESTED_LOGIN_DURATION_SECONDS, DEFAULT_OIDC_ANALYTICS_EVENT_NAMES, DEFAULT_OIDC_ANALYTICS_EVENT_NAME_PREFIX, DEFAULT_OIDC_CODE_CHALLENGE_METHODS, DEFAULT_OIDC_ID_TOKEN_SIGNING_ALG_VALUES, DEFAULT_OIDC_ISSUER_PATH, DEFAULT_OIDC_ROUTES, DEFAULT_OIDC_SUBJECT_TYPES, DEFAULT_OIDC_TOKEN_ENDPOINT_AUTH_METHODS, DEFAULT_OIDC_TOKEN_LIFETIMES, DEFAULT_ROTATED_KEY_MAX_AGE, FIREBASE_SERVER_OIDC_ANALYTICS_CONFIG, FIREBASE_SERVER_OIDC_ROUTES_FOR_GLOBAL_ROUTE_EXCLUDE, FirebaseServerOidcAnalyticsService, GRANTABLE_MODEL_NAMES, JwksFirestoreCollections, JwksKeyDocument, JwksService, JwksServiceConfig, JwksServiceStorageConfig, OIDC_ANALYTICS_SERVICE, OIDC_ENCRYPTED_PAYLOAD_FIELDS, OIDC_JSON_RENDER_ERROR_FUNCTION, OIDC_JWKS_ENCRYPTION_SECRET_ENV_KEY, OidcAccountService, OidcAccountServiceDelegate, OidcAccountServiceUserContext, OidcAnalyticsService, OidcAuth, OidcAuthBearerTokenMiddleware, OidcAuthMiddlewareConfig, OidcClientService, OidcEncryptionService, OidcInteractionController, OidcInteractionService, OidcModelServerActions, OidcModuleConfig, OidcProviderConfigService, OidcProviderController, OidcServerFirestoreCollections, OidcService, OidcWellKnownController, STALE_SESSION_ACCOUNT_CHECK_REASON, activeJwksKeysQuery, adminOnlyScopesForOidcProviderConfig, allOidcScopesStringForProviderConfig, appOidcAnalyticsModuleMetadata, appOidcModelModuleMetadata, applyOidcAuthMiddleware, applyOidcCorsMiddleware, buildBearerChallenge, buildFirebaseServerMcpResourceServer, buildOidcInteractionPolicy, createAdapterFactory, createOidcClientFactory, deleteOidcClientFactory, deleteOidcTokenFactory, deriveResourceMetadataUrlFromEnv, emitOidcAnalyticsEvent, getOidcScopesFromRequest, jwksKeyCollectionReference, jwksKeyConverter, jwksKeyFirestoreCollection, jwksKeyIdentity, jwksKeysWithStatusQuery, nonRetiredJwksKeysQuery, noopOidcAnalyticsService, oidcClientProviderProfileScopes, oidcCorsOriginDelegate, oidcFirestoreCollectionsFactory, oidcModelServerActions, oidcModelServerActionsFactory, oidcModuleConfigFactory, oidcModuleMetadata, resolveEffectiveSubset, rotateOidcClientSecretFactory, rotatedJwksKeysQuery, updateOidcClientFactory };
9021
+ export { DBX_FIREBASE_SERVER_OIDC_PROVIDER_PROFILES_CLIENT_METADATA, DEFAULT_APP_OAUTH_CONSENT_PATH_PART, DEFAULT_APP_OAUTH_INTERACTION_PATH, DEFAULT_APP_OAUTH_LOGIN_PATH_PART, DEFAULT_MAX_ADMIN_LOGIN_DURATION_SECONDS, DEFAULT_MAX_NONADMIN_LOGIN_DURATION_SECONDS, DEFAULT_MAX_REQUESTED_LOGIN_DURATION_SECONDS, DEFAULT_MAX_SERVICE_TOKEN_LOGIN_DURATION_SECONDS, DEFAULT_MIN_REQUESTED_LOGIN_DURATION_SECONDS, DEFAULT_OIDC_ANALYTICS_EVENT_NAMES, DEFAULT_OIDC_ANALYTICS_EVENT_NAME_PREFIX, DEFAULT_OIDC_CODE_CHALLENGE_METHODS, DEFAULT_OIDC_ID_TOKEN_SIGNING_ALG_VALUES, DEFAULT_OIDC_ISSUER_PATH, DEFAULT_OIDC_JWT_SIGNING_KEY_CACHE_MS, DEFAULT_OIDC_ROUTES, DEFAULT_OIDC_SIGNED_JWT_EXPIRES_IN_SECONDS, DEFAULT_OIDC_SIGNED_JWT_TYP, DEFAULT_OIDC_SUBJECT_TYPES, DEFAULT_OIDC_TOKEN_ENDPOINT_AUTH_METHODS, DEFAULT_OIDC_TOKEN_LIFETIMES, DEFAULT_ROTATED_KEY_MAX_AGE, FIREBASE_SERVER_OIDC_ANALYTICS_CONFIG, FIREBASE_SERVER_OIDC_ROUTES_FOR_GLOBAL_ROUTE_EXCLUDE, FirebaseServerOidcAnalyticsService, GRANTABLE_MODEL_NAMES, JwksFirestoreCollections, JwksKeyDocument, JwksService, JwksServiceConfig, JwksServiceStorageConfig, OIDC_ANALYTICS_SERVICE, OIDC_ENCRYPTED_PAYLOAD_FIELDS, OIDC_JSON_RENDER_ERROR_FUNCTION, OIDC_JWKS_ENCRYPTION_SECRET_ENV_KEY, OIDC_JWT_ACCESS_TOKEN_RESERVED_CLAIMS, OidcAccountService, OidcAccountServiceDelegate, OidcAccountServiceUserContext, OidcAnalyticsService, OidcAuth, OidcAuthBearerTokenMiddleware, OidcAuthMiddlewareConfig, OidcClientService, OidcEncryptionService, OidcInteractionController, OidcInteractionService, OidcJwtSigningService, OidcModelServerActions, OidcModuleConfig, OidcProviderConfigService, OidcProviderController, OidcServerFirestoreCollections, OidcService, OidcWellKnownController, STALE_SESSION_ACCOUNT_CHECK_REASON, activeJwksKeysQuery, adminOnlyScopesForOidcProviderConfig, allOidcScopesStringForProviderConfig, appOidcAnalyticsModuleMetadata, appOidcModelModuleMetadata, applyOidcAuthMiddleware, applyOidcCorsMiddleware, buildBearerChallenge, buildFirebaseServerMcpResourceServer, buildOidcInteractionPolicy, buildOidcResourceServer, createAdapterFactory, createOidcClientFactory, deleteOidcClientFactory, deleteOidcTokenFactory, deriveResourceMetadataUrlFromEnv, emitOidcAnalyticsEvent, firebaseServerIssuerProfiles, getOidcScopesFromRequest, jwksKeyCollectionReference, jwksKeyConverter, jwksKeyFirestoreCollection, jwksKeyIdentity, jwksKeysWithStatusQuery, nonRetiredJwksKeysQuery, noopOidcAnalyticsService, oidcClientProviderProfileScopes, oidcCorsOriginDelegate, oidcFirestoreCollectionsFactory, oidcModelServerActions, oidcModelServerActionsFactory, oidcModuleConfigFactory, oidcModuleMetadata, oidcResourceServerAudiences, reconsiderRejectedValues, requestedOIDCClaimNames, requestedResourceIndicators, resolveEffectiveSubset, rotateOidcClientSecretFactory, rotatedJwksKeysQuery, unrejectOIDCClaims, unrejectOIDCScopes, unrejectResourceScopes, updateOidcClientFactory };