@dereekb/firebase-server 13.30.0 → 13.32.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/test/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { randomEmailFactory, randomPhoneNumberFactory, mapGetter, incrementingNumberFactory, asGetter, getValueFromGetter, cachedGetter, asArray, mapObjectMap, unixDateTimeSecondsNumberForNow } from '@dereekb/util';
2
2
  import { useTestContextFixture, AbstractChildTestContextFixture, testContextBuilder, AbstractTestContextFixture, useTestFunctionFixture, useTestFunctionMapFixture, ExpectedErrorOfSpecificTypeError } from '@dereekb/util/test';
3
3
  import { decode } from 'jsonwebtoken';
4
- import { flatFirestoreModelKey, twoWayFlatFirestoreModelKey, firestoreContextFactory, firebaseStorageContextFactory, scopesForOidcProviderProfiles } from '@dereekb/firebase';
4
+ import { flatFirestoreModelKey, twoWayFlatFirestoreModelKey, firestoreContextFactory, firebaseStorageContextFactory, adminOnlyScopesForOidcProviderProfiles, assignmentOnlyScopesForOidcProviderProfiles } from '@dereekb/firebase';
5
5
  import admin from 'firebase-admin';
6
6
  import functions from 'firebase-functions-test';
7
7
  import { makeTestingFirestoreDrivers, TestFirestoreInstance, TestFirestoreContextFixture, makeTestingFirebaseStorageDrivers, TestFirebaseStorageInstance, TestFirebaseStorageContextFixture, mockItemFirestoreCollection, testWithMockItemCollectionFixture, testWithMockItemStorageFixture } from '@dereekb/firebase/test';
@@ -73,7 +73,7 @@ function _create_class$6(Constructor, protoProps, staticProps) {
73
73
  if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
74
74
  return Constructor;
75
75
  }
76
- function _define_property$8(obj, key, value) {
76
+ function _define_property$9(obj, key, value) {
77
77
  if (key in obj) {
78
78
  Object.defineProperty(obj, key, {
79
79
  value: value,
@@ -105,7 +105,7 @@ function _inherits$9(subClass, superClass) {
105
105
  });
106
106
  if (superClass) _set_prototype_of$9(subClass, superClass);
107
107
  }
108
- function _object_spread$5(target) {
108
+ function _object_spread$6(target) {
109
109
  for(var i = 1; i < arguments.length; i++){
110
110
  var source = arguments[i] != null ? arguments[i] : {};
111
111
  var ownKeys = Object.keys(source);
@@ -115,7 +115,7 @@ function _object_spread$5(target) {
115
115
  }));
116
116
  }
117
117
  ownKeys.forEach(function(key) {
118
- _define_property$8(target, key, source[key]);
118
+ _define_property$9(target, key, source[key]);
119
119
  });
120
120
  }
121
121
  return target;
@@ -370,8 +370,8 @@ function _ts_generator$a(thisArg, body) {
370
370
  */ var AuthorizedUserTestContextInstance = /*#__PURE__*/ function() {
371
371
  function AuthorizedUserTestContextInstance(uid, testContext) {
372
372
  _class_call_check$9(this, AuthorizedUserTestContextInstance);
373
- _define_property$8(this, "uid", void 0);
374
- _define_property$8(this, "testContext", void 0);
373
+ _define_property$9(this, "uid", void 0);
374
+ _define_property$9(this, "testContext", void 0);
375
375
  this.uid = uid;
376
376
  this.testContext = testContext;
377
377
  }
@@ -495,7 +495,7 @@ function _ts_generator$a(thisArg, body) {
495
495
  value: function callAuthBlockingFunction(input) {
496
496
  var fn = input.fn, userRecord = input.userRecord, eventType = input.eventType, eventOverride = input.eventOverride, _input_skipJsonConversion = input.skipJsonConversion, skipJsonConversion = _input_skipJsonConversion === void 0 ? false : _input_skipJsonConversion;
497
497
  var timestamp = new Date().toISOString();
498
- var event = _object_spread_props$3(_object_spread$5({
498
+ var event = _object_spread_props$3(_object_spread$6({
499
499
  ipAddress: '127.0.0.1',
500
500
  userAgent: 'testing',
501
501
  eventId: '0',
@@ -527,7 +527,7 @@ function _ts_generator$a(thisArg, body) {
527
527
  var skipJsonConversion = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
528
528
  var parsedParams = params == null || skipJsonConversion ? params : convertParamsToParsedJsonObjectAndBack(params);
529
529
  return this.makeContextOptions().then(function(options) {
530
- return fn(parsedParams, contextOptions ? _object_spread$5({}, contextOptions, options) : options);
530
+ return fn(parsedParams, contextOptions ? _object_spread$6({}, contextOptions, options) : options);
531
531
  });
532
532
  }
533
533
  }
@@ -602,7 +602,7 @@ function _ts_generator$a(thisArg, body) {
602
602
  inputUser = _state.sent();
603
603
  inputTemplate = templateGetter();
604
604
  uid = (inputUser === null || inputUser === void 0 ? void 0 : inputUser.uid) || makeUid();
605
- _$_object_spread = _object_spread$5({}, makeUserDetails(uid, params), inputTemplate), details = _$_object_spread.details, claims = _$_object_spread.claims, userDetailsAddContactInfo = _$_object_spread.addContactInfo;
605
+ _$_object_spread = _object_spread$6({}, makeUserDetails(uid, params), inputTemplate), details = _$_object_spread.details, claims = _$_object_spread.claims, userDetailsAddContactInfo = _$_object_spread.addContactInfo;
606
606
  _ref = details !== null && details !== void 0 ? details : {}, detailsPhoneNumber = _ref.phoneNumber, detailsEmail = _ref.email; // keep details if provided
607
607
  addContactInfo = inputAddContactInfo || userDetailsAddContactInfo;
608
608
  auth = f.instance.auth;
@@ -615,7 +615,7 @@ function _ts_generator$a(thisArg, body) {
615
615
  }
616
616
  return [
617
617
  4,
618
- auth.createUser(_object_spread$5(_object_spread_props$3(_object_spread$5({
618
+ auth.createUser(_object_spread$6(_object_spread_props$3(_object_spread$6({
619
619
  uid: uid,
620
620
  displayName: 'Test Person'
621
621
  }, details), {
@@ -807,7 +807,7 @@ function _ts_generator$a(thisArg, body) {
807
807
  var _ref;
808
808
  var _decoded_claims;
809
809
  var decoded = decode(token);
810
- var decodedToken = _object_spread_props$3(_object_spread$5({}, decoded, decoded.claims), {
810
+ var decodedToken = _object_spread_props$3(_object_spread$6({}, decoded, decoded.claims), {
811
811
  auth_time: decoded.iat,
812
812
  firebase: (_ref = (_decoded_claims = decoded.claims) === null || _decoded_claims === void 0 ? void 0 : _decoded_claims.firebase) !== null && _ref !== void 0 ? _ref : {}
813
813
  });
@@ -838,7 +838,7 @@ function _ts_generator$a(thisArg, body) {
838
838
  }
839
839
  };
840
840
  var customClaims = userRecord.customClaims;
841
- return _object_spread$5({}, customClaims, baseClaims);
841
+ return _object_spread$6({}, customClaims, baseClaims);
842
842
  }
843
843
 
844
844
  function _assert_this_initialized$8(self) {
@@ -898,7 +898,7 @@ function _create_class$5(Constructor, protoProps, staticProps) {
898
898
  if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
899
899
  return Constructor;
900
900
  }
901
- function _define_property$7(obj, key, value) {
901
+ function _define_property$8(obj, key, value) {
902
902
  if (key in obj) {
903
903
  Object.defineProperty(obj, key, {
904
904
  value: value,
@@ -1119,9 +1119,9 @@ function _ts_generator$9(thisArg, body) {
1119
1119
  */ var ModelTestContextInstance = /*#__PURE__*/ function() {
1120
1120
  function ModelTestContextInstance(collection, ref, testContext) {
1121
1121
  _class_call_check$8(this, ModelTestContextInstance);
1122
- _define_property$7(this, "collection", void 0);
1123
- _define_property$7(this, "ref", void 0);
1124
- _define_property$7(this, "testContext", void 0);
1122
+ _define_property$8(this, "collection", void 0);
1123
+ _define_property$8(this, "ref", void 0);
1124
+ _define_property$8(this, "testContext", void 0);
1125
1125
  this.collection = collection;
1126
1126
  this.ref = ref;
1127
1127
  this.testContext = testContext;
@@ -2008,7 +2008,7 @@ function _create_class$4(Constructor, protoProps, staticProps) {
2008
2008
  if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
2009
2009
  return Constructor;
2010
2010
  }
2011
- function _define_property$6(obj, key, value) {
2011
+ function _define_property$7(obj, key, value) {
2012
2012
  if (key in obj) {
2013
2013
  Object.defineProperty(obj, key, {
2014
2014
  value: value,
@@ -2040,7 +2040,7 @@ function _inherits$5(subClass, superClass) {
2040
2040
  });
2041
2041
  if (superClass) _set_prototype_of$5(subClass, superClass);
2042
2042
  }
2043
- function _object_spread$4(target) {
2043
+ function _object_spread$5(target) {
2044
2044
  for(var i = 1; i < arguments.length; i++){
2045
2045
  var source = arguments[i] != null ? arguments[i] : {};
2046
2046
  var ownKeys = Object.keys(source);
@@ -2050,7 +2050,7 @@ function _object_spread$4(target) {
2050
2050
  }));
2051
2051
  }
2052
2052
  ownKeys.forEach(function(key) {
2053
- _define_property$6(target, key, source[key]);
2053
+ _define_property$7(target, key, source[key]);
2054
2054
  });
2055
2055
  }
2056
2056
  return target;
@@ -2265,12 +2265,12 @@ function _ts_generator$6(thisArg, body) {
2265
2265
  function FirebaseAdminTestContextInstance(app) {
2266
2266
  var _this = this;
2267
2267
  _class_call_check$5(this, FirebaseAdminTestContextInstance);
2268
- _define_property$6(this, "app", void 0);
2269
- _define_property$6(this, "getTestFirestoreInstance", cachedGetter(function() {
2268
+ _define_property$7(this, "app", void 0);
2269
+ _define_property$7(this, "getTestFirestoreInstance", cachedGetter(function() {
2270
2270
  var drivers = makeTestingFirestoreDrivers(googleCloudFirestoreDrivers());
2271
2271
  return new GoogleCloudTestFirestoreInstance(drivers, _this.firestore);
2272
2272
  }));
2273
- _define_property$6(this, "getTestFirebaseStorageInstance", cachedGetter(function() {
2273
+ _define_property$7(this, "getTestFirebaseStorageInstance", cachedGetter(function() {
2274
2274
  var drivers = makeTestingFirebaseStorageDrivers(googleCloudFirebaseStorageDrivers());
2275
2275
  var defaultBucketId = _this.app.options.storageBucket;
2276
2276
  return new GoogleCloudTestFirebaseStorageInstance(drivers, _this.storage, defaultBucketId);
@@ -2340,7 +2340,7 @@ function _ts_generator$6(thisArg, body) {
2340
2340
  */ var AbstractFirebaseAdminTestContextInstanceChild = /*#__PURE__*/ function() {
2341
2341
  function AbstractFirebaseAdminTestContextInstanceChild(parent) {
2342
2342
  _class_call_check$5(this, AbstractFirebaseAdminTestContextInstanceChild);
2343
- _define_property$6(this, "parent", void 0);
2343
+ _define_property$7(this, "parent", void 0);
2344
2344
  this.parent = parent;
2345
2345
  }
2346
2346
  _create_class$4(AbstractFirebaseAdminTestContextInstanceChild, [
@@ -2408,7 +2408,7 @@ function _ts_generator$6(thisArg, body) {
2408
2408
  * This can be used to easily build a testing context that sets up RulesTestEnvironment for tests that sets itself up and tears itself down.
2409
2409
  */ var firebaseAdminTestBuilder = testContextBuilder({
2410
2410
  buildConfig: function buildConfig(input) {
2411
- var config = _object_spread$4({}, input);
2411
+ var config = _object_spread$5({}, input);
2412
2412
  return config;
2413
2413
  },
2414
2414
  buildFixture: function buildFixture() {
@@ -2535,7 +2535,7 @@ function _async_to_generator$5(fn) {
2535
2535
  });
2536
2536
  };
2537
2537
  }
2538
- function _define_property$5(obj, key, value) {
2538
+ function _define_property$6(obj, key, value) {
2539
2539
  if (key in obj) {
2540
2540
  Object.defineProperty(obj, key, {
2541
2541
  value: value,
@@ -2548,7 +2548,7 @@ function _define_property$5(obj, key, value) {
2548
2548
  }
2549
2549
  return obj;
2550
2550
  }
2551
- function _object_spread$3(target) {
2551
+ function _object_spread$4(target) {
2552
2552
  for(var i = 1; i < arguments.length; i++){
2553
2553
  var source = arguments[i] != null ? arguments[i] : {};
2554
2554
  var ownKeys = Object.keys(source);
@@ -2558,7 +2558,7 @@ function _object_spread$3(target) {
2558
2558
  }));
2559
2559
  }
2560
2560
  ownKeys.forEach(function(key) {
2561
- _define_property$5(target, key, source[key]);
2561
+ _define_property$6(target, key, source[key]);
2562
2562
  });
2563
2563
  }
2564
2564
  return target;
@@ -2709,7 +2709,7 @@ function _ts_generator$5(thisArg, body) {
2709
2709
  return _async_to_generator$5(function() {
2710
2710
  var _ref, request;
2711
2711
  return _ts_generator$5(this, function(_state) {
2712
- request = _object_spread_props$2(_object_spread$3({}, context), {
2712
+ request = _object_spread_props$2(_object_spread$4({}, context), {
2713
2713
  data: data,
2714
2714
  // NOTE: These will typically not be used/available as they are express.js properties that are not available or useful to the handlers
2715
2715
  rawRequest: (_ref = context === null || context === void 0 ? void 0 : context.rawRequest) !== null && _ref !== void 0 ? _ref : {},
@@ -2842,7 +2842,7 @@ function _create_class$3(Constructor, protoProps, staticProps) {
2842
2842
  if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
2843
2843
  return Constructor;
2844
2844
  }
2845
- function _define_property$4(obj, key, value) {
2845
+ function _define_property$5(obj, key, value) {
2846
2846
  if (key in obj) {
2847
2847
  Object.defineProperty(obj, key, {
2848
2848
  value: value,
@@ -2882,7 +2882,7 @@ function _instanceof$1(left, right) {
2882
2882
  return left instanceof right;
2883
2883
  }
2884
2884
  }
2885
- function _object_spread$2(target) {
2885
+ function _object_spread$3(target) {
2886
2886
  for(var i = 1; i < arguments.length; i++){
2887
2887
  var source = arguments[i] != null ? arguments[i] : {};
2888
2888
  var ownKeys = Object.keys(source);
@@ -2892,7 +2892,7 @@ function _object_spread$2(target) {
2892
2892
  }));
2893
2893
  }
2894
2894
  ownKeys.forEach(function(key) {
2895
- _define_property$4(target, key, source[key]);
2895
+ _define_property$5(target, key, source[key]);
2896
2896
  });
2897
2897
  }
2898
2898
  return target;
@@ -3171,7 +3171,7 @@ var functionsInitialized = false;
3171
3171
  var _this;
3172
3172
  _this = _call_super$4(this, FirebaseAdminFunctionTestContextInstance, [
3173
3173
  app
3174
- ]), _define_property$4(_this, "instance", void 0), _define_property$4(_this, "_fnWrapper", cachedGetter(function() {
3174
+ ]), _define_property$5(_this, "instance", void 0), _define_property$5(_this, "_fnWrapper", cachedGetter(function() {
3175
3175
  return firebaseAdminCloudFunctionWrapper(_this.instance);
3176
3176
  }));
3177
3177
  _this.instance = instance;
@@ -3214,7 +3214,7 @@ var functionsInitialized = false;
3214
3214
  */ var firebaseAdminFunctionTestBuilder = testContextBuilder({
3215
3215
  buildConfig: function buildConfig(input) {
3216
3216
  var _ref;
3217
- var config = _object_spread_props$1(_object_spread$2({}, input), {
3217
+ var config = _object_spread_props$1(_object_spread$3({}, input), {
3218
3218
  useFunctionSingletonContext: (_ref = input === null || input === void 0 ? void 0 : input.useFunctionSingletonContext) !== null && _ref !== void 0 ? _ref : DEFAULT_FIREBASE_ADMIN_FUNCTION_TEST_USE_FUNCTION_SINGLETON_CONTEXT
3219
3219
  });
3220
3220
  return config;
@@ -3421,7 +3421,7 @@ function _create_class$2(Constructor, protoProps, staticProps) {
3421
3421
  if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
3422
3422
  return Constructor;
3423
3423
  }
3424
- function _define_property$3(obj, key, value) {
3424
+ function _define_property$4(obj, key, value) {
3425
3425
  if (key in obj) {
3426
3426
  Object.defineProperty(obj, key, {
3427
3427
  value: value,
@@ -3459,7 +3459,7 @@ function _iterable_to_array$1(iter) {
3459
3459
  function _non_iterable_spread$1() {
3460
3460
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3461
3461
  }
3462
- function _object_spread$1(target) {
3462
+ function _object_spread$2(target) {
3463
3463
  for(var i = 1; i < arguments.length; i++){
3464
3464
  var source = arguments[i] != null ? arguments[i] : {};
3465
3465
  var ownKeys = Object.keys(source);
@@ -3469,7 +3469,7 @@ function _object_spread$1(target) {
3469
3469
  }));
3470
3470
  }
3471
3471
  ownKeys.forEach(function(key) {
3472
- _define_property$3(target, key, source[key]);
3472
+ _define_property$4(target, key, source[key]);
3473
3473
  });
3474
3474
  }
3475
3475
  return target;
@@ -3696,9 +3696,9 @@ function _ts_generator$3(thisArg, body) {
3696
3696
  var _this1;
3697
3697
  _this = _call_super$3(this, FirebaseAdminNestTestContextInstance, [
3698
3698
  parent
3699
- ]), _this1 = _this, _define_property$3(_this, "nest", void 0), _define_property$3(_this, "nestAppPromiseGetter", function() {
3699
+ ]), _this1 = _this, _define_property$4(_this, "nest", void 0), _define_property$4(_this, "nestAppPromiseGetter", function() {
3700
3700
  return Promise.resolve(_this.nest);
3701
- }), _define_property$3(_this, "_loadInitializedNestApplication", cachedGetter(function() {
3701
+ }), _define_property$4(_this, "_loadInitializedNestApplication", cachedGetter(function() {
3702
3702
  return _async_to_generator$3(function() {
3703
3703
  var app;
3704
3704
  return _ts_generator$3(this, function(_state) {
@@ -3811,7 +3811,7 @@ function _ts_generator$3(thisArg, body) {
3811
3811
  switch(_state.label){
3812
3812
  case 0:
3813
3813
  additionalProviders = (_makeProviders = makeProviders(f.instance)) !== null && _makeProviders !== void 0 ? _makeProviders : [];
3814
- rootModule = buildNestServerRootModule(_object_spread_props(_object_spread$1({}, serverInstanceConfig), {
3814
+ rootModule = buildNestServerRootModule(_object_spread_props(_object_spread$2({}, serverInstanceConfig), {
3815
3815
  modules: _to_consumable_array$1(asArray(nestModules)).concat(_to_consumable_array$1(asArray(serverInstanceConfig === null || serverInstanceConfig === void 0 ? void 0 : serverInstanceConfig.modules))),
3816
3816
  firebaseAppGetter: config.injectFirebaseServerAppTokenProvider ? asGetter(f.instance.app) : undefined,
3817
3817
  providers: additionalProviders,
@@ -3959,7 +3959,7 @@ function _create_class$1(Constructor, protoProps, staticProps) {
3959
3959
  if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
3960
3960
  return Constructor;
3961
3961
  }
3962
- function _define_property$2(obj, key, value) {
3962
+ function _define_property$3(obj, key, value) {
3963
3963
  if (key in obj) {
3964
3964
  Object.defineProperty(obj, key, {
3965
3965
  value: value,
@@ -3991,7 +3991,7 @@ function _inherits$2(subClass, superClass) {
3991
3991
  });
3992
3992
  if (superClass) _set_prototype_of$2(subClass, superClass);
3993
3993
  }
3994
- function _object_spread(target) {
3994
+ function _object_spread$1(target) {
3995
3995
  for(var i = 1; i < arguments.length; i++){
3996
3996
  var source = arguments[i] != null ? arguments[i] : {};
3997
3997
  var ownKeys = Object.keys(source);
@@ -4001,7 +4001,7 @@ function _object_spread(target) {
4001
4001
  }));
4002
4002
  }
4003
4003
  ownKeys.forEach(function(key) {
4004
- _define_property$2(target, key, source[key]);
4004
+ _define_property$3(target, key, source[key]);
4005
4005
  });
4006
4006
  }
4007
4007
  return target;
@@ -4160,7 +4160,7 @@ function _is_native_reflect_construct$2() {
4160
4160
  * @param buildTests - Callback that receives the child fixture and registers test cases.
4161
4161
  * @returns Whatever {@link firebaseAdminNestContextWithFixture} returns after registering the merged child fixture (typically `void`).
4162
4162
  */ function firebaseAdminFunctionNestContextWithFixture(config, f, buildTests) {
4163
- var mergedConfig = _object_spread({
4163
+ var mergedConfig = _object_spread$1({
4164
4164
  makeFixture: function makeFixture(parent) {
4165
4165
  return new FirebaseAdminFunctionNestTestContextFixture(parent);
4166
4166
  },
@@ -4502,7 +4502,7 @@ function _class_call_check$1(instance, Constructor) {
4502
4502
  throw new TypeError("Cannot call a class as a function");
4503
4503
  }
4504
4504
  }
4505
- function _define_property$1(obj, key, value) {
4505
+ function _define_property$2(obj, key, value) {
4506
4506
  if (key in obj) {
4507
4507
  Object.defineProperty(obj, key, {
4508
4508
  value: value,
@@ -4577,7 +4577,7 @@ function _is_native_reflect_construct$1() {
4577
4577
  var code = httpError.details.code;
4578
4578
  _this = _call_super$1(this, ExpectedHttpErrorWithSpecificServerErrorCode, [
4579
4579
  'Expected HttpError with an error code of "'.concat(expectedErrorCode, '", but recieved "').concat(code, '" instead.')
4580
- ]), _define_property$1(_this, "httpError", void 0), _define_property$1(_this, "expectedErrorCode", void 0);
4580
+ ]), _define_property$2(_this, "httpError", void 0), _define_property$2(_this, "expectedErrorCode", void 0);
4581
4581
  _this.httpError = httpError;
4582
4582
  _this.expectedErrorCode = expectedErrorCode;
4583
4583
  return _this;
@@ -4674,6 +4674,19 @@ function _async_to_generator$1(fn) {
4674
4674
  });
4675
4675
  };
4676
4676
  }
4677
+ function _define_property$1(obj, key, value) {
4678
+ if (key in obj) {
4679
+ Object.defineProperty(obj, key, {
4680
+ value: value,
4681
+ enumerable: true,
4682
+ configurable: true,
4683
+ writable: true
4684
+ });
4685
+ } else {
4686
+ obj[key] = value;
4687
+ }
4688
+ return obj;
4689
+ }
4677
4690
  function _iterable_to_array(iter) {
4678
4691
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
4679
4692
  }
@@ -4707,6 +4720,21 @@ function _non_iterable_rest() {
4707
4720
  function _non_iterable_spread() {
4708
4721
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4709
4722
  }
4723
+ function _object_spread(target) {
4724
+ for(var i = 1; i < arguments.length; i++){
4725
+ var source = arguments[i] != null ? arguments[i] : {};
4726
+ var ownKeys = Object.keys(source);
4727
+ if (typeof Object.getOwnPropertySymbols === "function") {
4728
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4729
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4730
+ }));
4731
+ }
4732
+ ownKeys.forEach(function(key) {
4733
+ _define_property$1(target, key, source[key]);
4734
+ });
4735
+ }
4736
+ return target;
4737
+ }
4710
4738
  function _sliced_to_array(arr, i) {
4711
4739
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
4712
4740
  }
@@ -4926,27 +4954,32 @@ function _ts_generator$1(thisArg, body) {
4926
4954
  * Admin-only scopes (e.g. `token.service`) are dropped from the default "all scopes" request because
4927
4955
  * the provider hard-rejects them for non-admin users, and this default flow logs in an arbitrary
4928
4956
  * (often non-admin) user. Tests that need an admin-only scope pass it explicitly via `config.scopes`.
4957
+ * Both sources of the gate are excluded: the provider config's `adminOnlyScopes` and the scopes of any
4958
+ * profile marked `adminOnly`.
4929
4959
  *
4930
- * Provider-profile-gated scopes (e.g. `lms`, `reports`) are dropped for the same reason: they are
4931
- * unlocked only for a client an admin has assigned the corresponding profile to, and this flow creates
4932
- * a fresh client with no profiles — so the consent unlock gate hard-rejects them (finishing the
4960
+ * Assignment-only profile-gated scopes (e.g. `lms`, `reports`) are dropped for the same reason: they
4961
+ * are unlocked only for a client an admin has assigned the corresponding profile to, and this flow
4962
+ * creates a fresh client with no profiles — so the consent unlock gate hard-rejects them (finishing the
4933
4963
  * interaction with `access_denied` and no `code`). Tests that need a gated scope create a client with
4934
- * the profile and pass the scope explicitly via `config.scopes`.
4964
+ * the profile and pass the scope explicitly via `config.scopes`. A scope unlocked by a DEFAULT profile
4965
+ * is deliberately kept: a client with no profiles assigned resolves to the default profiles, so it can
4966
+ * obtain that scope.
4935
4967
  *
4936
4968
  * @param nestApp - Initialized NestJS application used to resolve {@link OidcAccountService} when no scopes override is given.
4937
4969
  * @param config - Optional flow config; when `config.scopes` is set, it is returned verbatim.
4938
4970
  * @returns The space-separated scope string to pass to the `/oidc/auth` endpoint.
4939
4971
  */ function resolveScopes(nestApp, config) {
4940
4972
  return _async_to_generator$1(function() {
4941
- var result, _providerConfig_adminOnlyScopes, _providerConfig_providerProfiles, accountService, providerConfig, adminOnlyScopes, profileGatedScopes;
4973
+ var result, _providerConfig_providerProfiles, _providerConfig_adminOnlyScopes, accountService, providerConfig, providerProfiles, adminOnlyScopes, profileGatedScopes;
4942
4974
  return _ts_generator$1(this, function(_state) {
4943
4975
  if (config === null || config === void 0 ? void 0 : config.scopes) {
4944
4976
  result = config.scopes;
4945
4977
  } else {
4946
4978
  accountService = nestApp.get(OidcAccountService);
4947
4979
  providerConfig = accountService.providerConfig;
4948
- adminOnlyScopes = new Set((_providerConfig_adminOnlyScopes = providerConfig.adminOnlyScopes) !== null && _providerConfig_adminOnlyScopes !== void 0 ? _providerConfig_adminOnlyScopes : []);
4949
- profileGatedScopes = scopesForOidcProviderProfiles((_providerConfig_providerProfiles = providerConfig.providerProfiles) !== null && _providerConfig_providerProfiles !== void 0 ? _providerConfig_providerProfiles : []);
4980
+ providerProfiles = (_providerConfig_providerProfiles = providerConfig.providerProfiles) !== null && _providerConfig_providerProfiles !== void 0 ? _providerConfig_providerProfiles : [];
4981
+ adminOnlyScopes = new Set(_to_consumable_array((_providerConfig_adminOnlyScopes = providerConfig.adminOnlyScopes) !== null && _providerConfig_adminOnlyScopes !== void 0 ? _providerConfig_adminOnlyScopes : []).concat(_to_consumable_array(adminOnlyScopesForOidcProviderProfiles(providerProfiles))));
4982
+ profileGatedScopes = assignmentOnlyScopesForOidcProviderProfiles(providerProfiles);
4950
4983
  result = Object.keys(providerConfig.claims).filter(function(scope) {
4951
4984
  return !adminOnlyScopes.has(scope) && !profileGatedScopes.has(scope);
4952
4985
  }).join(' ');
@@ -4968,12 +5001,12 @@ function _ts_generator$1(thisArg, body) {
4968
5001
  * @param input.oidcClientService - Service used to create the OAuth client whose credentials drive the flow.
4969
5002
  * @param input.nestApp - Initialized NestJS application; used to resolve {@link OidcAccountService} for project-id-derived ID tokens and default scopes.
4970
5003
  * @param input.uid - Firebase user ID for whom the test ID token is minted and the OAuth flow is authorized.
4971
- * @param input.config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method).
5004
+ * @param input.config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method, provider profiles).
4972
5005
  * @returns The exchanged access token and ID token from the OIDC `/token` endpoint.
4973
5006
  * @throws {Error} When the token exchange step fails (the response body and status are included in the message).
4974
5007
  */ function performFullOAuthFlow(input) {
4975
5008
  return _async_to_generator$1(function() {
4976
- var _ref, _ref1, _ref2, server, oidcClientService, nestApp, uid, config, _createCookieJar, collectCookies, cookieHeader, redirectUri, clientName, tokenEndpointAuthMethod, scopes, _ref3, client_id, client_secret, codeVerifier, codeChallenge, authRes, loginUid, idToken, loginRes, resumeAfterLoginPath, consentRedirectRes, consentUid, consentRes, resumeAfterConsentPath, callbackRedirectRes, callbackUrl, authorizationCode, tokenRes;
5009
+ var _ref, _ref1, _ref2, server, oidcClientService, nestApp, uid, config, _createCookieJar, collectCookies, cookieHeader, redirectUri, clientName, tokenEndpointAuthMethod, providerProfiles, scopes, _ref3, client_id, client_secret, codeVerifier, codeChallenge, authRes, loginUid, idToken, loginRes, resumeAfterLoginPath, consentRedirectRes, consentUid, consentRes, resumeAfterConsentPath, callbackRedirectRes, callbackUrl, authorizationCode, tokenRes;
4977
5010
  return _ts_generator$1(this, function(_state) {
4978
5011
  switch(_state.label){
4979
5012
  case 0:
@@ -4982,6 +5015,7 @@ function _ts_generator$1(thisArg, body) {
4982
5015
  redirectUri = (_ref = config === null || config === void 0 ? void 0 : config.redirectUri) !== null && _ref !== void 0 ? _ref : 'https://example.com/callback';
4983
5016
  clientName = (_ref1 = config === null || config === void 0 ? void 0 : config.clientName) !== null && _ref1 !== void 0 ? _ref1 : 'test-oauth-context';
4984
5017
  tokenEndpointAuthMethod = (_ref2 = config === null || config === void 0 ? void 0 : config.tokenEndpointAuthMethod) !== null && _ref2 !== void 0 ? _ref2 : 'client_secret_post';
5018
+ providerProfiles = config === null || config === void 0 ? void 0 : config.providerProfiles;
4985
5019
  return [
4986
5020
  4,
4987
5021
  resolveScopes(nestApp, config)
@@ -4990,13 +5024,15 @@ function _ts_generator$1(thisArg, body) {
4990
5024
  scopes = _state.sent();
4991
5025
  return [
4992
5026
  4,
4993
- oidcClientService.createClient({
5027
+ oidcClientService.createClient(_object_spread({
4994
5028
  client_name: clientName,
4995
5029
  redirect_uris: [
4996
5030
  redirectUri
4997
5031
  ],
4998
5032
  token_endpoint_auth_method: tokenEndpointAuthMethod
4999
- })
5033
+ }, providerProfiles == null ? {} : {
5034
+ dbx_provider_profiles: _to_consumable_array(providerProfiles)
5035
+ }))
5000
5036
  ];
5001
5037
  case 2:
5002
5038
  _ref3 = _state.sent(), client_id = _ref3.client_id, client_secret = _ref3.client_secret;
@@ -5099,7 +5135,7 @@ function _ts_generator$1(thisArg, body) {
5099
5135
  *
5100
5136
  * @param nestApp - Initialized NestJS application from which {@link JwksService} and {@link OidcClientService} are resolved.
5101
5137
  * @param uid - Firebase user ID for whom the OAuth flow is authorized.
5102
- * @param config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method).
5138
+ * @param config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method, provider profiles).
5103
5139
  * @returns The exchanged access token and ID token from {@link performFullOAuthFlow}.
5104
5140
  */ function setupAndPerformFullOAuthFlow(nestApp, uid, config) {
5105
5141
  return _async_to_generator$1(function() {
@@ -5504,7 +5540,7 @@ function _ts_generator(thisArg, body) {
5504
5540
  * The returned factory function performs a full OAuth authorization code flow
5505
5541
  * and provides an authenticated supertest agent and helper methods.
5506
5542
  *
5507
- * @param config - Optional flow overrides (scopes, redirect URI, client name, timeout) and custom fixture/instance constructors.
5543
+ * @param config - Optional flow overrides (scopes, redirect URI, client name, provider profiles, timeout) and custom fixture/instance constructors.
5508
5544
  * @returns Function that, given parent fixtures and a `buildTests` callback, registers a `describe('(oauth)', ...)` block which performs the full OAuth flow and exposes the authenticated supertest fixture.
5509
5545
  *
5510
5546
  * @example
@@ -5533,7 +5569,7 @@ function _ts_generator(thisArg, body) {
5533
5569
  "makeFixture",
5534
5570
  "makeInstance"
5535
5571
  ]);
5536
- var flowConfig = flowConfigOverrides.scopes || flowConfigOverrides.redirectUri || flowConfigOverrides.clientName ? flowConfigOverrides : undefined;
5572
+ var flowConfig = flowConfigOverrides.scopes || flowConfigOverrides.redirectUri || flowConfigOverrides.clientName || flowConfigOverrides.providerProfiles ? flowConfigOverrides : undefined;
5537
5573
  return function(params, buildTests) {
5538
5574
  var f = params.f, u = params.u;
5539
5575
  describe('(oauth)', function() {
package/test/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/test",
3
- "version": "13.30.0",
3
+ "version": "13.32.0",
4
4
  "peerDependencies": {
5
- "@dereekb/analytics": "13.30.0",
6
- "@dereekb/date": "13.30.0",
7
- "@dereekb/firebase": "13.30.0",
8
- "@dereekb/firebase-server": "13.30.0",
9
- "@dereekb/firebase-server/oidc": "13.30.0",
10
- "@dereekb/model": "13.30.0",
11
- "@dereekb/nestjs": "13.30.0",
12
- "@dereekb/rxjs": "13.30.0",
13
- "@dereekb/util": "13.30.0",
5
+ "@dereekb/analytics": "13.32.0",
6
+ "@dereekb/date": "13.32.0",
7
+ "@dereekb/firebase": "13.32.0",
8
+ "@dereekb/firebase-server": "13.32.0",
9
+ "@dereekb/firebase-server/oidc": "13.32.0",
10
+ "@dereekb/model": "13.32.0",
11
+ "@dereekb/nestjs": "13.32.0",
12
+ "@dereekb/rxjs": "13.32.0",
13
+ "@dereekb/util": "13.32.0",
14
14
  "@google-cloud/firestore": "^7.11.6",
15
15
  "@google-cloud/storage": "^7.19.0",
16
16
  "@nestjs/common": "^11.1.19",
@@ -23,7 +23,7 @@
23
23
  "supertest": "^7.2.2"
24
24
  },
25
25
  "devDependencies": {
26
- "@dereekb/nestjs": "13.30.0"
26
+ "@dereekb/nestjs": "13.32.0"
27
27
  },
28
28
  "exports": {
29
29
  "./package.json": "./package.json",
@@ -1,5 +1,6 @@
1
1
  import request from 'supertest';
2
2
  import { type INestApplication } from '@nestjs/common';
3
+ import { type OidcProviderProfileKey } from '@dereekb/firebase';
3
4
  import { AbstractTestContextFixture } from '@dereekb/util/test';
4
5
  import { type FirebaseAdminNestTestContextFixture } from '../firebase/firebase.admin.nest';
5
6
  import { type AuthorizedUserTestContextFixture } from '../firebase';
@@ -20,6 +21,13 @@ export interface OAuthAuthorizedSuperTestContextFactoryConfig {
20
21
  * Client name. Defaults to `'test-oauth-context'`.
21
22
  */
22
23
  readonly clientName?: string;
24
+ /**
25
+ * Provider profile keys assigned to the created OAuth client. Defaults to none.
26
+ *
27
+ * Needed to issue a token carrying an assignment-only profile-gated scope (e.g. `lms`); pair it
28
+ * with an explicit `scopes` string that requests that scope.
29
+ */
30
+ readonly providerProfiles?: readonly OidcProviderProfileKey[];
23
31
  /**
24
32
  * Vitest hook/test timeout in milliseconds. Defaults to `30_000`.
25
33
  */
@@ -120,7 +128,7 @@ export declare class OAuthAuthorizedSuperTestFixture extends AbstractTestContext
120
128
  * The returned factory function performs a full OAuth authorization code flow
121
129
  * and provides an authenticated supertest agent and helper methods.
122
130
  *
123
- * @param config - Optional flow overrides (scopes, redirect URI, client name, timeout) and custom fixture/instance constructors.
131
+ * @param config - Optional flow overrides (scopes, redirect URI, client name, provider profiles, timeout) and custom fixture/instance constructors.
124
132
  * @returns Function that, given parent fixtures and a `buildTests` callback, registers a `describe('(oauth)', ...)` block which performs the full OAuth flow and exposes the authenticated supertest fixture.
125
133
  *
126
134
  * @example
@@ -1,5 +1,5 @@
1
1
  import { type INestApplication } from '@nestjs/common';
2
- import { type OidcTokenEndpointAuthMethod } from '@dereekb/firebase';
2
+ import { type OidcProviderProfileKey, type OidcTokenEndpointAuthMethod } from '@dereekb/firebase';
3
3
  import { OidcClientService } from '@dereekb/firebase-server/oidc';
4
4
  /**
5
5
  * Configuration for {@link performFullOAuthFlow}.
@@ -23,6 +23,16 @@ export interface OAuthTestFlowConfig {
23
23
  * Token endpoint auth method. Defaults to `'client_secret_post'`.
24
24
  */
25
25
  readonly tokenEndpointAuthMethod?: OidcTokenEndpointAuthMethod;
26
+ /**
27
+ * Provider profile keys to assign to the test client (persisted as its `dbx_provider_profiles`
28
+ * client metadata). Defaults to none.
29
+ *
30
+ * Required to obtain an assignment-only profile-gated scope (e.g. `lms`): the consent unlock gate
31
+ * rejects any gated scope the client's assigned profiles do not unlock. Pair this with an explicit
32
+ * {@link OAuthTestFlowConfig.scopes} string containing the gated scope, since the default
33
+ * "all registered scopes" resolution deliberately drops assignment-only scopes.
34
+ */
35
+ readonly providerProfiles?: readonly OidcProviderProfileKey[];
26
36
  }
27
37
  export interface PerformFullOAuthFlowResult {
28
38
  readonly accessToken: string;
@@ -48,7 +58,7 @@ export interface PerformFullOAuthFlowInput {
48
58
  * @param input.oidcClientService - Service used to create the OAuth client whose credentials drive the flow.
49
59
  * @param input.nestApp - Initialized NestJS application; used to resolve {@link OidcAccountService} for project-id-derived ID tokens and default scopes.
50
60
  * @param input.uid - Firebase user ID for whom the test ID token is minted and the OAuth flow is authorized.
51
- * @param input.config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method).
61
+ * @param input.config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method, provider profiles).
52
62
  * @returns The exchanged access token and ID token from the OIDC `/token` endpoint.
53
63
  * @throws {Error} When the token exchange step fails (the response body and status are included in the message).
54
64
  */
@@ -61,7 +71,7 @@ export declare function performFullOAuthFlow(input: PerformFullOAuthFlowInput):
61
71
  *
62
72
  * @param nestApp - Initialized NestJS application from which {@link JwksService} and {@link OidcClientService} are resolved.
63
73
  * @param uid - Firebase user ID for whom the OAuth flow is authorized.
64
- * @param config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method).
74
+ * @param config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method, provider profiles).
65
75
  * @returns The exchanged access token and ID token from {@link performFullOAuthFlow}.
66
76
  */
67
77
  export declare function setupAndPerformFullOAuthFlow(nestApp: INestApplication, uid: string, config?: OAuthTestFlowConfig): Promise<PerformFullOAuthFlowResult>;
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server/twilio",
3
- "version": "13.30.0",
3
+ "version": "13.32.0",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.30.0",
6
- "@dereekb/firebase": "13.30.0",
7
- "@dereekb/firebase-server": "13.30.0",
8
- "@dereekb/model": "13.30.0",
9
- "@dereekb/nestjs": "13.30.0",
10
- "@dereekb/rxjs": "13.30.0",
11
- "@dereekb/util": "13.30.0"
5
+ "@dereekb/date": "13.32.0",
6
+ "@dereekb/firebase": "13.32.0",
7
+ "@dereekb/firebase-server": "13.32.0",
8
+ "@dereekb/model": "13.32.0",
9
+ "@dereekb/nestjs": "13.32.0",
10
+ "@dereekb/rxjs": "13.32.0",
11
+ "@dereekb/util": "13.32.0"
12
12
  },
13
13
  "exports": {
14
14
  "./package.json": "./package.json",