@dereekb/firebase-server 13.11.18 → 13.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/index.cjs.js +218 -31
  2. package/index.esm.js +217 -34
  3. package/mailgun/package.json +9 -9
  4. package/mcp/index.cjs.default.js +1 -0
  5. package/mcp/index.cjs.js +3646 -0
  6. package/mcp/index.cjs.mjs +2 -0
  7. package/mcp/index.d.ts +1 -0
  8. package/mcp/index.esm.js +3609 -0
  9. package/mcp/package.json +33 -0
  10. package/mcp/src/index.d.ts +1 -0
  11. package/mcp/src/lib/controller/index.d.ts +2 -0
  12. package/mcp/src/lib/controller/mcp.controller.d.ts +19 -0
  13. package/mcp/src/lib/controller/mcp.wellknown.controller.d.ts +25 -0
  14. package/mcp/src/lib/index.d.ts +5 -0
  15. package/mcp/src/lib/mcp.config.d.ts +100 -0
  16. package/mcp/src/lib/mcp.module.d.ts +49 -0
  17. package/mcp/src/lib/service/index.d.ts +8 -0
  18. package/mcp/src/lib/service/mcp.manifest.d.ts +150 -0
  19. package/mcp/src/lib/service/mcp.response-formatter.d.ts +36 -0
  20. package/mcp/src/lib/service/mcp.server.factory.d.ts +124 -0
  21. package/mcp/src/lib/service/mcp.tool-generator.d.ts +235 -0
  22. package/mcp/src/lib/service/mcp.visibility.d.ts +99 -0
  23. package/mcp/src/lib/service/tools/mcp.tool.model-decode.d.ts +87 -0
  24. package/mcp/src/lib/service/tools/mcp.tool.model-get.d.ts +81 -0
  25. package/mcp/src/lib/service/tools/mcp.tool.model-info.d.ts +84 -0
  26. package/mcp/src/lib/service/tools/mcp.tool.whoami.d.ts +72 -0
  27. package/mcp/src/lib/transport/index.d.ts +1 -0
  28. package/mcp/src/lib/transport/streamable-http.transport.d.ts +21 -0
  29. package/model/index.cjs.js +639 -266
  30. package/model/index.esm.js +640 -270
  31. package/model/package.json +9 -9
  32. package/model/src/lib/storagefile/extension/compress.pdf.d.ts +29 -1
  33. package/model/src/lib/storagefile/index.d.ts +1 -0
  34. package/model/src/lib/storagefile/storagefile.action.server.d.ts +29 -2
  35. package/model/src/lib/storagefile/storagefile.mcp.d.ts +32 -0
  36. package/model/src/lib/storagefile/storagefile.module.d.ts +20 -3
  37. package/oidc/index.cjs.js +322 -147
  38. package/oidc/index.esm.js +321 -148
  39. package/oidc/package.json +10 -10
  40. package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +6 -15
  41. package/oidc/src/lib/middleware/oauth-auth.middleware.d.ts +22 -2
  42. package/oidc/src/lib/middleware/oauth-auth.module.d.ts +57 -0
  43. package/oidc/src/lib/oidc.config.d.ts +73 -0
  44. package/oidc/src/lib/oidc.module.d.ts +44 -2
  45. package/package.json +22 -10
  46. package/src/lib/auth/auth.service.d.ts +16 -1
  47. package/src/lib/auth/auth.service.error.util.d.ts +24 -5
  48. package/src/lib/env/env.config.d.ts +16 -0
  49. package/src/lib/env/env.service.d.ts +9 -0
  50. package/src/lib/nest/controller/model/model.api.get.service.d.ts +35 -1
  51. package/src/lib/nest/env/env.service.d.ts +1 -0
  52. package/src/lib/nest/model/api.details.d.ts +116 -5
  53. package/src/lib/nest/model/crud.assert.function.d.ts +1 -1
  54. package/src/lib/nest/model/index.d.ts +1 -0
  55. package/src/lib/nest/model/invoke.model.function.d.ts +89 -0
  56. package/test/package.json +11 -11
  57. package/twilio/LICENSE +21 -0
  58. package/twilio/index.cjs.default.js +1 -0
  59. package/twilio/index.cjs.js +404 -0
  60. package/twilio/index.cjs.mjs +2 -0
  61. package/twilio/index.d.ts +1 -0
  62. package/twilio/index.esm.js +398 -0
  63. package/twilio/package.json +25 -0
  64. package/twilio/src/index.d.ts +1 -0
  65. package/twilio/src/lib/index.d.ts +1 -0
  66. package/twilio/src/lib/notification.send.service.twilio.d.ts +148 -0
  67. package/zoho/package.json +9 -9
package/index.cjs.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var node_crypto = require('node:crypto');
3
4
  var firebase = require('@dereekb/firebase');
4
5
  var util = require('@dereekb/util');
5
6
  var https = require('firebase-functions/https');
@@ -1241,12 +1242,14 @@ function _ts_generator$g(thisArg, body) {
1241
1242
  key: "beginResetPassword",
1242
1243
  value: function beginResetPassword() {
1243
1244
  return _async_to_generator$g(function() {
1244
- var password, _obj, passwordClaimsData;
1245
+ var password, now, expiresAt, _obj, passwordClaimsData;
1245
1246
  return _ts_generator$g(this, function(_state) {
1246
1247
  switch(_state.label){
1247
1248
  case 0:
1248
1249
  password = this._generateResetPasswordKey();
1249
- passwordClaimsData = (_obj = {}, _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_PASSWORD_KEY, password), _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_LAST_COM_DATE_KEY, date.toISODateString(new Date())), _obj);
1250
+ now = new Date();
1251
+ expiresAt = new Date(now.getTime() + this._resetCodeExpiresInMs());
1252
+ passwordClaimsData = (_obj = {}, _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_PASSWORD_KEY, password), _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_LAST_COM_DATE_KEY, date.toISODateString(now)), _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_EXPIRES_AT_KEY, date.toISODateString(expiresAt)), _obj);
1250
1253
  // set the claims
1251
1254
  return [
1252
1255
  4,
@@ -1272,6 +1275,17 @@ function _ts_generator$g(thisArg, body) {
1272
1275
  }).call(this);
1273
1276
  }
1274
1277
  },
1278
+ {
1279
+ /**
1280
+ * Returns the TTL (in milliseconds) for newly-generated reset codes. Subclasses may override
1281
+ * to customize expiry.
1282
+ *
1283
+ * @returns The TTL in milliseconds for newly-generated reset codes.
1284
+ */ key: "_resetCodeExpiresInMs",
1285
+ value: function _resetCodeExpiresInMs() {
1286
+ return DEFAULT_RESET_CODE_EXPIRES_IN;
1287
+ }
1288
+ },
1275
1289
  {
1276
1290
  key: "loadResetPasswordClaims",
1277
1291
  value: function loadResetPasswordClaims() {
@@ -1315,7 +1329,7 @@ function _ts_generator$g(thisArg, body) {
1315
1329
  // clear password reset claims
1316
1330
  return [
1317
1331
  4,
1318
- this.updateClaims((_obj = {}, _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_PASSWORD_KEY, null), _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_LAST_COM_DATE_KEY, null), _obj))
1332
+ this.updateClaims((_obj = {}, _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_PASSWORD_KEY, null), _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_LAST_COM_DATE_KEY, null), _define_property$x(_obj, firebase.FIREBASE_SERVER_AUTH_CLAIMS_RESET_EXPIRES_AT_KEY, null), _obj))
1319
1333
  ];
1320
1334
  case 2:
1321
1335
  _state.sent();
@@ -2110,10 +2124,17 @@ function _ts_generator$g(thisArg, body) {
2110
2124
  return NoSetupContentFirebaseServerNewUserService;
2111
2125
  }(AbstractFirebaseServerNewUserService);
2112
2126
  /**
2113
- * Default throttle duration (1 hour) between reset content sends to prevent spam.
2127
+ * Default throttle duration (60 seconds) between reset content re-sends to prevent spam while
2128
+ * remaining responsive for legitimate users who didn't receive the first email.
2114
2129
  *
2115
2130
  * Used by {@link AbstractFirebaseServerUserPasswordResetService.sendResetContent} to rate-limit delivery.
2116
- */ var DEFAULT_RESET_COM_THROTTLE_TIME = date.hoursToMs(1);
2131
+ */ var DEFAULT_RESET_COM_THROTTLE_TIME = date.minutesToMs(1);
2132
+ /**
2133
+ * Default lifetime (15 minutes) of a reset code before it expires.
2134
+ *
2135
+ * Used by {@link AbstractFirebaseServerAuthUserContext.beginResetPassword} to set
2136
+ * `resetExpiresAt` in the user's claims.
2137
+ */ var DEFAULT_RESET_CODE_EXPIRES_IN = date.minutesToMs(15);
2117
2138
  /**
2118
2139
  * Base implementation of {@link FirebaseServerUserPasswordResetService} that handles reset initiation,
2119
2140
  * claims management, throttled reset content delivery, and reset completion.
@@ -2194,12 +2215,15 @@ function _ts_generator$g(thisArg, body) {
2194
2215
  3,
2195
2216
  7
2196
2217
  ];
2218
+ // beginResetPassword() just refreshed the claims (including resetCommunicationAt = now),
2219
+ // so the throttle window from any previous send no longer applies — this is the first send
2220
+ // of the newly-rotated code and must not be self-throttled.
2197
2221
  return [
2198
2222
  4,
2199
2223
  this.sendResetContent(resolvedUid, {
2200
2224
  data: data,
2201
2225
  sendResetDetailsOnce: sendResetDetailsOnce,
2202
- ignoreSendThrottleTime: sendResetIgnoreThrottle,
2226
+ ignoreSendThrottleTime: sendResetIgnoreThrottle !== null && sendResetIgnoreThrottle !== void 0 ? sendResetIgnoreThrottle : true,
2203
2227
  throwErrors: sendResetThrowErrors,
2204
2228
  sendDetailsInTestEnvironment: sendDetailsInTestEnvironment
2205
2229
  })
@@ -2353,7 +2377,8 @@ function _ts_generator$g(thisArg, body) {
2353
2377
  userContext: userContext,
2354
2378
  claims: {
2355
2379
  resetPassword: claims.resetPassword,
2356
- resetCommunicationAt: claims.resetCommunicationAt
2380
+ resetCommunicationAt: claims.resetCommunicationAt,
2381
+ resetExpiresAt: claims.resetExpiresAt
2357
2382
  },
2358
2383
  data: config === null || config === void 0 ? void 0 : config.data,
2359
2384
  sendDetailsInTestEnvironment: config === null || config === void 0 ? void 0 : config.sendDetailsInTestEnvironment
@@ -2399,7 +2424,7 @@ function _ts_generator$g(thisArg, body) {
2399
2424
  key: "completePasswordReset",
2400
2425
  value: function completePasswordReset(uid, input) {
2401
2426
  return _async_to_generator$g(function() {
2402
- var userContext, claims;
2427
+ var userContext, claims, storedCode, expiresAt, storedBuf, inputBuf;
2403
2428
  return _ts_generator$g(this, function(_state) {
2404
2429
  switch(_state.label){
2405
2430
  case 0:
@@ -2410,7 +2435,18 @@ function _ts_generator$g(thisArg, body) {
2410
2435
  ];
2411
2436
  case 1:
2412
2437
  claims = _state.sent();
2413
- if ((claims === null || claims === void 0 ? void 0 : claims.resetPassword) !== input.resetPassword) {
2438
+ storedCode = claims === null || claims === void 0 ? void 0 : claims.resetPassword;
2439
+ expiresAt = claims === null || claims === void 0 ? void 0 : claims.resetExpiresAt;
2440
+ // Reject if no active reset OR the stored code is missing/wrong length OR the code is expired.
2441
+ // All failure cases throw the same opaque error so callers cannot distinguish them.
2442
+ if (!storedCode || !expiresAt || storedCode.length !== input.resetPassword.length || new Date(expiresAt).getTime() <= Date.now()) {
2443
+ throw new FirebaseServerAuthPasswordResetInvalidCodeError();
2444
+ }
2445
+ // Constant-time comparison to avoid leaking timing information about how many leading
2446
+ // characters of the provided code matched. Lengths are equal per the guard above.
2447
+ storedBuf = Buffer.from(storedCode);
2448
+ inputBuf = Buffer.from(input.resetPassword);
2449
+ if (!node_crypto.timingSafeEqual(storedBuf, inputBuf)) {
2414
2450
  throw new FirebaseServerAuthPasswordResetInvalidCodeError();
2415
2451
  }
2416
2452
  return [
@@ -2919,7 +2955,7 @@ function _async_to_generator$e(fn) {
2919
2955
  });
2920
2956
  };
2921
2957
  }
2922
- function _instanceof$2(left, right) {
2958
+ function _instanceof$3(left, right) {
2923
2959
  "@swc/helpers - instanceof";
2924
2960
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
2925
2961
  return !!right[Symbol.hasInstance](left);
@@ -3031,15 +3067,28 @@ function _ts_generator$e(thisArg, body) {
3031
3067
  * catching password-reset-specific errors and re-throwing them as appropriate {@link HttpsError} instances
3032
3068
  * suitable for returning to clients.
3033
3069
  *
3034
- * Error mapping:
3070
+ * Default mapping (security-hardened — enumeration-safe, for end-user callers):
3071
+ * - {@link FirebaseServerAuthPasswordResetInvalidCodeError} → permission-denied (403)
3072
+ * - {@link FirebaseServerAuthPasswordResetNoResetConfigError} → permission-denied (403), same opaque
3073
+ * response as InvalidCode so callers cannot distinguish "wrong code" from "no reset active".
3074
+ * - {@link FirebaseServerAuthPasswordResetSendOnceError} → permission-denied (403), same opaque
3075
+ * response so callers cannot probe whether a reset was already initiated.
3076
+ * - {@link FirebaseServerAuthPasswordResetThrottleError} → unavailable (503) with a generic message
3077
+ * (no `lastSentAt` is leaked).
3078
+ *
3079
+ * Admin mapping (`isAdmin: true`) — preserves distinct error codes and statuses so an admin
3080
+ * resetting on behalf of another user can see the actual reason. Used when the call originates
3081
+ * from an authenticated admin, where enumeration is not a concern:
3035
3082
  * - {@link FirebaseServerAuthPasswordResetInvalidCodeError} → permission-denied (403)
3036
- * - {@link FirebaseServerAuthPasswordResetNoResetConfigError} → bad-request (400)
3037
- * - {@link FirebaseServerAuthPasswordResetThrottleError} → unavailable (503)
3038
- * - {@link FirebaseServerAuthPasswordResetSendOnceError} → bad-request (400)
3083
+ * - {@link FirebaseServerAuthPasswordResetNoResetConfigError} → bad-request (400), distinct message
3084
+ * - {@link FirebaseServerAuthPasswordResetSendOnceError} → bad-request (400), distinct message
3085
+ * - {@link FirebaseServerAuthPasswordResetThrottleError} → unavailable (503), same as default
3039
3086
  *
3040
3087
  * @param fn - The async function to execute.
3088
+ * @param isAdmin - When `true`, returns distinct error codes/messages instead of the
3089
+ * enumeration-safe opaque response. Pass the caller's admin status here.
3041
3090
  * @returns The result of the function.
3042
- */ function catchAndThrowPasswordResetServerErrors(fn) {
3091
+ */ function catchAndThrowPasswordResetServerErrors(fn, isAdmin) {
3043
3092
  return _async_to_generator$e(function() {
3044
3093
  var result, error;
3045
3094
  return _ts_generator$e(this, function(_state) {
@@ -3063,14 +3112,14 @@ function _ts_generator$e(thisArg, body) {
3063
3112
  ];
3064
3113
  case 2:
3065
3114
  error = _state.sent();
3066
- if (_instanceof$2(error, FirebaseServerAuthPasswordResetInvalidCodeError)) {
3115
+ if (_instanceof$3(error, FirebaseServerAuthPasswordResetInvalidCodeError)) {
3067
3116
  throw authServicePasswordResetInvalidCodeError();
3068
- } else if (_instanceof$2(error, FirebaseServerAuthPasswordResetNoResetConfigError)) {
3069
- throw authServicePasswordResetNoConfigError();
3070
- } else if (_instanceof$2(error, FirebaseServerAuthPasswordResetThrottleError)) {
3117
+ } else if (_instanceof$3(error, FirebaseServerAuthPasswordResetNoResetConfigError)) {
3118
+ throw isAdmin ? authServicePasswordResetNoConfigError() : authServicePasswordResetInvalidCodeError();
3119
+ } else if (_instanceof$3(error, FirebaseServerAuthPasswordResetSendOnceError)) {
3120
+ throw isAdmin ? authServicePasswordResetSendOnceError() : authServicePasswordResetInvalidCodeError();
3121
+ } else if (_instanceof$3(error, FirebaseServerAuthPasswordResetThrottleError)) {
3071
3122
  throw authServicePasswordResetThrottleError();
3072
- } else if (_instanceof$2(error, FirebaseServerAuthPasswordResetSendOnceError)) {
3073
- throw authServicePasswordResetSendOnceError();
3074
3123
  }
3075
3124
  throw error;
3076
3125
  case 3:
@@ -3089,12 +3138,17 @@ function _ts_generator$e(thisArg, body) {
3089
3138
  */ function authServicePasswordResetInvalidCodeError() {
3090
3139
  return permissionDeniedError({
3091
3140
  code: firebase.DBX_FIREBASE_SERVER_PASSWORD_RESET_INVALID_CODE_ERROR_CODE,
3092
- message: 'Invalid or expired reset password code.'
3141
+ message: 'Invalid or expired reset code.'
3093
3142
  });
3094
3143
  }
3095
3144
  /**
3096
3145
  * Creates a bad-request (400) server error when no active password reset exists for the user.
3097
3146
  *
3147
+ * Distinct from {@link authServicePasswordResetInvalidCodeError}. Use only when the caller is
3148
+ * trusted (e.g., an admin) and revealing "no reset active" is not an enumeration risk; for
3149
+ * end-user callers, {@link catchAndThrowPasswordResetServerErrors} maps this case to the same
3150
+ * opaque response as `InvalidCodeError`.
3151
+ *
3098
3152
  * @returns An {@link HttpsError} with code `invalid-argument`.
3099
3153
  */ function authServicePasswordResetNoConfigError() {
3100
3154
  return badRequestError({
@@ -6183,6 +6237,49 @@ function _ts_generator$b(thisArg, body) {
6183
6237
  })();
6184
6238
  }
6185
6239
 
6240
+ /**
6241
+ * Factory that creates a callable function handling model invokes for multiple model types.
6242
+ *
6243
+ * Dispatches to the correct handler based on the `modelType` field in the request,
6244
+ * enforces auth requirements per handler, and aggregates API details for MCP introspection.
6245
+ *
6246
+ * @param map - Maps model type strings to their invoke handler functions.
6247
+ * @param config - Optional configuration including a pre-assertion hook.
6248
+ * @returns A callable function for the 'invoke' call operation.
6249
+ *
6250
+ * @example
6251
+ * ```typescript
6252
+ * const invokeHandler = onCallInvokeModel<DemoNestContext>({
6253
+ * guestbookEntry: onCallSpecifierHandler({
6254
+ * recomputeLikes: guestbookEntryRecomputeLikes
6255
+ * })
6256
+ * });
6257
+ * ```
6258
+ */ function onCallInvokeModel(map) {
6259
+ var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6260
+ var preAssert = config.preAssert;
6261
+ return _onCallWithCallTypeFunction(map, {
6262
+ callType: 'invoke',
6263
+ preAssert: preAssert,
6264
+ throwOnUnknownModelType: invokeModelUnknownModelTypeError
6265
+ });
6266
+ }
6267
+ /**
6268
+ * Creates a bad-request error indicating the requested model type is not valid for invoking.
6269
+ *
6270
+ * @param modelType - The unrecognized model type string.
6271
+ * @returns A bad-request error with {@link UNKNOWN_MODEL_TYPE_ERROR_CODE} code.
6272
+ */ function invokeModelUnknownModelTypeError(modelType) {
6273
+ return badRequestError(util.serverError({
6274
+ status: 400,
6275
+ code: firebase.UNKNOWN_MODEL_TYPE_ERROR_CODE,
6276
+ message: 'Invalid type to invoke.',
6277
+ data: {
6278
+ modelType: modelType
6279
+ }
6280
+ }));
6281
+ }
6282
+
6186
6283
  function _array_like_to_array$8(arr, len) {
6187
6284
  if (len == null || len > arr.length) len = arr.length;
6188
6285
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -7203,6 +7300,14 @@ function _define_property$l(obj, key, value) {
7203
7300
  }
7204
7301
  return obj;
7205
7302
  }
7303
+ function _instanceof$2(left, right) {
7304
+ "@swc/helpers - instanceof";
7305
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
7306
+ return !!right[Symbol.hasInstance](left);
7307
+ } else {
7308
+ return left instanceof right;
7309
+ }
7310
+ }
7206
7311
  function _object_spread$c(target) {
7207
7312
  for(var i = 1; i < arguments.length; i++){
7208
7313
  var source = arguments[i] != null ? arguments[i] : {};
@@ -7321,6 +7426,28 @@ function _ts_generator$9(thisArg, body) {
7321
7426
  /**
7322
7427
  * Maximum number of keys allowed in a multi-read request.
7323
7428
  */ var MAX_MODEL_ACCESS_MULTI_READ_KEYS = 50;
7429
+ /**
7430
+ * Maps a single `useMultipleModels` failure entry into the public {@link ModelAccessReadError}
7431
+ * shape. Unwraps the typical Firebase error shapes via {@link firebaseServerErrorInfo} so
7432
+ * permission-denied / not-found errors surface a real message + code instead of the generic
7433
+ * `"Unknown error"` fallback the inline mapping used previously.
7434
+ *
7435
+ * @param entry - A failed-key entry from the underlying multi-read.
7436
+ * @returns A `{ key, message, code? }` triple safe to return to API/MCP callers.
7437
+ */ function modelAccessReadErrorFromUseMultipleModelsFailure(entry) {
7438
+ var _info_serverErrorCode, _ref, _ref1;
7439
+ var _info_httpsErrorDetailsServerError, _info_httpsError;
7440
+ var info = firebaseServerErrorInfo(entry.error);
7441
+ var serverMessage = (_info_httpsErrorDetailsServerError = info.httpsErrorDetailsServerError) === null || _info_httpsErrorDetailsServerError === void 0 ? void 0 : _info_httpsErrorDetailsServerError.message;
7442
+ var httpsMessage = (_info_httpsError = info.httpsError) === null || _info_httpsError === void 0 ? void 0 : _info_httpsError.message;
7443
+ var plainMessage = _instanceof$2(entry.error, Error) ? entry.error.message : undefined;
7444
+ var code = (_info_serverErrorCode = info.serverErrorCode) !== null && _info_serverErrorCode !== void 0 ? _info_serverErrorCode : info.firebaseErrorCode;
7445
+ return {
7446
+ key: entry.key,
7447
+ message: (_ref = (_ref1 = serverMessage !== null && serverMessage !== void 0 ? serverMessage : httpsMessage) !== null && _ref1 !== void 0 ? _ref1 : plainMessage) !== null && _ref !== void 0 ? _ref : 'permission denied or not found',
7448
+ code: code
7449
+ };
7450
+ }
7324
7451
  // MARK: Service
7325
7452
  /**
7326
7453
  * Service for direct document reads using the `useModel()` permission-checking pattern.
@@ -7332,9 +7459,67 @@ function _ts_generator$9(thisArg, body) {
7332
7459
  function ModelApiGetService(config, nestApplication) {
7333
7460
  _class_call_check$e(this, ModelApiGetService);
7334
7461
  _define_property$l(this, "_nestContext", void 0);
7462
+ _define_property$l(this, "_identityByModelType", void 0);
7335
7463
  this._nestContext = config.makeNestContext(nestApplication);
7336
7464
  }
7337
7465
  _create_class$9(ModelApiGetService, [
7466
+ {
7467
+ /**
7468
+ * Returns the registered {@link FirestoreModelIdentity} for the given `modelType` string, or
7469
+ * `undefined` when no model of that type is registered.
7470
+ *
7471
+ * Identities are read from `firebaseModelsService` and cached on first successful call. The
7472
+ * lookup uses the provided `auth` to build a real model context — `getFirestoreCollection(ctx)`
7473
+ * is context-dependent (calls `ctx.collection(...)` or similar), so a synthetic empty context
7474
+ * is not sufficient.
7475
+ *
7476
+ * @param modelType - The Firestore model type string (e.g., 'guestbook', 'profile').
7477
+ * @param auth - The request's auth data; used to build a context for the (one-time) lookup.
7478
+ * @returns The matching identity or `undefined`.
7479
+ */ key: "getModelIdentity",
7480
+ value: function getModelIdentity(modelType, auth) {
7481
+ var _this__identityByModelType;
7482
+ (_this__identityByModelType = this._identityByModelType) !== null && _this__identityByModelType !== void 0 ? _this__identityByModelType : this._identityByModelType = this._buildIdentityMap(auth);
7483
+ return this._identityByModelType.get(modelType);
7484
+ }
7485
+ },
7486
+ {
7487
+ key: "_buildIdentityMap",
7488
+ value: function _buildIdentityMap(auth) {
7489
+ var map = new Map();
7490
+ var authRef = this._makeAuthRef(auth);
7491
+ var inContextService = this._nestContext.model(authRef);
7492
+ var allTypes = inContextService.allTypes();
7493
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7494
+ try {
7495
+ for(var _iterator = allTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7496
+ var type = _step.value;
7497
+ try {
7498
+ var modelService = inContextService(type);
7499
+ var identity = modelService.getFirestoreCollection().modelIdentity;
7500
+ map.set(type, identity);
7501
+ } catch (unused) {
7502
+ // identity unavailable for this type — skipped silently. A subsequent get attempt for a
7503
+ // missing type surfaces a user-visible "Unknown modelType" error at the tool layer.
7504
+ }
7505
+ }
7506
+ } catch (err) {
7507
+ _didIteratorError = true;
7508
+ _iteratorError = err;
7509
+ } finally{
7510
+ try {
7511
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7512
+ _iterator.return();
7513
+ }
7514
+ } finally{
7515
+ if (_didIteratorError) {
7516
+ throw _iteratorError;
7517
+ }
7518
+ }
7519
+ }
7520
+ return map;
7521
+ }
7522
+ },
7338
7523
  {
7339
7524
  key: "readDocument",
7340
7525
  value: /**
@@ -7441,15 +7626,7 @@ function _ts_generator$9(thisArg, body) {
7441
7626
  ];
7442
7627
  case 1:
7443
7628
  results = _state.sent();
7444
- errors = failure.errors.map(function(e) {
7445
- var _ref;
7446
- var _e_error, _e_error1;
7447
- return {
7448
- key: e.key,
7449
- message: (_ref = (_e_error = e.error) === null || _e_error === void 0 ? void 0 : _e_error.message) !== null && _ref !== void 0 ? _ref : 'Unknown error',
7450
- code: (_e_error1 = e.error) === null || _e_error1 === void 0 ? void 0 : _e_error1.code
7451
- };
7452
- });
7629
+ errors = failure.errors.map(modelAccessReadErrorFromUseMultipleModelsFailure);
7453
7630
  return [
7454
7631
  2,
7455
7632
  {
@@ -8911,6 +9088,12 @@ function _is_native_reflect_construct$1() {
8911
9088
  return this._appUrlDetails();
8912
9089
  }
8913
9090
  },
9091
+ {
9092
+ key: "appMcpUrl",
9093
+ get: function get() {
9094
+ return this.env.appMcpUrl;
9095
+ }
9096
+ },
8914
9097
  {
8915
9098
  key: "appWebhookUrl",
8916
9099
  get: function get() {
@@ -12743,6 +12926,7 @@ exports.AbstractFirebaseServerUserPasswordResetService = AbstractFirebaseServerU
12743
12926
  exports.AbstractNestContext = AbstractNestContext;
12744
12927
  exports.AbstractServerFirebaseNestContext = AbstractServerFirebaseNestContext;
12745
12928
  exports.DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR = DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR;
12929
+ exports.DEFAULT_RESET_CODE_EXPIRES_IN = DEFAULT_RESET_CODE_EXPIRES_IN;
12746
12930
  exports.DEFAULT_RESET_COM_THROTTLE_TIME = DEFAULT_RESET_COM_THROTTLE_TIME;
12747
12931
  exports.DEFAULT_SERVER_ASSETS_BASE_PATH = DEFAULT_SERVER_ASSETS_BASE_PATH;
12748
12932
  exports.DEFAULT_SETUP_COM_THROTTLE_TIME = DEFAULT_SETUP_COM_THROTTLE_TIME;
@@ -12868,6 +13052,7 @@ exports.inAuthContext = inAuthContext;
12868
13052
  exports.injectNestApplicationContextIntoRequest = injectNestApplicationContextIntoRequest;
12869
13053
  exports.injectNestIntoRequest = injectNestIntoRequest;
12870
13054
  exports.internalServerError = internalServerError;
13055
+ exports.invokeModelUnknownModelTypeError = invokeModelUnknownModelTypeError;
12871
13056
  exports.isActualSpecifier = isActualSpecifier;
12872
13057
  exports.isAdminInRequest = isAdminInRequest;
12873
13058
  exports.isAdminOrTargetUserInRequestData = isAdminOrTargetUserInRequestData;
@@ -12881,6 +13066,7 @@ exports.isOnCallSpecifierApiDetails = isOnCallSpecifierApiDetails;
12881
13066
  exports.makeBlockingFunctionWithHandler = makeBlockingFunctionWithHandler;
12882
13067
  exports.makeOnScheduleHandlerWithNestApplicationRequest = makeOnScheduleHandlerWithNestApplicationRequest;
12883
13068
  exports.makeScheduledFunctionDevelopmentFunction = makeScheduledFunctionDevelopmentFunction;
13069
+ exports.modelAccessReadErrorFromUseMultipleModelsFailure = modelAccessReadErrorFromUseMultipleModelsFailure;
12884
13070
  exports.modelApiModuleMetadata = modelApiModuleMetadata;
12885
13071
  exports.modelNotAvailableError = modelNotAvailableError;
12886
13072
  exports.nestAppHasDevelopmentSchedulerEnabled = nestAppHasDevelopmentSchedulerEnabled;
@@ -12898,6 +13084,7 @@ exports.onCallDeleteModel = onCallDeleteModel;
12898
13084
  exports.onCallDevelopmentFunction = onCallDevelopmentFunction;
12899
13085
  exports.onCallHandlerWithNestApplicationFactory = onCallHandlerWithNestApplicationFactory;
12900
13086
  exports.onCallHandlerWithNestContextFactory = onCallHandlerWithNestContextFactory;
13087
+ exports.onCallInvokeModel = onCallInvokeModel;
12901
13088
  exports.onCallModel = onCallModel;
12902
13089
  exports.onCallModelMissingCallTypeError = onCallModelMissingCallTypeError;
12903
13090
  exports.onCallModelUnknownCallTypeError = onCallModelUnknownCallTypeError;