@dereekb/firebase-server 13.7.0 → 13.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -432,7 +432,7 @@ function _type_of$7(obj) {
432
432
  };
433
433
  }
434
434
 
435
- function asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, key, arg) {
435
+ function asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, key, arg) {
436
436
  try {
437
437
  var info = gen[key](arg);
438
438
  var value = info.value;
@@ -446,22 +446,22 @@ function asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, key, arg) {
446
446
  Promise.resolve(value).then(_next, _throw);
447
447
  }
448
448
  }
449
- function _async_to_generator$g(fn) {
449
+ function _async_to_generator$h(fn) {
450
450
  return function() {
451
451
  var self = this, args = arguments;
452
452
  return new Promise(function(resolve, reject) {
453
453
  var gen = fn.apply(self, args);
454
454
  function _next(value) {
455
- asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, "next", value);
455
+ asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, "next", value);
456
456
  }
457
457
  function _throw(err) {
458
- asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, "throw", err);
458
+ asyncGeneratorStep$h(gen, resolve, reject, _next, _throw, "throw", err);
459
459
  }
460
460
  _next(undefined);
461
461
  });
462
462
  };
463
463
  }
464
- function _ts_generator$g(thisArg, body) {
464
+ function _ts_generator$h(thisArg, body) {
465
465
  var f, y, t, _ = {
466
466
  label: 0,
467
467
  sent: function() {
@@ -577,9 +577,9 @@ function _ts_generator$g(thisArg, body) {
577
577
  * }
578
578
  * ```
579
579
  */ function getAuthUserOrUndefined(promise) {
580
- return _async_to_generator$g(function() {
580
+ return _async_to_generator$h(function() {
581
581
  var error;
582
- return _ts_generator$g(this, function(_state) {
582
+ return _ts_generator$h(this, function(_state) {
583
583
  switch(_state.label){
584
584
  case 0:
585
585
  _state.trys.push([
@@ -604,9 +604,8 @@ function _ts_generator$g(thisArg, body) {
604
604
  2,
605
605
  undefined
606
606
  ];
607
- } else {
608
- throw error;
609
607
  }
608
+ throw error;
610
609
  case 3:
611
610
  return [
612
611
  2
@@ -784,6 +783,62 @@ function _is_native_reflect_construct$5() {
784
783
  ]);
785
784
  }
786
785
  return FirebaseServerAuthNewUserSendSetupDetailsSendOnceError;
786
+ }(makeError.BaseError);
787
+ // MARK: Password Reset Errors
788
+ /**
789
+ * Thrown by {@link AbstractFirebaseServerUserPasswordResetService.sendResetContent} when the user
790
+ * has no active password reset claims, meaning no reset has been initiated or it has already been completed.
791
+ */ var FirebaseServerAuthPasswordResetNoResetConfigError = /*#__PURE__*/ function(BaseError) {
792
+ _inherits$5(FirebaseServerAuthPasswordResetNoResetConfigError, BaseError);
793
+ function FirebaseServerAuthPasswordResetNoResetConfigError() {
794
+ _class_call_check$r(this, FirebaseServerAuthPasswordResetNoResetConfigError);
795
+ return _call_super$5(this, FirebaseServerAuthPasswordResetNoResetConfigError, [
796
+ "This user has no active password reset configuration."
797
+ ]);
798
+ }
799
+ return FirebaseServerAuthPasswordResetNoResetConfigError;
800
+ }(makeError.BaseError);
801
+ /**
802
+ * Thrown by {@link AbstractFirebaseServerUserPasswordResetService.sendResetContent} when the user
803
+ * was recently sent reset content and the throttle window has not elapsed.
804
+ */ var FirebaseServerAuthPasswordResetThrottleError = /*#__PURE__*/ function(BaseError) {
805
+ _inherits$5(FirebaseServerAuthPasswordResetThrottleError, BaseError);
806
+ function FirebaseServerAuthPasswordResetThrottleError(lastSentAt) {
807
+ _class_call_check$r(this, FirebaseServerAuthPasswordResetThrottleError);
808
+ var _this;
809
+ _this = _call_super$5(this, FirebaseServerAuthPasswordResetThrottleError, [
810
+ "This user was recently sent password reset details. Try again later."
811
+ ]), _define_property$y(_this, "lastSentAt", void 0);
812
+ _this.lastSentAt = lastSentAt;
813
+ return _this;
814
+ }
815
+ return FirebaseServerAuthPasswordResetThrottleError;
816
+ }(makeError.BaseError);
817
+ /**
818
+ * Thrown by {@link AbstractFirebaseServerUserPasswordResetService.sendResetContent} when the user
819
+ * has already been sent reset content and the `sendResetDetailsOnce` option was enabled.
820
+ */ var FirebaseServerAuthPasswordResetSendOnceError = /*#__PURE__*/ function(BaseError) {
821
+ _inherits$5(FirebaseServerAuthPasswordResetSendOnceError, BaseError);
822
+ function FirebaseServerAuthPasswordResetSendOnceError() {
823
+ _class_call_check$r(this, FirebaseServerAuthPasswordResetSendOnceError);
824
+ return _call_super$5(this, FirebaseServerAuthPasswordResetSendOnceError, [
825
+ "The user has been sent password reset details before and the sendResetDetailsOnce configuration was true."
826
+ ]);
827
+ }
828
+ return FirebaseServerAuthPasswordResetSendOnceError;
829
+ }(makeError.BaseError);
830
+ /**
831
+ * Thrown by {@link AbstractFirebaseServerUserPasswordResetService.completePasswordReset} when the
832
+ * provided reset code does not match the one stored in the user's claims, or no reset is active.
833
+ */ var FirebaseServerAuthPasswordResetInvalidCodeError = /*#__PURE__*/ function(BaseError) {
834
+ _inherits$5(FirebaseServerAuthPasswordResetInvalidCodeError, BaseError);
835
+ function FirebaseServerAuthPasswordResetInvalidCodeError() {
836
+ _class_call_check$r(this, FirebaseServerAuthPasswordResetInvalidCodeError);
837
+ return _call_super$5(this, FirebaseServerAuthPasswordResetInvalidCodeError, [
838
+ "The provided reset password code is invalid or expired."
839
+ ]);
840
+ }
841
+ return FirebaseServerAuthPasswordResetInvalidCodeError;
787
842
  }
788
843
  (makeError.BaseError);
789
844
 
@@ -804,7 +859,7 @@ function _assert_this_initialized$4(self) {
804
859
  }
805
860
  return self;
806
861
  }
807
- function asyncGeneratorStep$f(gen, resolve, reject, _next, _throw, key, arg) {
862
+ function asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, key, arg) {
808
863
  try {
809
864
  var info = gen[key](arg);
810
865
  var value = info.value;
@@ -818,16 +873,16 @@ function asyncGeneratorStep$f(gen, resolve, reject, _next, _throw, key, arg) {
818
873
  Promise.resolve(value).then(_next, _throw);
819
874
  }
820
875
  }
821
- function _async_to_generator$f(fn) {
876
+ function _async_to_generator$g(fn) {
822
877
  return function() {
823
878
  var self = this, args = arguments;
824
879
  return new Promise(function(resolve, reject) {
825
880
  var gen = fn.apply(self, args);
826
881
  function _next(value) {
827
- asyncGeneratorStep$f(gen, resolve, reject, _next, _throw, "next", value);
882
+ asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, "next", value);
828
883
  }
829
884
  function _throw(err) {
830
- asyncGeneratorStep$f(gen, resolve, reject, _next, _throw, "throw", err);
885
+ asyncGeneratorStep$g(gen, resolve, reject, _next, _throw, "throw", err);
831
886
  }
832
887
  _next(undefined);
833
888
  });
@@ -974,7 +1029,7 @@ function _is_native_reflect_construct$4() {
974
1029
  return !!result;
975
1030
  })();
976
1031
  }
977
- function _ts_generator$f(thisArg, body) {
1032
+ function _ts_generator$g(thisArg, body) {
978
1033
  var f, y, t, _ = {
979
1034
  label: 0,
980
1035
  sent: function() {
@@ -1131,8 +1186,8 @@ function _ts_generator$f(thisArg, body) {
1131
1186
  {
1132
1187
  key: "exists",
1133
1188
  value: function exists() {
1134
- return _async_to_generator$f(function() {
1135
- return _ts_generator$f(this, function(_state) {
1189
+ return _async_to_generator$g(function() {
1190
+ return _ts_generator$g(this, function(_state) {
1136
1191
  return [
1137
1192
  2,
1138
1193
  getAuthUserOrUndefined(this._loadRecord()).then(function(x) {
@@ -1171,9 +1226,9 @@ function _ts_generator$f(thisArg, body) {
1171
1226
  {
1172
1227
  key: "beginResetPassword",
1173
1228
  value: function beginResetPassword() {
1174
- return _async_to_generator$f(function() {
1229
+ return _async_to_generator$g(function() {
1175
1230
  var password, _obj, passwordClaimsData;
1176
- return _ts_generator$f(this, function(_state) {
1231
+ return _ts_generator$g(this, function(_state) {
1177
1232
  switch(_state.label){
1178
1233
  case 0:
1179
1234
  password = this._generateResetPasswordKey();
@@ -1206,9 +1261,9 @@ function _ts_generator$f(thisArg, body) {
1206
1261
  {
1207
1262
  key: "loadResetPasswordClaims",
1208
1263
  value: function loadResetPasswordClaims() {
1209
- return _async_to_generator$f(function() {
1264
+ return _async_to_generator$g(function() {
1210
1265
  var claims, result;
1211
- return _ts_generator$f(this, function(_state) {
1266
+ return _ts_generator$g(this, function(_state) {
1212
1267
  switch(_state.label){
1213
1268
  case 0:
1214
1269
  return [
@@ -1230,9 +1285,9 @@ function _ts_generator$f(thisArg, body) {
1230
1285
  {
1231
1286
  key: "setPassword",
1232
1287
  value: function setPassword(password) {
1233
- return _async_to_generator$f(function() {
1288
+ return _async_to_generator$g(function() {
1234
1289
  var record, _obj;
1235
- return _ts_generator$f(this, function(_state) {
1290
+ return _ts_generator$g(this, function(_state) {
1236
1291
  switch(_state.label){
1237
1292
  case 0:
1238
1293
  return [
@@ -1262,8 +1317,8 @@ function _ts_generator$f(thisArg, body) {
1262
1317
  {
1263
1318
  key: "updateUser",
1264
1319
  value: function updateUser(template) {
1265
- return _async_to_generator$f(function() {
1266
- return _ts_generator$f(this, function(_state) {
1320
+ return _async_to_generator$g(function() {
1321
+ return _ts_generator$g(this, function(_state) {
1267
1322
  return [
1268
1323
  2,
1269
1324
  this.service.auth.updateUser(this.uid, template)
@@ -1275,9 +1330,9 @@ function _ts_generator$f(thisArg, body) {
1275
1330
  {
1276
1331
  key: "loadRoles",
1277
1332
  value: function loadRoles() {
1278
- return _async_to_generator$f(function() {
1333
+ return _async_to_generator$g(function() {
1279
1334
  var claims;
1280
- return _ts_generator$f(this, function(_state) {
1335
+ return _ts_generator$g(this, function(_state) {
1281
1336
  switch(_state.label){
1282
1337
  case 0:
1283
1338
  return [
@@ -1298,9 +1353,9 @@ function _ts_generator$f(thisArg, body) {
1298
1353
  {
1299
1354
  key: "addRoles",
1300
1355
  value: function addRoles(roles) {
1301
- return _async_to_generator$f(function() {
1356
+ return _async_to_generator$g(function() {
1302
1357
  var claims;
1303
- return _ts_generator$f(this, function(_state) {
1358
+ return _ts_generator$g(this, function(_state) {
1304
1359
  claims = this._claimsForRolesChange(roles);
1305
1360
  return [
1306
1361
  2,
@@ -1313,9 +1368,9 @@ function _ts_generator$f(thisArg, body) {
1313
1368
  {
1314
1369
  key: "removeRoles",
1315
1370
  value: function removeRoles(roles) {
1316
- return _async_to_generator$f(function() {
1371
+ return _async_to_generator$g(function() {
1317
1372
  var baseClaims, claims;
1318
- return _ts_generator$f(this, function(_state) {
1373
+ return _ts_generator$g(this, function(_state) {
1319
1374
  baseClaims = this._claimsForRolesChange(roles);
1320
1375
  claims = {};
1321
1376
  util.forEachKeyValue(baseClaims, {
@@ -1351,9 +1406,9 @@ function _ts_generator$f(thisArg, body) {
1351
1406
  * await userCtx.setRoles([AUTH_ADMIN_ROLE], { customFlag: 1 });
1352
1407
  * ```
1353
1408
  */ function setRoles(roles, claimsToRetain) {
1354
- return _async_to_generator$f(function() {
1409
+ return _async_to_generator$g(function() {
1355
1410
  var claims;
1356
- return _ts_generator$f(this, function(_state) {
1411
+ return _ts_generator$g(this, function(_state) {
1357
1412
  claims = _object_spread$i({}, claimsToRetain, this._claimsForRolesChange(_to_consumable_array$a(roles)));
1358
1413
  return [
1359
1414
  2,
@@ -1387,9 +1442,9 @@ function _ts_generator$f(thisArg, body) {
1387
1442
  {
1388
1443
  key: "updateClaims",
1389
1444
  value: function updateClaims(claims) {
1390
- return _async_to_generator$f(function() {
1445
+ return _async_to_generator$g(function() {
1391
1446
  var currentClaims, newClaims;
1392
- return _ts_generator$f(this, function(_state) {
1447
+ return _ts_generator$g(this, function(_state) {
1393
1448
  switch(_state.label){
1394
1449
  case 0:
1395
1450
  return [
@@ -1574,9 +1629,9 @@ function _ts_generator$f(thisArg, body) {
1574
1629
  {
1575
1630
  key: "initializeNewUser",
1576
1631
  value: function initializeNewUser(input) {
1577
- return _async_to_generator$f(function() {
1632
+ return _async_to_generator$g(function() {
1578
1633
  var uid, email, phone, sendSetupContent, sendSetupContentIfUserExists, sendSetupDetailsOnce, sendSetupIgnoreThrottle, sendSetupThrowErrors, data, sendDetailsInTestEnvironment, userRecordPromise, userRecord, userRecordId, createdUser, createResult, userContext, sentEmail, userContext1;
1579
- return _ts_generator$f(this, function(_state) {
1634
+ return _ts_generator$g(this, function(_state) {
1580
1635
  switch(_state.label){
1581
1636
  case 0:
1582
1637
  uid = input.uid, email = input.email, phone = input.phone, sendSetupContent = input.sendSetupContent, sendSetupContentIfUserExists = input.sendSetupContentIfUserExists, sendSetupDetailsOnce = input.sendSetupDetailsOnce, sendSetupIgnoreThrottle = input.sendSetupIgnoreThrottle, sendSetupThrowErrors = input.sendSetupThrowErrors, data = input.data, sendDetailsInTestEnvironment = input.sendDetailsInTestEnvironment;
@@ -1671,9 +1726,9 @@ function _ts_generator$f(thisArg, body) {
1671
1726
  {
1672
1727
  key: "addNewUserSetupClaims",
1673
1728
  value: function addNewUserSetupClaims(userContextOrUid, setupPassword) {
1674
- return _async_to_generator$f(function() {
1729
+ return _async_to_generator$g(function() {
1675
1730
  var password, userContext;
1676
- return _ts_generator$f(this, function(_state) {
1731
+ return _ts_generator$g(this, function(_state) {
1677
1732
  switch(_state.label){
1678
1733
  case 0:
1679
1734
  password = setupPassword !== null && setupPassword !== void 0 ? setupPassword : this.generateRandomSetupPassword();
@@ -1696,9 +1751,9 @@ function _ts_generator$f(thisArg, body) {
1696
1751
  {
1697
1752
  key: "sendSetupContent",
1698
1753
  value: function sendSetupContent(userContextOrUid, config) {
1699
- return _async_to_generator$f(function() {
1754
+ return _async_to_generator$g(function() {
1700
1755
  var setupDetails, sentContent, setupCommunicationAt, hasSentCommunication, lastSentAt, sendIsThrottled;
1701
- return _ts_generator$f(this, function(_state) {
1756
+ return _ts_generator$g(this, function(_state) {
1702
1757
  switch(_state.label){
1703
1758
  case 0:
1704
1759
  return [
@@ -1779,9 +1834,9 @@ function _ts_generator$f(thisArg, body) {
1779
1834
  {
1780
1835
  key: "loadSetupDetails",
1781
1836
  value: function loadSetupDetails(userContextOrUid, config) {
1782
- return _async_to_generator$f(function() {
1837
+ return _async_to_generator$g(function() {
1783
1838
  var userContext, userExists, details;
1784
- return _ts_generator$f(this, function(_state) {
1839
+ return _ts_generator$g(this, function(_state) {
1785
1840
  switch(_state.label){
1786
1841
  case 0:
1787
1842
  userContext = userContextFromUid(this.authService, userContextOrUid);
@@ -1815,9 +1870,9 @@ function _ts_generator$f(thisArg, body) {
1815
1870
  {
1816
1871
  key: "loadSetupDetailsForUserContext",
1817
1872
  value: function loadSetupDetailsForUserContext(userContext, config) {
1818
- return _async_to_generator$f(function() {
1873
+ return _async_to_generator$g(function() {
1819
1874
  var details, _ref, setupPassword, setupCommunicationAt;
1820
- return _ts_generator$f(this, function(_state) {
1875
+ return _ts_generator$g(this, function(_state) {
1821
1876
  switch(_state.label){
1822
1877
  case 0:
1823
1878
  return [
@@ -1853,9 +1908,9 @@ function _ts_generator$f(thisArg, body) {
1853
1908
  *
1854
1909
  * @param details - The user's setup details containing the user context.
1855
1910
  */ function updateSetupContentSentTime(details) {
1856
- return _async_to_generator$f(function() {
1911
+ return _async_to_generator$g(function() {
1857
1912
  var setupCommunicationAt;
1858
- return _ts_generator$f(this, function(_state) {
1913
+ return _ts_generator$g(this, function(_state) {
1859
1914
  switch(_state.label){
1860
1915
  case 0:
1861
1916
  setupCommunicationAt = date.toISODateString(new Date());
@@ -1878,9 +1933,9 @@ function _ts_generator$f(thisArg, body) {
1878
1933
  {
1879
1934
  key: "markUserSetupAsComplete",
1880
1935
  value: function markUserSetupAsComplete(uid) {
1881
- return _async_to_generator$f(function() {
1936
+ return _async_to_generator$g(function() {
1882
1937
  var userContext, userExists;
1883
- return _ts_generator$f(this, function(_state) {
1938
+ return _ts_generator$g(this, function(_state) {
1884
1939
  switch(_state.label){
1885
1940
  case 0:
1886
1941
  userContext = this.authService.userContext(uid);
@@ -1922,9 +1977,9 @@ function _ts_generator$f(thisArg, body) {
1922
1977
  * @returns The created user record and the setup password used.
1923
1978
  * @throws Throws if the Firebase Admin SDK rejects the user creation.
1924
1979
  */ function createNewUser(input) {
1925
- return _async_to_generator$f(function() {
1980
+ return _async_to_generator$g(function() {
1926
1981
  var uid, displayName, email, phoneNumber, inputPassword, password, user, e, firebaseError, errorCode;
1927
- return _ts_generator$f(this, function(_state) {
1982
+ return _ts_generator$g(this, function(_state) {
1928
1983
  switch(_state.label){
1929
1984
  case 0:
1930
1985
  uid = input.uid, displayName = input.displayName, email = input.email, phoneNumber = input.phone, inputPassword = input.setupPassword;
@@ -1991,9 +2046,9 @@ function _ts_generator$f(thisArg, body) {
1991
2046
  *
1992
2047
  * @param userContext - The user context to clear setup claims from.
1993
2048
  */ function updateClaimsToClearUser(userContext) {
1994
- return _async_to_generator$f(function() {
2049
+ return _async_to_generator$g(function() {
1995
2050
  var _obj;
1996
- return _ts_generator$f(this, function(_state) {
2051
+ return _ts_generator$g(this, function(_state) {
1997
2052
  switch(_state.label){
1998
2053
  case 0:
1999
2054
  return [
@@ -2027,8 +2082,8 @@ function _ts_generator$f(thisArg, body) {
2027
2082
  {
2028
2083
  key: "sendSetupContentToUser",
2029
2084
  value: function sendSetupContentToUser(_details) {
2030
- return _async_to_generator$f(function() {
2031
- return _ts_generator$f(this, function(_state) {
2085
+ return _async_to_generator$g(function() {
2086
+ return _ts_generator$g(this, function(_state) {
2032
2087
  return [
2033
2088
  2
2034
2089
  ];
@@ -2041,111 +2096,460 @@ function _ts_generator$f(thisArg, body) {
2041
2096
  return NoSetupContentFirebaseServerNewUserService;
2042
2097
  }(AbstractFirebaseServerNewUserService);
2043
2098
  /**
2044
- * Abstract contract for a Firebase Server authentication service.
2045
- *
2046
- * Provides the core API for creating auth contexts from callable requests, managing user contexts,
2047
- * checking admin/ToS status, converting between roles and claims, and creating new users.
2048
- *
2049
- * Implement this by extending {@link AbstractFirebaseServerAuthService}, which provides default
2050
- * implementations for most methods and only requires `readRoles`, `claimsForRoles`,
2051
- * `userContext`, and `_context` to be defined.
2099
+ * Default throttle duration (1 hour) between reset content sends to prevent spam.
2052
2100
  *
2053
- * @example
2054
- * ```typescript
2055
- * class MyAuthService extends AbstractFirebaseServerAuthService<MyUserContext, MyAuthContext> {
2056
- * readRoles(claims: AuthClaims): AuthRoleSet { ... }
2057
- * claimsForRoles(roles: AuthRoleSet): AuthClaimsUpdate { ... }
2058
- * userContext(uid: string): MyUserContext { ... }
2059
- * protected _context(ctx: CallableContextWithAuthData): MyAuthContext { ... }
2060
- * }
2061
- * ```
2062
- */ var FirebaseServerAuthService = function FirebaseServerAuthService() {
2063
- _class_call_check$q(this, FirebaseServerAuthService);
2064
- };
2101
+ * Used by {@link AbstractFirebaseServerUserPasswordResetService.sendResetContent} to rate-limit delivery.
2102
+ */ var DEFAULT_RESET_COM_THROTTLE_TIME = date.hoursToMs(1);
2065
2103
  /**
2066
- * Base implementation of {@link FirebaseServerAuthService} providing standard admin/ToS checks,
2067
- * auth context creation with assertion, and a default no-op new user service.
2104
+ * Base implementation of {@link FirebaseServerUserPasswordResetService} that handles reset initiation,
2105
+ * claims management, throttled reset content delivery, and reset completion.
2068
2106
  *
2069
- * Subclasses must implement:
2070
- * - {@link _context} - to create the concrete auth context type.
2071
- * - {@link userContext} - to create the concrete user context type.
2072
- * - {@link readRoles} - to define the claims-to-roles mapping.
2073
- * - {@link claimsForRoles} - to define the roles-to-claims mapping.
2107
+ * Subclasses must implement {@link sendPasswordResetContentToUser} to define how reset content
2108
+ * (e.g., reset email, SMS) is delivered to the user.
2074
2109
  *
2075
2110
  * @example
2076
2111
  * ```typescript
2077
- * export class MyAuthService extends AbstractFirebaseServerAuthService<MyUserContext, MyAuthContext> {
2078
- * protected _context(context: CallableContextWithAuthData): MyAuthContext {
2079
- * return new MyAuthContext(this, context);
2080
- * }
2081
- * userContext(uid: string): MyUserContext {
2082
- * return new MyUserContext(this, uid);
2083
- * }
2084
- * readRoles(claims: AuthClaims): AuthRoleSet {
2085
- * return MY_CLAIMS_SERVICE.toRoles(claims);
2086
- * }
2087
- * claimsForRoles(roles: AuthRoleSet): AuthClaimsUpdate {
2088
- * return MY_CLAIMS_SERVICE.toClaims(roles);
2112
+ * export class MyPasswordResetService extends AbstractFirebaseServerUserPasswordResetService<MyUserContext> {
2113
+ * protected async sendPasswordResetContentToUser(details: FirebaseServerAuthPasswordResetDetails<MyUserContext>): Promise<void> {
2114
+ * await this.emailService.sendResetEmail(details.userContext.uid, details.claims.resetPassword);
2089
2115
  * }
2090
2116
  * }
2091
2117
  * ```
2092
- */ var AbstractFirebaseServerAuthService = /*#__PURE__*/ function() {
2093
- function AbstractFirebaseServerAuthService(auth) {
2094
- _class_call_check$q(this, AbstractFirebaseServerAuthService);
2095
- _define_property$x(this, "_auth", void 0);
2096
- this._auth = auth;
2118
+ */ var AbstractFirebaseServerUserPasswordResetService = /*#__PURE__*/ function() {
2119
+ function AbstractFirebaseServerUserPasswordResetService(authService) {
2120
+ _class_call_check$q(this, AbstractFirebaseServerUserPasswordResetService);
2121
+ _define_property$x(this, "_authService", void 0);
2122
+ /**
2123
+ * Minimum time between reset content sends. Defaults to {@link DEFAULT_RESET_COM_THROTTLE_TIME} (1 hour).
2124
+ * Override in subclasses to customize the throttle window.
2125
+ */ _define_property$x(this, "resetThrottleTime", DEFAULT_RESET_COM_THROTTLE_TIME);
2126
+ this._authService = authService;
2097
2127
  }
2098
- _create_class$g(AbstractFirebaseServerAuthService, [
2128
+ _create_class$g(AbstractFirebaseServerUserPasswordResetService, [
2099
2129
  {
2100
- key: "auth",
2130
+ key: "authService",
2101
2131
  get: function get() {
2102
- return this._auth;
2103
- }
2104
- },
2105
- {
2106
- key: "context",
2107
- value: function context(context) {
2108
- assertIsContextWithAuthData(context);
2109
- return this._context(context);
2110
- }
2111
- },
2112
- {
2113
- key: "isAdmin",
2114
- value: function isAdmin(claims) {
2115
- return this.isAdminInRoles(this.readRoles(claims));
2116
- }
2117
- },
2118
- {
2119
- key: "isAdminInRoles",
2120
- value: function isAdminInRoles(roles) {
2121
- return roles.has(util.AUTH_ADMIN_ROLE);
2132
+ return this._authService;
2122
2133
  }
2123
2134
  },
2124
2135
  {
2125
- key: "hasSignedTos",
2126
- value: function hasSignedTos(claims) {
2127
- return this.hasSignedTosInRoles(this.readRoles(claims));
2136
+ key: "beginPasswordReset",
2137
+ value: function beginPasswordReset(input) {
2138
+ return _async_to_generator$g(function() {
2139
+ var uid, email, sendResetContent, sendResetDetailsOnce, sendResetIgnoreThrottle, sendResetThrowErrors, data, sendDetailsInTestEnvironment, resolvedUid, userRecord, userContext, claims;
2140
+ return _ts_generator$g(this, function(_state) {
2141
+ switch(_state.label){
2142
+ case 0:
2143
+ uid = input.uid, email = input.email, sendResetContent = input.sendResetContent, sendResetDetailsOnce = input.sendResetDetailsOnce, sendResetIgnoreThrottle = input.sendResetIgnoreThrottle, sendResetThrowErrors = input.sendResetThrowErrors, data = input.data, sendDetailsInTestEnvironment = input.sendDetailsInTestEnvironment;
2144
+ if (!uid) return [
2145
+ 3,
2146
+ 1
2147
+ ];
2148
+ resolvedUid = uid;
2149
+ return [
2150
+ 3,
2151
+ 4
2152
+ ];
2153
+ case 1:
2154
+ if (!email) return [
2155
+ 3,
2156
+ 3
2157
+ ];
2158
+ return [
2159
+ 4,
2160
+ this.authService.auth.getUserByEmail(email)
2161
+ ];
2162
+ case 2:
2163
+ userRecord = _state.sent();
2164
+ resolvedUid = userRecord.uid;
2165
+ return [
2166
+ 3,
2167
+ 4
2168
+ ];
2169
+ case 3:
2170
+ throw new Error('uid or email is required to initiate a password reset.');
2171
+ case 4:
2172
+ userContext = this.authService.userContext(resolvedUid);
2173
+ return [
2174
+ 4,
2175
+ userContext.beginResetPassword()
2176
+ ];
2177
+ case 5:
2178
+ claims = _state.sent();
2179
+ if (!sendResetContent) return [
2180
+ 3,
2181
+ 7
2182
+ ];
2183
+ return [
2184
+ 4,
2185
+ this.sendResetContent(resolvedUid, {
2186
+ data: data,
2187
+ sendResetDetailsOnce: sendResetDetailsOnce,
2188
+ ignoreSendThrottleTime: sendResetIgnoreThrottle,
2189
+ throwErrors: sendResetThrowErrors,
2190
+ sendDetailsInTestEnvironment: sendDetailsInTestEnvironment
2191
+ })
2192
+ ];
2193
+ case 6:
2194
+ _state.sent();
2195
+ _state.label = 7;
2196
+ case 7:
2197
+ return [
2198
+ 2,
2199
+ claims
2200
+ ];
2201
+ }
2202
+ });
2203
+ }).call(this);
2128
2204
  }
2129
2205
  },
2130
2206
  {
2131
- key: "hasSignedTosInRoles",
2132
- value: function hasSignedTosInRoles(roles) {
2133
- return roles.has(util.AUTH_TOS_SIGNED_ROLE);
2207
+ key: "sendResetContent",
2208
+ value: function sendResetContent(uid, config) {
2209
+ return _async_to_generator$g(function() {
2210
+ var resetDetails, sentContent, resetCommunicationAt, hasSentCommunication, lastSentAt, sendIsThrottled;
2211
+ return _ts_generator$g(this, function(_state) {
2212
+ switch(_state.label){
2213
+ case 0:
2214
+ return [
2215
+ 4,
2216
+ this.loadResetDetails(uid, config)
2217
+ ];
2218
+ case 1:
2219
+ resetDetails = _state.sent();
2220
+ sentContent = false;
2221
+ if (!resetDetails) return [
2222
+ 3,
2223
+ 7
2224
+ ];
2225
+ resetCommunicationAt = resetDetails.claims.resetCommunicationAt;
2226
+ hasSentCommunication = Boolean(resetCommunicationAt);
2227
+ if (!((config === null || config === void 0 ? void 0 : config.sendResetDetailsOnce) && hasSentCommunication)) return [
2228
+ 3,
2229
+ 2
2230
+ ];
2231
+ if (config.throwErrors) {
2232
+ throw new FirebaseServerAuthPasswordResetSendOnceError();
2233
+ }
2234
+ return [
2235
+ 3,
2236
+ 6
2237
+ ];
2238
+ case 2:
2239
+ lastSentAt = resetCommunicationAt ? new Date(resetCommunicationAt) : undefined;
2240
+ sendIsThrottled = hasSentCommunication && !(config === null || config === void 0 ? void 0 : config.ignoreSendThrottleTime) && util.isThrottled(this.resetThrottleTime, lastSentAt);
2241
+ if (!!sendIsThrottled) return [
2242
+ 3,
2243
+ 5
2244
+ ];
2245
+ return [
2246
+ 4,
2247
+ this.sendPasswordResetContentToUser(resetDetails)
2248
+ ];
2249
+ case 3:
2250
+ _state.sent();
2251
+ return [
2252
+ 4,
2253
+ this.updateResetContentSentTime(resetDetails)
2254
+ ];
2255
+ case 4:
2256
+ _state.sent();
2257
+ sentContent = true;
2258
+ return [
2259
+ 3,
2260
+ 6
2261
+ ];
2262
+ case 5:
2263
+ if (config === null || config === void 0 ? void 0 : config.throwErrors) {
2264
+ throw new FirebaseServerAuthPasswordResetThrottleError(lastSentAt);
2265
+ }
2266
+ _state.label = 6;
2267
+ case 6:
2268
+ return [
2269
+ 3,
2270
+ 8
2271
+ ];
2272
+ case 7:
2273
+ if (config === null || config === void 0 ? void 0 : config.throwErrors) {
2274
+ throw new FirebaseServerAuthPasswordResetNoResetConfigError();
2275
+ }
2276
+ _state.label = 8;
2277
+ case 8:
2278
+ return [
2279
+ 2,
2280
+ sentContent
2281
+ ];
2282
+ }
2283
+ });
2284
+ }).call(this);
2134
2285
  }
2135
2286
  },
2136
2287
  {
2137
- key: "newUser",
2138
- value: function newUser() {
2139
- return new NoSetupContentFirebaseServerNewUserService(this);
2288
+ key: "loadResetDetails",
2289
+ value: function loadResetDetails(uid, config) {
2290
+ return _async_to_generator$g(function() {
2291
+ var userContext, userExists, details;
2292
+ return _ts_generator$g(this, function(_state) {
2293
+ switch(_state.label){
2294
+ case 0:
2295
+ userContext = this.authService.userContext(uid);
2296
+ return [
2297
+ 4,
2298
+ userContext.exists()
2299
+ ];
2300
+ case 1:
2301
+ userExists = _state.sent();
2302
+ if (!userExists) return [
2303
+ 3,
2304
+ 3
2305
+ ];
2306
+ return [
2307
+ 4,
2308
+ this.loadResetDetailsForUserContext(userContext, config)
2309
+ ];
2310
+ case 2:
2311
+ details = _state.sent();
2312
+ _state.label = 3;
2313
+ case 3:
2314
+ return [
2315
+ 2,
2316
+ details
2317
+ ];
2318
+ }
2319
+ });
2320
+ }).call(this);
2140
2321
  }
2141
2322
  },
2142
2323
  {
2143
- key: "authContextInfo",
2144
- value: function authContextInfo(context) {
2145
- var _this = this;
2146
- var auth = context.auth;
2147
- var result;
2148
- if (auth) {
2324
+ key: "loadResetDetailsForUserContext",
2325
+ value: function loadResetDetailsForUserContext(userContext, config) {
2326
+ return _async_to_generator$g(function() {
2327
+ var details, claims;
2328
+ return _ts_generator$g(this, function(_state) {
2329
+ switch(_state.label){
2330
+ case 0:
2331
+ return [
2332
+ 4,
2333
+ userContext.loadResetPasswordClaims()
2334
+ ];
2335
+ case 1:
2336
+ claims = _state.sent();
2337
+ if (claims) {
2338
+ details = {
2339
+ userContext: userContext,
2340
+ claims: {
2341
+ resetPassword: claims.resetPassword,
2342
+ resetCommunicationAt: claims.resetCommunicationAt
2343
+ },
2344
+ data: config === null || config === void 0 ? void 0 : config.data,
2345
+ sendDetailsInTestEnvironment: config === null || config === void 0 ? void 0 : config.sendDetailsInTestEnvironment
2346
+ };
2347
+ }
2348
+ return [
2349
+ 2,
2350
+ details
2351
+ ];
2352
+ }
2353
+ });
2354
+ })();
2355
+ }
2356
+ },
2357
+ {
2358
+ key: "updateResetContentSentTime",
2359
+ value: /**
2360
+ * Records the current timestamp as the last reset content communication date in the user's claims.
2361
+ *
2362
+ * @param details - The user's reset details containing the user context.
2363
+ */ function updateResetContentSentTime(details) {
2364
+ return _async_to_generator$g(function() {
2365
+ var resetCommunicationAt;
2366
+ return _ts_generator$g(this, function(_state) {
2367
+ switch(_state.label){
2368
+ case 0:
2369
+ resetCommunicationAt = date.toISODateString(new Date());
2370
+ return [
2371
+ 4,
2372
+ details.userContext.updateClaims(_define_property$x({}, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_LAST_COM_DATE_KEY, resetCommunicationAt))
2373
+ ];
2374
+ case 1:
2375
+ _state.sent();
2376
+ return [
2377
+ 2
2378
+ ];
2379
+ }
2380
+ });
2381
+ })();
2382
+ }
2383
+ },
2384
+ {
2385
+ key: "completePasswordReset",
2386
+ value: function completePasswordReset(uid, input) {
2387
+ return _async_to_generator$g(function() {
2388
+ var userContext, claims;
2389
+ return _ts_generator$g(this, function(_state) {
2390
+ switch(_state.label){
2391
+ case 0:
2392
+ userContext = this.authService.userContext(uid);
2393
+ return [
2394
+ 4,
2395
+ userContext.loadResetPasswordClaims()
2396
+ ];
2397
+ case 1:
2398
+ claims = _state.sent();
2399
+ if ((claims === null || claims === void 0 ? void 0 : claims.resetPassword) !== input.resetPassword) {
2400
+ throw new FirebaseServerAuthPasswordResetInvalidCodeError();
2401
+ }
2402
+ return [
2403
+ 2,
2404
+ userContext.setPassword(input.newPassword)
2405
+ ];
2406
+ }
2407
+ });
2408
+ }).call(this);
2409
+ }
2410
+ }
2411
+ ]);
2412
+ return AbstractFirebaseServerUserPasswordResetService;
2413
+ }();
2414
+ /**
2415
+ * No-op implementation of {@link AbstractFirebaseServerUserPasswordResetService} that skips sending reset content.
2416
+ *
2417
+ * Used as the default {@link FirebaseServerUserPasswordResetService} when no custom delivery mechanism is configured.
2418
+ */ var NoContentFirebaseServerUserPasswordResetService = /*#__PURE__*/ function(AbstractFirebaseServerUserPasswordResetService) {
2419
+ _inherits$4(NoContentFirebaseServerUserPasswordResetService, AbstractFirebaseServerUserPasswordResetService);
2420
+ function NoContentFirebaseServerUserPasswordResetService() {
2421
+ _class_call_check$q(this, NoContentFirebaseServerUserPasswordResetService);
2422
+ return _call_super$4(this, NoContentFirebaseServerUserPasswordResetService, arguments);
2423
+ }
2424
+ _create_class$g(NoContentFirebaseServerUserPasswordResetService, [
2425
+ {
2426
+ key: "sendPasswordResetContentToUser",
2427
+ value: function sendPasswordResetContentToUser(_details) {
2428
+ return _async_to_generator$g(function() {
2429
+ return _ts_generator$g(this, function(_state) {
2430
+ return [
2431
+ 2
2432
+ ];
2433
+ });
2434
+ // send nothing.
2435
+ })();
2436
+ }
2437
+ }
2438
+ ]);
2439
+ return NoContentFirebaseServerUserPasswordResetService;
2440
+ }(AbstractFirebaseServerUserPasswordResetService);
2441
+ /**
2442
+ * Abstract contract for a Firebase Server authentication service.
2443
+ *
2444
+ * Provides the core API for creating auth contexts from callable requests, managing user contexts,
2445
+ * checking admin/ToS status, converting between roles and claims, and creating new users.
2446
+ *
2447
+ * Implement this by extending {@link AbstractFirebaseServerAuthService}, which provides default
2448
+ * implementations for most methods and only requires `readRoles`, `claimsForRoles`,
2449
+ * `userContext`, and `_context` to be defined.
2450
+ *
2451
+ * @example
2452
+ * ```typescript
2453
+ * class MyAuthService extends AbstractFirebaseServerAuthService<MyUserContext, MyAuthContext> {
2454
+ * readRoles(claims: AuthClaims): AuthRoleSet { ... }
2455
+ * claimsForRoles(roles: AuthRoleSet): AuthClaimsUpdate { ... }
2456
+ * userContext(uid: string): MyUserContext { ... }
2457
+ * protected _context(ctx: CallableContextWithAuthData): MyAuthContext { ... }
2458
+ * }
2459
+ * ```
2460
+ */ var FirebaseServerAuthService = function FirebaseServerAuthService() {
2461
+ _class_call_check$q(this, FirebaseServerAuthService);
2462
+ };
2463
+ /**
2464
+ * Base implementation of {@link FirebaseServerAuthService} providing standard admin/ToS checks,
2465
+ * auth context creation with assertion, and a default no-op new user service.
2466
+ *
2467
+ * Subclasses must implement:
2468
+ * - {@link _context} - to create the concrete auth context type.
2469
+ * - {@link userContext} - to create the concrete user context type.
2470
+ * - {@link readRoles} - to define the claims-to-roles mapping.
2471
+ * - {@link claimsForRoles} - to define the roles-to-claims mapping.
2472
+ *
2473
+ * @example
2474
+ * ```typescript
2475
+ * export class MyAuthService extends AbstractFirebaseServerAuthService<MyUserContext, MyAuthContext> {
2476
+ * protected _context(context: CallableContextWithAuthData): MyAuthContext {
2477
+ * return new MyAuthContext(this, context);
2478
+ * }
2479
+ * userContext(uid: string): MyUserContext {
2480
+ * return new MyUserContext(this, uid);
2481
+ * }
2482
+ * readRoles(claims: AuthClaims): AuthRoleSet {
2483
+ * return MY_CLAIMS_SERVICE.toRoles(claims);
2484
+ * }
2485
+ * claimsForRoles(roles: AuthRoleSet): AuthClaimsUpdate {
2486
+ * return MY_CLAIMS_SERVICE.toClaims(roles);
2487
+ * }
2488
+ * }
2489
+ * ```
2490
+ */ var AbstractFirebaseServerAuthService = /*#__PURE__*/ function() {
2491
+ function AbstractFirebaseServerAuthService(auth) {
2492
+ _class_call_check$q(this, AbstractFirebaseServerAuthService);
2493
+ _define_property$x(this, "_auth", void 0);
2494
+ this._auth = auth;
2495
+ }
2496
+ _create_class$g(AbstractFirebaseServerAuthService, [
2497
+ {
2498
+ key: "auth",
2499
+ get: function get() {
2500
+ return this._auth;
2501
+ }
2502
+ },
2503
+ {
2504
+ key: "context",
2505
+ value: function context(context) {
2506
+ assertIsContextWithAuthData(context);
2507
+ return this._context(context);
2508
+ }
2509
+ },
2510
+ {
2511
+ key: "isAdmin",
2512
+ value: function isAdmin(claims) {
2513
+ return this.isAdminInRoles(this.readRoles(claims));
2514
+ }
2515
+ },
2516
+ {
2517
+ key: "isAdminInRoles",
2518
+ value: function isAdminInRoles(roles) {
2519
+ return roles.has(util.AUTH_ADMIN_ROLE);
2520
+ }
2521
+ },
2522
+ {
2523
+ key: "hasSignedTos",
2524
+ value: function hasSignedTos(claims) {
2525
+ return this.hasSignedTosInRoles(this.readRoles(claims));
2526
+ }
2527
+ },
2528
+ {
2529
+ key: "hasSignedTosInRoles",
2530
+ value: function hasSignedTosInRoles(roles) {
2531
+ return roles.has(util.AUTH_TOS_SIGNED_ROLE);
2532
+ }
2533
+ },
2534
+ {
2535
+ key: "newUser",
2536
+ value: function newUser() {
2537
+ return new NoSetupContentFirebaseServerNewUserService(this);
2538
+ }
2539
+ },
2540
+ {
2541
+ key: "passwordReset",
2542
+ value: function passwordReset() {
2543
+ return new NoContentFirebaseServerUserPasswordResetService(this);
2544
+ }
2545
+ },
2546
+ {
2547
+ key: "authContextInfo",
2548
+ value: function authContextInfo(context) {
2549
+ var _this = this;
2550
+ var auth = context.auth;
2551
+ var result;
2552
+ if (auth) {
2149
2553
  var _roles = util.cachedGetter(function() {
2150
2554
  return _this.readRoles(auth.token);
2151
2555
  });
@@ -2187,781 +2591,333 @@ function _ts_generator$f(thisArg, body) {
2187
2591
  }
2188
2592
  ();
2189
2593
 
2190
- // MARK: Tokens
2191
- /**
2192
- * Token to access a configured FirebaseServerEnvironmentServiceConfig for the app.
2193
- */ var FIREBASE_SERVER_ENV_TOKEN = 'FIREBASE_SERVER_ENV_TOKEN';
2194
- /**
2195
- * Creates a NestJS provider that binds the given config to the {@link FIREBASE_SERVER_ENV_TOKEN} injection token.
2196
- *
2197
- * @param env - The Firebase server environment configuration.
2198
- * @returns A NestJS provider binding the config to the {@link FIREBASE_SERVER_ENV_TOKEN} token.
2199
- *
2200
- * @example
2201
- * ```typescript
2202
- * const provider = firebaseServerEnvTokenProvider({ appUrl: 'https://myapp.com', ... });
2203
- * ```
2204
- */ function firebaseServerEnvTokenProvider(env) {
2205
- return {
2206
- provide: FIREBASE_SERVER_ENV_TOKEN,
2207
- useValue: env
2208
- };
2209
- }
2210
- /**
2211
- * Creates NestJS providers that bind the given config to both {@link FIREBASE_SERVER_ENV_TOKEN}
2212
- * and the base {@link SERVER_ENV_TOKEN} from `@dereekb/nestjs`.
2213
- *
2214
- * Use this when the NestJS app needs the config accessible via either token.
2215
- *
2216
- * @param env - The Firebase server environment configuration.
2217
- * @returns An array of providers binding the config to both Firebase and base server env tokens.
2218
- *
2219
- * @example
2220
- * ```typescript
2221
- * @Module({
2222
- * providers: [...firebaseServerEnvTokenProviders(myEnvConfig)]
2223
- * })
2224
- * export class AppModule {}
2225
- * ```
2226
- */ function firebaseServerEnvTokenProviders(env) {
2227
- return [
2228
- firebaseServerEnvTokenProvider(env),
2229
- {
2230
- provide: nestjs.SERVER_ENV_TOKEN,
2231
- useExisting: FIREBASE_SERVER_ENV_TOKEN
2232
- }
2233
- ];
2234
- }
2235
-
2236
- function _class_call_check$p(instance, Constructor) {
2237
- if (!(instance instanceof Constructor)) {
2238
- throw new TypeError("Cannot call a class as a function");
2594
+ function asyncGeneratorStep$f(gen, resolve, reject, _next, _throw, key, arg) {
2595
+ try {
2596
+ var info = gen[key](arg);
2597
+ var value = info.value;
2598
+ } catch (error) {
2599
+ reject(error);
2600
+ return;
2601
+ }
2602
+ if (info.done) {
2603
+ resolve(value);
2604
+ } else {
2605
+ Promise.resolve(value).then(_next, _throw);
2239
2606
  }
2240
2607
  }
2241
- /**
2242
- * Abstract service providing Firebase server environment information such as deployment stage,
2243
- * feature flags, and app URL.
2244
- *
2245
- * Implementations are typically injected via {@link FIREBASE_SERVER_ENV_TOKEN} and
2246
- * backed by a {@link FirebaseServerEnvironmentConfig}.
2247
- */ var FirebaseServerEnvService = function FirebaseServerEnvService() {
2248
- _class_call_check$p(this, FirebaseServerEnvService);
2249
- }
2250
- ;
2251
-
2252
- /**
2253
- * Converts a {@link FirestoreAccessorIncrementUpdate} into Firestore {@link UpdateData} using
2254
- * Google Cloud Firestore's {@link FieldValue.increment}.
2255
- *
2256
- * Each field in the input maps to an atomic increment operation. Null/undefined values default to 0.
2257
- *
2258
- * @param input - The increment specification mapping field names to numeric deltas.
2259
- * @returns Firestore {@link UpdateData} with atomic increment operations.
2260
- *
2261
- * @example
2262
- * ```typescript
2263
- * const updateData = firestoreServerIncrementUpdateToUpdateData<Stats>({
2264
- * viewCount: 1,
2265
- * likeCount: -1
2266
- * });
2267
- * ```
2268
- */ function firestoreServerIncrementUpdateToUpdateData(input) {
2269
- return util.mapObjectMap(input, function(incrementValue) {
2270
- return firestore.FieldValue.increment(incrementValue !== null && incrementValue !== void 0 ? incrementValue : 0);
2271
- });
2272
- }
2273
-
2274
- function _array_like_to_array$d(arr, len) {
2275
- if (len == null || len > arr.length) len = arr.length;
2276
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2277
- return arr2;
2278
- }
2279
- function _array_without_holes$9(arr) {
2280
- if (Array.isArray(arr)) return _array_like_to_array$d(arr);
2281
- }
2282
- function _define_property$w(obj, key, value) {
2283
- if (key in obj) {
2284
- Object.defineProperty(obj, key, {
2285
- value: value,
2286
- enumerable: true,
2287
- configurable: true,
2288
- writable: true
2608
+ function _async_to_generator$f(fn) {
2609
+ return function() {
2610
+ var self = this, args = arguments;
2611
+ return new Promise(function(resolve, reject) {
2612
+ var gen = fn.apply(self, args);
2613
+ function _next(value) {
2614
+ asyncGeneratorStep$f(gen, resolve, reject, _next, _throw, "next", value);
2615
+ }
2616
+ function _throw(err) {
2617
+ asyncGeneratorStep$f(gen, resolve, reject, _next, _throw, "throw", err);
2618
+ }
2619
+ _next(undefined);
2289
2620
  });
2290
- } else {
2291
- obj[key] = value;
2292
- }
2293
- return obj;
2294
- }
2295
- function _iterable_to_array$9(iter) {
2296
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
2297
- }
2298
- function _non_iterable_spread$9() {
2299
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2621
+ };
2300
2622
  }
2301
- function _object_spread$h(target) {
2302
- for(var i = 1; i < arguments.length; i++){
2303
- var source = arguments[i] != null ? arguments[i] : {};
2304
- var ownKeys = Object.keys(source);
2305
- if (typeof Object.getOwnPropertySymbols === "function") {
2306
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2307
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2308
- }));
2623
+ function _ts_generator$f(thisArg, body) {
2624
+ var f, y, t, _ = {
2625
+ label: 0,
2626
+ sent: function() {
2627
+ if (t[0] & 1) throw t[1];
2628
+ return t[1];
2629
+ },
2630
+ trys: [],
2631
+ ops: []
2632
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
2633
+ return d(g, "next", {
2634
+ value: verb(0)
2635
+ }), d(g, "throw", {
2636
+ value: verb(1)
2637
+ }), d(g, "return", {
2638
+ value: verb(2)
2639
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
2640
+ value: function() {
2641
+ return this;
2309
2642
  }
2310
- ownKeys.forEach(function(key) {
2311
- _define_property$w(target, key, source[key]);
2312
- });
2643
+ }), g;
2644
+ function verb(n) {
2645
+ return function(v) {
2646
+ return step([
2647
+ n,
2648
+ v
2649
+ ]);
2650
+ };
2651
+ }
2652
+ function step(op) {
2653
+ if (f) throw new TypeError("Generator is already executing.");
2654
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
2655
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2656
+ if (y = 0, t) op = [
2657
+ op[0] & 2,
2658
+ t.value
2659
+ ];
2660
+ switch(op[0]){
2661
+ case 0:
2662
+ case 1:
2663
+ t = op;
2664
+ break;
2665
+ case 4:
2666
+ _.label++;
2667
+ return {
2668
+ value: op[1],
2669
+ done: false
2670
+ };
2671
+ case 5:
2672
+ _.label++;
2673
+ y = op[1];
2674
+ op = [
2675
+ 0
2676
+ ];
2677
+ continue;
2678
+ case 7:
2679
+ op = _.ops.pop();
2680
+ _.trys.pop();
2681
+ continue;
2682
+ default:
2683
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2684
+ _ = 0;
2685
+ continue;
2686
+ }
2687
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
2688
+ _.label = op[1];
2689
+ break;
2690
+ }
2691
+ if (op[0] === 6 && _.label < t[1]) {
2692
+ _.label = t[1];
2693
+ t = op;
2694
+ break;
2695
+ }
2696
+ if (t && _.label < t[2]) {
2697
+ _.label = t[2];
2698
+ _.ops.push(op);
2699
+ break;
2700
+ }
2701
+ if (t[2]) _.ops.pop();
2702
+ _.trys.pop();
2703
+ continue;
2704
+ }
2705
+ op = body.call(thisArg, _);
2706
+ } catch (e) {
2707
+ op = [
2708
+ 6,
2709
+ e
2710
+ ];
2711
+ y = 0;
2712
+ } finally{
2713
+ f = t = 0;
2714
+ }
2715
+ if (op[0] & 5) throw op[1];
2716
+ return {
2717
+ value: op[0] ? op[1] : void 0,
2718
+ done: true
2719
+ };
2313
2720
  }
2314
- return target;
2315
- }
2316
- function _to_consumable_array$9(arr) {
2317
- return _array_without_holes$9(arr) || _iterable_to_array$9(arr) || _unsupported_iterable_to_array$d(arr) || _non_iterable_spread$9();
2318
- }
2319
- function _unsupported_iterable_to_array$d(o, minLen) {
2320
- if (!o) return;
2321
- if (typeof o === "string") return _array_like_to_array$d(o, minLen);
2322
- var n = Object.prototype.toString.call(o).slice(8, -1);
2323
- if (n === "Object" && o.constructor) n = o.constructor.name;
2324
- if (n === "Map" || n === "Set") return Array.from(n);
2325
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$d(o, minLen);
2326
2721
  }
2327
2722
  /**
2328
- * Converts a {@link FirestoreAccessorArrayUpdate} into Firestore {@link UpdateData} using
2329
- * Google Cloud Firestore's {@link FieldValue.arrayUnion} and {@link FieldValue.arrayRemove}.
2723
+ * Asserts that the callable context contains auth data with a valid UID.
2330
2724
  *
2331
- * @param input - The array update specification with `union` and/or `remove` field maps.
2332
- * @returns Firestore {@link UpdateData} with array union/remove operations.
2725
+ * @param context - The callable context to check for auth data.
2726
+ * @throws {HttpsError} Throws unauthenticated error if no auth data is present.
2333
2727
  *
2334
2728
  * @example
2335
2729
  * ```typescript
2336
- * const updateData = firestoreServerArrayUpdateToUpdateData<User>({
2337
- * union: { tags: ['new-tag'] },
2338
- * remove: { tags: ['old-tag'] }
2339
- * });
2730
+ * assertContextHasAuth(context);
2731
+ * // Safe to access context.auth.uid
2340
2732
  * ```
2341
- */ function firestoreServerArrayUpdateToUpdateData(input) {
2342
- var union = input.union;
2343
- var remove = input.remove;
2344
- function createUpdatesWithArrayFunction(fieldUpdate, arrayUpdateFunction) {
2345
- var result;
2346
- if (fieldUpdate) {
2347
- result = util.mapObjectMap(fieldUpdate, function(arrayUpdate) {
2348
- var result;
2349
- if (arrayUpdate) {
2350
- result = arrayUpdateFunction.apply(void 0, _to_consumable_array$9(arrayUpdate)); // use spread operator to insert each value as an argument, as "nested arrays" are not allowed in the Firestore
2351
- }
2352
- return result;
2353
- });
2354
- }
2355
- return result;
2356
- }
2357
- var updateData = _object_spread$h({}, createUpdatesWithArrayFunction(union, firestore.FieldValue.arrayUnion), createUpdatesWithArrayFunction(remove, firestore.FieldValue.arrayRemove));
2358
- return updateData;
2359
- }
2360
-
2361
- function _class_call_check$o(instance, Constructor) {
2362
- if (!(instance instanceof Constructor)) {
2363
- throw new TypeError("Cannot call a class as a function");
2364
- }
2365
- }
2366
- function _defineProperties$f(target, props) {
2367
- for(var i = 0; i < props.length; i++){
2368
- var descriptor = props[i];
2369
- descriptor.enumerable = descriptor.enumerable || false;
2370
- descriptor.configurable = true;
2371
- if ("value" in descriptor) descriptor.writable = true;
2372
- Object.defineProperty(target, descriptor.key, descriptor);
2373
- }
2374
- }
2375
- function _create_class$f(Constructor, protoProps, staticProps) {
2376
- if (protoProps) _defineProperties$f(Constructor.prototype, protoProps);
2377
- return Constructor;
2378
- }
2379
- function _define_property$v(obj, key, value) {
2380
- if (key in obj) {
2381
- Object.defineProperty(obj, key, {
2382
- value: value,
2383
- enumerable: true,
2384
- configurable: true,
2385
- writable: true
2386
- });
2387
- } else {
2388
- obj[key] = value;
2733
+ */ function assertContextHasAuth(context) {
2734
+ if (!isContextWithAuthData(context)) {
2735
+ throw unauthenticatedContextHasNoUidError();
2389
2736
  }
2390
- return obj;
2391
2737
  }
2392
- // MARK: Accessor
2393
2738
  /**
2394
- * Google Cloud Firestore implementation of {@link FirestoreDocumentDataAccessor} that queues
2395
- * all write operations (create, set, update, delete) into a {@link WriteBatch}.
2739
+ * Loads the snapshot data from a Firestore document, throwing if the document does not exist.
2396
2740
  *
2397
- * Writes are not committed until the batch is explicitly committed. Read operations
2398
- * (get, exists) bypass the batch and read directly from Firestore.
2399
- */ var WriteBatchFirestoreDocumentDataAccessor = /*#__PURE__*/ function() {
2400
- function WriteBatchFirestoreDocumentDataAccessor(batch, documentRef) {
2401
- _class_call_check$o(this, WriteBatchFirestoreDocumentDataAccessor);
2402
- _define_property$v(this, "documentRef", void 0);
2403
- _define_property$v(this, "_batch", void 0);
2404
- this.documentRef = documentRef;
2405
- this._batch = batch;
2406
- }
2407
- _create_class$f(WriteBatchFirestoreDocumentDataAccessor, [
2408
- {
2409
- key: "batch",
2410
- get: function get() {
2411
- return this._batch;
2412
- }
2413
- },
2414
- {
2415
- key: "stream",
2416
- value: function stream() {
2417
- return rxjs.from(this.get()); // todo
2418
- }
2419
- },
2420
- {
2421
- key: "create",
2422
- value: function create(data) {
2423
- this.batch.create(this.documentRef, data);
2424
- return Promise.resolve();
2425
- }
2426
- },
2427
- {
2428
- key: "exists",
2429
- value: function exists() {
2430
- return this.get().then(function(x) {
2431
- return x.exists;
2432
- });
2433
- }
2434
- },
2435
- {
2436
- key: "get",
2437
- value: function get() {
2438
- return this.documentRef.get();
2439
- }
2440
- },
2441
- {
2442
- key: "getWithConverter",
2443
- value: function getWithConverter(converter) {
2444
- return this.documentRef.withConverter(converter).get();
2445
- }
2446
- },
2447
- {
2448
- key: "delete",
2449
- value: function _delete(params) {
2450
- this.batch.delete(this.documentRef, params === null || params === void 0 ? void 0 : params.precondition);
2451
- return Promise.resolve();
2452
- }
2453
- },
2454
- {
2455
- key: "set",
2456
- value: function set(data) {
2457
- this.batch.set(this.documentRef, data);
2458
- return Promise.resolve();
2459
- }
2460
- },
2461
- {
2462
- key: "increment",
2463
- value: function increment(data, params) {
2464
- return this.update(firestoreServerIncrementUpdateToUpdateData(data), params);
2465
- }
2466
- },
2467
- {
2468
- key: "arrayUpdate",
2469
- value: function arrayUpdate(data, params) {
2470
- return this.update(firestoreServerArrayUpdateToUpdateData(data), params);
2471
- }
2472
- },
2473
- {
2474
- key: "update",
2475
- value: function update(data, params) {
2476
- if ((params === null || params === void 0 ? void 0 : params.precondition) != null) {
2477
- this.batch.update(this.documentRef, data, params.precondition);
2478
- } else {
2479
- this.batch.update(this.documentRef, data);
2480
- }
2481
- return Promise.resolve();
2482
- }
2483
- }
2484
- ]);
2485
- return WriteBatchFirestoreDocumentDataAccessor;
2486
- }();
2487
- /**
2488
- * Creates a {@link FirestoreDocumentDataAccessorFactory} that produces batch-backed accessors.
2489
- *
2490
- * All accessors created from this factory share the same {@link WriteBatch}, so committing
2491
- * the batch applies all queued writes atomically.
2492
- *
2493
- * @param writeBatch - The Google Cloud WriteBatch to queue operations into.
2494
- * @returns A factory that creates batch-backed accessors sharing the given WriteBatch.
2741
+ * @param document - The Firestore document to load data from.
2742
+ * @param message - Optional custom error message.
2743
+ * @returns The document's snapshot data.
2744
+ * @throws {HttpsError} Throws a {@link modelNotAvailableError} (404) if the document has no data.
2495
2745
  *
2496
2746
  * @example
2497
2747
  * ```typescript
2498
- * const batch = firestore.batch();
2499
- * const factory = writeBatchAccessorFactory<User>(batch);
2500
- * const accessor = factory.accessorFor(userDocRef);
2501
- * await accessor.set({ name: 'Alice' });
2502
- * await batch.commit();
2748
+ * const userData = await assertSnapshotData(userDocument);
2503
2749
  * ```
2504
- */ function writeBatchAccessorFactory(writeBatch) {
2505
- return {
2506
- accessorFor: function accessorFor(ref) {
2507
- return new WriteBatchFirestoreDocumentDataAccessor(writeBatch, ref);
2508
- }
2509
- };
2750
+ */ function assertSnapshotData(document, message) {
2751
+ return _async_to_generator$f(function() {
2752
+ var data;
2753
+ return _ts_generator$f(this, function(_state) {
2754
+ switch(_state.label){
2755
+ case 0:
2756
+ return [
2757
+ 4,
2758
+ document.snapshotData()
2759
+ ];
2760
+ case 1:
2761
+ data = _state.sent();
2762
+ if (data == null) {
2763
+ throw modelNotAvailableError({
2764
+ message: message !== null && message !== void 0 ? message : "The ".concat(document.modelType, " was unavailable.")
2765
+ });
2766
+ }
2767
+ return [
2768
+ 2,
2769
+ data
2770
+ ];
2771
+ }
2772
+ });
2773
+ })();
2510
2774
  }
2511
- // MARK: Context
2512
2775
  /**
2513
- * A {@link FirestoreDocumentContext} backed by a Google Cloud {@link WriteBatch}.
2776
+ * Loads snapshot data and attaches the document's `id` and `key` to the result.
2514
2777
  *
2515
- * All document accessors created from this context queue writes into the same batch.
2516
- */ var WriteBatchFirestoreDocumentContext = /*#__PURE__*/ function() {
2517
- function WriteBatchFirestoreDocumentContext(batch) {
2518
- _class_call_check$o(this, WriteBatchFirestoreDocumentContext);
2519
- _define_property$v(this, "_batch", void 0);
2520
- _define_property$v(this, "contextType", firebase.FirestoreDocumentContextType.BATCH);
2521
- _define_property$v(this, "accessorFactory", void 0);
2522
- this._batch = batch;
2523
- this.accessorFactory = writeBatchAccessorFactory(batch);
2524
- }
2525
- _create_class$f(WriteBatchFirestoreDocumentContext, [
2526
- {
2527
- key: "batch",
2528
- get: function get() {
2529
- return this._batch;
2778
+ * Combines {@link assertSnapshotData} with {@link setIdAndKeyFromKeyIdRefOnDocumentData}.
2779
+ *
2780
+ * @param document - The Firestore document to load data from.
2781
+ * @param message - Optional custom error message.
2782
+ * @returns The document's snapshot data with `id` and `key` attached.
2783
+ * @throws {HttpsError} Throws a {@link modelNotAvailableError} (404) if the document has no data.
2784
+ */ function assertSnapshotDataWithKey(document, message) {
2785
+ return _async_to_generator$f(function() {
2786
+ var data;
2787
+ return _ts_generator$f(this, function(_state) {
2788
+ switch(_state.label){
2789
+ case 0:
2790
+ return [
2791
+ 4,
2792
+ assertSnapshotData(document, message)
2793
+ ];
2794
+ case 1:
2795
+ data = _state.sent();
2796
+ return [
2797
+ 2,
2798
+ firebase.setIdAndKeyFromKeyIdRefOnDocumentData(data, document)
2799
+ ];
2530
2800
  }
2531
- }
2532
- ]);
2533
- return WriteBatchFirestoreDocumentContext;
2534
- }();
2801
+ });
2802
+ })();
2803
+ }
2535
2804
  /**
2536
- * Creates a {@link WriteBatchFirestoreDocumentContext} wrapping the given batch.
2805
+ * Asserts that the Firestore document exists without loading its data.
2537
2806
  *
2538
- * @param batch - The Google Cloud WriteBatch to use.
2539
- * @returns A new {@link WriteBatchFirestoreDocumentContext} for the given batch.
2540
- */ function writeBatchDocumentContext(batch) {
2541
- return new WriteBatchFirestoreDocumentContext(batch);
2542
- }
2543
-
2544
- function _class_call_check$n(instance, Constructor) {
2545
- if (!(instance instanceof Constructor)) {
2546
- throw new TypeError("Cannot call a class as a function");
2547
- }
2548
- }
2549
- function _defineProperties$e(target, props) {
2550
- for(var i = 0; i < props.length; i++){
2551
- var descriptor = props[i];
2552
- descriptor.enumerable = descriptor.enumerable || false;
2553
- descriptor.configurable = true;
2554
- if ("value" in descriptor) descriptor.writable = true;
2555
- Object.defineProperty(target, descriptor.key, descriptor);
2556
- }
2557
- }
2558
- function _create_class$e(Constructor, protoProps, staticProps) {
2559
- if (protoProps) _defineProperties$e(Constructor.prototype, protoProps);
2560
- return Constructor;
2561
- }
2562
- function _define_property$u(obj, key, value) {
2563
- if (key in obj) {
2564
- Object.defineProperty(obj, key, {
2565
- value: value,
2566
- enumerable: true,
2567
- configurable: true,
2568
- writable: true
2807
+ * @param document - The Firestore document to check.
2808
+ * @param message - Optional custom error message.
2809
+ * @throws {HttpsError} Throws a {@link modelNotAvailableError} (404) if the document does not exist.
2810
+ */ function assertDocumentExists(document, message) {
2811
+ return _async_to_generator$f(function() {
2812
+ var exists;
2813
+ return _ts_generator$f(this, function(_state) {
2814
+ switch(_state.label){
2815
+ case 0:
2816
+ return [
2817
+ 4,
2818
+ document.exists()
2819
+ ];
2820
+ case 1:
2821
+ exists = _state.sent();
2822
+ if (!exists) {
2823
+ throw documentModelNotAvailableError(document, message);
2824
+ }
2825
+ return [
2826
+ 2
2827
+ ];
2828
+ }
2569
2829
  });
2570
- } else {
2571
- obj[key] = value;
2572
- }
2573
- return obj;
2830
+ })();
2574
2831
  }
2575
- // MARK: Accessor
2576
2832
  /**
2577
- * Default Google Cloud Firestore implementation of {@link FirestoreDocumentDataAccessor}.
2833
+ * Creates a {@link modelNotAvailableError} for the given document's model type.
2578
2834
  *
2579
- * Performs all operations directly against the Firestore document reference without
2580
- * batching or transactional context. Supports real-time streaming via `onSnapshot`.
2581
- */ var DefaultFirestoreDocumentDataAccessor = /*#__PURE__*/ function() {
2582
- function DefaultFirestoreDocumentDataAccessor(documentRef) {
2583
- _class_call_check$n(this, DefaultFirestoreDocumentDataAccessor);
2584
- _define_property$u(this, "_documentRef", void 0);
2585
- this._documentRef = documentRef;
2586
- }
2587
- _create_class$e(DefaultFirestoreDocumentDataAccessor, [
2588
- {
2589
- key: "documentRef",
2590
- get: function get() {
2591
- return this._documentRef;
2592
- }
2593
- },
2594
- {
2595
- key: "stream",
2596
- value: function stream() {
2597
- var _this = this;
2598
- return firebase.streamFromOnSnapshot(function(param) {
2599
- var next = param.next, error = param.error;
2600
- return _this.documentRef.onSnapshot(next, error);
2601
- });
2602
- }
2603
- },
2604
- {
2605
- key: "create",
2606
- value: function create(data) {
2607
- return this.documentRef.create(data);
2608
- }
2609
- },
2610
- {
2611
- key: "exists",
2612
- value: function exists() {
2613
- return this.get().then(function(x) {
2614
- return x.exists;
2615
- });
2616
- }
2617
- },
2618
- {
2619
- key: "get",
2620
- value: function get() {
2621
- return this.documentRef.get();
2622
- }
2623
- },
2624
- {
2625
- key: "getWithConverter",
2626
- value: function getWithConverter(converter) {
2627
- return this.documentRef.withConverter(converter).get();
2628
- }
2629
- },
2630
- {
2631
- key: "delete",
2632
- value: function _delete(params) {
2633
- return this.documentRef.delete(params === null || params === void 0 ? void 0 : params.precondition);
2634
- }
2635
- },
2636
- {
2637
- key: "set",
2638
- value: function set(data, options) {
2639
- return options ? this.documentRef.set(data, options) : this.documentRef.set(data);
2640
- }
2641
- },
2642
- {
2643
- key: "increment",
2644
- value: function increment(data, params) {
2645
- return this.update(firestoreServerIncrementUpdateToUpdateData(data), params);
2646
- }
2647
- },
2648
- {
2649
- key: "arrayUpdate",
2650
- value: function arrayUpdate(data, params) {
2651
- return this.update(firestoreServerArrayUpdateToUpdateData(data), params);
2652
- }
2653
- },
2654
- {
2655
- key: "update",
2656
- value: function update(data, params) {
2657
- return (params === null || params === void 0 ? void 0 : params.precondition) ? this.documentRef.update(data, params.precondition) : this.documentRef.update(data);
2658
- }
2659
- }
2660
- ]);
2661
- return DefaultFirestoreDocumentDataAccessor;
2662
- }();
2663
- /**
2664
- * Creates a {@link FirestoreDocumentDataAccessorFactory} that produces default (non-batched, non-transactional) accessors.
2835
+ * Used by {@link assertDocumentExists} and other assertion functions.
2665
2836
  *
2666
- * @returns A factory that creates default (non-batched, non-transactional) accessors.
2837
+ * @param document - The document (or object with `modelType`) to generate the error for.
2838
+ * @param message - Optional custom error message.
2839
+ * @returns A {@link modelNotAvailableError} with the document's model type in the message.
2840
+ */ function documentModelNotAvailableError(document, message) {
2841
+ return modelNotAvailableError({
2842
+ message: message !== null && message !== void 0 ? message : "The ".concat(document.modelType, " was unavailable.")
2843
+ });
2844
+ }
2845
+
2846
+ /**
2847
+ * Error code for when a phone number is already registered in Firebase Auth.
2848
+ */ var PHONE_NUMBER_ALREADY_EXISTS_ERROR_CODE = 'PHONE_NUMBER_ALREADY_EXISTS';
2849
+ /**
2850
+ * Creates a precondition conflict (409) error indicating the phone number already exists.
2667
2851
  *
2668
- * @example
2669
- * ```typescript
2670
- * const factory = defaultFirestoreAccessorFactory<User>();
2671
- * const accessor = factory.accessorFor(userDocRef);
2672
- * ```
2673
- */ function defaultFirestoreAccessorFactory() {
2674
- return {
2675
- accessorFor: function accessorFor(ref) {
2676
- return new DefaultFirestoreDocumentDataAccessor(ref);
2677
- }
2678
- };
2852
+ * @returns A new precondition-conflict (409) {@link HttpsError} with the phone-number-exists code.
2853
+ */ function phoneNumberAlreadyExistsError() {
2854
+ return preconditionConflictError({
2855
+ code: PHONE_NUMBER_ALREADY_EXISTS_ERROR_CODE,
2856
+ message: 'This phone number already exists in the system.'
2857
+ });
2679
2858
  }
2680
- // MARK: Context
2681
2859
  /**
2682
- * Creates a {@link FirestoreDocumentContext} with no special execution context (no batch, no transaction).
2860
+ * Handles Firebase Auth errors by mapping known error codes to typed HTTP errors.
2683
2861
  *
2684
- * Operations performed through this context execute immediately against Firestore.
2862
+ * Currently maps `auth/phone-number-already-exists` to a 409 conflict error.
2863
+ * Unknown error codes are forwarded to the optional handler.
2685
2864
  *
2686
- * @returns A {@link FirestoreDocumentContext} for direct Firestore operations.
2687
- */ function defaultFirestoreDocumentContext() {
2688
- return {
2689
- contextType: firebase.FirestoreDocumentContextType.NONE,
2690
- accessorFactory: defaultFirestoreAccessorFactory()
2691
- };
2865
+ * @param e - The caught error.
2866
+ * @param handleUnknownCode - Optional handler for Firebase errors with unrecognized codes.
2867
+ */ function handleFirebaseAuthError(e, handleUnknownCode) {
2868
+ handleFirebaseError(e, function(firebaseError) {
2869
+ switch(firebaseError.code){
2870
+ case firebase.FIREBASE_AUTH_PHONE_NUMBER_ALREADY_EXISTS_ERROR:
2871
+ throw phoneNumberAlreadyExistsError();
2872
+ default:
2873
+ handleUnknownCode === null || handleUnknownCode === void 0 ? void 0 : handleUnknownCode(firebaseError);
2874
+ break;
2875
+ }
2876
+ });
2692
2877
  }
2693
2878
 
2694
- function _class_call_check$m(instance, Constructor) {
2695
- if (!(instance instanceof Constructor)) {
2696
- throw new TypeError("Cannot call a class as a function");
2879
+ function asyncGeneratorStep$e(gen, resolve, reject, _next, _throw, key, arg) {
2880
+ try {
2881
+ var info = gen[key](arg);
2882
+ var value = info.value;
2883
+ } catch (error) {
2884
+ reject(error);
2885
+ return;
2697
2886
  }
2698
- }
2699
- function _defineProperties$d(target, props) {
2700
- for(var i = 0; i < props.length; i++){
2701
- var descriptor = props[i];
2702
- descriptor.enumerable = descriptor.enumerable || false;
2703
- descriptor.configurable = true;
2704
- if ("value" in descriptor) descriptor.writable = true;
2705
- Object.defineProperty(target, descriptor.key, descriptor);
2887
+ if (info.done) {
2888
+ resolve(value);
2889
+ } else {
2890
+ Promise.resolve(value).then(_next, _throw);
2706
2891
  }
2707
2892
  }
2708
- function _create_class$d(Constructor, protoProps, staticProps) {
2709
- if (protoProps) _defineProperties$d(Constructor.prototype, protoProps);
2710
- return Constructor;
2711
- }
2712
- function _define_property$t(obj, key, value) {
2713
- if (key in obj) {
2714
- Object.defineProperty(obj, key, {
2715
- value: value,
2716
- enumerable: true,
2717
- configurable: true,
2718
- writable: true
2893
+ function _async_to_generator$e(fn) {
2894
+ return function() {
2895
+ var self = this, args = arguments;
2896
+ return new Promise(function(resolve, reject) {
2897
+ var gen = fn.apply(self, args);
2898
+ function _next(value) {
2899
+ asyncGeneratorStep$e(gen, resolve, reject, _next, _throw, "next", value);
2900
+ }
2901
+ function _throw(err) {
2902
+ asyncGeneratorStep$e(gen, resolve, reject, _next, _throw, "throw", err);
2903
+ }
2904
+ _next(undefined);
2719
2905
  });
2906
+ };
2907
+ }
2908
+ function _instanceof$2(left, right) {
2909
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
2910
+ return !!right[Symbol.hasInstance](left);
2720
2911
  } else {
2721
- obj[key] = value;
2912
+ return left instanceof right;
2722
2913
  }
2723
- return obj;
2724
2914
  }
2725
- // MARK: Accessor
2726
- /**
2727
- * Google Cloud Firestore implementation of {@link FirestoreDocumentDataAccessor} that executes
2728
- * all operations within a Firestore {@link Transaction}.
2729
- *
2730
- * Reads performed through this accessor are included in the transaction's read set, ensuring
2731
- * consistency. Writes are committed atomically when the transaction completes.
2732
- */ var TransactionFirestoreDocumentDataAccessor = /*#__PURE__*/ function() {
2733
- function TransactionFirestoreDocumentDataAccessor(transaction, documentRef) {
2734
- _class_call_check$m(this, TransactionFirestoreDocumentDataAccessor);
2735
- _define_property$t(this, "_transaction", void 0);
2736
- _define_property$t(this, "_documentRef", void 0);
2737
- this._transaction = transaction;
2738
- this._documentRef = documentRef;
2739
- }
2740
- _create_class$d(TransactionFirestoreDocumentDataAccessor, [
2741
- {
2742
- key: "transaction",
2743
- get: function get() {
2744
- return this._transaction;
2745
- }
2746
- },
2747
- {
2748
- key: "documentRef",
2749
- get: function get() {
2750
- return this._documentRef;
2751
- }
2752
- },
2753
- {
2754
- key: "stream",
2755
- value: function stream() {
2756
- return rxjs.from(this.get());
2757
- }
2758
- },
2759
- {
2760
- key: "create",
2761
- value: function create(data) {
2762
- this.transaction.create(this.documentRef, data);
2763
- return Promise.resolve();
2764
- }
2765
- },
2766
- {
2767
- key: "exists",
2768
- value: function exists() {
2769
- return this.get().then(function(x) {
2770
- return x.exists;
2771
- });
2772
- }
2773
- },
2774
- {
2775
- key: "get",
2776
- value: function get() {
2777
- return this.transaction.get(this.documentRef);
2778
- }
2779
- },
2780
- {
2781
- key: "getWithConverter",
2782
- value: function getWithConverter(converter) {
2783
- return this.transaction.get(this.documentRef.withConverter(converter));
2784
- }
2785
- },
2786
- {
2787
- key: "delete",
2788
- value: function _delete() {
2789
- this.transaction.delete(this.documentRef);
2790
- return Promise.resolve();
2791
- }
2792
- },
2793
- {
2794
- key: "set",
2795
- value: function set(data, options) {
2796
- this.transaction.set(this.documentRef, data, options);
2797
- return Promise.resolve();
2798
- }
2799
- },
2800
- {
2801
- key: "increment",
2802
- value: function increment(data, params) {
2803
- return this.update(firestoreServerIncrementUpdateToUpdateData(data), params);
2804
- }
2805
- },
2806
- {
2807
- key: "arrayUpdate",
2808
- value: function arrayUpdate(data, params) {
2809
- return this.update(firestoreServerArrayUpdateToUpdateData(data), params);
2810
- }
2811
- },
2812
- {
2813
- key: "update",
2814
- value: function update(data, params) {
2815
- if (params === null || params === void 0 ? void 0 : params.precondition) {
2816
- this.transaction.update(this.documentRef, data, params.precondition);
2817
- } else {
2818
- this.transaction.update(this.documentRef, data);
2819
- }
2820
- return Promise.resolve();
2821
- }
2822
- }
2823
- ]);
2824
- return TransactionFirestoreDocumentDataAccessor;
2825
- }();
2826
- /**
2827
- * Creates a {@link FirestoreDocumentDataAccessorFactory} that produces transaction-backed accessors.
2828
- *
2829
- * All accessors share the same transaction, so reads and writes participate in the same
2830
- * atomic operation.
2831
- *
2832
- * @param transaction - The Google Cloud Transaction to execute operations within.
2833
- * @returns A factory that creates transaction-backed accessors sharing the given transaction.
2834
- *
2835
- * @example
2836
- * ```typescript
2837
- * await firestore.runTransaction(async (transaction) => {
2838
- * const factory = transactionAccessorFactory<User>(transaction);
2839
- * const accessor = factory.accessorFor(userDocRef);
2840
- * const snapshot = await accessor.get();
2841
- * await accessor.update({ name: 'Updated' });
2842
- * });
2843
- * ```
2844
- */ function transactionAccessorFactory(transaction) {
2845
- return {
2846
- accessorFor: function accessorFor(ref) {
2847
- return new TransactionFirestoreDocumentDataAccessor(transaction, ref);
2848
- }
2849
- };
2850
- }
2851
- // MARK: Context
2852
- /**
2853
- * A {@link FirestoreDocumentContext} backed by a Google Cloud {@link Transaction}.
2854
- *
2855
- * All document accessors created from this context operate within the same transaction.
2856
- */ var TransactionFirestoreDocumentContext = /*#__PURE__*/ function() {
2857
- function TransactionFirestoreDocumentContext(transaction) {
2858
- _class_call_check$m(this, TransactionFirestoreDocumentContext);
2859
- _define_property$t(this, "_transaction", void 0);
2860
- _define_property$t(this, "contextType", firebase.FirestoreDocumentContextType.TRANSACTION);
2861
- _define_property$t(this, "accessorFactory", void 0);
2862
- this._transaction = transaction;
2863
- this.accessorFactory = transactionAccessorFactory(transaction);
2864
- }
2865
- _create_class$d(TransactionFirestoreDocumentContext, [
2866
- {
2867
- key: "transaction",
2868
- get: function get() {
2869
- return this._transaction;
2870
- }
2871
- }
2872
- ]);
2873
- return TransactionFirestoreDocumentContext;
2874
- }();
2875
- /**
2876
- * Creates a {@link TransactionFirestoreDocumentContext} wrapping the given transaction.
2877
- *
2878
- * @param transaction - The Google Cloud Transaction to use.
2879
- * @returns A new {@link TransactionFirestoreDocumentContext} for the given transaction.
2880
- */ function transactionDocumentContext(transaction) {
2881
- return new TransactionFirestoreDocumentContext(transaction);
2882
- }
2883
-
2884
- function _array_like_to_array$c(arr, len) {
2885
- if (len == null || len > arr.length) len = arr.length;
2886
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2887
- return arr2;
2888
- }
2889
- function _array_with_holes$3(arr) {
2890
- if (Array.isArray(arr)) return arr;
2891
- }
2892
- function asyncGeneratorStep$e(gen, resolve, reject, _next, _throw, key, arg) {
2893
- try {
2894
- var info = gen[key](arg);
2895
- var value = info.value;
2896
- } catch (error) {
2897
- reject(error);
2898
- return;
2899
- }
2900
- if (info.done) {
2901
- resolve(value);
2902
- } else {
2903
- Promise.resolve(value).then(_next, _throw);
2904
- }
2905
- }
2906
- function _async_to_generator$e(fn) {
2907
- return function() {
2908
- var self = this, args = arguments;
2909
- return new Promise(function(resolve, reject) {
2910
- var gen = fn.apply(self, args);
2911
- function _next(value) {
2912
- asyncGeneratorStep$e(gen, resolve, reject, _next, _throw, "next", value);
2913
- }
2914
- function _throw(err) {
2915
- asyncGeneratorStep$e(gen, resolve, reject, _next, _throw, "throw", err);
2916
- }
2917
- _next(undefined);
2918
- });
2919
- };
2920
- }
2921
- function _iterable_to_array_limit$3(arr, i) {
2922
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2923
- if (_i == null) return;
2924
- var _arr = [];
2925
- var _n = true;
2926
- var _d = false;
2927
- var _s, _e;
2928
- try {
2929
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2930
- _arr.push(_s.value);
2931
- if (i && _arr.length === i) break;
2932
- }
2933
- } catch (err) {
2934
- _d = true;
2935
- _e = err;
2936
- } finally{
2937
- try {
2938
- if (!_n && _i["return"] != null) _i["return"]();
2939
- } finally{
2940
- if (_d) throw _e;
2941
- }
2942
- }
2943
- return _arr;
2944
- }
2945
- function _non_iterable_rest$3() {
2946
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2947
- }
2948
- function _sliced_to_array$3(arr, i) {
2949
- return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$c(arr, i) || _non_iterable_rest$3();
2950
- }
2951
- function _unsupported_iterable_to_array$c(o, minLen) {
2952
- if (!o) return;
2953
- if (typeof o === "string") return _array_like_to_array$c(o, minLen);
2954
- var n = Object.prototype.toString.call(o).slice(8, -1);
2955
- if (n === "Object" && o.constructor) n = o.constructor.name;
2956
- if (n === "Map" || n === "Set") return Array.from(n);
2957
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
2958
- }
2959
- function _ts_generator$e(thisArg, body) {
2960
- var f, y, t, _ = {
2961
- label: 0,
2962
- sent: function() {
2963
- if (t[0] & 1) throw t[1];
2964
- return t[1];
2915
+ function _ts_generator$e(thisArg, body) {
2916
+ var f, y, t, _ = {
2917
+ label: 0,
2918
+ sent: function() {
2919
+ if (t[0] & 1) throw t[1];
2920
+ return t[1];
2965
2921
  },
2966
2922
  trys: [],
2967
2923
  ops: []
@@ -3056,133 +3012,626 @@ function _ts_generator$e(thisArg, body) {
3056
3012
  }
3057
3013
  }
3058
3014
  /**
3059
- * Resolves a Firestore {@link CollectionReference} from a starting point and optional additional path segments.
3015
+ * Wraps an async function that uses {@link FirebaseServerUserPasswordResetService} methods,
3016
+ * catching password-reset-specific errors and re-throwing them as appropriate {@link HttpsError} instances
3017
+ * suitable for returning to clients.
3060
3018
  *
3061
- * Supports nested subcollection paths by processing segments in pairs (doc ID, collection name).
3019
+ * Error mapping:
3020
+ * - {@link FirebaseServerAuthPasswordResetInvalidCodeError} → permission-denied (403)
3021
+ * - {@link FirebaseServerAuthPasswordResetNoResetConfigError} → bad-request (400)
3022
+ * - {@link FirebaseServerAuthPasswordResetThrottleError} → unavailable (503)
3023
+ * - {@link FirebaseServerAuthPasswordResetSendOnceError} → bad-request (400)
3062
3024
  *
3063
- * @param start - A Firestore object that can resolve collection paths (e.g., Firestore instance, DocumentReference).
3064
- * @param path - The initial collection path.
3065
- * @param pathSegments - Optional pairs of [docId, collectionName] for subcollection traversal.
3066
- * @returns The resolved {@link CollectionReference} at the given path.
3067
- * @throws Error if pathSegments length is odd (segments must come in pairs).
3025
+ * @param fn - The async function to execute.
3026
+ * @returns The result of the function.
3027
+ */ function catchAndThrowPasswordResetServerErrors(fn) {
3028
+ return _async_to_generator$e(function() {
3029
+ var result, error;
3030
+ return _ts_generator$e(this, function(_state) {
3031
+ switch(_state.label){
3032
+ case 0:
3033
+ _state.trys.push([
3034
+ 0,
3035
+ 2,
3036
+ ,
3037
+ 3
3038
+ ]);
3039
+ return [
3040
+ 4,
3041
+ fn()
3042
+ ];
3043
+ case 1:
3044
+ result = _state.sent();
3045
+ return [
3046
+ 3,
3047
+ 3
3048
+ ];
3049
+ case 2:
3050
+ error = _state.sent();
3051
+ if (_instanceof$2(error, FirebaseServerAuthPasswordResetInvalidCodeError)) {
3052
+ throw authServicePasswordResetInvalidCodeError();
3053
+ } else if (_instanceof$2(error, FirebaseServerAuthPasswordResetNoResetConfigError)) {
3054
+ throw authServicePasswordResetNoConfigError();
3055
+ } else if (_instanceof$2(error, FirebaseServerAuthPasswordResetThrottleError)) {
3056
+ throw authServicePasswordResetThrottleError();
3057
+ } else if (_instanceof$2(error, FirebaseServerAuthPasswordResetSendOnceError)) {
3058
+ throw authServicePasswordResetSendOnceError();
3059
+ }
3060
+ throw error;
3061
+ case 3:
3062
+ return [
3063
+ 2,
3064
+ result
3065
+ ];
3066
+ }
3067
+ });
3068
+ })();
3069
+ }
3070
+ /**
3071
+ * Creates a permission-denied (403) server error for an invalid or expired password reset code.
3072
+ *
3073
+ * @returns An {@link HttpsError} with code `permission-denied`.
3074
+ */ function authServicePasswordResetInvalidCodeError() {
3075
+ return permissionDeniedError({
3076
+ code: firebase.DBX_FIREBASE_SERVER_PASSWORD_RESET_INVALID_CODE_ERROR_CODE,
3077
+ message: 'Invalid or expired reset password code.'
3078
+ });
3079
+ }
3080
+ /**
3081
+ * Creates a bad-request (400) server error when no active password reset exists for the user.
3082
+ *
3083
+ * @returns An {@link HttpsError} with code `invalid-argument`.
3084
+ */ function authServicePasswordResetNoConfigError() {
3085
+ return badRequestError({
3086
+ code: firebase.DBX_FIREBASE_SERVER_PASSWORD_RESET_NO_CONFIG_ERROR_CODE,
3087
+ message: 'No active password reset for this user.'
3088
+ });
3089
+ }
3090
+ /**
3091
+ * Creates an unavailable (503) server error when password reset email sending is throttled.
3092
+ *
3093
+ * @returns An {@link HttpsError} with code `unavailable`.
3094
+ */ function authServicePasswordResetThrottleError() {
3095
+ return unavailableError({
3096
+ code: firebase.DBX_FIREBASE_SERVER_PASSWORD_RESET_THROTTLE_ERROR_CODE,
3097
+ message: 'Password reset email was recently sent. Try again later.'
3098
+ });
3099
+ }
3100
+ /**
3101
+ * Creates a bad-request (400) server error when the password reset email has already been sent
3102
+ * and the send-once constraint is active.
3103
+ *
3104
+ * @returns An {@link HttpsError} with code `invalid-argument`.
3105
+ */ function authServicePasswordResetSendOnceError() {
3106
+ return badRequestError({
3107
+ code: firebase.DBX_FIREBASE_SERVER_PASSWORD_RESET_SEND_ONCE_ERROR_CODE,
3108
+ message: 'Password reset email has already been sent.'
3109
+ });
3110
+ }
3111
+
3112
+ // MARK: Tokens
3113
+ /**
3114
+ * Token to access a configured FirebaseServerEnvironmentServiceConfig for the app.
3115
+ */ var FIREBASE_SERVER_ENV_TOKEN = 'FIREBASE_SERVER_ENV_TOKEN';
3116
+ /**
3117
+ * Creates a NestJS provider that binds the given config to the {@link FIREBASE_SERVER_ENV_TOKEN} injection token.
3118
+ *
3119
+ * @param env - The Firebase server environment configuration.
3120
+ * @returns A NestJS provider binding the config to the {@link FIREBASE_SERVER_ENV_TOKEN} token.
3068
3121
  *
3069
3122
  * @example
3070
3123
  * ```typescript
3071
- * const ref = collectionRefForPath<User>(firestore, 'users');
3072
- * const subRef = collectionRefForPath<Comment>(firestore, 'users', ['user123', 'comments']);
3124
+ * const provider = firebaseServerEnvTokenProvider({ appUrl: 'https://myapp.com', ... });
3073
3125
  * ```
3074
- */ function collectionRefForPath(start, path, pathSegments) {
3075
- var ref = start.collection(path);
3076
- if (pathSegments === null || pathSegments === void 0 ? void 0 : pathSegments.length) {
3077
- if (pathSegments.length % 2 !== 0) {
3078
- throw new Error('Invalid number of path segments provided for collection. Path: "'.concat(path, '" + "').concat(pathSegments, '"'));
3126
+ */ function firebaseServerEnvTokenProvider(env) {
3127
+ return {
3128
+ provide: FIREBASE_SERVER_ENV_TOKEN,
3129
+ useValue: env
3130
+ };
3131
+ }
3132
+ /**
3133
+ * Creates NestJS providers that bind the given config to both {@link FIREBASE_SERVER_ENV_TOKEN}
3134
+ * and the base {@link SERVER_ENV_TOKEN} from `@dereekb/nestjs`.
3135
+ *
3136
+ * Use this when the NestJS app needs the config accessible via either token.
3137
+ *
3138
+ * @param env - The Firebase server environment configuration.
3139
+ * @returns An array of providers binding the config to both Firebase and base server env tokens.
3140
+ *
3141
+ * @example
3142
+ * ```typescript
3143
+ * @Module({
3144
+ * providers: [...firebaseServerEnvTokenProviders(myEnvConfig)]
3145
+ * })
3146
+ * export class AppModule {}
3147
+ * ```
3148
+ */ function firebaseServerEnvTokenProviders(env) {
3149
+ return [
3150
+ firebaseServerEnvTokenProvider(env),
3151
+ {
3152
+ provide: nestjs.SERVER_ENV_TOKEN,
3153
+ useExisting: FIREBASE_SERVER_ENV_TOKEN
3154
+ }
3155
+ ];
3156
+ }
3157
+
3158
+ function _class_call_check$p(instance, Constructor) {
3159
+ if (!(instance instanceof Constructor)) {
3160
+ throw new TypeError("Cannot call a class as a function");
3161
+ }
3162
+ }
3163
+ /**
3164
+ * Abstract service providing Firebase server environment information such as deployment stage,
3165
+ * feature flags, and app URL.
3166
+ *
3167
+ * Implementations are typically injected via {@link FIREBASE_SERVER_ENV_TOKEN} and
3168
+ * backed by a {@link FirebaseServerEnvironmentConfig}.
3169
+ */ var FirebaseServerEnvService = function FirebaseServerEnvService() {
3170
+ _class_call_check$p(this, FirebaseServerEnvService);
3171
+ }
3172
+ ;
3173
+
3174
+ /**
3175
+ * Converts a {@link FirestoreAccessorIncrementUpdate} into Firestore {@link UpdateData} using
3176
+ * Google Cloud Firestore's {@link FieldValue.increment}.
3177
+ *
3178
+ * Each field in the input maps to an atomic increment operation. Null/undefined values default to 0.
3179
+ *
3180
+ * @param input - The increment specification mapping field names to numeric deltas.
3181
+ * @returns Firestore {@link UpdateData} with atomic increment operations.
3182
+ *
3183
+ * @example
3184
+ * ```typescript
3185
+ * const updateData = firestoreServerIncrementUpdateToUpdateData<Stats>({
3186
+ * viewCount: 1,
3187
+ * likeCount: -1
3188
+ * });
3189
+ * ```
3190
+ */ function firestoreServerIncrementUpdateToUpdateData(input) {
3191
+ return util.mapObjectMap(input, function(incrementValue) {
3192
+ return firestore.FieldValue.increment(incrementValue !== null && incrementValue !== void 0 ? incrementValue : 0);
3193
+ });
3194
+ }
3195
+
3196
+ function _array_like_to_array$d(arr, len) {
3197
+ if (len == null || len > arr.length) len = arr.length;
3198
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3199
+ return arr2;
3200
+ }
3201
+ function _array_without_holes$9(arr) {
3202
+ if (Array.isArray(arr)) return _array_like_to_array$d(arr);
3203
+ }
3204
+ function _define_property$w(obj, key, value) {
3205
+ if (key in obj) {
3206
+ Object.defineProperty(obj, key, {
3207
+ value: value,
3208
+ enumerable: true,
3209
+ configurable: true,
3210
+ writable: true
3211
+ });
3212
+ } else {
3213
+ obj[key] = value;
3214
+ }
3215
+ return obj;
3216
+ }
3217
+ function _iterable_to_array$9(iter) {
3218
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
3219
+ }
3220
+ function _non_iterable_spread$9() {
3221
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3222
+ }
3223
+ function _object_spread$h(target) {
3224
+ for(var i = 1; i < arguments.length; i++){
3225
+ var source = arguments[i] != null ? arguments[i] : {};
3226
+ var ownKeys = Object.keys(source);
3227
+ if (typeof Object.getOwnPropertySymbols === "function") {
3228
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3229
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3230
+ }));
3231
+ }
3232
+ ownKeys.forEach(function(key) {
3233
+ _define_property$w(target, key, source[key]);
3234
+ });
3235
+ }
3236
+ return target;
3237
+ }
3238
+ function _to_consumable_array$9(arr) {
3239
+ return _array_without_holes$9(arr) || _iterable_to_array$9(arr) || _unsupported_iterable_to_array$d(arr) || _non_iterable_spread$9();
3240
+ }
3241
+ function _unsupported_iterable_to_array$d(o, minLen) {
3242
+ if (!o) return;
3243
+ if (typeof o === "string") return _array_like_to_array$d(o, minLen);
3244
+ var n = Object.prototype.toString.call(o).slice(8, -1);
3245
+ if (n === "Object" && o.constructor) n = o.constructor.name;
3246
+ if (n === "Map" || n === "Set") return Array.from(n);
3247
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$d(o, minLen);
3248
+ }
3249
+ /**
3250
+ * Converts a {@link FirestoreAccessorArrayUpdate} into Firestore {@link UpdateData} using
3251
+ * Google Cloud Firestore's {@link FieldValue.arrayUnion} and {@link FieldValue.arrayRemove}.
3252
+ *
3253
+ * @param input - The array update specification with `union` and/or `remove` field maps.
3254
+ * @returns Firestore {@link UpdateData} with array union/remove operations.
3255
+ *
3256
+ * @example
3257
+ * ```typescript
3258
+ * const updateData = firestoreServerArrayUpdateToUpdateData<User>({
3259
+ * union: { tags: ['new-tag'] },
3260
+ * remove: { tags: ['old-tag'] }
3261
+ * });
3262
+ * ```
3263
+ */ function firestoreServerArrayUpdateToUpdateData(input) {
3264
+ var union = input.union;
3265
+ var remove = input.remove;
3266
+ function createUpdatesWithArrayFunction(fieldUpdate, arrayUpdateFunction) {
3267
+ var result;
3268
+ if (fieldUpdate) {
3269
+ result = util.mapObjectMap(fieldUpdate, function(arrayUpdate) {
3270
+ var result;
3271
+ if (arrayUpdate) {
3272
+ result = arrayUpdateFunction.apply(void 0, _to_consumable_array$9(arrayUpdate)); // use spread operator to insert each value as an argument, as "nested arrays" are not allowed in the Firestore
3273
+ }
3274
+ return result;
3275
+ });
3276
+ }
3277
+ return result;
3278
+ }
3279
+ var updateData = _object_spread$h({}, createUpdatesWithArrayFunction(union, firestore.FieldValue.arrayUnion), createUpdatesWithArrayFunction(remove, firestore.FieldValue.arrayRemove));
3280
+ return updateData;
3281
+ }
3282
+
3283
+ function _class_call_check$o(instance, Constructor) {
3284
+ if (!(instance instanceof Constructor)) {
3285
+ throw new TypeError("Cannot call a class as a function");
3286
+ }
3287
+ }
3288
+ function _defineProperties$f(target, props) {
3289
+ for(var i = 0; i < props.length; i++){
3290
+ var descriptor = props[i];
3291
+ descriptor.enumerable = descriptor.enumerable || false;
3292
+ descriptor.configurable = true;
3293
+ if ("value" in descriptor) descriptor.writable = true;
3294
+ Object.defineProperty(target, descriptor.key, descriptor);
3295
+ }
3296
+ }
3297
+ function _create_class$f(Constructor, protoProps, staticProps) {
3298
+ if (protoProps) _defineProperties$f(Constructor.prototype, protoProps);
3299
+ return Constructor;
3300
+ }
3301
+ function _define_property$v(obj, key, value) {
3302
+ if (key in obj) {
3303
+ Object.defineProperty(obj, key, {
3304
+ value: value,
3305
+ enumerable: true,
3306
+ configurable: true,
3307
+ writable: true
3308
+ });
3309
+ } else {
3310
+ obj[key] = value;
3311
+ }
3312
+ return obj;
3313
+ }
3314
+ // MARK: Accessor
3315
+ /**
3316
+ * Google Cloud Firestore implementation of {@link FirestoreDocumentDataAccessor} that queues
3317
+ * all write operations (create, set, update, delete) into a {@link WriteBatch}.
3318
+ *
3319
+ * Writes are not committed until the batch is explicitly committed. Read operations
3320
+ * (get, exists) bypass the batch and read directly from Firestore.
3321
+ */ var WriteBatchFirestoreDocumentDataAccessor = /*#__PURE__*/ function() {
3322
+ function WriteBatchFirestoreDocumentDataAccessor(batch, documentRef) {
3323
+ _class_call_check$o(this, WriteBatchFirestoreDocumentDataAccessor);
3324
+ _define_property$v(this, "documentRef", void 0);
3325
+ _define_property$v(this, "_batch", void 0);
3326
+ this.documentRef = documentRef;
3327
+ this._batch = batch;
3328
+ }
3329
+ _create_class$f(WriteBatchFirestoreDocumentDataAccessor, [
3330
+ {
3331
+ key: "batch",
3332
+ get: function get() {
3333
+ return this._batch;
3334
+ }
3335
+ },
3336
+ {
3337
+ key: "stream",
3338
+ value: function stream() {
3339
+ return rxjs.from(this.get()); // todo
3340
+ }
3341
+ },
3342
+ {
3343
+ key: "create",
3344
+ value: function create(data) {
3345
+ this.batch.create(this.documentRef, data);
3346
+ return Promise.resolve();
3347
+ }
3348
+ },
3349
+ {
3350
+ key: "exists",
3351
+ value: function exists() {
3352
+ return this.get().then(function(x) {
3353
+ return x.exists;
3354
+ });
3355
+ }
3356
+ },
3357
+ {
3358
+ key: "get",
3359
+ value: function get() {
3360
+ return this.documentRef.get();
3361
+ }
3362
+ },
3363
+ {
3364
+ key: "getWithConverter",
3365
+ value: function getWithConverter(converter) {
3366
+ return this.documentRef.withConverter(converter).get();
3367
+ }
3368
+ },
3369
+ {
3370
+ key: "delete",
3371
+ value: function _delete(params) {
3372
+ this.batch.delete(this.documentRef, params === null || params === void 0 ? void 0 : params.precondition);
3373
+ return Promise.resolve();
3374
+ }
3375
+ },
3376
+ {
3377
+ key: "set",
3378
+ value: function set(data) {
3379
+ this.batch.set(this.documentRef, data);
3380
+ return Promise.resolve();
3381
+ }
3382
+ },
3383
+ {
3384
+ key: "increment",
3385
+ value: function increment(data, params) {
3386
+ return this.update(firestoreServerIncrementUpdateToUpdateData(data), params);
3387
+ }
3388
+ },
3389
+ {
3390
+ key: "arrayUpdate",
3391
+ value: function arrayUpdate(data, params) {
3392
+ return this.update(firestoreServerArrayUpdateToUpdateData(data), params);
3393
+ }
3394
+ },
3395
+ {
3396
+ key: "update",
3397
+ value: function update(data, params) {
3398
+ if ((params === null || params === void 0 ? void 0 : params.precondition) != null) {
3399
+ this.batch.update(this.documentRef, data, params.precondition);
3400
+ } else {
3401
+ this.batch.update(this.documentRef, data);
3402
+ }
3403
+ return Promise.resolve();
3404
+ }
3405
+ }
3406
+ ]);
3407
+ return WriteBatchFirestoreDocumentDataAccessor;
3408
+ }();
3409
+ /**
3410
+ * Creates a {@link FirestoreDocumentDataAccessorFactory} that produces batch-backed accessors.
3411
+ *
3412
+ * All accessors created from this factory share the same {@link WriteBatch}, so committing
3413
+ * the batch applies all queued writes atomically.
3414
+ *
3415
+ * @param writeBatch - The Google Cloud WriteBatch to queue operations into.
3416
+ * @returns A factory that creates batch-backed accessors sharing the given WriteBatch.
3417
+ *
3418
+ * @example
3419
+ * ```typescript
3420
+ * const batch = firestore.batch();
3421
+ * const factory = writeBatchAccessorFactory<User>(batch);
3422
+ * const accessor = factory.accessorFor(userDocRef);
3423
+ * await accessor.set({ name: 'Alice' });
3424
+ * await batch.commit();
3425
+ * ```
3426
+ */ function writeBatchAccessorFactory(writeBatch) {
3427
+ return {
3428
+ accessorFor: function accessorFor(ref) {
3429
+ return new WriteBatchFirestoreDocumentDataAccessor(writeBatch, ref);
3430
+ }
3431
+ };
3432
+ }
3433
+ // MARK: Context
3434
+ /**
3435
+ * A {@link FirestoreDocumentContext} backed by a Google Cloud {@link WriteBatch}.
3436
+ *
3437
+ * All document accessors created from this context queue writes into the same batch.
3438
+ */ var WriteBatchFirestoreDocumentContext = /*#__PURE__*/ function() {
3439
+ function WriteBatchFirestoreDocumentContext(batch) {
3440
+ _class_call_check$o(this, WriteBatchFirestoreDocumentContext);
3441
+ _define_property$v(this, "_batch", void 0);
3442
+ _define_property$v(this, "contextType", firebase.FirestoreDocumentContextType.BATCH);
3443
+ _define_property$v(this, "accessorFactory", void 0);
3444
+ this._batch = batch;
3445
+ this.accessorFactory = writeBatchAccessorFactory(batch);
3446
+ }
3447
+ _create_class$f(WriteBatchFirestoreDocumentContext, [
3448
+ {
3449
+ key: "batch",
3450
+ get: function get() {
3451
+ return this._batch;
3452
+ }
3453
+ }
3454
+ ]);
3455
+ return WriteBatchFirestoreDocumentContext;
3456
+ }();
3457
+ /**
3458
+ * Creates a {@link WriteBatchFirestoreDocumentContext} wrapping the given batch.
3459
+ *
3460
+ * @param batch - The Google Cloud WriteBatch to use.
3461
+ * @returns A new {@link WriteBatchFirestoreDocumentContext} for the given batch.
3462
+ */ function writeBatchDocumentContext(batch) {
3463
+ return new WriteBatchFirestoreDocumentContext(batch);
3464
+ }
3465
+
3466
+ function _class_call_check$n(instance, Constructor) {
3467
+ if (!(instance instanceof Constructor)) {
3468
+ throw new TypeError("Cannot call a class as a function");
3469
+ }
3470
+ }
3471
+ function _defineProperties$e(target, props) {
3472
+ for(var i = 0; i < props.length; i++){
3473
+ var descriptor = props[i];
3474
+ descriptor.enumerable = descriptor.enumerable || false;
3475
+ descriptor.configurable = true;
3476
+ if ("value" in descriptor) descriptor.writable = true;
3477
+ Object.defineProperty(target, descriptor.key, descriptor);
3478
+ }
3479
+ }
3480
+ function _create_class$e(Constructor, protoProps, staticProps) {
3481
+ if (protoProps) _defineProperties$e(Constructor.prototype, protoProps);
3482
+ return Constructor;
3483
+ }
3484
+ function _define_property$u(obj, key, value) {
3485
+ if (key in obj) {
3486
+ Object.defineProperty(obj, key, {
3487
+ value: value,
3488
+ enumerable: true,
3489
+ configurable: true,
3490
+ writable: true
3491
+ });
3492
+ } else {
3493
+ obj[key] = value;
3494
+ }
3495
+ return obj;
3496
+ }
3497
+ // MARK: Accessor
3498
+ /**
3499
+ * Default Google Cloud Firestore implementation of {@link FirestoreDocumentDataAccessor}.
3500
+ *
3501
+ * Performs all operations directly against the Firestore document reference without
3502
+ * batching or transactional context. Supports real-time streaming via `onSnapshot`.
3503
+ */ var DefaultFirestoreDocumentDataAccessor = /*#__PURE__*/ function() {
3504
+ function DefaultFirestoreDocumentDataAccessor(documentRef) {
3505
+ _class_call_check$n(this, DefaultFirestoreDocumentDataAccessor);
3506
+ _define_property$u(this, "_documentRef", void 0);
3507
+ this._documentRef = documentRef;
3508
+ }
3509
+ _create_class$e(DefaultFirestoreDocumentDataAccessor, [
3510
+ {
3511
+ key: "documentRef",
3512
+ get: function get() {
3513
+ return this._documentRef;
3514
+ }
3515
+ },
3516
+ {
3517
+ key: "stream",
3518
+ value: function stream() {
3519
+ var _this = this;
3520
+ return firebase.streamFromOnSnapshot(function(param) {
3521
+ var next = param.next, error = param.error;
3522
+ return _this.documentRef.onSnapshot(next, error);
3523
+ });
3524
+ }
3525
+ },
3526
+ {
3527
+ key: "create",
3528
+ value: function create(data) {
3529
+ return this.documentRef.create(data);
3530
+ }
3531
+ },
3532
+ {
3533
+ key: "exists",
3534
+ value: function exists() {
3535
+ return this.get().then(function(x) {
3536
+ return x.exists;
3537
+ });
3538
+ }
3539
+ },
3540
+ {
3541
+ key: "get",
3542
+ value: function get() {
3543
+ return this.documentRef.get();
3544
+ }
3545
+ },
3546
+ {
3547
+ key: "getWithConverter",
3548
+ value: function getWithConverter(converter) {
3549
+ return this.documentRef.withConverter(converter).get();
3550
+ }
3551
+ },
3552
+ {
3553
+ key: "delete",
3554
+ value: function _delete(params) {
3555
+ return this.documentRef.delete(params === null || params === void 0 ? void 0 : params.precondition);
3556
+ }
3557
+ },
3558
+ {
3559
+ key: "set",
3560
+ value: function set(data, options) {
3561
+ return options ? this.documentRef.set(data, options) : this.documentRef.set(data);
3562
+ }
3563
+ },
3564
+ {
3565
+ key: "increment",
3566
+ value: function increment(data, params) {
3567
+ return this.update(firestoreServerIncrementUpdateToUpdateData(data), params);
3568
+ }
3569
+ },
3570
+ {
3571
+ key: "arrayUpdate",
3572
+ value: function arrayUpdate(data, params) {
3573
+ return this.update(firestoreServerArrayUpdateToUpdateData(data), params);
3574
+ }
3575
+ },
3576
+ {
3577
+ key: "update",
3578
+ value: function update(data, params) {
3579
+ return (params === null || params === void 0 ? void 0 : params.precondition) ? this.documentRef.update(data, params.precondition) : this.documentRef.update(data);
3580
+ }
3079
3581
  }
3080
- var batches = util.batch(pathSegments, 2); // batch to tuple [string, string]
3081
- batches.forEach(function(x) {
3082
- var _x = _sliced_to_array$3(x, 2), first = _x[0], second = _x[1];
3083
- ref = ref.doc(first).collection(second);
3084
- });
3085
- }
3086
- return ref;
3087
- }
3582
+ ]);
3583
+ return DefaultFirestoreDocumentDataAccessor;
3584
+ }();
3088
3585
  /**
3089
- * Resolves a Firestore {@link DocumentReference} from a starting point, optional document path, and additional path segments.
3090
- *
3091
- * If no path is provided, auto-generates a document ID. Supports nested subcollection
3092
- * traversal via path segment pairs.
3586
+ * Creates a {@link FirestoreDocumentDataAccessorFactory} that produces default (non-batched, non-transactional) accessors.
3093
3587
  *
3094
- * @param start - A Firestore object that can resolve document paths (e.g., CollectionReference).
3095
- * @param path - Optional document ID or path within the collection.
3096
- * @param pathSegments - Optional pairs of [collectionName, docId] for subcollection traversal.
3097
- * @returns The resolved {@link DocumentReference} at the given path.
3588
+ * @returns A factory that creates default (non-batched, non-transactional) accessors.
3098
3589
  *
3099
3590
  * @example
3100
3591
  * ```typescript
3101
- * const ref = docRefForPath<User>(usersCollection, 'user123');
3102
- * const autoRef = docRefForPath<User>(usersCollection); // auto-generated ID
3592
+ * const factory = defaultFirestoreAccessorFactory<User>();
3593
+ * const accessor = factory.accessorFor(userDocRef);
3103
3594
  * ```
3104
- */ function docRefForPath(start, path, pathSegments) {
3105
- var doc = path ? start.doc(path) : start.doc();
3106
- if (pathSegments === null || pathSegments === void 0 ? void 0 : pathSegments.length) {
3107
- var batches = util.batch(pathSegments, 2); // batch to tuple [string, string]
3108
- batches.forEach(function(x) {
3109
- var _x = _sliced_to_array$3(x, 2), first = _x[0], second = _x[1];
3110
- var collection = doc.collection(first);
3111
- doc = second ? collection.doc(second) : collection.doc();
3112
- });
3113
- }
3114
- return doc;
3595
+ */ function defaultFirestoreAccessorFactory() {
3596
+ return {
3597
+ accessorFor: function accessorFor(ref) {
3598
+ return new DefaultFirestoreDocumentDataAccessor(ref);
3599
+ }
3600
+ };
3115
3601
  }
3602
+ // MARK: Context
3116
3603
  /**
3117
- * Creates a {@link FirestoreAccessorDriver} for Google Cloud Firestore (Admin SDK).
3118
- *
3119
- * Implements document/collection resolution, transaction/batch factories, and context factories
3120
- * using the `@google-cloud/firestore` library.
3604
+ * Creates a {@link FirestoreDocumentContext} with no special execution context (no batch, no transaction).
3121
3605
  *
3122
- * @returns A {@link FirestoreAccessorDriver} for the Google Cloud Admin SDK.
3606
+ * Operations performed through this context execute immediately against Firestore.
3123
3607
  *
3124
- * @example
3125
- * ```typescript
3126
- * const accessorDriver = googleCloudFirestoreAccessorDriver();
3127
- * ```
3128
- */ function googleCloudFirestoreAccessorDriver() {
3608
+ * @returns A {@link FirestoreDocumentContext} for direct Firestore operations.
3609
+ */ function defaultFirestoreDocumentContext() {
3129
3610
  return {
3130
- doc: function doc(collection, path) {
3131
- for(var _len = arguments.length, pathSegments = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
3132
- pathSegments[_key - 2] = arguments[_key];
3133
- }
3134
- return docRefForPath(collection, path, pathSegments);
3135
- },
3136
- docAtPath: function docAtPath(firestore, fullPath) {
3137
- return firestore.doc(fullPath);
3138
- },
3139
- collectionGroup: function collectionGroup(firestore, collectionId) {
3140
- return firestore.collectionGroup(collectionId);
3141
- },
3142
- collection: function collection(firestore, path) {
3143
- for(var _len = arguments.length, pathSegments = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
3144
- pathSegments[_key - 2] = arguments[_key];
3145
- }
3146
- return collectionRefForPath(firestore, path, pathSegments);
3147
- },
3148
- subcollection: function subcollection(document, path) {
3149
- for(var _len = arguments.length, pathSegments = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
3150
- pathSegments[_key - 2] = arguments[_key];
3151
- }
3152
- return collectionRefForPath(document, path, pathSegments);
3153
- },
3154
- transactionFactoryForFirestore: function transactionFactoryForFirestore(firestore) {
3155
- return function(fn) {
3156
- return _async_to_generator$e(function() {
3157
- return _ts_generator$e(this, function(_state) {
3158
- return [
3159
- 2,
3160
- firestore.runTransaction(fn)
3161
- ];
3162
- });
3163
- })();
3164
- };
3165
- },
3166
- writeBatchFactoryForFirestore: function writeBatchFactoryForFirestore(firestore) {
3167
- return function() {
3168
- return firestore.batch();
3169
- };
3170
- },
3171
- defaultContextFactory: defaultFirestoreDocumentContext,
3172
- transactionContextFactory: transactionDocumentContext,
3173
- writeBatchContextFactory: writeBatchDocumentContext
3611
+ contextType: firebase.FirestoreDocumentContextType.NONE,
3612
+ accessorFactory: defaultFirestoreAccessorFactory()
3174
3613
  };
3175
3614
  }
3176
3615
 
3177
- function _array_like_to_array$b(arr, len) {
3178
- if (len == null || len > arr.length) len = arr.length;
3179
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3180
- return arr2;
3616
+ function _class_call_check$m(instance, Constructor) {
3617
+ if (!(instance instanceof Constructor)) {
3618
+ throw new TypeError("Cannot call a class as a function");
3619
+ }
3181
3620
  }
3182
- function _array_without_holes$8(arr) {
3183
- if (Array.isArray(arr)) return _array_like_to_array$b(arr);
3621
+ function _defineProperties$d(target, props) {
3622
+ for(var i = 0; i < props.length; i++){
3623
+ var descriptor = props[i];
3624
+ descriptor.enumerable = descriptor.enumerable || false;
3625
+ descriptor.configurable = true;
3626
+ if ("value" in descriptor) descriptor.writable = true;
3627
+ Object.defineProperty(target, descriptor.key, descriptor);
3628
+ }
3184
3629
  }
3185
- function _define_property$s(obj, key, value) {
3630
+ function _create_class$d(Constructor, protoProps, staticProps) {
3631
+ if (protoProps) _defineProperties$d(Constructor.prototype, protoProps);
3632
+ return Constructor;
3633
+ }
3634
+ function _define_property$t(obj, key, value) {
3186
3635
  if (key in obj) {
3187
3636
  Object.defineProperty(obj, key, {
3188
3637
  value: value,
@@ -3195,242 +3644,173 @@ function _define_property$s(obj, key, value) {
3195
3644
  }
3196
3645
  return obj;
3197
3646
  }
3198
- function _iterable_to_array$8(iter) {
3199
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
3200
- }
3201
- function _non_iterable_spread$8() {
3202
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3203
- }
3204
- function _object_spread$g(target) {
3205
- for(var i = 1; i < arguments.length; i++){
3206
- var source = arguments[i] != null ? arguments[i] : {};
3207
- var ownKeys = Object.keys(source);
3208
- if (typeof Object.getOwnPropertySymbols === "function") {
3209
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3210
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3211
- }));
3212
- }
3213
- ownKeys.forEach(function(key) {
3214
- _define_property$s(target, key, source[key]);
3215
- });
3216
- }
3217
- return target;
3218
- }
3219
- function ownKeys$d(object, enumerableOnly) {
3220
- var keys = Object.keys(object);
3221
- if (Object.getOwnPropertySymbols) {
3222
- var symbols = Object.getOwnPropertySymbols(object);
3223
- keys.push.apply(keys, symbols);
3224
- }
3225
- return keys;
3226
- }
3227
- function _object_spread_props$d(target, source) {
3228
- source = source != null ? source : {};
3229
- if (Object.getOwnPropertyDescriptors) {
3230
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3231
- } else {
3232
- ownKeys$d(Object(source)).forEach(function(key) {
3233
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3234
- });
3235
- }
3236
- return target;
3237
- }
3238
- function _to_consumable_array$8(arr) {
3239
- return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$b(arr) || _non_iterable_spread$8();
3240
- }
3241
- function _unsupported_iterable_to_array$b(o, minLen) {
3242
- if (!o) return;
3243
- if (typeof o === "string") return _array_like_to_array$b(o, minLen);
3244
- var n = Object.prototype.toString.call(o).slice(8, -1);
3245
- if (n === "Object" && o.constructor) n = o.constructor.name;
3246
- if (n === "Map" || n === "Set") return Array.from(n);
3247
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
3248
- }
3249
- var _builder, _builder1;
3250
- var _obj;
3251
- /**
3252
- * Maps each abstract query constraint type to its Google Cloud Firestore implementation.
3253
- *
3254
- * Used by {@link firestoreClientQueryConstraintFunctionsDriver} to build the server-side query driver.
3255
- */ var FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING = (_obj = {}, _define_property$s(_obj, firebase.FIRESTORE_LIMIT_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3256
- return builder.limit(data.limit);
3257
- }), _define_property$s(_obj, firebase.FIRESTORE_LIMIT_TO_LAST_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3258
- return builder.limitToLast(data.limit);
3259
- }), _define_property$s(_obj, firebase.FIRESTORE_ORDER_BY_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3260
- return builder.orderBy(data.fieldPath, data.directionStr);
3261
- }), _define_property$s(_obj, firebase.FIRESTORE_ORDER_BY_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3262
- return builder.orderBy(firestore.FieldPath.documentId(), data.directionStr);
3263
- }), _define_property$s(_obj, firebase.FIRESTORE_WHERE_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3264
- return builder.where(data.fieldPath, data.opStr, data.value);
3265
- }), _define_property$s(_obj, firebase.FIRESTORE_WHERE_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3266
- return builder.where(firestore.FieldPath.documentId(), data.opStr, data.value);
3267
- }), _define_property$s(_obj, firebase.FIRESTORE_OFFSET_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3268
- return builder.offset(data.offset);
3269
- }), _define_property$s(_obj, firebase.FIRESTORE_START_AT_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3270
- return builder.startAt(data.snapshot);
3271
- }), _define_property$s(_obj, firebase.FIRESTORE_START_AT_VALUE_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3272
- return (_builder = builder).startAt.apply(_builder, _to_consumable_array$8(data.fieldValues));
3273
- }), _define_property$s(_obj, firebase.FIRESTORE_START_AFTER_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3274
- return builder.startAfter(data.snapshot);
3275
- }), _define_property$s(_obj, firebase.FIRESTORE_END_AT_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3276
- return builder.endAt(data.snapshot);
3277
- }), _define_property$s(_obj, firebase.FIRESTORE_END_AT_VALUE_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3278
- return (_builder1 = builder).endAt.apply(_builder1, _to_consumable_array$8(data.fieldValues));
3279
- }), _define_property$s(_obj, firebase.FIRESTORE_END_BEFORE_QUERY_CONSTRAINT_TYPE, function(builder, data) {
3280
- return builder.endBefore(data.snapshot);
3281
- }), _obj);
3647
+ // MARK: Accessor
3282
3648
  /**
3283
- * Creates a {@link FirestoreQueryConstraintFunctionsDriver} for the Google Cloud Firestore server SDK.
3284
- *
3285
- * Translates abstract query constraints into Google Cloud Firestore query builder calls.
3649
+ * Google Cloud Firestore implementation of {@link FirestoreDocumentDataAccessor} that executes
3650
+ * all operations within a Firestore {@link Transaction}.
3286
3651
  *
3287
- * @returns A {@link FirestoreQueryConstraintFunctionsDriver} for the server SDK.
3288
- */ function firestoreClientQueryConstraintFunctionsDriver() {
3289
- return firebase.makeFirestoreQueryConstraintFunctionsDriver({
3290
- mapping: FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING,
3291
- init: function init(query) {
3292
- return query;
3652
+ * Reads performed through this accessor are included in the transaction's read set, ensuring
3653
+ * consistency. Writes are committed atomically when the transaction completes.
3654
+ */ var TransactionFirestoreDocumentDataAccessor = /*#__PURE__*/ function() {
3655
+ function TransactionFirestoreDocumentDataAccessor(transaction, documentRef) {
3656
+ _class_call_check$m(this, TransactionFirestoreDocumentDataAccessor);
3657
+ _define_property$t(this, "_transaction", void 0);
3658
+ _define_property$t(this, "_documentRef", void 0);
3659
+ this._transaction = transaction;
3660
+ this._documentRef = documentRef;
3661
+ }
3662
+ _create_class$d(TransactionFirestoreDocumentDataAccessor, [
3663
+ {
3664
+ key: "transaction",
3665
+ get: function get() {
3666
+ return this._transaction;
3667
+ }
3668
+ },
3669
+ {
3670
+ key: "documentRef",
3671
+ get: function get() {
3672
+ return this._documentRef;
3673
+ }
3674
+ },
3675
+ {
3676
+ key: "stream",
3677
+ value: function stream() {
3678
+ return rxjs.from(this.get());
3679
+ }
3680
+ },
3681
+ {
3682
+ key: "create",
3683
+ value: function create(data) {
3684
+ this.transaction.create(this.documentRef, data);
3685
+ return Promise.resolve();
3686
+ }
3293
3687
  },
3294
- build: function build(query) {
3295
- return query;
3688
+ {
3689
+ key: "exists",
3690
+ value: function exists() {
3691
+ return this.get().then(function(x) {
3692
+ return x.exists;
3693
+ });
3694
+ }
3296
3695
  },
3297
- documentIdFieldPath: function documentIdFieldPath() {
3298
- return firestore.FieldPath.documentId();
3299
- }
3300
- });
3301
- }
3302
- /**
3303
- * Creates a complete {@link FirestoreQueryDriver} for Google Cloud Firestore (Admin SDK).
3304
- *
3305
- * Supports query execution (getDocs), document counting (countDocs), and real-time
3306
- * streaming (streamDocs) via `onSnapshot`. Transaction-aware reads are supported
3307
- * through the optional transaction parameter in `getDocs`.
3308
- *
3309
- * @returns A complete {@link FirestoreQueryDriver} for the Google Cloud Admin SDK.
3310
- *
3311
- * @example
3312
- * ```typescript
3313
- * const queryDriver = googleCloudFirestoreQueryDriver();
3314
- * ```
3315
- */ function googleCloudFirestoreQueryDriver() {
3316
- return _object_spread_props$d(_object_spread$g({}, firestoreClientQueryConstraintFunctionsDriver()), {
3317
- countDocs: function countDocs(query) {
3318
- return query.count().get().then(function(x) {
3319
- return x.data().count;
3320
- });
3696
+ {
3697
+ key: "get",
3698
+ value: function get() {
3699
+ return this.transaction.get(this.documentRef);
3700
+ }
3321
3701
  },
3322
- getDocs: function getDocs(query, transaction) {
3323
- var result;
3324
- if (transaction) {
3325
- result = transaction.get(query);
3326
- } else {
3327
- result = query.get();
3702
+ {
3703
+ key: "getWithConverter",
3704
+ value: function getWithConverter(converter) {
3705
+ return this.transaction.get(this.documentRef.withConverter(converter));
3328
3706
  }
3329
- return result;
3330
3707
  },
3331
- streamDocs: function streamDocs(query) {
3332
- return firebase.streamFromOnSnapshot(function(param) {
3333
- var next = param.next, error = param.error;
3334
- return query.onSnapshot(next, error);
3335
- });
3708
+ {
3709
+ key: "delete",
3710
+ value: function _delete() {
3711
+ this.transaction.delete(this.documentRef);
3712
+ return Promise.resolve();
3713
+ }
3714
+ },
3715
+ {
3716
+ key: "set",
3717
+ value: function set(data, options) {
3718
+ this.transaction.set(this.documentRef, data, options);
3719
+ return Promise.resolve();
3720
+ }
3721
+ },
3722
+ {
3723
+ key: "increment",
3724
+ value: function increment(data, params) {
3725
+ return this.update(firestoreServerIncrementUpdateToUpdateData(data), params);
3726
+ }
3727
+ },
3728
+ {
3729
+ key: "arrayUpdate",
3730
+ value: function arrayUpdate(data, params) {
3731
+ return this.update(firestoreServerArrayUpdateToUpdateData(data), params);
3732
+ }
3733
+ },
3734
+ {
3735
+ key: "update",
3736
+ value: function update(data, params) {
3737
+ if (params === null || params === void 0 ? void 0 : params.precondition) {
3738
+ this.transaction.update(this.documentRef, data, params.precondition);
3739
+ } else {
3740
+ this.transaction.update(this.documentRef, data);
3741
+ }
3742
+ return Promise.resolve();
3743
+ }
3336
3744
  }
3337
- });
3338
- }
3339
-
3745
+ ]);
3746
+ return TransactionFirestoreDocumentDataAccessor;
3747
+ }();
3340
3748
  /**
3341
- * Creates a complete set of {@link FirestoreDrivers} for Google Cloud Firestore (Admin SDK).
3749
+ * Creates a {@link FirestoreDocumentDataAccessorFactory} that produces transaction-backed accessors.
3342
3750
  *
3343
- * Bundles the server-side accessor driver and query driver, identified as `@google-cloud/firestore`.
3751
+ * All accessors share the same transaction, so reads and writes participate in the same
3752
+ * atomic operation.
3344
3753
  *
3345
- * @returns A complete set of {@link FirestoreDrivers} for the Google Cloud Admin SDK.
3754
+ * @param transaction - The Google Cloud Transaction to execute operations within.
3755
+ * @returns A factory that creates transaction-backed accessors sharing the given transaction.
3346
3756
  *
3347
3757
  * @example
3348
3758
  * ```typescript
3349
- * const drivers = googleCloudFirestoreDrivers();
3350
- * const context = firestoreContextFactory(drivers);
3759
+ * await firestore.runTransaction(async (transaction) => {
3760
+ * const factory = transactionAccessorFactory<User>(transaction);
3761
+ * const accessor = factory.accessorFor(userDocRef);
3762
+ * const snapshot = await accessor.get();
3763
+ * await accessor.update({ name: 'Updated' });
3764
+ * });
3351
3765
  * ```
3352
- */ function googleCloudFirestoreDrivers() {
3766
+ */ function transactionAccessorFactory(transaction) {
3353
3767
  return {
3354
- firestoreDriverIdentifier: '@google-cloud/firestore',
3355
- firestoreDriverType: 'production',
3356
- firestoreAccessorDriver: googleCloudFirestoreAccessorDriver(),
3357
- firestoreQueryDriver: googleCloudFirestoreQueryDriver()
3768
+ accessorFor: function accessorFor(ref) {
3769
+ return new TransactionFirestoreDocumentDataAccessor(transaction, ref);
3770
+ }
3358
3771
  };
3359
3772
  }
3360
-
3361
- /**
3362
- * Pre-configured {@link FirestoreContextFactory} for Google Cloud Firestore (Admin SDK) usage.
3363
- *
3364
- * Wires the server-side Firestore drivers into the abstract {@link FirestoreContextFactory}
3365
- * so that collections, documents, queries, and transactions all use the Admin SDK implementation.
3366
- *
3367
- * @example
3368
- * ```ts
3369
- * const context = googleCloudFirestoreContextFactory(firestore);
3370
- * ```
3371
- */ var googleCloudFirestoreContextFactory = firebase.firestoreContextFactory(googleCloudFirestoreDrivers());
3372
-
3373
- // MARK: Field Converters
3773
+ // MARK: Context
3374
3774
  /**
3375
- * Creates a Firestore field mapping that encrypts/decrypts a JSON-serializable value
3376
- * using AES-256-GCM. The value is stored in Firestore as a base64-encoded string.
3377
- *
3378
- * The encryption key is resolved from the configured secret source on each read/write,
3379
- * allowing for key rotation via environment variable changes.
3380
- *
3381
- * @example
3382
- * ```typescript
3383
- * const jwksField = firestoreEncryptedField<JWKSet>({
3384
- * secret: process.env['FIRESTORE_ENCRYPTION_KEY']!,
3385
- * default: () => ({ keys: [] })
3386
- * });
3387
- * ```
3775
+ * A {@link FirestoreDocumentContext} backed by a Google Cloud {@link Transaction}.
3388
3776
  *
3389
- * @template T - The JSON-serializable value type.
3390
- * @param config - Encryption field configuration.
3391
- * @returns A field mapping configuration for encrypted values.
3392
- */ function firestoreEncryptedField(config) {
3393
- var secret = config.secret, defaultValue = config.default;
3394
- var getKey = nestjs.resolveEncryptionKey(secret);
3395
- return firebase.firestoreField({
3396
- default: defaultValue,
3397
- fromData: function fromData(data) {
3398
- return nestjs.decryptValue(data, getKey());
3399
- },
3400
- toData: function toData(value) {
3401
- return nestjs.encryptValue(value, getKey());
3777
+ * All document accessors created from this context operate within the same transaction.
3778
+ */ var TransactionFirestoreDocumentContext = /*#__PURE__*/ function() {
3779
+ function TransactionFirestoreDocumentContext(transaction) {
3780
+ _class_call_check$m(this, TransactionFirestoreDocumentContext);
3781
+ _define_property$t(this, "_transaction", void 0);
3782
+ _define_property$t(this, "contextType", firebase.FirestoreDocumentContextType.TRANSACTION);
3783
+ _define_property$t(this, "accessorFactory", void 0);
3784
+ this._transaction = transaction;
3785
+ this.accessorFactory = transactionAccessorFactory(transaction);
3786
+ }
3787
+ _create_class$d(TransactionFirestoreDocumentContext, [
3788
+ {
3789
+ key: "transaction",
3790
+ get: function get() {
3791
+ return this._transaction;
3792
+ }
3402
3793
  }
3403
- });
3404
- }
3794
+ ]);
3795
+ return TransactionFirestoreDocumentContext;
3796
+ }();
3405
3797
  /**
3406
- * Creates a Firestore field mapping for an optional encrypted field.
3407
- *
3408
- * When the value is null/undefined, it is stored/read as null. When present, it is
3409
- * encrypted/decrypted using AES-256-GCM.
3410
- *
3411
- * @example
3412
- * ```typescript
3413
- * const optionalSecretField = optionalFirestoreEncryptedField<OAuthClientSecret>({
3414
- * secret: process.env['FIRESTORE_ENCRYPTION_KEY']!
3415
- * });
3416
- * ```
3798
+ * Creates a {@link TransactionFirestoreDocumentContext} wrapping the given transaction.
3417
3799
  *
3418
- * @template T - The JSON-serializable value type.
3419
- * @param config - Encryption field configuration.
3420
- * @returns A field mapping configuration for optional encrypted values.
3421
- */ function optionalFirestoreEncryptedField(config) {
3422
- var secret = config.secret;
3423
- var getKey = nestjs.resolveEncryptionKey(secret);
3424
- return firebase.optionalFirestoreField({
3425
- transformFromData: function transformFromData(data) {
3426
- return nestjs.decryptValue(data, getKey());
3427
- },
3428
- transformToData: function transformToData(value) {
3429
- return nestjs.encryptValue(value, getKey());
3430
- }
3431
- });
3800
+ * @param transaction - The Google Cloud Transaction to use.
3801
+ * @returns A new {@link TransactionFirestoreDocumentContext} for the given transaction.
3802
+ */ function transactionDocumentContext(transaction) {
3803
+ return new TransactionFirestoreDocumentContext(transaction);
3432
3804
  }
3433
3805
 
3806
+ function _array_like_to_array$c(arr, len) {
3807
+ if (len == null || len > arr.length) len = arr.length;
3808
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3809
+ return arr2;
3810
+ }
3811
+ function _array_with_holes$3(arr) {
3812
+ if (Array.isArray(arr)) return arr;
3813
+ }
3434
3814
  function asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, key, arg) {
3435
3815
  try {
3436
3816
  var info = gen[key](arg);
@@ -3445,20 +3825,58 @@ function asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, key, arg) {
3445
3825
  Promise.resolve(value).then(_next, _throw);
3446
3826
  }
3447
3827
  }
3448
- function _async_to_generator$d(fn) {
3449
- return function() {
3450
- var self = this, args = arguments;
3451
- return new Promise(function(resolve, reject) {
3452
- var gen = fn.apply(self, args);
3453
- function _next(value) {
3454
- asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, "next", value);
3455
- }
3456
- function _throw(err) {
3457
- asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, "throw", err);
3458
- }
3459
- _next(undefined);
3460
- });
3461
- };
3828
+ function _async_to_generator$d(fn) {
3829
+ return function() {
3830
+ var self = this, args = arguments;
3831
+ return new Promise(function(resolve, reject) {
3832
+ var gen = fn.apply(self, args);
3833
+ function _next(value) {
3834
+ asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, "next", value);
3835
+ }
3836
+ function _throw(err) {
3837
+ asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, "throw", err);
3838
+ }
3839
+ _next(undefined);
3840
+ });
3841
+ };
3842
+ }
3843
+ function _iterable_to_array_limit$3(arr, i) {
3844
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
3845
+ if (_i == null) return;
3846
+ var _arr = [];
3847
+ var _n = true;
3848
+ var _d = false;
3849
+ var _s, _e;
3850
+ try {
3851
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
3852
+ _arr.push(_s.value);
3853
+ if (i && _arr.length === i) break;
3854
+ }
3855
+ } catch (err) {
3856
+ _d = true;
3857
+ _e = err;
3858
+ } finally{
3859
+ try {
3860
+ if (!_n && _i["return"] != null) _i["return"]();
3861
+ } finally{
3862
+ if (_d) throw _e;
3863
+ }
3864
+ }
3865
+ return _arr;
3866
+ }
3867
+ function _non_iterable_rest$3() {
3868
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3869
+ }
3870
+ function _sliced_to_array$3(arr, i) {
3871
+ return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$c(arr, i) || _non_iterable_rest$3();
3872
+ }
3873
+ function _unsupported_iterable_to_array$c(o, minLen) {
3874
+ if (!o) return;
3875
+ if (typeof o === "string") return _array_like_to_array$c(o, minLen);
3876
+ var n = Object.prototype.toString.call(o).slice(8, -1);
3877
+ if (n === "Object" && o.constructor) n = o.constructor.name;
3878
+ if (n === "Map" || n === "Set") return Array.from(n);
3879
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
3462
3880
  }
3463
3881
  function _ts_generator$d(thisArg, body) {
3464
3882
  var f, y, t, _ = {
@@ -3552,166 +3970,385 @@ function _ts_generator$d(thisArg, body) {
3552
3970
  } finally{
3553
3971
  f = t = 0;
3554
3972
  }
3555
- if (op[0] & 5) throw op[1];
3556
- return {
3557
- value: op[0] ? op[1] : void 0,
3558
- done: true
3559
- };
3560
- }
3973
+ if (op[0] & 5) throw op[1];
3974
+ return {
3975
+ value: op[0] ? op[1] : void 0,
3976
+ done: true
3977
+ };
3978
+ }
3979
+ }
3980
+ /**
3981
+ * Resolves a Firestore {@link CollectionReference} from a starting point and optional additional path segments.
3982
+ *
3983
+ * Supports nested subcollection paths by processing segments in pairs (doc ID, collection name).
3984
+ *
3985
+ * @param start - A Firestore object that can resolve collection paths (e.g., Firestore instance, DocumentReference).
3986
+ * @param path - The initial collection path.
3987
+ * @param pathSegments - Optional pairs of [docId, collectionName] for subcollection traversal.
3988
+ * @returns The resolved {@link CollectionReference} at the given path.
3989
+ * @throws Error if pathSegments length is odd (segments must come in pairs).
3990
+ *
3991
+ * @example
3992
+ * ```typescript
3993
+ * const ref = collectionRefForPath<User>(firestore, 'users');
3994
+ * const subRef = collectionRefForPath<Comment>(firestore, 'users', ['user123', 'comments']);
3995
+ * ```
3996
+ */ function collectionRefForPath(start, path, pathSegments) {
3997
+ var ref = start.collection(path);
3998
+ if (pathSegments === null || pathSegments === void 0 ? void 0 : pathSegments.length) {
3999
+ if (pathSegments.length % 2 !== 0) {
4000
+ throw new Error('Invalid number of path segments provided for collection. Path: "'.concat(path, '" + "').concat(pathSegments, '"'));
4001
+ }
4002
+ var batches = util.batch(pathSegments, 2); // batch to tuple [string, string]
4003
+ batches.forEach(function(x) {
4004
+ var _x = _sliced_to_array$3(x, 2), first = _x[0], second = _x[1];
4005
+ ref = ref.doc(first).collection(second);
4006
+ });
4007
+ }
4008
+ return ref;
4009
+ }
4010
+ /**
4011
+ * Resolves a Firestore {@link DocumentReference} from a starting point, optional document path, and additional path segments.
4012
+ *
4013
+ * If no path is provided, auto-generates a document ID. Supports nested subcollection
4014
+ * traversal via path segment pairs.
4015
+ *
4016
+ * @param start - A Firestore object that can resolve document paths (e.g., CollectionReference).
4017
+ * @param path - Optional document ID or path within the collection.
4018
+ * @param pathSegments - Optional pairs of [collectionName, docId] for subcollection traversal.
4019
+ * @returns The resolved {@link DocumentReference} at the given path.
4020
+ *
4021
+ * @example
4022
+ * ```typescript
4023
+ * const ref = docRefForPath<User>(usersCollection, 'user123');
4024
+ * const autoRef = docRefForPath<User>(usersCollection); // auto-generated ID
4025
+ * ```
4026
+ */ function docRefForPath(start, path, pathSegments) {
4027
+ var doc = path ? start.doc(path) : start.doc();
4028
+ if (pathSegments === null || pathSegments === void 0 ? void 0 : pathSegments.length) {
4029
+ var batches = util.batch(pathSegments, 2); // batch to tuple [string, string]
4030
+ batches.forEach(function(x) {
4031
+ var _x = _sliced_to_array$3(x, 2), first = _x[0], second = _x[1];
4032
+ var collection = doc.collection(first);
4033
+ doc = second ? collection.doc(second) : collection.doc();
4034
+ });
4035
+ }
4036
+ return doc;
4037
+ }
4038
+ /**
4039
+ * Creates a {@link FirestoreAccessorDriver} for Google Cloud Firestore (Admin SDK).
4040
+ *
4041
+ * Implements document/collection resolution, transaction/batch factories, and context factories
4042
+ * using the `@google-cloud/firestore` library.
4043
+ *
4044
+ * @returns A {@link FirestoreAccessorDriver} for the Google Cloud Admin SDK.
4045
+ *
4046
+ * @example
4047
+ * ```typescript
4048
+ * const accessorDriver = googleCloudFirestoreAccessorDriver();
4049
+ * ```
4050
+ */ function googleCloudFirestoreAccessorDriver() {
4051
+ return {
4052
+ doc: function doc(collection, path) {
4053
+ for(var _len = arguments.length, pathSegments = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
4054
+ pathSegments[_key - 2] = arguments[_key];
4055
+ }
4056
+ return docRefForPath(collection, path, pathSegments);
4057
+ },
4058
+ docAtPath: function docAtPath(firestore, fullPath) {
4059
+ return firestore.doc(fullPath);
4060
+ },
4061
+ collectionGroup: function collectionGroup(firestore, collectionId) {
4062
+ return firestore.collectionGroup(collectionId);
4063
+ },
4064
+ collection: function collection(firestore, path) {
4065
+ for(var _len = arguments.length, pathSegments = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
4066
+ pathSegments[_key - 2] = arguments[_key];
4067
+ }
4068
+ return collectionRefForPath(firestore, path, pathSegments);
4069
+ },
4070
+ subcollection: function subcollection(document, path) {
4071
+ for(var _len = arguments.length, pathSegments = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
4072
+ pathSegments[_key - 2] = arguments[_key];
4073
+ }
4074
+ return collectionRefForPath(document, path, pathSegments);
4075
+ },
4076
+ transactionFactoryForFirestore: function transactionFactoryForFirestore(firestore) {
4077
+ return function(fn) {
4078
+ return _async_to_generator$d(function() {
4079
+ return _ts_generator$d(this, function(_state) {
4080
+ return [
4081
+ 2,
4082
+ firestore.runTransaction(fn)
4083
+ ];
4084
+ });
4085
+ })();
4086
+ };
4087
+ },
4088
+ writeBatchFactoryForFirestore: function writeBatchFactoryForFirestore(firestore) {
4089
+ return function() {
4090
+ return firestore.batch();
4091
+ };
4092
+ },
4093
+ defaultContextFactory: defaultFirestoreDocumentContext,
4094
+ transactionContextFactory: transactionDocumentContext,
4095
+ writeBatchContextFactory: writeBatchDocumentContext
4096
+ };
4097
+ }
4098
+
4099
+ function _array_like_to_array$b(arr, len) {
4100
+ if (len == null || len > arr.length) len = arr.length;
4101
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4102
+ return arr2;
4103
+ }
4104
+ function _array_without_holes$8(arr) {
4105
+ if (Array.isArray(arr)) return _array_like_to_array$b(arr);
4106
+ }
4107
+ function _define_property$s(obj, key, value) {
4108
+ if (key in obj) {
4109
+ Object.defineProperty(obj, key, {
4110
+ value: value,
4111
+ enumerable: true,
4112
+ configurable: true,
4113
+ writable: true
4114
+ });
4115
+ } else {
4116
+ obj[key] = value;
4117
+ }
4118
+ return obj;
4119
+ }
4120
+ function _iterable_to_array$8(iter) {
4121
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
4122
+ }
4123
+ function _non_iterable_spread$8() {
4124
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4125
+ }
4126
+ function _object_spread$g(target) {
4127
+ for(var i = 1; i < arguments.length; i++){
4128
+ var source = arguments[i] != null ? arguments[i] : {};
4129
+ var ownKeys = Object.keys(source);
4130
+ if (typeof Object.getOwnPropertySymbols === "function") {
4131
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4132
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4133
+ }));
4134
+ }
4135
+ ownKeys.forEach(function(key) {
4136
+ _define_property$s(target, key, source[key]);
4137
+ });
4138
+ }
4139
+ return target;
4140
+ }
4141
+ function ownKeys$d(object, enumerableOnly) {
4142
+ var keys = Object.keys(object);
4143
+ if (Object.getOwnPropertySymbols) {
4144
+ var symbols = Object.getOwnPropertySymbols(object);
4145
+ keys.push.apply(keys, symbols);
4146
+ }
4147
+ return keys;
4148
+ }
4149
+ function _object_spread_props$d(target, source) {
4150
+ source = source != null ? source : {};
4151
+ if (Object.getOwnPropertyDescriptors) {
4152
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4153
+ } else {
4154
+ ownKeys$d(Object(source)).forEach(function(key) {
4155
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4156
+ });
4157
+ }
4158
+ return target;
4159
+ }
4160
+ function _to_consumable_array$8(arr) {
4161
+ return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$b(arr) || _non_iterable_spread$8();
4162
+ }
4163
+ function _unsupported_iterable_to_array$b(o, minLen) {
4164
+ if (!o) return;
4165
+ if (typeof o === "string") return _array_like_to_array$b(o, minLen);
4166
+ var n = Object.prototype.toString.call(o).slice(8, -1);
4167
+ if (n === "Object" && o.constructor) n = o.constructor.name;
4168
+ if (n === "Map" || n === "Set") return Array.from(n);
4169
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
4170
+ }
4171
+ var _builder, _builder1;
4172
+ var _obj;
4173
+ /**
4174
+ * Maps each abstract query constraint type to its Google Cloud Firestore implementation.
4175
+ *
4176
+ * Used by {@link firestoreClientQueryConstraintFunctionsDriver} to build the server-side query driver.
4177
+ */ var FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING = (_obj = {}, _define_property$s(_obj, firebase.FIRESTORE_LIMIT_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4178
+ return builder.limit(data.limit);
4179
+ }), _define_property$s(_obj, firebase.FIRESTORE_LIMIT_TO_LAST_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4180
+ return builder.limitToLast(data.limit);
4181
+ }), _define_property$s(_obj, firebase.FIRESTORE_ORDER_BY_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4182
+ return builder.orderBy(data.fieldPath, data.directionStr);
4183
+ }), _define_property$s(_obj, firebase.FIRESTORE_ORDER_BY_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4184
+ return builder.orderBy(firestore.FieldPath.documentId(), data.directionStr);
4185
+ }), _define_property$s(_obj, firebase.FIRESTORE_WHERE_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4186
+ return builder.where(data.fieldPath, data.opStr, data.value);
4187
+ }), _define_property$s(_obj, firebase.FIRESTORE_WHERE_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4188
+ return builder.where(firestore.FieldPath.documentId(), data.opStr, data.value);
4189
+ }), _define_property$s(_obj, firebase.FIRESTORE_OFFSET_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4190
+ return builder.offset(data.offset);
4191
+ }), _define_property$s(_obj, firebase.FIRESTORE_START_AT_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4192
+ return builder.startAt(data.snapshot);
4193
+ }), _define_property$s(_obj, firebase.FIRESTORE_START_AT_VALUE_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4194
+ return (_builder = builder).startAt.apply(_builder, _to_consumable_array$8(data.fieldValues));
4195
+ }), _define_property$s(_obj, firebase.FIRESTORE_START_AFTER_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4196
+ return builder.startAfter(data.snapshot);
4197
+ }), _define_property$s(_obj, firebase.FIRESTORE_END_AT_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4198
+ return builder.endAt(data.snapshot);
4199
+ }), _define_property$s(_obj, firebase.FIRESTORE_END_AT_VALUE_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4200
+ return (_builder1 = builder).endAt.apply(_builder1, _to_consumable_array$8(data.fieldValues));
4201
+ }), _define_property$s(_obj, firebase.FIRESTORE_END_BEFORE_QUERY_CONSTRAINT_TYPE, function(builder, data) {
4202
+ return builder.endBefore(data.snapshot);
4203
+ }), _obj);
4204
+ /**
4205
+ * Creates a {@link FirestoreQueryConstraintFunctionsDriver} for the Google Cloud Firestore server SDK.
4206
+ *
4207
+ * Translates abstract query constraints into Google Cloud Firestore query builder calls.
4208
+ *
4209
+ * @returns A {@link FirestoreQueryConstraintFunctionsDriver} for the server SDK.
4210
+ */ function firestoreClientQueryConstraintFunctionsDriver() {
4211
+ return firebase.makeFirestoreQueryConstraintFunctionsDriver({
4212
+ mapping: FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING,
4213
+ init: function init(query) {
4214
+ return query;
4215
+ },
4216
+ build: function build(query) {
4217
+ return query;
4218
+ },
4219
+ documentIdFieldPath: function documentIdFieldPath() {
4220
+ return firestore.FieldPath.documentId();
4221
+ }
4222
+ });
3561
4223
  }
3562
4224
  /**
3563
- * Asserts that the callable context contains auth data with a valid UID.
4225
+ * Creates a complete {@link FirestoreQueryDriver} for Google Cloud Firestore (Admin SDK).
3564
4226
  *
3565
- * @param context - The callable context to check for auth data.
3566
- * @throws {HttpsError} Throws unauthenticated error if no auth data is present.
4227
+ * Supports query execution (getDocs), document counting (countDocs), and real-time
4228
+ * streaming (streamDocs) via `onSnapshot`. Transaction-aware reads are supported
4229
+ * through the optional transaction parameter in `getDocs`.
4230
+ *
4231
+ * @returns A complete {@link FirestoreQueryDriver} for the Google Cloud Admin SDK.
3567
4232
  *
3568
4233
  * @example
3569
4234
  * ```typescript
3570
- * assertContextHasAuth(context);
3571
- * // Safe to access context.auth.uid
4235
+ * const queryDriver = googleCloudFirestoreQueryDriver();
3572
4236
  * ```
3573
- */ function assertContextHasAuth(context) {
3574
- if (!isContextWithAuthData(context)) {
3575
- throw unauthenticatedContextHasNoUidError();
3576
- }
4237
+ */ function googleCloudFirestoreQueryDriver() {
4238
+ return _object_spread_props$d(_object_spread$g({}, firestoreClientQueryConstraintFunctionsDriver()), {
4239
+ countDocs: function countDocs(query) {
4240
+ return query.count().get().then(function(x) {
4241
+ return x.data().count;
4242
+ });
4243
+ },
4244
+ getDocs: function getDocs(query, transaction) {
4245
+ var result;
4246
+ if (transaction) {
4247
+ result = transaction.get(query);
4248
+ } else {
4249
+ result = query.get();
4250
+ }
4251
+ return result;
4252
+ },
4253
+ streamDocs: function streamDocs(query) {
4254
+ return firebase.streamFromOnSnapshot(function(param) {
4255
+ var next = param.next, error = param.error;
4256
+ return query.onSnapshot(next, error);
4257
+ });
4258
+ }
4259
+ });
3577
4260
  }
4261
+
3578
4262
  /**
3579
- * Loads the snapshot data from a Firestore document, throwing if the document does not exist.
4263
+ * Creates a complete set of {@link FirestoreDrivers} for Google Cloud Firestore (Admin SDK).
3580
4264
  *
3581
- * @param document - The Firestore document to load data from.
3582
- * @param message - Optional custom error message.
3583
- * @returns The document's snapshot data.
3584
- * @throws {HttpsError} Throws a {@link modelNotAvailableError} (404) if the document has no data.
4265
+ * Bundles the server-side accessor driver and query driver, identified as `@google-cloud/firestore`.
4266
+ *
4267
+ * @returns A complete set of {@link FirestoreDrivers} for the Google Cloud Admin SDK.
3585
4268
  *
3586
4269
  * @example
3587
4270
  * ```typescript
3588
- * const userData = await assertSnapshotData(userDocument);
4271
+ * const drivers = googleCloudFirestoreDrivers();
4272
+ * const context = firestoreContextFactory(drivers);
3589
4273
  * ```
3590
- */ function assertSnapshotData(document, message) {
3591
- return _async_to_generator$d(function() {
3592
- var data;
3593
- return _ts_generator$d(this, function(_state) {
3594
- switch(_state.label){
3595
- case 0:
3596
- return [
3597
- 4,
3598
- document.snapshotData()
3599
- ];
3600
- case 1:
3601
- data = _state.sent();
3602
- if (data == null) {
3603
- throw modelNotAvailableError({
3604
- message: message !== null && message !== void 0 ? message : "The ".concat(document.modelType, " was unavailable.")
3605
- });
3606
- }
3607
- return [
3608
- 2,
3609
- data
3610
- ];
3611
- }
3612
- });
3613
- })();
4274
+ */ function googleCloudFirestoreDrivers() {
4275
+ return {
4276
+ firestoreDriverIdentifier: '@google-cloud/firestore',
4277
+ firestoreDriverType: 'production',
4278
+ firestoreAccessorDriver: googleCloudFirestoreAccessorDriver(),
4279
+ firestoreQueryDriver: googleCloudFirestoreQueryDriver()
4280
+ };
3614
4281
  }
4282
+
3615
4283
  /**
3616
- * Loads snapshot data and attaches the document's `id` and `key` to the result.
4284
+ * Pre-configured {@link FirestoreContextFactory} for Google Cloud Firestore (Admin SDK) usage.
3617
4285
  *
3618
- * Combines {@link assertSnapshotData} with {@link setIdAndKeyFromKeyIdRefOnDocumentData}.
4286
+ * Wires the server-side Firestore drivers into the abstract {@link FirestoreContextFactory}
4287
+ * so that collections, documents, queries, and transactions all use the Admin SDK implementation.
3619
4288
  *
3620
- * @param document - The Firestore document to load data from.
3621
- * @param message - Optional custom error message.
3622
- * @returns The document's snapshot data with `id` and `key` attached.
3623
- * @throws {HttpsError} Throws a {@link modelNotAvailableError} (404) if the document has no data.
3624
- */ function assertSnapshotDataWithKey(document, message) {
3625
- return _async_to_generator$d(function() {
3626
- var data;
3627
- return _ts_generator$d(this, function(_state) {
3628
- switch(_state.label){
3629
- case 0:
3630
- return [
3631
- 4,
3632
- assertSnapshotData(document, message)
3633
- ];
3634
- case 1:
3635
- data = _state.sent();
3636
- return [
3637
- 2,
3638
- firebase.setIdAndKeyFromKeyIdRefOnDocumentData(data, document)
3639
- ];
3640
- }
3641
- });
3642
- })();
3643
- }
4289
+ * @example
4290
+ * ```ts
4291
+ * const context = googleCloudFirestoreContextFactory(firestore);
4292
+ * ```
4293
+ */ var googleCloudFirestoreContextFactory = firebase.firestoreContextFactory(googleCloudFirestoreDrivers());
4294
+
4295
+ // MARK: Field Converters
3644
4296
  /**
3645
- * Asserts that the Firestore document exists without loading its data.
4297
+ * Creates a Firestore field mapping that encrypts/decrypts a JSON-serializable value
4298
+ * using AES-256-GCM. The value is stored in Firestore as a base64-encoded string.
3646
4299
  *
3647
- * @param document - The Firestore document to check.
3648
- * @param message - Optional custom error message.
3649
- * @throws {HttpsError} Throws a {@link modelNotAvailableError} (404) if the document does not exist.
3650
- */ function assertDocumentExists(document, message) {
3651
- return _async_to_generator$d(function() {
3652
- var exists;
3653
- return _ts_generator$d(this, function(_state) {
3654
- switch(_state.label){
3655
- case 0:
3656
- return [
3657
- 4,
3658
- document.exists()
3659
- ];
3660
- case 1:
3661
- exists = _state.sent();
3662
- if (!exists) {
3663
- throw documentModelNotAvailableError(document, message);
3664
- }
3665
- return [
3666
- 2
3667
- ];
3668
- }
3669
- });
3670
- })();
3671
- }
3672
- /**
3673
- * Creates a {@link modelNotAvailableError} for the given document's model type.
4300
+ * The encryption key is resolved from the configured secret source on each read/write,
4301
+ * allowing for key rotation via environment variable changes.
3674
4302
  *
3675
- * Used by {@link assertDocumentExists} and other assertion functions.
4303
+ * @example
4304
+ * ```typescript
4305
+ * const jwksField = firestoreEncryptedField<JWKSet>({
4306
+ * secret: process.env['FIRESTORE_ENCRYPTION_KEY']!,
4307
+ * default: () => ({ keys: [] })
4308
+ * });
4309
+ * ```
3676
4310
  *
3677
- * @param document - The document (or object with `modelType`) to generate the error for.
3678
- * @param message - Optional custom error message.
3679
- * @returns A {@link modelNotAvailableError} with the document's model type in the message.
3680
- */ function documentModelNotAvailableError(document, message) {
3681
- return modelNotAvailableError({
3682
- message: message !== null && message !== void 0 ? message : "The ".concat(document.modelType, " was unavailable.")
4311
+ * @template T - The JSON-serializable value type.
4312
+ * @param config - Encryption field configuration.
4313
+ * @returns A field mapping configuration for encrypted values.
4314
+ */ function firestoreEncryptedField(config) {
4315
+ var secret = config.secret, defaultValue = config.default;
4316
+ var getKey = nestjs.resolveEncryptionKey(secret);
4317
+ return firebase.firestoreField({
4318
+ default: defaultValue,
4319
+ fromData: function fromData(data) {
4320
+ return nestjs.decryptValue(data, getKey());
4321
+ },
4322
+ toData: function toData(value) {
4323
+ return nestjs.encryptValue(value, getKey());
4324
+ }
3683
4325
  });
3684
4326
  }
3685
-
3686
- /**
3687
- * Error code for when a phone number is already registered in Firebase Auth.
3688
- */ var PHONE_NUMBER_ALREADY_EXISTS_ERROR_CODE = 'PHONE_NUMBER_ALREADY_EXISTS';
3689
4327
  /**
3690
- * Creates a precondition conflict (409) error indicating the phone number already exists.
4328
+ * Creates a Firestore field mapping for an optional encrypted field.
3691
4329
  *
3692
- * @returns A new precondition-conflict (409) {@link HttpsError} with the phone-number-exists code.
3693
- */ function phoneNumberAlreadyExistsError() {
3694
- return preconditionConflictError({
3695
- code: PHONE_NUMBER_ALREADY_EXISTS_ERROR_CODE,
3696
- message: 'This phone number already exists in the system.'
3697
- });
3698
- }
3699
- /**
3700
- * Handles Firebase Auth errors by mapping known error codes to typed HTTP errors.
4330
+ * When the value is null/undefined, it is stored/read as null. When present, it is
4331
+ * encrypted/decrypted using AES-256-GCM.
3701
4332
  *
3702
- * Currently maps `auth/phone-number-already-exists` to a 409 conflict error.
3703
- * Unknown error codes are forwarded to the optional handler.
4333
+ * @example
4334
+ * ```typescript
4335
+ * const optionalSecretField = optionalFirestoreEncryptedField<OAuthClientSecret>({
4336
+ * secret: process.env['FIRESTORE_ENCRYPTION_KEY']!
4337
+ * });
4338
+ * ```
3704
4339
  *
3705
- * @param e - The caught error.
3706
- * @param handleUnknownCode - Optional handler for Firebase errors with unrecognized codes.
3707
- */ function handleFirebaseAuthError(e, handleUnknownCode) {
3708
- handleFirebaseError(e, function(firebaseError) {
3709
- switch(firebaseError.code){
3710
- case firebase.FIREBASE_AUTH_PHONE_NUMBER_ALREADY_EXISTS_ERROR:
3711
- throw phoneNumberAlreadyExistsError();
3712
- default:
3713
- handleUnknownCode === null || handleUnknownCode === void 0 ? void 0 : handleUnknownCode(firebaseError);
3714
- break;
4340
+ * @template T - The JSON-serializable value type.
4341
+ * @param config - Encryption field configuration.
4342
+ * @returns A field mapping configuration for optional encrypted values.
4343
+ */ function optionalFirestoreEncryptedField(config) {
4344
+ var secret = config.secret;
4345
+ var getKey = nestjs.resolveEncryptionKey(secret);
4346
+ return firebase.optionalFirestoreField({
4347
+ transformFromData: function transformFromData(data) {
4348
+ return nestjs.decryptValue(data, getKey());
4349
+ },
4350
+ transformToData: function transformToData(value) {
4351
+ return nestjs.encryptValue(value, getKey());
3715
4352
  }
3716
4353
  });
3717
4354
  }
@@ -4760,9 +5397,8 @@ function resolveAnalyticsFromApiDetails(apiDetails, call, modelType, specifier)
4760
5397
  if (handler != null) {
4761
5398
  assertRequestRequiresAuthForFunction(handler, request);
4762
5399
  return handler(request);
4763
- } else {
4764
- throw unknownModelCrudFunctionSpecifierError(specifier);
4765
5400
  }
5401
+ throw unknownModelCrudFunctionSpecifierError(specifier);
4766
5402
  };
4767
5403
  fn._requireAuth = false;
4768
5404
  // Aggregate _apiDetails from handler functions in the config
@@ -4984,9 +5620,8 @@ function _object_spread_props$c(target, source) {
4984
5620
  specifier: specifier,
4985
5621
  data: request.data.data
4986
5622
  }));
4987
- } else {
4988
- throw throwOnUnknownModelType(modelType);
4989
5623
  }
5624
+ throw throwOnUnknownModelType(modelType);
4990
5625
  };
4991
5626
  // Aggregate _apiDetails from model type handlers in the map
4992
5627
  var crudModelApiDetails = aggregateCrudModelApiDetails(map);
@@ -7491,9 +8126,8 @@ function _object_spread_props$8(target, source) {
7491
8126
  specifier: specifier,
7492
8127
  data: request.data.data
7493
8128
  }));
7494
- } else {
7495
- throw developmentUnknownSpecifierError(specifier);
7496
8129
  }
8130
+ throw developmentUnknownSpecifierError(specifier);
7497
8131
  };
7498
8132
  }
7499
8133
  /**
@@ -11988,9 +12622,11 @@ exports.AbstractFirebaseServerAuthContext = AbstractFirebaseServerAuthContext;
11988
12622
  exports.AbstractFirebaseServerAuthService = AbstractFirebaseServerAuthService;
11989
12623
  exports.AbstractFirebaseServerAuthUserContext = AbstractFirebaseServerAuthUserContext;
11990
12624
  exports.AbstractFirebaseServerNewUserService = AbstractFirebaseServerNewUserService;
12625
+ exports.AbstractFirebaseServerUserPasswordResetService = AbstractFirebaseServerUserPasswordResetService;
11991
12626
  exports.AbstractNestContext = AbstractNestContext;
11992
12627
  exports.AbstractServerFirebaseNestContext = AbstractServerFirebaseNestContext;
11993
12628
  exports.DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR = DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR;
12629
+ exports.DEFAULT_RESET_COM_THROTTLE_TIME = DEFAULT_RESET_COM_THROTTLE_TIME;
11994
12630
  exports.DEFAULT_SERVER_ASSETS_BASE_PATH = DEFAULT_SERVER_ASSETS_BASE_PATH;
11995
12631
  exports.DEFAULT_SETUP_COM_THROTTLE_TIME = DEFAULT_SETUP_COM_THROTTLE_TIME;
11996
12632
  exports.FIREBASE_APP_TOKEN = FIREBASE_APP_TOKEN;
@@ -12009,6 +12645,10 @@ exports.FirebaseServerAnalyticsServiceListener = FirebaseServerAnalyticsServiceL
12009
12645
  exports.FirebaseServerAuthNewUserSendSetupDetailsNoSetupConfigError = FirebaseServerAuthNewUserSendSetupDetailsNoSetupConfigError;
12010
12646
  exports.FirebaseServerAuthNewUserSendSetupDetailsSendOnceError = FirebaseServerAuthNewUserSendSetupDetailsSendOnceError;
12011
12647
  exports.FirebaseServerAuthNewUserSendSetupDetailsThrottleError = FirebaseServerAuthNewUserSendSetupDetailsThrottleError;
12648
+ exports.FirebaseServerAuthPasswordResetInvalidCodeError = FirebaseServerAuthPasswordResetInvalidCodeError;
12649
+ exports.FirebaseServerAuthPasswordResetNoResetConfigError = FirebaseServerAuthPasswordResetNoResetConfigError;
12650
+ exports.FirebaseServerAuthPasswordResetSendOnceError = FirebaseServerAuthPasswordResetSendOnceError;
12651
+ exports.FirebaseServerAuthPasswordResetThrottleError = FirebaseServerAuthPasswordResetThrottleError;
12012
12652
  exports.FirebaseServerAuthService = FirebaseServerAuthService;
12013
12653
  exports.FirebaseServerAuthUserBadInputError = FirebaseServerAuthUserBadInputError;
12014
12654
  exports.FirebaseServerAuthUserExistsError = FirebaseServerAuthUserExistsError;
@@ -12019,6 +12659,7 @@ exports.MAX_MODEL_ACCESS_MULTI_READ_KEYS = MAX_MODEL_ACCESS_MULTI_READ_KEYS;
12019
12659
  exports.MODEL_API_NEST_APPLICATION_CONTEXT = MODEL_API_NEST_APPLICATION_CONTEXT;
12020
12660
  exports.ModelApiDispatchConfig = ModelApiDispatchConfig;
12021
12661
  exports.NO_RUN_NAME_SPECIFIED_FOR_SCHEDULED_FUNCTION_DEVELOPMENT_FUNCTION_CODE = NO_RUN_NAME_SPECIFIED_FOR_SCHEDULED_FUNCTION_DEVELOPMENT_FUNCTION_CODE;
12662
+ exports.NoContentFirebaseServerUserPasswordResetService = NoContentFirebaseServerUserPasswordResetService;
12022
12663
  exports.NoSetupContentFirebaseServerNewUserService = NoSetupContentFirebaseServerNewUserService;
12023
12664
  exports.ON_CALL_MODEL_ANALYTICS_HANDLER = ON_CALL_MODEL_ANALYTICS_HANDLER;
12024
12665
  exports.ON_CALL_MODEL_ANALYTICS_SERVICE = ON_CALL_MODEL_ANALYTICS_SERVICE;
@@ -12044,10 +12685,15 @@ exports.assertIsContextWithAuthData = assertIsContextWithAuthData;
12044
12685
  exports.assertRequestRequiresAuthForFunction = assertRequestRequiresAuthForFunction;
12045
12686
  exports.assertSnapshotData = assertSnapshotData;
12046
12687
  exports.assertSnapshotDataWithKey = assertSnapshotDataWithKey;
12688
+ exports.authServicePasswordResetInvalidCodeError = authServicePasswordResetInvalidCodeError;
12689
+ exports.authServicePasswordResetNoConfigError = authServicePasswordResetNoConfigError;
12690
+ exports.authServicePasswordResetSendOnceError = authServicePasswordResetSendOnceError;
12691
+ exports.authServicePasswordResetThrottleError = authServicePasswordResetThrottleError;
12047
12692
  exports.badRequestError = badRequestError;
12048
12693
  exports.blockingFunctionHandlerWithNestContextFactory = blockingFunctionHandlerWithNestContextFactory;
12049
12694
  exports.buildNestServerRootModule = buildNestServerRootModule;
12050
12695
  exports.callWithAnalytics = callWithAnalytics;
12696
+ exports.catchAndThrowPasswordResetServerErrors = catchAndThrowPasswordResetServerErrors;
12051
12697
  exports.cloudEventHandlerWithNestContextFactory = cloudEventHandlerWithNestContextFactory;
12052
12698
  exports.collectionRefForPath = collectionRefForPath;
12053
12699
  exports.createModelUnknownModelTypeError = createModelUnknownModelTypeError;