@dereekb/firebase-server 13.10.9 → 13.11.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase-server",
3
- "version": "13.10.9",
3
+ "version": "13.11.1",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  "./test": {
@@ -44,15 +44,15 @@
44
44
  "main": "./index.cjs.js",
45
45
  "types": "./src/index.d.ts",
46
46
  "peerDependencies": {
47
- "@dereekb/analytics": "13.10.9",
48
- "@dereekb/date": "13.10.9",
49
- "@dereekb/dbx-core": "13.10.9",
50
- "@dereekb/firebase": "13.10.9",
51
- "@dereekb/model": "13.10.9",
52
- "@dereekb/nestjs": "13.10.9",
53
- "@dereekb/rxjs": "13.10.9",
54
- "@dereekb/util": "13.10.9",
55
- "@dereekb/zoho": "13.10.9",
47
+ "@dereekb/analytics": "13.11.1",
48
+ "@dereekb/date": "13.11.1",
49
+ "@dereekb/dbx-core": "13.11.1",
50
+ "@dereekb/firebase": "13.11.1",
51
+ "@dereekb/model": "13.11.1",
52
+ "@dereekb/nestjs": "13.11.1",
53
+ "@dereekb/rxjs": "13.11.1",
54
+ "@dereekb/util": "13.11.1",
55
+ "@dereekb/zoho": "13.11.1",
56
56
  "@google-cloud/firestore": "^7.11.6",
57
57
  "@google-cloud/storage": "^7.19.0",
58
58
  "@nestjs/common": "^11.1.19",
@@ -2,6 +2,7 @@ export * from './analytics.details';
2
2
  export * from './analytics.emit';
3
3
  export * from './analytics.handler';
4
4
  export * from './api.details';
5
+ export * from './crud.assert.function';
5
6
  export * from './permission.error';
6
7
  export * from './specifier.function';
7
8
  export * from './call.model.function';
package/test/index.cjs.js CHANGED
@@ -337,6 +337,9 @@ function _ts_generator$a(thisArg, body) {
337
337
  * where non-JSON-safe values (e.g., `Date` instances, `undefined` fields) are stripped
338
338
  * or transformed. Used internally by {@link AuthorizedUserTestContextInstance.callWrappedFunction}
339
339
  * to ensure test params match real-world serialization behavior.
340
+ *
341
+ * @param object - Arbitrary value to round-trip through `JSON.stringify` then `JSON.parse`.
342
+ * @returns The input value after a JSON serialize/parse cycle, with any non-JSON-safe fields stripped.
340
343
  */ function convertParamsToParsedJsonObjectAndBack(object) {
341
344
  var paramsAsJson = JSON.parse(JSON.stringify(object));
342
345
  return paramsAsJson;
@@ -420,9 +423,10 @@ function _ts_generator$a(thisArg, body) {
420
423
  /**
421
424
  * Calls a wrapped function with the input params and the context from makeContextOptions().
422
425
  *
423
- * @param fn
424
- * @param params
425
- * @param skipJsonConversion
426
+ * @param fn - Wrapped gen 2 callable request to invoke.
427
+ * @param params - Request payload to pass to the callable, simulating the JSON body of an HTTP call.
428
+ * @param skipJsonConversion - When `true`, skip the JSON serialize/parse round-trip applied to `params` (default `false`).
429
+ * @returns A promise resolving to the callable's return value.
426
430
  */ key: "callWrappedFunction",
427
431
  value: function callWrappedFunction(fn, params, skipJsonConversion) {
428
432
  // Parse to JSON then back to simulate sending JSON to the server, and the server parsing it as a POJO.
@@ -449,15 +453,19 @@ function _ts_generator$a(thisArg, body) {
449
453
  /**
450
454
  * Calls a wrapped gen 2 auth blocking function with the input params and context options from makeContextOptions().
451
455
  *
452
- * @param fn
453
- * @param userRecord
454
- * @param eventType
455
- * @param eventOverride
456
- * @param skipJsonConversion
457
- * @returns
456
+ * Synthesizes a minimal {@link AuthBlockingEvent} (filling in placeholder ip/user-agent/resource fields)
457
+ * from the supplied user record and event type, then dispatches it to the wrapped function.
458
+ *
459
+ * @param input - Options bag describing the blocking function invocation.
460
+ * @param input.fn - Wrapped gen 2 auth blocking function (e.g., from `beforeUserCreated`/`beforeUserSignedIn`) to invoke.
461
+ * @param input.userRecord - The Firebase Auth {@link UserRecord} that will be attached to the synthesized event's `data` field.
462
+ * @param input.eventType - Discriminator for the auth event being simulated (`google.firebase.auth.user.create` or `google.firebase.auth.user.delete`).
463
+ * @param input.eventOverride - Partial event fields used to override the default placeholder values (e.g., `ipAddress`, `userAgent`, `resource`).
464
+ * @param input.skipJsonConversion - When `true`, skip the JSON serialize/parse round-trip applied to the event payload (default `false`).
465
+ * @returns A promise that resolves once the blocking function has completed.
458
466
  */ key: "callAuthBlockingFunction",
459
- value: function callAuthBlockingFunction(fn, userRecord, eventType, eventOverride) {
460
- var skipJsonConversion = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
467
+ value: function callAuthBlockingFunction(input) {
468
+ 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;
461
469
  var timestamp = new Date().toISOString();
462
470
  var event = _object_spread_props$3(_object_spread$5({
463
471
  ipAddress: '127.0.0.1',
@@ -485,7 +493,8 @@ function _ts_generator$a(thisArg, body) {
485
493
  * @param contextOptions
486
494
  * @param skipJsonConversion
487
495
  * @returns
488
- */ key: "callEventCloudFunction",
496
+ */ // eslint-disable-next-line @typescript-eslint/max-params -- deprecated gen 1 signature kept for downstream compatibility
497
+ key: "callEventCloudFunction",
489
498
  value: function callEventCloudFunction(fn, params, contextOptions) {
490
499
  var skipJsonConversion = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
491
500
  var parsedParams = params == null || skipJsonConversion ? params : convertParamsToParsedJsonObjectAndBack(params);
@@ -499,6 +508,9 @@ function _ts_generator$a(thisArg, body) {
499
508
  }();
500
509
  /**
501
510
  * Convenience function for using authorizedUserContextFactory directly and passing buildTests.
511
+ *
512
+ * @param config - Test context parameters (parent fixture, optional uid/template, custom factories) used to create the authorized user context.
513
+ * @param buildTests - Callback invoked with the built {@link AuthorizedUserTestContextFixture}; should register `it(...)`/`describe(...)` blocks against it.
502
514
  */ function authorizedUserContext(config, buildTests) {
503
515
  authorizedUserContextFactory(config)({
504
516
  f: config.f
@@ -518,6 +530,13 @@ function _ts_generator$a(thisArg, body) {
518
530
  */ var AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY = util.randomPhoneNumberFactory();
519
531
  /**
520
532
  * Creates a new Jest Context that has a random user for authorization for use in firebase server tests.
533
+ *
534
+ * The returned function, when called with runtime params and a `buildTests` callback, registers the
535
+ * `beforeEach`/`afterEach` lifecycle hooks that create the test user (with optional contact info,
536
+ * custom claims, and post-create initialization) and tear it down afterward.
537
+ *
538
+ * @param config - Factory configuration: optional uid generator, custom fixture/instance constructors, user-detail builder, and `initUser` hook.
539
+ * @returns A function that, given runtime params and a `buildTests` callback, wires the authorized-user fixture into the active test context.
521
540
  */ function authorizedUserContextFactory(config) {
522
541
  var uidGetter = config.uid, _config_makeInstance = config.makeInstance, makeInstance = _config_makeInstance === void 0 ? function(uid, testInstance) {
523
542
  return new AuthorizedUserTestContextInstance(uid, testInstance);
@@ -752,6 +771,9 @@ function _ts_generator$a(thisArg, body) {
752
771
  * in the JWT payload. This function flattens those claims onto the top-level decoded token to match
753
772
  * the structure of a real `DecodedIdToken`, and injects `auth_time` from the `iat` field.
754
773
  *
774
+ * @param token - Encoded JWT string produced by {@link createEncodedTestFirestoreTokenForUserRecord}.
775
+ * @returns A {@link DecodedIdToken}-shaped object with custom claims hoisted to the top level and `claims` removed.
776
+ *
755
777
  * @see {@link createEncodedTestFirestoreTokenForUserRecord} for creating the encoded token
756
778
  */ function decodeEncodedCreateCustomTokenResult(token) {
757
779
  var _ref;
@@ -771,6 +793,9 @@ function _ts_generator$a(thisArg, body) {
771
793
  * custom claims already set on the user record. The resulting object is used as the
772
794
  * custom claims parameter for `Auth.createCustomToken()` in test token generation.
773
795
  *
796
+ * @param userRecord - Firebase Auth user record whose identity fields and existing custom claims should be folded into the returned claims.
797
+ * @returns A plain claims object suitable for passing to `Auth.createCustomToken()` in tests.
798
+ *
774
799
  * @see {@link createEncodedTestFirestoreTokenForUserRecord}
775
800
  */ function testFirestoreClaimsFromUserRecord(userRecord) {
776
801
  var _userRecord_emailVerified;
@@ -1121,6 +1146,9 @@ function _ts_generator$9(thisArg, body) {
1121
1146
  * hooks that create a new document (or wrap an existing one via {@link ModelTestContextDocumentRefParams}),
1122
1147
  * build the test context instance, optionally initialize the document, and clean up after each test.
1123
1148
  *
1149
+ * @param config - Factory configuration that resolves the collection, optionally produces document refs, builds fixtures/instances, and tears down state.
1150
+ * @returns A function that, given runtime params and a `buildTests` callback, registers the model fixture hooks against the active test context.
1151
+ *
1124
1152
  * @see {@link ModelTestContextFactoryParams} for configuration options
1125
1153
  */ function modelTestContextFactory(config) {
1126
1154
  var getCollection = config.getCollection, collectionForDocument = config.collectionForDocument, _config_makeRef = config.makeRef, makeRef = _config_makeRef === void 0 ? function(collection) {
@@ -1218,6 +1246,8 @@ var adminEnvironmentInitialized = false;
1218
1246
  *
1219
1247
  * Useful for guarding against double-initialization or verifying that setup has completed
1220
1248
  * before creating test contexts.
1249
+ *
1250
+ * @returns `true` once {@link initFirebaseAdminTestEnvironment} has run successfully; otherwise `false`.
1221
1251
  */ function isAdminEnvironmentInitialized() {
1222
1252
  return adminEnvironmentInitialized;
1223
1253
  }
@@ -1227,6 +1257,8 @@ var adminEnvironmentInitialized = false;
1227
1257
  * The generated ID has the format `firebase-test-<epoch-millis>`, ensuring each test run
1228
1258
  * operates against an isolated project namespace in the emulators.
1229
1259
  *
1260
+ * @returns A new project ID string of the form `firebase-test-<epoch-millis>`.
1261
+ *
1230
1262
  * @example
1231
1263
  * ```ts
1232
1264
  * const projectId = generateNewProjectId();
@@ -1254,6 +1286,8 @@ var adminEnvironmentInitialized = false;
1254
1286
  * Reads the current `GCLOUD_PROJECT` environment variable.
1255
1287
  *
1256
1288
  * This is the "active" project ID that the Firebase Admin SDK resolves at runtime.
1289
+ *
1290
+ * @returns The current value of `process.env.GCLOUD_PROJECT`, or `undefined` when unset.
1257
1291
  */ function getGCloudProjectId() {
1258
1292
  return process.env.GCLOUD_PROJECT;
1259
1293
  }
@@ -1263,6 +1297,8 @@ var adminEnvironmentInitialized = false;
1263
1297
  * This holds the canonical test project ID set during {@link rollNewGCloudProjectEnvironmentVariable},
1264
1298
  * and is used by {@link applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv} as the source of truth
1265
1299
  * when re-applying the project ID after external libraries overwrite `FIREBASE_CONFIG`.
1300
+ *
1301
+ * @returns The current value of `process.env.GCLOUD_TEST_PROJECT`, or `undefined` when unset.
1266
1302
  */ function getGCloudTestProjectId() {
1267
1303
  return process.env.GCLOUD_TEST_PROJECT;
1268
1304
  }
@@ -1271,6 +1307,9 @@ var adminEnvironmentInitialized = false;
1271
1307
  *
1272
1308
  * This is done as some external testing libraries (firebase-functions-test) will overwrite but we want to enforce using our project id
1273
1309
  * so that each component can also
1310
+ *
1311
+ * @returns The test project ID that was re-applied to `FIREBASE_CONFIG`/`GCLOUD_PROJECT`.
1312
+ * @throws Error when no test project ID is present in the environment (i.e., {@link initFirebaseAdminTestEnvironment} has not been called).
1274
1313
  */ function applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv() {
1275
1314
  var _process_env_FIREBASE_CONFIG;
1276
1315
  // firebase-functions-test overwrites this each time.
@@ -1288,6 +1327,8 @@ var adminEnvironmentInitialized = false;
1288
1327
  }
1289
1328
  /**
1290
1329
  * Should be called before calling/using adminFirebaseTestBuilder(). This should only be called once.
1330
+ *
1331
+ * @param config - Emulator host configuration; each emulator entry must be either a host string or `null` (any `undefined` non-null value will throw).
1291
1332
  */ function initFirebaseAdminTestEnvironment(config) {
1292
1333
  function crashForEmulator(emulator) {
1293
1334
  throw new Error("Emulator for ".concat(emulator, " was not set null or to a host. Crashing to prevent contamination."));
@@ -1504,6 +1545,7 @@ function _ts_generator$8(thisArg, body) {
1504
1545
  *
1505
1546
  * @param drivers - Testing-aware Firestore driver set to attach to the context.
1506
1547
  * @param firestore - The `@google-cloud/firestore` Firestore instance (typically pointed at an emulator).
1548
+ * @returns A {@link TestFirestoreContext} backed by the supplied Firestore client with `drivers` attached for test introspection.
1507
1549
  */ function makeGoogleFirestoreContext(drivers, firestore) {
1508
1550
  var context = firebase.firestoreContextFactory(drivers)(firestore);
1509
1551
  context.drivers = drivers;
@@ -1792,6 +1834,7 @@ function _ts_generator$7(thisArg, body) {
1792
1834
  * @param drivers - Testing-aware storage driver set to attach to the context.
1793
1835
  * @param firebaseStorage - The `@google-cloud/storage` Storage instance (typically pointed at an emulator).
1794
1836
  * @param defaultBucketId - Optional default bucket name; when provided, storage operations that omit a bucket will use this.
1837
+ * @returns A {@link TestFirebaseStorageContext} backed by the supplied storage client with `drivers` attached for test introspection.
1795
1838
  */ function makeGoogleFirebaseStorageContext(drivers, firebaseStorage, defaultBucketId) {
1796
1839
  var context = firebase.firebaseStorageContextFactory(drivers)(firebaseStorage, {
1797
1840
  defaultBucketId: defaultBucketId
@@ -2617,6 +2660,9 @@ function _ts_generator$5(thisArg, body) {
2617
2660
  * callable requests, and blocking functions for use in integration tests. Each method delegates
2618
2661
  * to the underlying `FeaturesList.wrap()` with appropriate type coercion.
2619
2662
  *
2663
+ * @param instance - The initialized `firebase-functions-test` features list whose `wrap()` is delegated to.
2664
+ * @returns A wrapper object exposing typed `wrap*` helpers for gen 1, gen 2, callable, and blocking functions.
2665
+ *
2620
2666
  * @example
2621
2667
  * ```ts
2622
2668
  * const testEnv = functionsTest();
@@ -2682,6 +2728,10 @@ function _ts_generator$5(thisArg, body) {
2682
2728
  * The returned getter re-wraps on every invocation, so it always reflects the latest function
2683
2729
  * reference from the provided getter — useful when the function under test is re-created between tests.
2684
2730
  *
2731
+ * @param wrapper - The cloud function wrapper providing gen 1 wrap support.
2732
+ * @param getter - Lazy accessor for the gen 1 cloud function under test; re-evaluated on every getter call.
2733
+ * @returns A getter that, when invoked, returns a freshly wrapped gen 1 cloud function ready for invocation in tests.
2734
+ *
2685
2735
  * @example
2686
2736
  * ```ts
2687
2737
  * const getWrapped = wrapCloudFunctionV1ForTests(wrapper, () => myV1Function);
@@ -2700,6 +2750,10 @@ function _ts_generator$5(thisArg, body) {
2700
2750
  * The wrapped callable accepts raw data and {@link CallableContextOptions} (e.g., auth context),
2701
2751
  * simulating an incoming HTTP callable request without needing a running server.
2702
2752
  *
2753
+ * @param wrapper - The cloud function wrapper providing the `wrapCallableRequest` accessor.
2754
+ * @param getter - Lazy accessor for the {@link CallableHttpFunction} under test; re-evaluated on every getter call.
2755
+ * @returns A getter that, when invoked, returns a freshly wrapped callable that accepts raw `data` and {@link CallableContextOptions}.
2756
+ *
2703
2757
  * @example
2704
2758
  * ```ts
2705
2759
  * const getWrapped = wrapCallableRequestForTests(wrapper, () => myCallable);
@@ -3123,6 +3177,8 @@ var functionsInitialized = false;
3123
3177
  * Globally sets whether new {@link FirebaseAdminFunctionTestConfig} instances default to
3124
3178
  * singleton mode. Primarily used in global test setup files.
3125
3179
  *
3180
+ * @param use - When `true`, new function-test configs reuse the firebase-functions-test singleton; when `false`, each suite gets its own instance.
3181
+ *
3126
3182
  * @example
3127
3183
  * ```ts
3128
3184
  * // in jest globalSetup
@@ -3835,6 +3891,9 @@ function _ts_generator$3(thisArg, body) {
3835
3891
  * {@link firebaseAdminTestContextFactory}. This is the simplest way to get a
3836
3892
  * fully configured Firebase Admin + NestJS test context.
3837
3893
  *
3894
+ * @param config - NestJS module + provider configuration plus optional fixture/instance overrides.
3895
+ * @returns A {@link FirebaseAdminNestTestContextFactory} that produces a configured fixture for each test suite.
3896
+ *
3838
3897
  * @example
3839
3898
  * ```ts
3840
3899
  * const f = firebaseAdminNestContextFactory({
@@ -4079,6 +4138,7 @@ function _is_native_reflect_construct$2() {
4079
4138
  * @param config - NestJS module, provider, and fixture configuration.
4080
4139
  * @param f - The parent fixture that is already set up.
4081
4140
  * @param buildTests - Callback that receives the child fixture and registers test cases.
4141
+ * @returns Whatever {@link firebaseAdminNestContextWithFixture} returns after registering the merged child fixture (typically `void`).
4082
4142
  */ function firebaseAdminFunctionNestContextWithFixture(config, f, buildTests) {
4083
4143
  var mergedConfig = _object_spread({
4084
4144
  makeFixture: function makeFixture(parent) {
@@ -4095,6 +4155,9 @@ function _is_native_reflect_construct$2() {
4095
4155
  * default {@link firebaseAdminFunctionTestContextFactory}. This is the simplest entry point
4096
4156
  * for tests that need both NestJS module access and Cloud Function wrapping.
4097
4157
  *
4158
+ * @param config - NestJS module + provider configuration plus optional fixture/instance overrides.
4159
+ * @returns A {@link FirebaseAdminFunctionNestTestContextFactory} that produces a configured fixture for each test suite.
4160
+ *
4098
4161
  * @example
4099
4162
  * ```ts
4100
4163
  * const f = firebaseAdminFunctionNestContextFactory({
@@ -4120,6 +4183,9 @@ var CallableRequestTestMultipleFixtureSuffix = 'WrappedFn';
4120
4183
  /**
4121
4184
  * Type guard that distinguishes a {@link CallableRequestTestSingleConfig} from a
4122
4185
  * {@link CallableRequestTestMultipleConfig} by checking for the presence of the `fn` property.
4186
+ *
4187
+ * @param config - Either a single-function or multiple-function callable test config to inspect.
4188
+ * @returns `true` when `config` carries a single `fn` (single-config variant); `false` when it carries `fns` (map variant).
4123
4189
  */ function isCallableRequestTestSingleConfig(config) {
4124
4190
  return Boolean(config.fn);
4125
4191
  }
@@ -4156,6 +4222,9 @@ function describeCallableRequestTest(label, config, buildTests) {
4156
4222
  /**
4157
4223
  * Type guard that distinguishes a {@link CloudFunctionTestSingleConfig} from a
4158
4224
  * {@link CloudFunctionTestMultipleConfig} by checking for the presence of the `fn` property.
4225
+ *
4226
+ * @param config - Either a single-function or multiple-function cloud function test config to inspect.
4227
+ * @returns `true` when `config` carries a single `fn` (single-config variant); `false` when it carries `fns` (map variant).
4159
4228
  */ function isCloudFunctionTestSingleConfig(config) {
4160
4229
  return Boolean(config.fn);
4161
4230
  }
@@ -4501,8 +4570,8 @@ function _is_native_reflect_construct$1() {
4501
4570
  * Throws a ExpectedErrorOfSpecificTypeError if the input is not a HttpsError.
4502
4571
  * Throws a ExpectedHttpErrorWithSpecificServerErrorCode if the input's server error data has a different error code.
4503
4572
  *
4504
- * @param expectedType
4505
- * @returns
4573
+ * @param expectedCode - The server error code (from the {@link ServerError} carried in `HttpsError.details`) that the caught error must match.
4574
+ * @returns An assertion function suitable for use with `ExpectFailAssertionFunction` that verifies both the error type and its server error code.
4506
4575
  */ function expectFailAssertHttpErrorServerErrorCode(expectedCode) {
4507
4576
  return function(error) {
4508
4577
  if (_instanceof(error, https.HttpsError)) {
@@ -4737,6 +4806,10 @@ function _ts_generator$1(thisArg, body) {
4737
4806
  *
4738
4807
  * The Auth emulator accepts unsigned JWTs (alg: "none") as long as the audience
4739
4808
  * matches the project ID the Admin SDK was initialized with.
4809
+ *
4810
+ * @param nestApp - Initialized NestJS application used to resolve {@link OidcAccountService} for the project ID.
4811
+ * @param uid - Firebase user ID to embed in the token's `sub`/`user_id` claims.
4812
+ * @returns An unsigned JWT (`alg: "none"`) string suitable for use against the Firebase Auth emulator.
4740
4813
  */ function createTestIdToken(nestApp, uid) {
4741
4814
  return _async_to_generator$1(function() {
4742
4815
  var accountService, projectId, now, payload, header, body;
@@ -4771,6 +4844,9 @@ function _ts_generator$1(thisArg, body) {
4771
4844
  }
4772
4845
  /**
4773
4846
  * Extracts the interaction UID from a redirect to the login/consent frontend URL.
4847
+ *
4848
+ * @param res - Supertest response whose `Location` header points at the login/consent frontend, with `?uid=...` carrying the interaction UID.
4849
+ * @returns The `uid` query parameter from the redirect URL (the interaction identifier issued by `oidc-provider`).
4774
4850
  */ function extractInteractionUid(res) {
4775
4851
  var location = res.headers['location'];
4776
4852
  var url = location.startsWith('/') ? new URL(location, 'http://localhost') : new URL(location);
@@ -4781,6 +4857,8 @@ function _ts_generator$1(thisArg, body) {
4781
4857
  *
4782
4858
  * oidc-provider scopes cookies to specific paths, so supertest.agent()
4783
4859
  * won't forward them between /oidc/* and /interaction/* controllers.
4860
+ *
4861
+ * @returns A pair of helpers — `collectCookies(res)` to absorb `Set-Cookie` headers from a response, and `cookieHeader()` to produce a combined `Cookie` header string for subsequent requests.
4784
4862
  */ function createCookieJar() {
4785
4863
  var cookieJar = new Map();
4786
4864
  function collectCookies(res) {
@@ -4824,6 +4902,10 @@ function _ts_generator$1(thisArg, body) {
4824
4902
  /**
4825
4903
  * Resolves the scopes string from config, or falls back to all registered scopes
4826
4904
  * from `OidcAccountService.allRegisteredScopes`.
4905
+ *
4906
+ * @param nestApp - Initialized NestJS application used to resolve {@link OidcAccountService} when no scopes override is given.
4907
+ * @param config - Optional flow config; when `config.scopes` is set, it is returned verbatim.
4908
+ * @returns The space-separated scope string to pass to the `/oidc/auth` endpoint.
4827
4909
  */ function resolveScopes(nestApp, config) {
4828
4910
  return _async_to_generator$1(function() {
4829
4911
  var accountService;
@@ -4842,17 +4924,26 @@ function _ts_generator$1(thisArg, body) {
4842
4924
  });
4843
4925
  })();
4844
4926
  }
4845
- // MARK: Flow
4846
4927
  /**
4847
4928
  * Performs the full OAuth authorization code flow with PKCE and returns tokens.
4848
4929
  *
4849
4930
  * Steps: create client → PKCE → auth redirect → login → consent → code exchange → token
4850
- */ function performFullOAuthFlow(server, oidcClientService, nestApp, uid, config) {
4931
+ *
4932
+ * @param input - Bag of services and overrides needed to drive the flow end-to-end.
4933
+ * @param input.server - HTTP server returned by `nestApp.getHttpServer()` against which all supertest requests are issued.
4934
+ * @param input.oidcClientService - Service used to create the OAuth client whose credentials drive the flow.
4935
+ * @param input.nestApp - Initialized NestJS application; used to resolve {@link OidcAccountService} for project-id-derived ID tokens and default scopes.
4936
+ * @param input.uid - Firebase user ID for whom the test ID token is minted and the OAuth flow is authorized.
4937
+ * @param input.config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method).
4938
+ * @returns The exchanged access token and ID token from the OIDC `/token` endpoint.
4939
+ * @throws Error when the token exchange step fails (the response body and status are included in the message).
4940
+ */ function performFullOAuthFlow(input) {
4851
4941
  return _async_to_generator$1(function() {
4852
- var _ref, _ref1, _ref2, _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;
4942
+ 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;
4853
4943
  return _ts_generator$1(this, function(_state) {
4854
4944
  switch(_state.label){
4855
4945
  case 0:
4946
+ server = input.server, oidcClientService = input.oidcClientService, nestApp = input.nestApp, uid = input.uid, config = input.config;
4856
4947
  _createCookieJar = createCookieJar(), collectCookies = _createCookieJar.collectCookies, cookieHeader = _createCookieJar.cookieHeader;
4857
4948
  redirectUri = (_ref = config === null || config === void 0 ? void 0 : config.redirectUri) !== null && _ref !== void 0 ? _ref : 'https://example.com/callback';
4858
4949
  clientName = (_ref1 = config === null || config === void 0 ? void 0 : config.clientName) !== null && _ref1 !== void 0 ? _ref1 : 'test-oauth-context';
@@ -4971,6 +5062,11 @@ function _ts_generator$1(thisArg, body) {
4971
5062
  * rotates JWKS keys, and then performs the full OAuth flow.
4972
5063
  *
4973
5064
  * This avoids callers needing to import from `@dereekb/firebase-server/oidc` directly.
5065
+ *
5066
+ * @param nestApp - Initialized NestJS application from which {@link JwksService} and {@link OidcClientService} are resolved.
5067
+ * @param uid - Firebase user ID for whom the OAuth flow is authorized.
5068
+ * @param config - Optional flow overrides (scopes, redirect URI, client name, token endpoint auth method).
5069
+ * @returns The exchanged access token and ID token from {@link performFullOAuthFlow}.
4974
5070
  */ function setupAndPerformFullOAuthFlow(nestApp, uid, config) {
4975
5071
  return _async_to_generator$1(function() {
4976
5072
  var jwksService, oidcClientService, server;
@@ -4990,7 +5086,13 @@ function _ts_generator$1(thisArg, body) {
4990
5086
  server = nestApp.getHttpServer();
4991
5087
  return [
4992
5088
  2,
4993
- performFullOAuthFlow(server, oidcClientService, nestApp, uid, config)
5089
+ performFullOAuthFlow({
5090
+ server: server,
5091
+ oidcClientService: oidcClientService,
5092
+ nestApp: nestApp,
5093
+ uid: uid,
5094
+ config: config
5095
+ })
4994
5096
  ];
4995
5097
  }
4996
5098
  });
@@ -5262,6 +5364,9 @@ function _ts_generator(thisArg, body) {
5262
5364
  /**
5263
5365
  * Apply Bearer auth to a supertest request.
5264
5366
  *
5367
+ * @param test - An existing supertest request (e.g., `request(server).get(...)`) that should be authorized with this instance's access token.
5368
+ * @returns The same supertest request with an `Authorization: Bearer <accessToken>` header applied for chaining.
5369
+ *
5265
5370
  * @example
5266
5371
  * ```typescript
5267
5372
  * await oauth.withAuth(request(oauth.server).get('/oidc/me')).expect(200);
@@ -5276,6 +5381,10 @@ function _ts_generator(thisArg, body) {
5276
5381
  /**
5277
5382
  * Shorthand: create a supertest request with auth already applied.
5278
5383
  *
5384
+ * @param method - HTTP verb to use for the supertest request (`get`, `post`, `put`, `patch`, or `delete`).
5385
+ * @param path - The URL path on the wrapped server to issue the request against.
5386
+ * @returns A supertest request pointed at `path` and pre-authorized with this instance's `Bearer` access token.
5387
+ *
5279
5388
  * @example
5280
5389
  * ```typescript
5281
5390
  * await oauth.authRequest('get', '/oidc/me').expect(200);
@@ -5315,6 +5424,9 @@ function _ts_generator(thisArg, body) {
5315
5424
  /**
5316
5425
  * Apply Bearer auth to a supertest request.
5317
5426
  *
5427
+ * @param test - An existing supertest request (e.g., `request(server).get(...)`) that should be authorized with the underlying instance's access token.
5428
+ * @returns The same supertest request with an `Authorization: Bearer <accessToken>` header applied for chaining.
5429
+ *
5318
5430
  * @example
5319
5431
  * ```typescript
5320
5432
  * await oauth.withAuth(request(oauth.server).get('/oidc/me')).expect(200);
@@ -5328,6 +5440,10 @@ function _ts_generator(thisArg, body) {
5328
5440
  /**
5329
5441
  * Shorthand: create a supertest request with auth already applied.
5330
5442
  *
5443
+ * @param method - HTTP verb to use for the supertest request (`get`, `post`, `put`, `patch`, or `delete`).
5444
+ * @param path - The URL path on the wrapped server to issue the request against.
5445
+ * @returns A supertest request pointed at `path` and pre-authorized with the underlying instance's `Bearer` access token.
5446
+ *
5331
5447
  * @example
5332
5448
  * ```typescript
5333
5449
  * await oauth.authRequest('get', '/oidc/me').expect(200);
@@ -5354,6 +5470,9 @@ function _ts_generator(thisArg, body) {
5354
5470
  * The returned factory function performs a full OAuth authorization code flow
5355
5471
  * and provides an authenticated supertest agent and helper methods.
5356
5472
  *
5473
+ * @param config - Optional flow overrides (scopes, redirect URI, client name, timeout) and custom fixture/instance constructors.
5474
+ * @returns A 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.
5475
+ *
5357
5476
  * @example
5358
5477
  * ```typescript
5359
5478
  * // In shared test setup (e.g. fixture.oidc.ts)