@dereekb/firebase-server 13.32.0 → 13.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/calcom/index.cjs.default.js +1 -0
  2. package/calcom/index.cjs.js +1451 -0
  3. package/calcom/index.cjs.mjs +2 -0
  4. package/calcom/index.d.ts +1 -0
  5. package/calcom/index.esm.js +1437 -0
  6. package/calcom/package.json +29 -0
  7. package/calcom/src/index.d.ts +1 -0
  8. package/calcom/src/lib/calcom.oauth.connection.cache.d.ts +49 -0
  9. package/calcom/src/lib/calcom.oauth.connection.config.d.ts +75 -0
  10. package/calcom/src/lib/calcom.oauth.connection.context.d.ts +84 -0
  11. package/calcom/src/lib/calcom.oauth.connection.controller.d.ts +18 -0
  12. package/calcom/src/lib/calcom.oauth.connection.module.d.ts +55 -0
  13. package/calcom/src/lib/calcom.oauth.connection.service.d.ts +33 -0
  14. package/calcom/src/lib/index.d.ts +6 -0
  15. package/discord/index.cjs.default.js +1 -0
  16. package/discord/index.cjs.js +761 -0
  17. package/discord/index.cjs.mjs +2 -0
  18. package/discord/index.d.ts +1 -0
  19. package/discord/index.esm.js +753 -0
  20. package/discord/package.json +29 -0
  21. package/discord/src/index.d.ts +1 -0
  22. package/discord/src/lib/discord.oauth.connection.config.d.ts +69 -0
  23. package/discord/src/lib/discord.oauth.connection.controller.d.ts +18 -0
  24. package/discord/src/lib/discord.oauth.connection.module.d.ts +39 -0
  25. package/discord/src/lib/discord.oauth.connection.service.d.ts +43 -0
  26. package/discord/src/lib/index.d.ts +4 -0
  27. package/index.cjs.js +14 -3
  28. package/index.esm.js +14 -3
  29. package/mailgun/package.json +9 -9
  30. package/mcp/package.json +11 -11
  31. package/model/index.cjs.js +3986 -855
  32. package/model/index.esm.js +3934 -862
  33. package/model/package.json +10 -9
  34. package/model/src/lib/index.d.ts +1 -0
  35. package/model/src/lib/userexternalconnection/index.d.ts +8 -0
  36. package/model/src/lib/userexternalconnection/oauth/index.d.ts +7 -0
  37. package/model/src/lib/userexternalconnection/oauth/userexternalconnection.oauth.config.d.ts +110 -0
  38. package/model/src/lib/userexternalconnection/oauth/userexternalconnection.oauth.controller.d.ts +68 -0
  39. package/model/src/lib/userexternalconnection/oauth/userexternalconnection.oauth.error.d.ts +29 -0
  40. package/model/src/lib/userexternalconnection/oauth/userexternalconnection.oauth.refresh.d.ts +24 -0
  41. package/model/src/lib/userexternalconnection/oauth/userexternalconnection.oauth.registry.d.ts +54 -0
  42. package/model/src/lib/userexternalconnection/oauth/userexternalconnection.oauth.service.d.ts +216 -0
  43. package/model/src/lib/userexternalconnection/oauth/userexternalconnection.oauth.state.d.ts +114 -0
  44. package/model/src/lib/userexternalconnection/userexternalconnection.accessor.service.d.ts +111 -0
  45. package/model/src/lib/userexternalconnection/userexternalconnection.action.server.d.ts +172 -0
  46. package/model/src/lib/userexternalconnection/userexternalconnection.error.d.ts +44 -0
  47. package/model/src/lib/userexternalconnection/userexternalconnection.module.d.ts +129 -0
  48. package/model/src/lib/userexternalconnection/userexternalconnection.private.d.ts +192 -0
  49. package/model/src/lib/userexternalconnection/userexternalconnection.reader.service.d.ts +157 -0
  50. package/model/src/lib/userexternalconnection/userexternalconnection.refresh.service.d.ts +46 -0
  51. package/oidc/index.cjs.js +104 -78
  52. package/oidc/index.esm.js +104 -78
  53. package/oidc/package.json +10 -10
  54. package/package.json +24 -10
  55. package/src/lib/env/env.config.d.ts +15 -0
  56. package/src/lib/env/env.service.d.ts +7 -0
  57. package/src/lib/nest/env/env.service.d.ts +1 -0
  58. package/test/index.cjs.js +14 -2
  59. package/test/index.esm.js +15 -3
  60. package/test/package.json +11 -11
  61. package/test/src/lib/firebase/firebase.admin.auth.d.ts +1 -1
  62. package/twilio/package.json +8 -8
  63. package/zoho/README.md +8 -0
  64. package/zoho/index.cjs.js +1223 -33
  65. package/zoho/index.esm.js +1212 -36
  66. package/zoho/package.json +12 -9
  67. package/zoho/src/lib/index.d.ts +5 -0
  68. package/zoho/src/lib/zoho.oauth.connection.cache.d.ts +45 -0
  69. package/zoho/src/lib/zoho.oauth.connection.config.d.ts +80 -0
  70. package/zoho/src/lib/zoho.oauth.connection.controller.d.ts +18 -0
  71. package/zoho/src/lib/zoho.oauth.connection.module.d.ts +43 -0
  72. package/zoho/src/lib/zoho.oauth.connection.service.d.ts +107 -0
package/oidc/index.cjs.js CHANGED
@@ -6219,7 +6219,7 @@ var OidcInteractionController_1;
6219
6219
  * @throws {HttpException} HTTP 400 when the consent interaction cannot be completed.
6220
6220
  */ function postConsent(uid, body, res) {
6221
6221
  return _async_to_generator$2(function() {
6222
- var startedAt, clientId, accountId, _ref, _prompt_details_missingOIDCScope, _this_accountService_providerConfig_adminOnlyScopes, _ref1, _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, configAdminOnlyScopes, adminOnlyScopes, requestedAdminOnlyScopes, requestsServiceToken, isAdmin, _tmp1, _ref5, redirectTo1, _oidcClientProviderProfileScopes, clientUnlockedScopes, clientRequiredScopes, profileGatedScopes, disallowedGatedScopes, _ref6, redirectTo2, missingRequiredScopes, _ref7, redirectTo3, requestedRawTtl, clientMaxSessionTtl, expiresInSeconds, grant, _tmp2, _resolveEffectiveSubset, granted, rejected, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, encounteredOIDCClaims, missingOIDCClaims, _resolveEffectiveSubset1, granted1, rejected1, missingResourceScopes, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, indicator, scopes, _body_grantedResourceScopes, requestedSubset, encounteredResourceScopes, _resolveEffectiveSubset2, granted2, rejected2, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, value1, grantId, _ref8, redirectTo4, err;
6222
+ 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;
6223
6223
  return _ts_generator$2(this, function(_state) {
6224
6224
  switch(_state.label){
6225
6225
  case 0:
@@ -6301,66 +6301,44 @@ var OidcInteractionController_1;
6301
6301
  ];
6302
6302
  case 9:
6303
6303
  clientPayload = _state.sent();
6304
- // Admin-only scope gate. The requested OIDC scope set is `missingOIDCScope ∪ encounteredOIDCScopes`
6305
- // (a fresh consent has everything in `missing`; a re-consent may carry already-granted scopes in
6306
- // `encountered`). If that set intersects the admin-only scopes — the provider's `adminOnlyScopes`
6307
- // unioned with the scopes of every profile marked `adminOnly` — and the resolving user is not an
6308
- // admin, hard-reject with `access_denied` rather than silently dropping the scope.
6304
+ // The requested OIDC scope set is `missingOIDCScope ∪ encounteredOIDCScopes` (a fresh consent has
6305
+ // everything in `missing`; a re-consent may carry already-granted scopes in `encountered`). The two
6306
+ // provider-profile gates below judge the REQUEST — what this client may ask for at all — so they
6307
+ // read this set. The admin-only gate further down judges what the user actually consented to
6308
+ // instead, and reads `consentedOIDCScopeSet`.
6309
6309
  requestedOIDCScopeSet = new Set(_to_consumable_array$1(missingOIDCScope).concat(_to_consumable_array$1(encounteredOIDCScopes)));
6310
6310
  providerProfiles = this.accountService.providerConfig.providerProfiles;
6311
- configAdminOnlyScopes = (_this_accountService_providerConfig_adminOnlyScopes = this.accountService.providerConfig.adminOnlyScopes) !== null && _this_accountService_providerConfig_adminOnlyScopes !== void 0 ? _this_accountService_providerConfig_adminOnlyScopes : [];
6312
- adminOnlyScopes = new Set(_to_consumable_array$1(configAdminOnlyScopes).concat(_to_consumable_array$1(firebase.adminOnlyScopesForOidcProviderProfiles(providerProfiles !== null && providerProfiles !== void 0 ? providerProfiles : []))));
6313
- requestedAdminOnlyScopes = Array.from(adminOnlyScopes).filter(function(scope) {
6314
- return requestedOIDCScopeSet.has(scope);
6315
- });
6316
- // Deliberately sourced from the provider config's `adminOnlyScopes` ALONE, unlike the gate above:
6317
- // this flag also selects the (highest) service-token TTL tier further down, and a profile marked
6318
- // `adminOnly` must gate by admin status WITHOUT widening its grant's lifetime to that tier.
6319
- requestsServiceToken = configAdminOnlyScopes.some(function(scope) {
6320
- return requestedOIDCScopeSet.has(scope);
6311
+ // Provider-profile scope gate. Any scope referenced by a provider profile is "gated" — available
6312
+ // only to clients whose assigned profiles unlock it (a client with NO assigned profiles resolves
6313
+ // to the registry's default profiles). Independent of the admin-only gate below; a scope may be
6314
+ // subject to both.
6315
+ _oidcClientProviderProfileScopes = oidcClientProviderProfileScopes(providerProfiles, (_ref1 = clientPayload === null || clientPayload === void 0 ? void 0 : clientPayload.dbx_provider_profiles) !== null && _ref1 !== void 0 ? _ref1 : undefined), clientUnlockedScopes = _oidcClientProviderProfileScopes.unlocked, clientRequiredScopes = _oidcClientProviderProfileScopes.required;
6316
+ profileGatedScopes = firebase.scopesForOidcProviderProfiles(providerProfiles !== null && providerProfiles !== void 0 ? providerProfiles : []);
6317
+ // Unlock gate: reject any requested gated scope this client's profiles do not unlock.
6318
+ disallowedGatedScopes = Array.from(requestedOIDCScopeSet).filter(function(scope) {
6319
+ return profileGatedScopes.has(scope) && !clientUnlockedScopes.has(scope);
6321
6320
  });
6322
- if (!accountId) return [
6321
+ if (!(disallowedGatedScopes.length > 0)) return [
6323
6322
  3,
6324
6323
  11
6325
6324
  ];
6326
- return [
6327
- 4,
6328
- (_ref1 = (_this_accountService_delegate_isAdminUser = (_this_accountService_delegate = this.accountService.delegate).isAdminUser) === null || _this_accountService_delegate_isAdminUser === void 0 ? void 0 : _this_accountService_delegate_isAdminUser.call(_this_accountService_delegate, this.accountService.userContext(accountId).authUserContext)) !== null && _ref1 !== void 0 ? _ref1 : false
6329
- ];
6330
- case 10:
6331
- _tmp1 = _state.sent();
6332
- return [
6333
- 3,
6334
- 12
6335
- ];
6336
- case 11:
6337
- _tmp1 = false;
6338
- _state.label = 12;
6339
- case 12:
6340
- isAdmin = _tmp1;
6341
- if (!(requestedAdminOnlyScopes.length > 0 && !isAdmin)) return [
6342
- 3,
6343
- 14
6344
- ];
6345
6325
  return [
6346
6326
  4,
6347
6327
  this.oidcInteractionService.finishInteractionByUid(uid, {
6348
6328
  error: 'access_denied',
6349
- error_description: "The following scope(s) are restricted to admins: ".concat(requestedAdminOnlyScopes.join(', '), ".")
6329
+ error_description: "The following scope(s) are not available to this client: ".concat(disallowedGatedScopes.join(', '), ".")
6350
6330
  }, {
6351
6331
  mergeWithLastSubmission: true
6352
6332
  })
6353
6333
  ];
6354
- case 13:
6334
+ case 10:
6355
6335
  _ref5 = _state.sent(), redirectTo1 = _ref5.returnTo;
6356
6336
  emitOidcAnalyticsEvent(this._analytics, {
6357
6337
  type: 'consent',
6358
6338
  isSuccessful: false,
6359
6339
  uid: accountId,
6360
6340
  clientId: clientId,
6361
- serviceToken: requestsServiceToken,
6362
- isAdmin: false,
6363
- reason: 'service_token_non_admin',
6341
+ reason: 'scope_not_unlocked_for_client',
6364
6342
  durationMs: Date.now() - startedAt
6365
6343
  }, this._logger);
6366
6344
  res.json({
@@ -6369,38 +6347,33 @@ var OidcInteractionController_1;
6369
6347
  return [
6370
6348
  2
6371
6349
  ];
6372
- case 14:
6373
- // Provider-profile scope gate. Any scope referenced by a provider profile is "gated" — available
6374
- // only to clients whose assigned profiles unlock it (a client with NO assigned profiles resolves
6375
- // to the registry's default profiles). Independent of the admin-only gate above; a scope may be
6376
- // subject to both.
6377
- _oidcClientProviderProfileScopes = oidcClientProviderProfileScopes(providerProfiles, (_ref2 = clientPayload === null || clientPayload === void 0 ? void 0 : clientPayload.dbx_provider_profiles) !== null && _ref2 !== void 0 ? _ref2 : undefined), clientUnlockedScopes = _oidcClientProviderProfileScopes.unlocked, clientRequiredScopes = _oidcClientProviderProfileScopes.required;
6378
- profileGatedScopes = firebase.scopesForOidcProviderProfiles(providerProfiles !== null && providerProfiles !== void 0 ? providerProfiles : []);
6379
- // Unlock gate: reject any requested gated scope this client's profiles do not unlock.
6380
- disallowedGatedScopes = Array.from(requestedOIDCScopeSet).filter(function(scope) {
6381
- return profileGatedScopes.has(scope) && !clientUnlockedScopes.has(scope);
6350
+ case 11:
6351
+ // Required gate: a scope a client's profiles force-require (`require: 'required'`) must be present
6352
+ // in the request. Reject when the client did not request a required scope.
6353
+ missingRequiredScopes = Array.from(clientRequiredScopes).filter(function(scope) {
6354
+ return !requestedOIDCScopeSet.has(scope);
6382
6355
  });
6383
- if (!(disallowedGatedScopes.length > 0)) return [
6356
+ if (!(missingRequiredScopes.length > 0)) return [
6384
6357
  3,
6385
- 16
6358
+ 13
6386
6359
  ];
6387
6360
  return [
6388
6361
  4,
6389
6362
  this.oidcInteractionService.finishInteractionByUid(uid, {
6390
6363
  error: 'access_denied',
6391
- error_description: "The following scope(s) are not available to this client: ".concat(disallowedGatedScopes.join(', '), ".")
6364
+ error_description: "This client must request the required scope(s): ".concat(missingRequiredScopes.join(', '), ".")
6392
6365
  }, {
6393
6366
  mergeWithLastSubmission: true
6394
6367
  })
6395
6368
  ];
6396
- case 15:
6369
+ case 12:
6397
6370
  _ref6 = _state.sent(), redirectTo2 = _ref6.returnTo;
6398
6371
  emitOidcAnalyticsEvent(this._analytics, {
6399
6372
  type: 'consent',
6400
6373
  isSuccessful: false,
6401
6374
  uid: accountId,
6402
6375
  clientId: clientId,
6403
- reason: 'scope_not_unlocked_for_client',
6376
+ reason: 'required_scope_missing',
6404
6377
  durationMs: Date.now() - startedAt
6405
6378
  }, this._logger);
6406
6379
  res.json({
@@ -6409,13 +6382,62 @@ var OidcInteractionController_1;
6409
6382
  return [
6410
6383
  2
6411
6384
  ];
6412
- case 16:
6413
- // Required gate: a scope a client's profiles force-require (`require: 'required'`) must be present
6414
- // in the request. Reject when the client did not request a required scope.
6415
- missingRequiredScopes = Array.from(clientRequiredScopes).filter(function(scope) {
6416
- return !requestedOIDCScopeSet.has(scope);
6385
+ case 13:
6386
+ // The scopes this consent actually puts in force. Resolved once here and re-applied to the grant
6387
+ // further down, so the admin-only gate below judges exactly the set that will be granted.
6388
+ //
6389
+ // Force-grants the client's required profile scopes (in addition to `openid`) so they cannot be
6390
+ // dropped at consent — the required gate above already guarantees they were requested.
6391
+ effectiveOIDCScopes = resolveEffectiveSubset({
6392
+ missing: missingOIDCScope,
6393
+ requestedSubset: body.grantedOIDCScopes,
6394
+ alwaysGranted: _to_consumable_array$1(ALWAYS_GRANTED_OIDC_SCOPES).concat(_to_consumable_array$1(clientRequiredScopes)),
6395
+ alreadyEncountered: encounteredOIDCScopes
6417
6396
  });
6418
- if (!(missingRequiredScopes.length > 0)) return [
6397
+ // Scopes the existing Grant already holds (granted, minus any it rejected). Nothing here revokes
6398
+ // them, so they stay in force through this consent and the gate below has to count them too.
6399
+ heldOIDCScopes = existingGrant ? existingGrant.getOIDCScope().split(' ').filter(Boolean) : [];
6400
+ consentedOIDCScopeSet = new Set(_to_consumable_array$1(heldOIDCScopes).concat(_to_consumable_array$1(effectiveOIDCScopes.granted)));
6401
+ // Admin-only scope gate. If the consented set intersects the admin-only scopes — the provider's
6402
+ // `adminOnlyScopes` unioned with the scopes of every profile marked `adminOnly` — and the resolving
6403
+ // user is not an admin, hard-reject with `access_denied` rather than silently dropping the scope.
6404
+ //
6405
+ // Deliberately gated on what the user CONSENTED to rather than on what the client requested: the
6406
+ // consent UI renders a deselectable checkbox for every scope in the auth request, and a client
6407
+ // cannot know the caller's admin status when it builds that request. Gating on the request would
6408
+ // make an admin-only scope in `scopes_supported` fatal for every non-admin — deselecting it at
6409
+ // consent has to be a way through.
6410
+ configAdminOnlyScopes = (_this_accountService_providerConfig_adminOnlyScopes = this.accountService.providerConfig.adminOnlyScopes) !== null && _this_accountService_providerConfig_adminOnlyScopes !== void 0 ? _this_accountService_providerConfig_adminOnlyScopes : [];
6411
+ adminOnlyScopes = new Set(_to_consumable_array$1(configAdminOnlyScopes).concat(_to_consumable_array$1(firebase.adminOnlyScopesForOidcProviderProfiles(providerProfiles !== null && providerProfiles !== void 0 ? providerProfiles : []))));
6412
+ consentedAdminOnlyScopes = Array.from(adminOnlyScopes).filter(function(scope) {
6413
+ return consentedOIDCScopeSet.has(scope);
6414
+ });
6415
+ // Deliberately sourced from the provider config's `adminOnlyScopes` ALONE, unlike the gate above:
6416
+ // this flag also selects the (highest) service-token TTL tier further down, and a profile marked
6417
+ // `adminOnly` must gate by admin status WITHOUT widening its grant's lifetime to that tier.
6418
+ requestsServiceToken = configAdminOnlyScopes.some(function(scope) {
6419
+ return consentedOIDCScopeSet.has(scope);
6420
+ });
6421
+ if (!accountId) return [
6422
+ 3,
6423
+ 15
6424
+ ];
6425
+ return [
6426
+ 4,
6427
+ (_ref2 = (_this_accountService_delegate_isAdminUser = (_this_accountService_delegate = this.accountService.delegate).isAdminUser) === null || _this_accountService_delegate_isAdminUser === void 0 ? void 0 : _this_accountService_delegate_isAdminUser.call(_this_accountService_delegate, this.accountService.userContext(accountId).authUserContext)) !== null && _ref2 !== void 0 ? _ref2 : false
6428
+ ];
6429
+ case 14:
6430
+ _tmp1 = _state.sent();
6431
+ return [
6432
+ 3,
6433
+ 16
6434
+ ];
6435
+ case 15:
6436
+ _tmp1 = false;
6437
+ _state.label = 16;
6438
+ case 16:
6439
+ isAdmin = _tmp1;
6440
+ if (!(consentedAdminOnlyScopes.length > 0 && !isAdmin)) return [
6419
6441
  3,
6420
6442
  18
6421
6443
  ];
@@ -6423,7 +6445,7 @@ var OidcInteractionController_1;
6423
6445
  4,
6424
6446
  this.oidcInteractionService.finishInteractionByUid(uid, {
6425
6447
  error: 'access_denied',
6426
- error_description: "This client must request the required scope(s): ".concat(missingRequiredScopes.join(', '), ".")
6448
+ error_description: "The following scope(s) are restricted to admins: ".concat(consentedAdminOnlyScopes.join(', '), ".")
6427
6449
  }, {
6428
6450
  mergeWithLastSubmission: true
6429
6451
  })
@@ -6435,7 +6457,9 @@ var OidcInteractionController_1;
6435
6457
  isSuccessful: false,
6436
6458
  uid: accountId,
6437
6459
  clientId: clientId,
6438
- reason: 'required_scope_missing',
6460
+ serviceToken: requestsServiceToken,
6461
+ isAdmin: false,
6462
+ reason: 'service_token_non_admin',
6439
6463
  durationMs: Date.now() - startedAt
6440
6464
  }, this._logger);
6441
6465
  res.json({
@@ -6478,14 +6502,7 @@ var OidcInteractionController_1;
6478
6502
  case 21:
6479
6503
  grant = _tmp2;
6480
6504
  if (missingOIDCScope.length > 0) {
6481
- // Force-grant the client's required profile scopes (in addition to `openid`) so they cannot be
6482
- // dropped at consent — the required gate above already guarantees they were requested.
6483
- _resolveEffectiveSubset = resolveEffectiveSubset({
6484
- missing: missingOIDCScope,
6485
- requestedSubset: body.grantedOIDCScopes,
6486
- alwaysGranted: _to_consumable_array$1(ALWAYS_GRANTED_OIDC_SCOPES).concat(_to_consumable_array$1(clientRequiredScopes)),
6487
- alreadyEncountered: encounteredOIDCScopes
6488
- }), granted = _resolveEffectiveSubset.granted, rejected = _resolveEffectiveSubset.rejected;
6505
+ granted = effectiveOIDCScopes.granted, rejected = effectiveOIDCScopes.rejected;
6489
6506
  if (granted.length > 0) {
6490
6507
  grant.addOIDCScope(granted.join(' '));
6491
6508
  }
@@ -6513,11 +6530,11 @@ var OidcInteractionController_1;
6513
6530
  encounteredOIDCClaims = grant.getOIDCClaimsEncountered();
6514
6531
  missingOIDCClaims = (_prompt_details_missingOIDCClaims = prompt.details.missingOIDCClaims) !== null && _prompt_details_missingOIDCClaims !== void 0 ? _prompt_details_missingOIDCClaims : [];
6515
6532
  if (missingOIDCClaims.length > 0) {
6516
- _resolveEffectiveSubset1 = resolveEffectiveSubset({
6533
+ _resolveEffectiveSubset = resolveEffectiveSubset({
6517
6534
  missing: missingOIDCClaims,
6518
6535
  requestedSubset: body.grantedOIDCClaims,
6519
6536
  alreadyEncountered: encounteredOIDCClaims
6520
- }), granted1 = _resolveEffectiveSubset1.granted, rejected1 = _resolveEffectiveSubset1.rejected;
6537
+ }), granted1 = _resolveEffectiveSubset.granted, rejected1 = _resolveEffectiveSubset.rejected;
6521
6538
  if (granted1.length > 0) {
6522
6539
  grant.addOIDCClaims(granted1);
6523
6540
  }
@@ -6531,13 +6548,22 @@ var OidcInteractionController_1;
6531
6548
  for(_iterator1 = Object.entries(missingResourceScopes)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6532
6549
  _step_value = _sliced_to_array(_step1.value, 2), indicator = _step_value[0], scopes = _step_value[1];
6533
6550
  ;
6534
- requestedSubset = (_body_grantedResourceScopes = body.grantedResourceScopes) === null || _body_grantedResourceScopes === void 0 ? void 0 : _body_grantedResourceScopes[indicator];
6551
+ ;
6552
+ // A submission with no explicit per-resource selection falls back to the OIDC scope selection
6553
+ // rather than granting everything the resource server declares. A resource server's scope list
6554
+ // is drawn from the same provider scopes the consent UI renders as one checkbox list, so a scope
6555
+ // deselected there must not reappear on the resource-bound access token — otherwise deselecting
6556
+ // an admin-only scope would clear the gate above while the token still carried it.
6557
+ // `grantedOIDCScopes` being absent still means "grant everything requested".
6558
+ 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) {
6559
+ return consentedOIDCScopeSet.has(scope);
6560
+ }) : undefined;
6535
6561
  encounteredResourceScopes = grant.getResourceScopeEncountered(indicator).split(' ').filter(Boolean);
6536
- _resolveEffectiveSubset2 = resolveEffectiveSubset({
6562
+ _resolveEffectiveSubset1 = resolveEffectiveSubset({
6537
6563
  missing: scopes,
6538
6564
  requestedSubset: requestedSubset,
6539
6565
  alreadyEncountered: encounteredResourceScopes
6540
- }), granted2 = _resolveEffectiveSubset2.granted, rejected2 = _resolveEffectiveSubset2.rejected;
6566
+ }), granted2 = _resolveEffectiveSubset1.granted, rejected2 = _resolveEffectiveSubset1.rejected;
6541
6567
  if (granted2.length > 0) {
6542
6568
  grant.addResourceScope(indicator, granted2.join(' '));
6543
6569
  }
@@ -6593,7 +6619,7 @@ var OidcInteractionController_1;
6593
6619
  })
6594
6620
  ];
6595
6621
  case 23:
6596
- _ref8 = _state.sent(), redirectTo4 = _ref8.returnTo;
6622
+ _ref9 = _state.sent(), redirectTo4 = _ref9.returnTo;
6597
6623
  emitOidcAnalyticsEvent(this._analytics, {
6598
6624
  type: 'consent',
6599
6625
  isSuccessful: true,