@rebasepro/server-core 0.0.1-canary.c53f5db → 0.0.1-canary.cbdd980

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 (36) hide show
  1. package/dist/index.es.js +608 -2356
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +607 -2355
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/server-core/src/auth/google-oauth.d.ts +36 -3
  6. package/dist/server-core/src/auth/index.d.ts +1 -0
  7. package/dist/server-core/src/init.d.ts +1 -0
  8. package/dist/types/src/controllers/auth.d.ts +8 -2
  9. package/dist/types/src/controllers/client.d.ts +13 -0
  10. package/dist/types/src/controllers/navigation.d.ts +18 -6
  11. package/dist/types/src/controllers/registry.d.ts +9 -1
  12. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
  13. package/dist/types/src/rebase_context.d.ts +17 -0
  14. package/dist/types/src/types/collections.d.ts +21 -1
  15. package/dist/types/src/types/component_ref.d.ts +47 -0
  16. package/dist/types/src/types/cron.d.ts +1 -1
  17. package/dist/types/src/types/entity_views.d.ts +2 -1
  18. package/dist/types/src/types/index.d.ts +1 -0
  19. package/dist/types/src/types/properties.d.ts +68 -84
  20. package/dist/types/src/types/translations.d.ts +2 -0
  21. package/package.json +7 -8
  22. package/src/api/errors.ts +3 -2
  23. package/src/api/server.ts +5 -2
  24. package/src/auth/apple-oauth.ts +8 -18
  25. package/src/auth/google-oauth.ts +192 -22
  26. package/src/auth/index.ts +1 -0
  27. package/src/auth/routes.ts +25 -5
  28. package/src/collections/loader.ts +3 -3
  29. package/src/init.ts +14 -2
  30. package/src/storage/LocalStorageController.ts +33 -9
  31. package/src/storage/S3StorageController.ts +4 -1
  32. package/src/storage/routes.ts +51 -5
  33. package/history_diff.log +0 -385
  34. package/scratch.ts +0 -9
  35. package/test-ast.ts +0 -28
  36. package/test_output.txt +0 -1133
package/dist/index.es.js CHANGED
@@ -7,7 +7,7 @@ import { Hono } from "hono";
7
7
  import require$$0$2 from "buffer";
8
8
  import require$$0$3 from "stream";
9
9
  import require$$5, { promisify } from "util";
10
- import require$$0$4, { randomBytes, createHash, timingSafeEqual as timingSafeEqual$1, scrypt, createPrivateKey as createPrivateKey$1 } from "crypto";
10
+ import require$$0$4, { randomBytes, createHash, timingSafeEqual as timingSafeEqual$1, scrypt } from "crypto";
11
11
  import { bodyLimit } from "hono/body-limit";
12
12
  import { csrf } from "hono/csrf";
13
13
  import require$$0$a from "child_process";
@@ -1020,13 +1020,30 @@ var object_hash = { exports: {} };
1020
1020
  }, { buffer: 3, lYpoI2: 11 }] }, {}, [1])(1);
1021
1021
  });
1022
1022
  })(object_hash);
1023
- const snakeCaseRegex = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
1023
+ const tokenizeRegex = /[A-Z]{2,}(?=[A-Z][a-z]|\b)|[A-Z]?[a-z]+|[0-9]+(?:[a-z](?![a-z]))?|[A-Z]/g;
1024
+ const snakeCaseRegex = tokenizeRegex;
1024
1025
  const toSnakeCase = (str) => {
1025
1026
  const regExpMatchArray = str.match(snakeCaseRegex);
1026
1027
  if (!regExpMatchArray) return "";
1027
1028
  return regExpMatchArray.map((x) => x.toLowerCase()).join("_");
1028
1029
  };
1029
- function isObject$b(item) {
1030
+ function deepClone(value) {
1031
+ if (value === null || value === void 0) return value;
1032
+ if (typeof value === "function") return value;
1033
+ if (typeof value !== "object") return value;
1034
+ if (Array.isArray(value)) {
1035
+ return value.map((item) => deepClone(item));
1036
+ }
1037
+ if (Object.getPrototypeOf(value) !== Object.prototype) {
1038
+ return value;
1039
+ }
1040
+ const result = {};
1041
+ for (const key of Object.keys(value)) {
1042
+ result[key] = deepClone(value[key]);
1043
+ }
1044
+ return result;
1045
+ }
1046
+ function isObject$4(item) {
1030
1047
  return !!item && typeof item === "object" && !Array.isArray(item);
1031
1048
  }
1032
1049
  function isPlainObject$3(obj) {
@@ -1037,13 +1054,13 @@ function isPlainObject$3(obj) {
1037
1054
  return proto === Object.prototype;
1038
1055
  }
1039
1056
  function mergeDeep(target, source, ignoreUndefined = false) {
1040
- if (!isObject$b(target)) {
1057
+ if (!isObject$4(target)) {
1041
1058
  return target;
1042
1059
  }
1043
1060
  const output = {
1044
1061
  ...target
1045
1062
  };
1046
- if (!isObject$b(source)) {
1063
+ if (!isObject$4(source)) {
1047
1064
  return output;
1048
1065
  }
1049
1066
  for (const key in source) {
@@ -1084,7 +1101,7 @@ function mergeDeep(target, source, ignoreUndefined = false) {
1084
1101
  } else {
1085
1102
  output[key] = sourceValue;
1086
1103
  }
1087
- } else if (isObject$b(sourceValue)) {
1104
+ } else if (isObject$4(sourceValue)) {
1088
1105
  output[key] = sourceValue;
1089
1106
  } else {
1090
1107
  output[key] = sourceValue;
@@ -1354,7 +1371,7 @@ function findRelation(resolvedRelations, key) {
1354
1371
  }
1355
1372
  var logic = { exports: {} };
1356
1373
  (function(module, exports$1) {
1357
- (function(root2, factory) {
1374
+ (function(root, factory) {
1358
1375
  {
1359
1376
  module.exports = factory();
1360
1377
  }
@@ -1722,7 +1739,7 @@ var logic = { exports: {} };
1722
1739
  });
1723
1740
  })(logic);
1724
1741
  const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
1725
- const { hasOwnProperty: hasOwnProperty$d } = Object.prototype;
1742
+ const { hasOwnProperty: hasOwnProperty$3 } = Object.prototype;
1726
1743
  function combineComparators(comparatorA, comparatorB) {
1727
1744
  return function isEqual(a2, b, state) {
1728
1745
  return comparatorA(a2, b, state) && comparatorB(a2, b, state);
@@ -1733,17 +1750,17 @@ function createIsCircular(areItemsEqual) {
1733
1750
  if (!a2 || !b || typeof a2 !== "object" || typeof b !== "object") {
1734
1751
  return areItemsEqual(a2, b, state);
1735
1752
  }
1736
- const { cache: cache2 } = state;
1737
- const cachedA = cache2.get(a2);
1738
- const cachedB = cache2.get(b);
1753
+ const { cache } = state;
1754
+ const cachedA = cache.get(a2);
1755
+ const cachedB = cache.get(b);
1739
1756
  if (cachedA && cachedB) {
1740
1757
  return cachedA === b && cachedB === a2;
1741
1758
  }
1742
- cache2.set(a2, b);
1743
- cache2.set(b, a2);
1759
+ cache.set(a2, b);
1760
+ cache.set(b, a2);
1744
1761
  const result = areItemsEqual(a2, b, state);
1745
- cache2.delete(a2);
1746
- cache2.delete(b);
1762
+ cache.delete(a2);
1763
+ cache.delete(b);
1747
1764
  return result;
1748
1765
  };
1749
1766
  }
@@ -1752,12 +1769,12 @@ function getStrictProperties(object) {
1752
1769
  }
1753
1770
  const hasOwn$1 = (
1754
1771
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1755
- Object.hasOwn || ((object, property) => hasOwnProperty$d.call(object, property))
1772
+ Object.hasOwn || ((object, property) => hasOwnProperty$3.call(object, property))
1756
1773
  );
1757
1774
  const PREACT_VNODE = "__v";
1758
1775
  const PREACT_OWNER = "__o";
1759
1776
  const REACT_OWNER = "_owner";
1760
- const { getOwnPropertyDescriptor, keys: keys$5 } = Object;
1777
+ const { getOwnPropertyDescriptor, keys: keys$1 } = Object;
1761
1778
  const sameValueEqual = (
1762
1779
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1763
1780
  Object.is || function sameValueEqual2(a2, b) {
@@ -1835,9 +1852,9 @@ function areMapsEqual(a2, b, state) {
1835
1852
  return true;
1836
1853
  }
1837
1854
  function areObjectsEqual(a2, b, state) {
1838
- const properties = keys$5(a2);
1855
+ const properties = keys$1(a2);
1839
1856
  let index = properties.length;
1840
- if (keys$5(b).length !== index) {
1857
+ if (keys$1(b).length !== index) {
1841
1858
  return false;
1842
1859
  }
1843
1860
  while (index-- > 0) {
@@ -1983,12 +2000,12 @@ function createEqualityComparator(config) {
1983
2000
  if (Array.isArray(a2)) {
1984
2001
  return areArraysEqual2(a2, b, state);
1985
2002
  }
1986
- const tag2 = toString$2.call(a2);
1987
- const supportedComparator = supportedComparatorMap[tag2];
2003
+ const tag = toString$2.call(a2);
2004
+ const supportedComparator = supportedComparatorMap[tag];
1988
2005
  if (supportedComparator) {
1989
2006
  return supportedComparator(a2, b, state);
1990
2007
  }
1991
- const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a2, b, state, tag2);
2008
+ const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a2, b, state, tag);
1992
2009
  if (unsupportedCustomComparator) {
1993
2010
  return unsupportedCustomComparator(a2, b, state);
1994
2011
  }
@@ -2038,9 +2055,9 @@ function createInternalEqualityComparator(compare2) {
2038
2055
  function createIsEqual({ circular, comparator: comparator2, createState, equals, strict }) {
2039
2056
  if (createState) {
2040
2057
  return function isEqual(a2, b) {
2041
- const { cache: cache2 = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
2058
+ const { cache = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
2042
2059
  return comparator2(a2, b, {
2043
- cache: cache2,
2060
+ cache,
2044
2061
  equals,
2045
2062
  meta,
2046
2063
  strict
@@ -2140,982 +2157,6 @@ function createCustomEqual(options2 = {}) {
2140
2157
  const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator2) : createInternalEqualityComparator(comparator2);
2141
2158
  return createIsEqual({ circular, comparator: comparator2, createState, equals, strict });
2142
2159
  }
2143
- function listCacheClear$1() {
2144
- this.__data__ = [];
2145
- this.size = 0;
2146
- }
2147
- var _listCacheClear = listCacheClear$1;
2148
- function eq$5(value, other) {
2149
- return value === other || value !== value && other !== other;
2150
- }
2151
- var eq_1$1 = eq$5;
2152
- var eq$4 = eq_1$1;
2153
- function assocIndexOf$4(array, key) {
2154
- var length = array.length;
2155
- while (length--) {
2156
- if (eq$4(array[length][0], key)) {
2157
- return length;
2158
- }
2159
- }
2160
- return -1;
2161
- }
2162
- var _assocIndexOf = assocIndexOf$4;
2163
- var assocIndexOf$3 = _assocIndexOf;
2164
- var arrayProto = Array.prototype;
2165
- var splice = arrayProto.splice;
2166
- function listCacheDelete$1(key) {
2167
- var data = this.__data__, index = assocIndexOf$3(data, key);
2168
- if (index < 0) {
2169
- return false;
2170
- }
2171
- var lastIndex = data.length - 1;
2172
- if (index == lastIndex) {
2173
- data.pop();
2174
- } else {
2175
- splice.call(data, index, 1);
2176
- }
2177
- --this.size;
2178
- return true;
2179
- }
2180
- var _listCacheDelete = listCacheDelete$1;
2181
- var assocIndexOf$2 = _assocIndexOf;
2182
- function listCacheGet$1(key) {
2183
- var data = this.__data__, index = assocIndexOf$2(data, key);
2184
- return index < 0 ? void 0 : data[index][1];
2185
- }
2186
- var _listCacheGet = listCacheGet$1;
2187
- var assocIndexOf$1 = _assocIndexOf;
2188
- function listCacheHas$1(key) {
2189
- return assocIndexOf$1(this.__data__, key) > -1;
2190
- }
2191
- var _listCacheHas = listCacheHas$1;
2192
- var assocIndexOf = _assocIndexOf;
2193
- function listCacheSet$1(key, value) {
2194
- var data = this.__data__, index = assocIndexOf(data, key);
2195
- if (index < 0) {
2196
- ++this.size;
2197
- data.push([key, value]);
2198
- } else {
2199
- data[index][1] = value;
2200
- }
2201
- return this;
2202
- }
2203
- var _listCacheSet = listCacheSet$1;
2204
- var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
2205
- function ListCache$4(entries) {
2206
- var index = -1, length = entries == null ? 0 : entries.length;
2207
- this.clear();
2208
- while (++index < length) {
2209
- var entry = entries[index];
2210
- this.set(entry[0], entry[1]);
2211
- }
2212
- }
2213
- ListCache$4.prototype.clear = listCacheClear;
2214
- ListCache$4.prototype["delete"] = listCacheDelete;
2215
- ListCache$4.prototype.get = listCacheGet;
2216
- ListCache$4.prototype.has = listCacheHas;
2217
- ListCache$4.prototype.set = listCacheSet;
2218
- var _ListCache = ListCache$4;
2219
- var ListCache$3 = _ListCache;
2220
- function stackClear$1() {
2221
- this.__data__ = new ListCache$3();
2222
- this.size = 0;
2223
- }
2224
- var _stackClear = stackClear$1;
2225
- function stackDelete$1(key) {
2226
- var data = this.__data__, result = data["delete"](key);
2227
- this.size = data.size;
2228
- return result;
2229
- }
2230
- var _stackDelete = stackDelete$1;
2231
- function stackGet$1(key) {
2232
- return this.__data__.get(key);
2233
- }
2234
- var _stackGet = stackGet$1;
2235
- function stackHas$1(key) {
2236
- return this.__data__.has(key);
2237
- }
2238
- var _stackHas = stackHas$1;
2239
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2240
- var _freeGlobal = freeGlobal$1;
2241
- var freeGlobal = _freeGlobal;
2242
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
2243
- var root$8 = freeGlobal || freeSelf || Function("return this")();
2244
- var _root = root$8;
2245
- var root$7 = _root;
2246
- var Symbol$4 = root$7.Symbol;
2247
- var _Symbol = Symbol$4;
2248
- var Symbol$3 = _Symbol;
2249
- var objectProto$j = Object.prototype;
2250
- var hasOwnProperty$c = objectProto$j.hasOwnProperty;
2251
- var nativeObjectToString$1 = objectProto$j.toString;
2252
- var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
2253
- function getRawTag$1(value) {
2254
- var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag2 = value[symToStringTag$1];
2255
- try {
2256
- value[symToStringTag$1] = void 0;
2257
- var unmasked = true;
2258
- } catch (e) {
2259
- }
2260
- var result = nativeObjectToString$1.call(value);
2261
- if (unmasked) {
2262
- if (isOwn) {
2263
- value[symToStringTag$1] = tag2;
2264
- } else {
2265
- delete value[symToStringTag$1];
2266
- }
2267
- }
2268
- return result;
2269
- }
2270
- var _getRawTag = getRawTag$1;
2271
- var objectProto$i = Object.prototype;
2272
- var nativeObjectToString = objectProto$i.toString;
2273
- function objectToString$8(value) {
2274
- return nativeObjectToString.call(value);
2275
- }
2276
- var _objectToString = objectToString$8;
2277
- var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString$7 = _objectToString;
2278
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
2279
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
2280
- function baseGetTag$4(value) {
2281
- if (value == null) {
2282
- return value === void 0 ? undefinedTag : nullTag;
2283
- }
2284
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString$7(value);
2285
- }
2286
- var _baseGetTag = baseGetTag$4;
2287
- function isObject$a(value) {
2288
- var type = typeof value;
2289
- return value != null && (type == "object" || type == "function");
2290
- }
2291
- var isObject_1 = isObject$a;
2292
- var baseGetTag$3 = _baseGetTag, isObject$9 = isObject_1;
2293
- var asyncTag = "[object AsyncFunction]", funcTag$3 = "[object Function]", genTag$2 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
2294
- function isFunction$3(value) {
2295
- if (!isObject$9(value)) {
2296
- return false;
2297
- }
2298
- var tag2 = baseGetTag$3(value);
2299
- return tag2 == funcTag$3 || tag2 == genTag$2 || tag2 == asyncTag || tag2 == proxyTag;
2300
- }
2301
- var isFunction_1 = isFunction$3;
2302
- var root$6 = _root;
2303
- var coreJsData$1 = root$6["__core-js_shared__"];
2304
- var _coreJsData = coreJsData$1;
2305
- var coreJsData = _coreJsData;
2306
- var maskSrcKey = function() {
2307
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
2308
- return uid ? "Symbol(src)_1." + uid : "";
2309
- }();
2310
- function isMasked$1(func) {
2311
- return !!maskSrcKey && maskSrcKey in func;
2312
- }
2313
- var _isMasked = isMasked$1;
2314
- var funcProto$2 = Function.prototype;
2315
- var funcToString$2 = funcProto$2.toString;
2316
- function toSource$2(func) {
2317
- if (func != null) {
2318
- try {
2319
- return funcToString$2.call(func);
2320
- } catch (e) {
2321
- }
2322
- try {
2323
- return func + "";
2324
- } catch (e) {
2325
- }
2326
- }
2327
- return "";
2328
- }
2329
- var _toSource = toSource$2;
2330
- var isFunction$2 = isFunction_1, isMasked = _isMasked, isObject$8 = isObject_1, toSource$1 = _toSource;
2331
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
2332
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
2333
- var funcProto$1 = Function.prototype, objectProto$h = Object.prototype;
2334
- var funcToString$1 = funcProto$1.toString;
2335
- var hasOwnProperty$b = objectProto$h.hasOwnProperty;
2336
- var reIsNative = RegExp(
2337
- "^" + funcToString$1.call(hasOwnProperty$b).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
2338
- );
2339
- function baseIsNative$1(value) {
2340
- if (!isObject$8(value) || isMasked(value)) {
2341
- return false;
2342
- }
2343
- var pattern = isFunction$2(value) ? reIsNative : reIsHostCtor;
2344
- return pattern.test(toSource$1(value));
2345
- }
2346
- var _baseIsNative = baseIsNative$1;
2347
- function getValue$1(object, key) {
2348
- return object == null ? void 0 : object[key];
2349
- }
2350
- var _getValue = getValue$1;
2351
- var baseIsNative = _baseIsNative, getValue = _getValue;
2352
- function getNative$7(object, key) {
2353
- var value = getValue(object, key);
2354
- return baseIsNative(value) ? value : void 0;
2355
- }
2356
- var _getNative = getNative$7;
2357
- var getNative$6 = _getNative, root$5 = _root;
2358
- var Map$4 = getNative$6(root$5, "Map");
2359
- var _Map = Map$4;
2360
- var getNative$5 = _getNative;
2361
- var nativeCreate$4 = getNative$5(Object, "create");
2362
- var _nativeCreate = nativeCreate$4;
2363
- var nativeCreate$3 = _nativeCreate;
2364
- function hashClear$1() {
2365
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
2366
- this.size = 0;
2367
- }
2368
- var _hashClear = hashClear$1;
2369
- function hashDelete$1(key) {
2370
- var result = this.has(key) && delete this.__data__[key];
2371
- this.size -= result ? 1 : 0;
2372
- return result;
2373
- }
2374
- var _hashDelete = hashDelete$1;
2375
- var nativeCreate$2 = _nativeCreate;
2376
- var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
2377
- var objectProto$g = Object.prototype;
2378
- var hasOwnProperty$a = objectProto$g.hasOwnProperty;
2379
- function hashGet$1(key) {
2380
- var data = this.__data__;
2381
- if (nativeCreate$2) {
2382
- var result = data[key];
2383
- return result === HASH_UNDEFINED$1 ? void 0 : result;
2384
- }
2385
- return hasOwnProperty$a.call(data, key) ? data[key] : void 0;
2386
- }
2387
- var _hashGet = hashGet$1;
2388
- var nativeCreate$1 = _nativeCreate;
2389
- var objectProto$f = Object.prototype;
2390
- var hasOwnProperty$9 = objectProto$f.hasOwnProperty;
2391
- function hashHas$1(key) {
2392
- var data = this.__data__;
2393
- return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$9.call(data, key);
2394
- }
2395
- var _hashHas = hashHas$1;
2396
- var nativeCreate = _nativeCreate;
2397
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
2398
- function hashSet$1(key, value) {
2399
- var data = this.__data__;
2400
- this.size += this.has(key) ? 0 : 1;
2401
- data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
2402
- return this;
2403
- }
2404
- var _hashSet = hashSet$1;
2405
- var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
2406
- function Hash$1(entries) {
2407
- var index = -1, length = entries == null ? 0 : entries.length;
2408
- this.clear();
2409
- while (++index < length) {
2410
- var entry = entries[index];
2411
- this.set(entry[0], entry[1]);
2412
- }
2413
- }
2414
- Hash$1.prototype.clear = hashClear;
2415
- Hash$1.prototype["delete"] = hashDelete;
2416
- Hash$1.prototype.get = hashGet;
2417
- Hash$1.prototype.has = hashHas;
2418
- Hash$1.prototype.set = hashSet;
2419
- var _Hash = Hash$1;
2420
- var Hash = _Hash, ListCache$2 = _ListCache, Map$3 = _Map;
2421
- function mapCacheClear$1() {
2422
- this.size = 0;
2423
- this.__data__ = {
2424
- "hash": new Hash(),
2425
- "map": new (Map$3 || ListCache$2)(),
2426
- "string": new Hash()
2427
- };
2428
- }
2429
- var _mapCacheClear = mapCacheClear$1;
2430
- function isKeyable$1(value) {
2431
- var type = typeof value;
2432
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
2433
- }
2434
- var _isKeyable = isKeyable$1;
2435
- var isKeyable = _isKeyable;
2436
- function getMapData$4(map2, key) {
2437
- var data = map2.__data__;
2438
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
2439
- }
2440
- var _getMapData = getMapData$4;
2441
- var getMapData$3 = _getMapData;
2442
- function mapCacheDelete$1(key) {
2443
- var result = getMapData$3(this, key)["delete"](key);
2444
- this.size -= result ? 1 : 0;
2445
- return result;
2446
- }
2447
- var _mapCacheDelete = mapCacheDelete$1;
2448
- var getMapData$2 = _getMapData;
2449
- function mapCacheGet$1(key) {
2450
- return getMapData$2(this, key).get(key);
2451
- }
2452
- var _mapCacheGet = mapCacheGet$1;
2453
- var getMapData$1 = _getMapData;
2454
- function mapCacheHas$1(key) {
2455
- return getMapData$1(this, key).has(key);
2456
- }
2457
- var _mapCacheHas = mapCacheHas$1;
2458
- var getMapData = _getMapData;
2459
- function mapCacheSet$1(key, value) {
2460
- var data = getMapData(this, key), size = data.size;
2461
- data.set(key, value);
2462
- this.size += data.size == size ? 0 : 1;
2463
- return this;
2464
- }
2465
- var _mapCacheSet = mapCacheSet$1;
2466
- var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
2467
- function MapCache$1(entries) {
2468
- var index = -1, length = entries == null ? 0 : entries.length;
2469
- this.clear();
2470
- while (++index < length) {
2471
- var entry = entries[index];
2472
- this.set(entry[0], entry[1]);
2473
- }
2474
- }
2475
- MapCache$1.prototype.clear = mapCacheClear;
2476
- MapCache$1.prototype["delete"] = mapCacheDelete;
2477
- MapCache$1.prototype.get = mapCacheGet;
2478
- MapCache$1.prototype.has = mapCacheHas;
2479
- MapCache$1.prototype.set = mapCacheSet;
2480
- var _MapCache = MapCache$1;
2481
- var ListCache$1 = _ListCache, Map$2 = _Map, MapCache = _MapCache;
2482
- var LARGE_ARRAY_SIZE = 200;
2483
- function stackSet$1(key, value) {
2484
- var data = this.__data__;
2485
- if (data instanceof ListCache$1) {
2486
- var pairs = data.__data__;
2487
- if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
2488
- pairs.push([key, value]);
2489
- this.size = ++data.size;
2490
- return this;
2491
- }
2492
- data = this.__data__ = new MapCache(pairs);
2493
- }
2494
- data.set(key, value);
2495
- this.size = data.size;
2496
- return this;
2497
- }
2498
- var _stackSet = stackSet$1;
2499
- var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet;
2500
- function Stack$1(entries) {
2501
- var data = this.__data__ = new ListCache(entries);
2502
- this.size = data.size;
2503
- }
2504
- Stack$1.prototype.clear = stackClear;
2505
- Stack$1.prototype["delete"] = stackDelete;
2506
- Stack$1.prototype.get = stackGet;
2507
- Stack$1.prototype.has = stackHas;
2508
- Stack$1.prototype.set = stackSet;
2509
- var _Stack = Stack$1;
2510
- function arrayEach$1(array, iteratee) {
2511
- var index = -1, length = array == null ? 0 : array.length;
2512
- while (++index < length) {
2513
- if (iteratee(array[index], index, array) === false) {
2514
- break;
2515
- }
2516
- }
2517
- return array;
2518
- }
2519
- var _arrayEach = arrayEach$1;
2520
- var getNative$4 = _getNative;
2521
- var defineProperty$2 = function() {
2522
- try {
2523
- var func = getNative$4(Object, "defineProperty");
2524
- func({}, "", {});
2525
- return func;
2526
- } catch (e) {
2527
- }
2528
- }();
2529
- var _defineProperty = defineProperty$2;
2530
- var defineProperty$1 = _defineProperty;
2531
- function baseAssignValue$2(object, key, value) {
2532
- if (key == "__proto__" && defineProperty$1) {
2533
- defineProperty$1(object, key, {
2534
- "configurable": true,
2535
- "enumerable": true,
2536
- "value": value,
2537
- "writable": true
2538
- });
2539
- } else {
2540
- object[key] = value;
2541
- }
2542
- }
2543
- var _baseAssignValue = baseAssignValue$2;
2544
- var baseAssignValue$1 = _baseAssignValue, eq$3 = eq_1$1;
2545
- var objectProto$e = Object.prototype;
2546
- var hasOwnProperty$8 = objectProto$e.hasOwnProperty;
2547
- function assignValue$2(object, key, value) {
2548
- var objValue = object[key];
2549
- if (!(hasOwnProperty$8.call(object, key) && eq$3(objValue, value)) || value === void 0 && !(key in object)) {
2550
- baseAssignValue$1(object, key, value);
2551
- }
2552
- }
2553
- var _assignValue = assignValue$2;
2554
- var assignValue$1 = _assignValue, baseAssignValue = _baseAssignValue;
2555
- function copyObject$4(source, props, object, customizer) {
2556
- var isNew = !object;
2557
- object || (object = {});
2558
- var index = -1, length = props.length;
2559
- while (++index < length) {
2560
- var key = props[index];
2561
- var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
2562
- if (newValue === void 0) {
2563
- newValue = source[key];
2564
- }
2565
- if (isNew) {
2566
- baseAssignValue(object, key, newValue);
2567
- } else {
2568
- assignValue$1(object, key, newValue);
2569
- }
2570
- }
2571
- return object;
2572
- }
2573
- var _copyObject = copyObject$4;
2574
- function baseTimes$2(n, iteratee) {
2575
- var index = -1, result = Array(n);
2576
- while (++index < n) {
2577
- result[index] = iteratee(index);
2578
- }
2579
- return result;
2580
- }
2581
- var _baseTimes = baseTimes$2;
2582
- function isObjectLike$e(value) {
2583
- return value != null && typeof value == "object";
2584
- }
2585
- var isObjectLike_1 = isObjectLike$e;
2586
- var baseGetTag$2 = _baseGetTag, isObjectLike$d = isObjectLike_1;
2587
- var argsTag$3 = "[object Arguments]";
2588
- function baseIsArguments$1(value) {
2589
- return isObjectLike$d(value) && baseGetTag$2(value) == argsTag$3;
2590
- }
2591
- var _baseIsArguments = baseIsArguments$1;
2592
- var baseIsArguments = _baseIsArguments, isObjectLike$c = isObjectLike_1;
2593
- var objectProto$d = Object.prototype;
2594
- var hasOwnProperty$7 = objectProto$d.hasOwnProperty;
2595
- var propertyIsEnumerable$2 = objectProto$d.propertyIsEnumerable;
2596
- var isArguments$2 = baseIsArguments(/* @__PURE__ */ function() {
2597
- return arguments;
2598
- }()) ? baseIsArguments : function(value) {
2599
- return isObjectLike$c(value) && hasOwnProperty$7.call(value, "callee") && !propertyIsEnumerable$2.call(value, "callee");
2600
- };
2601
- var isArguments_1 = isArguments$2;
2602
- var isArray$6 = Array.isArray;
2603
- var isArray_1 = isArray$6;
2604
- var isBuffer$2 = { exports: {} };
2605
- function stubFalse() {
2606
- return false;
2607
- }
2608
- var stubFalse_1 = stubFalse;
2609
- isBuffer$2.exports;
2610
- (function(module, exports$1) {
2611
- var root2 = _root, stubFalse2 = stubFalse_1;
2612
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2613
- var freeModule = freeExports && true && module && !module.nodeType && module;
2614
- var moduleExports = freeModule && freeModule.exports === freeExports;
2615
- var Buffer2 = moduleExports ? root2.Buffer : void 0;
2616
- var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
2617
- var isBuffer2 = nativeIsBuffer || stubFalse2;
2618
- module.exports = isBuffer2;
2619
- })(isBuffer$2, isBuffer$2.exports);
2620
- var isBufferExports = isBuffer$2.exports;
2621
- var MAX_SAFE_INTEGER$4 = 9007199254740991;
2622
- var reIsUint$1 = /^(?:0|[1-9]\d*)$/;
2623
- function isIndex$2(value, length) {
2624
- var type = typeof value;
2625
- length = length == null ? MAX_SAFE_INTEGER$4 : length;
2626
- return !!length && (type == "number" || type != "symbol" && reIsUint$1.test(value)) && (value > -1 && value % 1 == 0 && value < length);
2627
- }
2628
- var _isIndex = isIndex$2;
2629
- var MAX_SAFE_INTEGER$3 = 9007199254740991;
2630
- function isLength$3(value) {
2631
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$3;
2632
- }
2633
- var isLength_1 = isLength$3;
2634
- var baseGetTag$1 = _baseGetTag, isLength$2 = isLength_1, isObjectLike$b = isObjectLike_1;
2635
- var argsTag$2 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$3 = "[object Boolean]", dateTag$2 = "[object Date]", errorTag$1 = "[object Error]", funcTag$2 = "[object Function]", mapTag$4 = "[object Map]", numberTag$3 = "[object Number]", objectTag$3 = "[object Object]", regexpTag$2 = "[object RegExp]", setTag$4 = "[object Set]", stringTag$4 = "[object String]", weakMapTag$2 = "[object WeakMap]";
2636
- var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$3 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
2637
- var typedArrayTags = {};
2638
- typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = typedArrayTags[uint32Tag$2] = true;
2639
- typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$3] = typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$2] = typedArrayTags[mapTag$4] = typedArrayTags[numberTag$3] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$2] = typedArrayTags[setTag$4] = typedArrayTags[stringTag$4] = typedArrayTags[weakMapTag$2] = false;
2640
- function baseIsTypedArray$1(value) {
2641
- return isObjectLike$b(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$1(value)];
2642
- }
2643
- var _baseIsTypedArray = baseIsTypedArray$1;
2644
- function baseUnary$3(func) {
2645
- return function(value) {
2646
- return func(value);
2647
- };
2648
- }
2649
- var _baseUnary = baseUnary$3;
2650
- var _nodeUtil = { exports: {} };
2651
- _nodeUtil.exports;
2652
- (function(module, exports$1) {
2653
- var freeGlobal2 = _freeGlobal;
2654
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2655
- var freeModule = freeExports && true && module && !module.nodeType && module;
2656
- var moduleExports = freeModule && freeModule.exports === freeExports;
2657
- var freeProcess = moduleExports && freeGlobal2.process;
2658
- var nodeUtil2 = function() {
2659
- try {
2660
- var types2 = freeModule && freeModule.require && freeModule.require("util").types;
2661
- if (types2) {
2662
- return types2;
2663
- }
2664
- return freeProcess && freeProcess.binding && freeProcess.binding("util");
2665
- } catch (e) {
2666
- }
2667
- }();
2668
- module.exports = nodeUtil2;
2669
- })(_nodeUtil, _nodeUtil.exports);
2670
- var _nodeUtilExports = _nodeUtil.exports;
2671
- var baseIsTypedArray = _baseIsTypedArray, baseUnary$2 = _baseUnary, nodeUtil$2 = _nodeUtilExports;
2672
- var nodeIsTypedArray = nodeUtil$2 && nodeUtil$2.isTypedArray;
2673
- var isTypedArray$1 = nodeIsTypedArray ? baseUnary$2(nodeIsTypedArray) : baseIsTypedArray;
2674
- var isTypedArray_1 = isTypedArray$1;
2675
- var baseTimes$1 = _baseTimes, isArguments$1 = isArguments_1, isArray$5 = isArray_1, isBuffer$1 = isBufferExports, isIndex$1 = _isIndex, isTypedArray = isTypedArray_1;
2676
- var objectProto$c = Object.prototype;
2677
- var hasOwnProperty$6 = objectProto$c.hasOwnProperty;
2678
- function arrayLikeKeys$3(value, inherited) {
2679
- var isArr = isArray$5(value), isArg = !isArr && isArguments$1(value), isBuff = !isArr && !isArg && isBuffer$1(value), isType2 = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType2, result = skipIndexes ? baseTimes$1(value.length, String) : [], length = result.length;
2680
- for (var key in value) {
2681
- if ((inherited || hasOwnProperty$6.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
2682
- (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
2683
- isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
2684
- isType2 && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
2685
- isIndex$1(key, length)))) {
2686
- result.push(key);
2687
- }
2688
- }
2689
- return result;
2690
- }
2691
- var _arrayLikeKeys = arrayLikeKeys$3;
2692
- var objectProto$b = Object.prototype;
2693
- function isPrototype$4(value) {
2694
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$b;
2695
- return value === proto;
2696
- }
2697
- var _isPrototype = isPrototype$4;
2698
- function overArg$4(func, transform) {
2699
- return function(arg) {
2700
- return func(transform(arg));
2701
- };
2702
- }
2703
- var _overArg = overArg$4;
2704
- var overArg$3 = _overArg;
2705
- var nativeKeys$2 = overArg$3(Object.keys, Object);
2706
- var _nativeKeys = nativeKeys$2;
2707
- var isPrototype$3 = _isPrototype, nativeKeys$1 = _nativeKeys;
2708
- var objectProto$a = Object.prototype;
2709
- var hasOwnProperty$5 = objectProto$a.hasOwnProperty;
2710
- function baseKeys$2(object) {
2711
- if (!isPrototype$3(object)) {
2712
- return nativeKeys$1(object);
2713
- }
2714
- var result = [];
2715
- for (var key in Object(object)) {
2716
- if (hasOwnProperty$5.call(object, key) && key != "constructor") {
2717
- result.push(key);
2718
- }
2719
- }
2720
- return result;
2721
- }
2722
- var _baseKeys = baseKeys$2;
2723
- var isFunction$1 = isFunction_1, isLength$1 = isLength_1;
2724
- function isArrayLike$3(value) {
2725
- return value != null && isLength$1(value.length) && !isFunction$1(value);
2726
- }
2727
- var isArrayLike_1 = isArrayLike$3;
2728
- var arrayLikeKeys$2 = _arrayLikeKeys, baseKeys$1 = _baseKeys, isArrayLike$2 = isArrayLike_1;
2729
- function keys$4(object) {
2730
- return isArrayLike$2(object) ? arrayLikeKeys$2(object) : baseKeys$1(object);
2731
- }
2732
- var keys_1 = keys$4;
2733
- var copyObject$3 = _copyObject, keys$3 = keys_1;
2734
- function baseAssign$1(object, source) {
2735
- return object && copyObject$3(source, keys$3(source), object);
2736
- }
2737
- var _baseAssign = baseAssign$1;
2738
- function nativeKeysIn$1(object) {
2739
- var result = [];
2740
- if (object != null) {
2741
- for (var key in Object(object)) {
2742
- result.push(key);
2743
- }
2744
- }
2745
- return result;
2746
- }
2747
- var _nativeKeysIn = nativeKeysIn$1;
2748
- var isObject$7 = isObject_1, isPrototype$2 = _isPrototype, nativeKeysIn = _nativeKeysIn;
2749
- var objectProto$9 = Object.prototype;
2750
- var hasOwnProperty$4 = objectProto$9.hasOwnProperty;
2751
- function baseKeysIn$1(object) {
2752
- if (!isObject$7(object)) {
2753
- return nativeKeysIn(object);
2754
- }
2755
- var isProto = isPrototype$2(object), result = [];
2756
- for (var key in object) {
2757
- if (!(key == "constructor" && (isProto || !hasOwnProperty$4.call(object, key)))) {
2758
- result.push(key);
2759
- }
2760
- }
2761
- return result;
2762
- }
2763
- var _baseKeysIn = baseKeysIn$1;
2764
- var arrayLikeKeys$1 = _arrayLikeKeys, baseKeysIn = _baseKeysIn, isArrayLike$1 = isArrayLike_1;
2765
- function keysIn$3(object) {
2766
- return isArrayLike$1(object) ? arrayLikeKeys$1(object, true) : baseKeysIn(object);
2767
- }
2768
- var keysIn_1 = keysIn$3;
2769
- var copyObject$2 = _copyObject, keysIn$2 = keysIn_1;
2770
- function baseAssignIn$1(object, source) {
2771
- return object && copyObject$2(source, keysIn$2(source), object);
2772
- }
2773
- var _baseAssignIn = baseAssignIn$1;
2774
- var _cloneBuffer = { exports: {} };
2775
- _cloneBuffer.exports;
2776
- (function(module, exports$1) {
2777
- var root2 = _root;
2778
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
2779
- var freeModule = freeExports && true && module && !module.nodeType && module;
2780
- var moduleExports = freeModule && freeModule.exports === freeExports;
2781
- var Buffer2 = moduleExports ? root2.Buffer : void 0, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
2782
- function cloneBuffer2(buffer, isDeep) {
2783
- if (isDeep) {
2784
- return buffer.slice();
2785
- }
2786
- var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
2787
- buffer.copy(result);
2788
- return result;
2789
- }
2790
- module.exports = cloneBuffer2;
2791
- })(_cloneBuffer, _cloneBuffer.exports);
2792
- var _cloneBufferExports = _cloneBuffer.exports;
2793
- function copyArray$1(source, array) {
2794
- var index = -1, length = source.length;
2795
- array || (array = Array(length));
2796
- while (++index < length) {
2797
- array[index] = source[index];
2798
- }
2799
- return array;
2800
- }
2801
- var _copyArray = copyArray$1;
2802
- function arrayFilter$1(array, predicate) {
2803
- var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
2804
- while (++index < length) {
2805
- var value = array[index];
2806
- if (predicate(value, index, array)) {
2807
- result[resIndex++] = value;
2808
- }
2809
- }
2810
- return result;
2811
- }
2812
- var _arrayFilter = arrayFilter$1;
2813
- function stubArray$2() {
2814
- return [];
2815
- }
2816
- var stubArray_1 = stubArray$2;
2817
- var arrayFilter = _arrayFilter, stubArray$1 = stubArray_1;
2818
- var objectProto$8 = Object.prototype;
2819
- var propertyIsEnumerable$1 = objectProto$8.propertyIsEnumerable;
2820
- var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
2821
- var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
2822
- if (object == null) {
2823
- return [];
2824
- }
2825
- object = Object(object);
2826
- return arrayFilter(nativeGetSymbols$1(object), function(symbol) {
2827
- return propertyIsEnumerable$1.call(object, symbol);
2828
- });
2829
- };
2830
- var _getSymbols = getSymbols$3;
2831
- var copyObject$1 = _copyObject, getSymbols$2 = _getSymbols;
2832
- function copySymbols$1(source, object) {
2833
- return copyObject$1(source, getSymbols$2(source), object);
2834
- }
2835
- var _copySymbols = copySymbols$1;
2836
- function arrayPush$2(array, values2) {
2837
- var index = -1, length = values2.length, offset = array.length;
2838
- while (++index < length) {
2839
- array[offset + index] = values2[index];
2840
- }
2841
- return array;
2842
- }
2843
- var _arrayPush = arrayPush$2;
2844
- var overArg$2 = _overArg;
2845
- var getPrototype$3 = overArg$2(Object.getPrototypeOf, Object);
2846
- var _getPrototype = getPrototype$3;
2847
- var arrayPush$1 = _arrayPush, getPrototype$2 = _getPrototype, getSymbols$1 = _getSymbols, stubArray = stubArray_1;
2848
- var nativeGetSymbols = Object.getOwnPropertySymbols;
2849
- var getSymbolsIn$2 = !nativeGetSymbols ? stubArray : function(object) {
2850
- var result = [];
2851
- while (object) {
2852
- arrayPush$1(result, getSymbols$1(object));
2853
- object = getPrototype$2(object);
2854
- }
2855
- return result;
2856
- };
2857
- var _getSymbolsIn = getSymbolsIn$2;
2858
- var copyObject = _copyObject, getSymbolsIn$1 = _getSymbolsIn;
2859
- function copySymbolsIn$1(source, object) {
2860
- return copyObject(source, getSymbolsIn$1(source), object);
2861
- }
2862
- var _copySymbolsIn = copySymbolsIn$1;
2863
- var arrayPush = _arrayPush, isArray$4 = isArray_1;
2864
- function baseGetAllKeys$2(object, keysFunc, symbolsFunc) {
2865
- var result = keysFunc(object);
2866
- return isArray$4(object) ? result : arrayPush(result, symbolsFunc(object));
2867
- }
2868
- var _baseGetAllKeys = baseGetAllKeys$2;
2869
- var baseGetAllKeys$1 = _baseGetAllKeys, getSymbols = _getSymbols, keys$2 = keys_1;
2870
- function getAllKeys$1(object) {
2871
- return baseGetAllKeys$1(object, keys$2, getSymbols);
2872
- }
2873
- var _getAllKeys = getAllKeys$1;
2874
- var baseGetAllKeys = _baseGetAllKeys, getSymbolsIn = _getSymbolsIn, keysIn$1 = keysIn_1;
2875
- function getAllKeysIn$1(object) {
2876
- return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
2877
- }
2878
- var _getAllKeysIn = getAllKeysIn$1;
2879
- var getNative$3 = _getNative, root$4 = _root;
2880
- var DataView$1 = getNative$3(root$4, "DataView");
2881
- var _DataView = DataView$1;
2882
- var getNative$2 = _getNative, root$3 = _root;
2883
- var Promise$2 = getNative$2(root$3, "Promise");
2884
- var _Promise = Promise$2;
2885
- var getNative$1 = _getNative, root$2 = _root;
2886
- var Set$2 = getNative$1(root$2, "Set");
2887
- var _Set = Set$2;
2888
- var getNative = _getNative, root$1 = _root;
2889
- var WeakMap$2 = getNative(root$1, "WeakMap");
2890
- var _WeakMap = WeakMap$2;
2891
- var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set$1 = _Set, WeakMap$1 = _WeakMap, baseGetTag = _baseGetTag, toSource = _toSource;
2892
- var mapTag$3 = "[object Map]", objectTag$2 = "[object Object]", promiseTag = "[object Promise]", setTag$3 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
2893
- var dataViewTag$2 = "[object DataView]";
2894
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
2895
- var getTag$3 = baseGetTag;
2896
- if (DataView && getTag$3(new DataView(new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag$3(new Map$1()) != mapTag$3 || Promise$1 && getTag$3(Promise$1.resolve()) != promiseTag || Set$1 && getTag$3(new Set$1()) != setTag$3 || WeakMap$1 && getTag$3(new WeakMap$1()) != weakMapTag$1) {
2897
- getTag$3 = function(value) {
2898
- var result = baseGetTag(value), Ctor = result == objectTag$2 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
2899
- if (ctorString) {
2900
- switch (ctorString) {
2901
- case dataViewCtorString:
2902
- return dataViewTag$2;
2903
- case mapCtorString:
2904
- return mapTag$3;
2905
- case promiseCtorString:
2906
- return promiseTag;
2907
- case setCtorString:
2908
- return setTag$3;
2909
- case weakMapCtorString:
2910
- return weakMapTag$1;
2911
- }
2912
- }
2913
- return result;
2914
- };
2915
- }
2916
- var _getTag = getTag$3;
2917
- var objectProto$7 = Object.prototype;
2918
- var hasOwnProperty$3 = objectProto$7.hasOwnProperty;
2919
- function initCloneArray$1(array) {
2920
- var length = array.length, result = new array.constructor(length);
2921
- if (length && typeof array[0] == "string" && hasOwnProperty$3.call(array, "index")) {
2922
- result.index = array.index;
2923
- result.input = array.input;
2924
- }
2925
- return result;
2926
- }
2927
- var _initCloneArray = initCloneArray$1;
2928
- var root = _root;
2929
- var Uint8Array$2 = root.Uint8Array;
2930
- var _Uint8Array = Uint8Array$2;
2931
- var Uint8Array$1 = _Uint8Array;
2932
- function cloneArrayBuffer$3(arrayBuffer) {
2933
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2934
- new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer));
2935
- return result;
2936
- }
2937
- var _cloneArrayBuffer = cloneArrayBuffer$3;
2938
- var cloneArrayBuffer$2 = _cloneArrayBuffer;
2939
- function cloneDataView$1(dataView, isDeep) {
2940
- var buffer = isDeep ? cloneArrayBuffer$2(dataView.buffer) : dataView.buffer;
2941
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
2942
- }
2943
- var _cloneDataView = cloneDataView$1;
2944
- var reFlags = /\w*$/;
2945
- function cloneRegExp$1(regexp) {
2946
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2947
- result.lastIndex = regexp.lastIndex;
2948
- return result;
2949
- }
2950
- var _cloneRegExp = cloneRegExp$1;
2951
- var Symbol$1 = _Symbol;
2952
- var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2953
- function cloneSymbol$1(symbol) {
2954
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2955
- }
2956
- var _cloneSymbol = cloneSymbol$1;
2957
- var cloneArrayBuffer$1 = _cloneArrayBuffer;
2958
- function cloneTypedArray$1(typedArray, isDeep) {
2959
- var buffer = isDeep ? cloneArrayBuffer$1(typedArray.buffer) : typedArray.buffer;
2960
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2961
- }
2962
- var _cloneTypedArray = cloneTypedArray$1;
2963
- var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
2964
- var boolTag$2 = "[object Boolean]", dateTag$1 = "[object Date]", mapTag$2 = "[object Map]", numberTag$2 = "[object Number]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$3 = "[object String]", symbolTag$4 = "[object Symbol]";
2965
- var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
2966
- function initCloneByTag$1(object, tag2, isDeep) {
2967
- var Ctor = object.constructor;
2968
- switch (tag2) {
2969
- case arrayBufferTag$1:
2970
- return cloneArrayBuffer(object);
2971
- case boolTag$2:
2972
- case dateTag$1:
2973
- return new Ctor(+object);
2974
- case dataViewTag$1:
2975
- return cloneDataView(object, isDeep);
2976
- case float32Tag$1:
2977
- case float64Tag$1:
2978
- case int8Tag$1:
2979
- case int16Tag$1:
2980
- case int32Tag$1:
2981
- case uint8Tag$1:
2982
- case uint8ClampedTag$1:
2983
- case uint16Tag$1:
2984
- case uint32Tag$1:
2985
- return cloneTypedArray(object, isDeep);
2986
- case mapTag$2:
2987
- return new Ctor();
2988
- case numberTag$2:
2989
- case stringTag$3:
2990
- return new Ctor(object);
2991
- case regexpTag$1:
2992
- return cloneRegExp(object);
2993
- case setTag$2:
2994
- return new Ctor();
2995
- case symbolTag$4:
2996
- return cloneSymbol(object);
2997
- }
2998
- }
2999
- var _initCloneByTag = initCloneByTag$1;
3000
- var isObject$6 = isObject_1;
3001
- var objectCreate = Object.create;
3002
- var baseCreate$1 = /* @__PURE__ */ function() {
3003
- function object() {
3004
- }
3005
- return function(proto) {
3006
- if (!isObject$6(proto)) {
3007
- return {};
3008
- }
3009
- if (objectCreate) {
3010
- return objectCreate(proto);
3011
- }
3012
- object.prototype = proto;
3013
- var result = new object();
3014
- object.prototype = void 0;
3015
- return result;
3016
- };
3017
- }();
3018
- var _baseCreate = baseCreate$1;
3019
- var baseCreate = _baseCreate, getPrototype$1 = _getPrototype, isPrototype$1 = _isPrototype;
3020
- function initCloneObject$1(object) {
3021
- return typeof object.constructor == "function" && !isPrototype$1(object) ? baseCreate(getPrototype$1(object)) : {};
3022
- }
3023
- var _initCloneObject = initCloneObject$1;
3024
- var getTag$2 = _getTag, isObjectLike$a = isObjectLike_1;
3025
- var mapTag$1 = "[object Map]";
3026
- function baseIsMap$1(value) {
3027
- return isObjectLike$a(value) && getTag$2(value) == mapTag$1;
3028
- }
3029
- var _baseIsMap = baseIsMap$1;
3030
- var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtilExports;
3031
- var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
3032
- var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
3033
- var isMap_1 = isMap$1;
3034
- var getTag$1 = _getTag, isObjectLike$9 = isObjectLike_1;
3035
- var setTag$1 = "[object Set]";
3036
- function baseIsSet$1(value) {
3037
- return isObjectLike$9(value) && getTag$1(value) == setTag$1;
3038
- }
3039
- var _baseIsSet = baseIsSet$1;
3040
- var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
3041
- var nodeIsSet = nodeUtil && nodeUtil.isSet;
3042
- var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
3043
- var isSet_1 = isSet$1;
3044
- var Stack = _Stack, arrayEach = _arrayEach, assignValue = _assignValue, baseAssign = _baseAssign, baseAssignIn = _baseAssignIn, cloneBuffer = _cloneBufferExports, copyArray = _copyArray, copySymbols = _copySymbols, copySymbolsIn = _copySymbolsIn, getAllKeys = _getAllKeys, getAllKeysIn = _getAllKeysIn, getTag = _getTag, initCloneArray = _initCloneArray, initCloneByTag = _initCloneByTag, initCloneObject = _initCloneObject, isArray$3 = isArray_1, isBuffer = isBufferExports, isMap = isMap_1, isObject$5 = isObject_1, isSet = isSet_1, keys$1 = keys_1, keysIn = keysIn_1;
3045
- var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
3046
- var argsTag$1 = "[object Arguments]", arrayTag = "[object Array]", boolTag$1 = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag$1 = "[object Function]", genTag$1 = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag$1 = "[object Number]", objectTag$1 = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag$2 = "[object String]", symbolTag$3 = "[object Symbol]", weakMapTag = "[object WeakMap]";
3047
- var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
3048
- var cloneableTags = {};
3049
- cloneableTags[argsTag$1] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag$1] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag$1] = cloneableTags[objectTag$1] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag$2] = cloneableTags[symbolTag$3] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
3050
- cloneableTags[errorTag] = cloneableTags[funcTag$1] = cloneableTags[weakMapTag] = false;
3051
- function baseClone$1(value, bitmask, customizer, key, object, stack) {
3052
- var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
3053
- if (customizer) {
3054
- result = object ? customizer(value, key, object, stack) : customizer(value);
3055
- }
3056
- if (result !== void 0) {
3057
- return result;
3058
- }
3059
- if (!isObject$5(value)) {
3060
- return value;
3061
- }
3062
- var isArr = isArray$3(value);
3063
- if (isArr) {
3064
- result = initCloneArray(value);
3065
- if (!isDeep) {
3066
- return copyArray(value, result);
3067
- }
3068
- } else {
3069
- var tag2 = getTag(value), isFunc = tag2 == funcTag$1 || tag2 == genTag$1;
3070
- if (isBuffer(value)) {
3071
- return cloneBuffer(value, isDeep);
3072
- }
3073
- if (tag2 == objectTag$1 || tag2 == argsTag$1 || isFunc && !object) {
3074
- result = isFlat || isFunc ? {} : initCloneObject(value);
3075
- if (!isDeep) {
3076
- return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
3077
- }
3078
- } else {
3079
- if (!cloneableTags[tag2]) {
3080
- return object ? value : {};
3081
- }
3082
- result = initCloneByTag(value, tag2, isDeep);
3083
- }
3084
- }
3085
- stack || (stack = new Stack());
3086
- var stacked = stack.get(value);
3087
- if (stacked) {
3088
- return stacked;
3089
- }
3090
- stack.set(value, result);
3091
- if (isSet(value)) {
3092
- value.forEach(function(subValue) {
3093
- result.add(baseClone$1(subValue, bitmask, customizer, subValue, value, stack));
3094
- });
3095
- } else if (isMap(value)) {
3096
- value.forEach(function(subValue, key2) {
3097
- result.set(key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
3098
- });
3099
- }
3100
- var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys$1;
3101
- var props = isArr ? void 0 : keysFunc(value);
3102
- arrayEach(props || value, function(subValue, key2) {
3103
- if (props) {
3104
- key2 = subValue;
3105
- subValue = value[key2];
3106
- }
3107
- assignValue(result, key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
3108
- });
3109
- return result;
3110
- }
3111
- var _baseClone = baseClone$1;
3112
- var baseClone = _baseClone;
3113
- var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4;
3114
- function cloneDeep(value) {
3115
- return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
3116
- }
3117
- var cloneDeep_1 = cloneDeep;
3118
- const cloneDeep$1 = /* @__PURE__ */ getDefaultExportFromCjs(cloneDeep_1);
3119
2160
  class CollectionRegistry {
3120
2161
  // Normalized runtime layer (used by Data Grid / UI)
3121
2162
  collectionsByTableName = /* @__PURE__ */ new Map();
@@ -3163,7 +2204,7 @@ class CollectionRegistry {
3163
2204
  ...c
3164
2205
  }));
3165
2206
  normalizedCollections.forEach((c, index) => {
3166
- const raw = cloneDeep$1(collections[index]);
2207
+ const raw = deepClone(collections[index]);
3167
2208
  this.rootCollections.push(c);
3168
2209
  this.rawRootCollections.push(raw);
3169
2210
  const normalized2 = this.normalizeCollection(c);
@@ -3183,7 +2224,7 @@ class CollectionRegistry {
3183
2224
  if (!subCollection) return;
3184
2225
  this._registerRecursively(this.normalizeCollection({
3185
2226
  ...subCollection
3186
- }), cloneDeep$1(subCollection));
2227
+ }), deepClone(subCollection));
3187
2228
  });
3188
2229
  }
3189
2230
  });
@@ -3191,7 +2232,7 @@ class CollectionRegistry {
3191
2232
  return true;
3192
2233
  }
3193
2234
  register(collection, rawCollection) {
3194
- const raw = rawCollection ? cloneDeep$1(rawCollection) : cloneDeep$1(collection);
2235
+ const raw = rawCollection ? deepClone(rawCollection) : deepClone(collection);
3195
2236
  this.rootCollections.push(collection);
3196
2237
  this.rawRootCollections.push(raw);
3197
2238
  this._registerRecursively(collection, raw);
@@ -3215,7 +2256,7 @@ class CollectionRegistry {
3215
2256
  if (!subCollection) return;
3216
2257
  this._registerRecursively(this.normalizeCollection({
3217
2258
  ...subCollection
3218
- }), cloneDeep$1(subCollection));
2259
+ }), deepClone(subCollection));
3219
2260
  });
3220
2261
  }
3221
2262
  }
@@ -3474,16 +2515,15 @@ async function loadCollectionsFromDirectory(directory) {
3474
2515
  const filePath = path$3.join(directory, file);
3475
2516
  try {
3476
2517
  const fileUrl = pathToFileURL(filePath).href;
3477
- const dynamicImport = new Function("url", "return import(url)");
3478
- const module = await dynamicImport(fileUrl);
2518
+ const module = await import(fileUrl);
3479
2519
  if (module && module.default) {
3480
2520
  collections.push(module.default);
3481
2521
  } else {
3482
2522
  console.warn(`[loadCollectionsFromDirectory] File ${file} does not have a default export. Skipping.`);
3483
2523
  }
3484
2524
  } catch (err) {
3485
- const message2 = err instanceof Error ? err.message : String(err);
3486
- console.error(`[loadCollectionsFromDirectory] Failed to load collection from ${file}: ${message2}`);
2525
+ const message = err instanceof Error ? err.message : String(err);
2526
+ console.error(`[loadCollectionsFromDirectory] Failed to load collection from ${file}: ${message}`);
3487
2527
  }
3488
2528
  }
3489
2529
  }
@@ -3566,34 +2606,34 @@ class ApiError extends Error {
3566
2606
  statusCode;
3567
2607
  code;
3568
2608
  details;
3569
- constructor(statusCode, code2, message2, details) {
3570
- super(message2);
2609
+ constructor(statusCode, code2, message, details) {
2610
+ super(message);
3571
2611
  this.name = "ApiError";
3572
2612
  this.statusCode = statusCode;
3573
2613
  this.code = code2;
3574
2614
  this.details = details;
3575
2615
  }
3576
2616
  // ── Factory methods ──────────────────────────────────────────────
3577
- static badRequest(message2, code2 = "BAD_REQUEST", details) {
3578
- return new ApiError(400, code2, message2, details);
2617
+ static badRequest(message, code2 = "BAD_REQUEST", details) {
2618
+ return new ApiError(400, code2, message, details);
3579
2619
  }
3580
- static unauthorized(message2, code2 = "UNAUTHORIZED") {
3581
- return new ApiError(401, code2, message2);
2620
+ static unauthorized(message, code2 = "UNAUTHORIZED") {
2621
+ return new ApiError(401, code2, message);
3582
2622
  }
3583
- static forbidden(message2, code2 = "FORBIDDEN") {
3584
- return new ApiError(403, code2, message2);
2623
+ static forbidden(message, code2 = "FORBIDDEN") {
2624
+ return new ApiError(403, code2, message);
3585
2625
  }
3586
- static notFound(message2, code2 = "NOT_FOUND") {
3587
- return new ApiError(404, code2, message2);
2626
+ static notFound(message, code2 = "NOT_FOUND") {
2627
+ return new ApiError(404, code2, message);
3588
2628
  }
3589
- static conflict(message2, code2 = "CONFLICT") {
3590
- return new ApiError(409, code2, message2);
2629
+ static conflict(message, code2 = "CONFLICT") {
2630
+ return new ApiError(409, code2, message);
3591
2631
  }
3592
- static internal(message2, code2 = "INTERNAL_ERROR") {
3593
- return new ApiError(500, code2, message2);
2632
+ static internal(message, code2 = "INTERNAL_ERROR") {
2633
+ return new ApiError(500, code2, message);
3594
2634
  }
3595
- static serviceUnavailable(message2, code2 = "SERVICE_UNAVAILABLE") {
3596
- return new ApiError(503, code2, message2);
2635
+ static serviceUnavailable(message, code2 = "SERVICE_UNAVAILABLE") {
2636
+ return new ApiError(503, code2, message);
3597
2637
  }
3598
2638
  }
3599
2639
  const errorHandler = (err, c) => {
@@ -3633,7 +2673,8 @@ const errorHandler = (err, c) => {
3633
2673
  console.error(`❌ [API] ${c.req.method} ${c.req.path} → ${statusCode} ${code2}: ${logMessage}`);
3634
2674
  const causePg = error2.cause && typeof error2.cause === "object" ? error2.cause : void 0;
3635
2675
  const pgErrorCode = causePg?.code || error2.code;
3636
- if (pgErrorCode !== "42703" && pgErrorCode !== "42P01") {
2676
+ const suppressStack = pgErrorCode === "42703" || pgErrorCode === "42P01" || statusCode < 500 && code2 === "BAD_REQUEST";
2677
+ if (!suppressStack) {
3637
2678
  console.error(error2.stack || error2);
3638
2679
  }
3639
2680
  let clientMessage = "An unexpected error occurred";
@@ -3721,8 +2762,8 @@ function parseQueryOptions(query) {
3721
2762
  }
3722
2763
  Object.assign(options2.where, parsedWhere);
3723
2764
  } catch (e) {
3724
- const message2 = e instanceof Error ? e.message : "malformed JSON";
3725
- const err = new Error(`Invalid 'where' filter: ${message2}`);
2765
+ const message = e instanceof Error ? e.message : "malformed JSON";
2766
+ const err = new Error(`Invalid 'where' filter: ${message}`);
3726
2767
  err.code = "BAD_REQUEST";
3727
2768
  err.statusCode = 400;
3728
2769
  throw err;
@@ -4830,11 +3871,11 @@ var Stream$1 = require$$0$3;
4830
3871
  var toString2 = tostring;
4831
3872
  var util$4 = require$$5;
4832
3873
  var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
4833
- function isObject$4(thing) {
3874
+ function isObject$3(thing) {
4834
3875
  return Object.prototype.toString.call(thing) === "[object Object]";
4835
3876
  }
4836
3877
  function safeJsonParse(thing) {
4837
- if (isObject$4(thing))
3878
+ if (isObject$3(thing))
4838
3879
  return thing;
4839
3880
  try {
4840
3881
  return JSON.parse(thing);
@@ -4960,7 +4001,7 @@ jws$5.createVerify = function createVerify(opts) {
4960
4001
  return new VerifyStream(opts);
4961
4002
  };
4962
4003
  var jws$4 = jws$5;
4963
- var decode$3 = function(jwt2, options2) {
4004
+ var decode$2 = function(jwt2, options2) {
4964
4005
  options2 = options2 || {};
4965
4006
  var decoded = jws$4.decode(jwt2, options2);
4966
4007
  if (!decoded) {
@@ -4985,21 +4026,21 @@ var decode$3 = function(jwt2, options2) {
4985
4026
  }
4986
4027
  return payload;
4987
4028
  };
4988
- var JsonWebTokenError$3 = function(message2, error2) {
4989
- Error.call(this, message2);
4029
+ var JsonWebTokenError$3 = function(message, error2) {
4030
+ Error.call(this, message);
4990
4031
  if (Error.captureStackTrace) {
4991
4032
  Error.captureStackTrace(this, this.constructor);
4992
4033
  }
4993
4034
  this.name = "JsonWebTokenError";
4994
- this.message = message2;
4035
+ this.message = message;
4995
4036
  if (error2) this.inner = error2;
4996
4037
  };
4997
4038
  JsonWebTokenError$3.prototype = Object.create(Error.prototype);
4998
4039
  JsonWebTokenError$3.prototype.constructor = JsonWebTokenError$3;
4999
4040
  var JsonWebTokenError_1 = JsonWebTokenError$3;
5000
4041
  var JsonWebTokenError$2 = JsonWebTokenError_1;
5001
- var NotBeforeError$1 = function(message2, date) {
5002
- JsonWebTokenError$2.call(this, message2);
4042
+ var NotBeforeError$1 = function(message, date) {
4043
+ JsonWebTokenError$2.call(this, message);
5003
4044
  this.name = "NotBeforeError";
5004
4045
  this.date = date;
5005
4046
  };
@@ -5007,8 +4048,8 @@ NotBeforeError$1.prototype = Object.create(JsonWebTokenError$2.prototype);
5007
4048
  NotBeforeError$1.prototype.constructor = NotBeforeError$1;
5008
4049
  var NotBeforeError_1 = NotBeforeError$1;
5009
4050
  var JsonWebTokenError$1 = JsonWebTokenError_1;
5010
- var TokenExpiredError$1 = function(message2, expiredAt) {
5011
- JsonWebTokenError$1.call(this, message2);
4051
+ var TokenExpiredError$1 = function(message, expiredAt) {
4052
+ JsonWebTokenError$1.call(this, message);
5012
4053
  this.name = "TokenExpiredError";
5013
4054
  this.expiredAt = expiredAt;
5014
4055
  };
@@ -5873,7 +4914,7 @@ function requireRange() {
5873
4914
  parseRange(range2) {
5874
4915
  const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
5875
4916
  const memoKey = memoOpts + ":" + range2;
5876
- const cached = cache2.get(memoKey);
4917
+ const cached = cache.get(memoKey);
5877
4918
  if (cached) {
5878
4919
  return cached;
5879
4920
  }
@@ -5907,7 +4948,7 @@ function requireRange() {
5907
4948
  rangeMap.delete("");
5908
4949
  }
5909
4950
  const result = [...rangeMap.values()];
5910
- cache2.set(memoKey, result);
4951
+ cache.set(memoKey, result);
5911
4952
  return result;
5912
4953
  }
5913
4954
  intersects(range2, options2) {
@@ -5946,7 +4987,7 @@ function requireRange() {
5946
4987
  }
5947
4988
  range = Range2;
5948
4989
  const LRU = lrucache;
5949
- const cache2 = new LRU();
4990
+ const cache = new LRU();
5950
4991
  const parseOptions2 = parseOptions_1;
5951
4992
  const Comparator2 = requireComparator();
5952
4993
  const debug2 = debug_1;
@@ -6823,7 +5864,7 @@ var psSupported = semver.satisfies(process.version, "^6.12.0 || >=8.0.0");
6823
5864
  const JsonWebTokenError = JsonWebTokenError_1;
6824
5865
  const NotBeforeError = NotBeforeError_1;
6825
5866
  const TokenExpiredError = TokenExpiredError_1;
6826
- const decode$2 = decode$3;
5867
+ const decode$1 = decode$2;
6827
5868
  const timespan$1 = timespan$2;
6828
5869
  const validateAsymmetricKey$1 = validateAsymmetricKey$2;
6829
5870
  const PS_SUPPORTED$1 = psSupported;
@@ -6877,7 +5918,7 @@ var verify2 = function(jwtString, secretOrPublicKey, options2, callback) {
6877
5918
  }
6878
5919
  let decodedToken;
6879
5920
  try {
6880
- decodedToken = decode$2(jwtString, { complete: true });
5921
+ decodedToken = decode$1(jwtString, { complete: true });
6881
5922
  } catch (err) {
6882
5923
  return done(err);
6883
5924
  }
@@ -7137,27 +6178,27 @@ function isArrayLike(value) {
7137
6178
  return value != null && isLength(value.length) && !isFunction(value);
7138
6179
  }
7139
6180
  function isArrayLikeObject(value) {
7140
- return isObjectLike$8(value) && isArrayLike(value);
6181
+ return isObjectLike$7(value) && isArrayLike(value);
7141
6182
  }
7142
6183
  function isFunction(value) {
7143
- var tag2 = isObject$3(value) ? objectToString$6.call(value) : "";
7144
- return tag2 == funcTag || tag2 == genTag;
6184
+ var tag = isObject$2(value) ? objectToString$6.call(value) : "";
6185
+ return tag == funcTag || tag == genTag;
7145
6186
  }
7146
6187
  function isLength(value) {
7147
6188
  return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
7148
6189
  }
7149
- function isObject$3(value) {
6190
+ function isObject$2(value) {
7150
6191
  var type = typeof value;
7151
6192
  return !!value && (type == "object" || type == "function");
7152
6193
  }
7153
- function isObjectLike$8(value) {
6194
+ function isObjectLike$7(value) {
7154
6195
  return !!value && typeof value == "object";
7155
6196
  }
7156
6197
  function isString$2(value) {
7157
- return typeof value == "string" || !isArray$2(value) && isObjectLike$8(value) && objectToString$6.call(value) == stringTag$1;
6198
+ return typeof value == "string" || !isArray$2(value) && isObjectLike$7(value) && objectToString$6.call(value) == stringTag$1;
7158
6199
  }
7159
6200
  function isSymbol$2(value) {
7160
- return typeof value == "symbol" || isObjectLike$8(value) && objectToString$6.call(value) == symbolTag$2;
6201
+ return typeof value == "symbol" || isObjectLike$7(value) && objectToString$6.call(value) == symbolTag$2;
7161
6202
  }
7162
6203
  function toFinite$2(value) {
7163
6204
  if (!value) {
@@ -7181,9 +6222,9 @@ function toNumber$2(value) {
7181
6222
  if (isSymbol$2(value)) {
7182
6223
  return NAN$2;
7183
6224
  }
7184
- if (isObject$3(value)) {
6225
+ if (isObject$2(value)) {
7185
6226
  var other = typeof value.valueOf == "function" ? value.valueOf() : value;
7186
- value = isObject$3(other) ? other + "" : other;
6227
+ value = isObject$2(other) ? other + "" : other;
7187
6228
  }
7188
6229
  if (typeof value != "string") {
7189
6230
  return value === 0 ? value : +value;
@@ -7203,9 +6244,9 @@ var boolTag = "[object Boolean]";
7203
6244
  var objectProto$5 = Object.prototype;
7204
6245
  var objectToString$5 = objectProto$5.toString;
7205
6246
  function isBoolean$1(value) {
7206
- return value === true || value === false || isObjectLike$7(value) && objectToString$5.call(value) == boolTag;
6247
+ return value === true || value === false || isObjectLike$6(value) && objectToString$5.call(value) == boolTag;
7207
6248
  }
7208
- function isObjectLike$7(value) {
6249
+ function isObjectLike$6(value) {
7209
6250
  return !!value && typeof value == "object";
7210
6251
  }
7211
6252
  var lodash_isboolean = isBoolean$1;
@@ -7221,15 +6262,15 @@ var objectToString$4 = objectProto$4.toString;
7221
6262
  function isInteger$1(value) {
7222
6263
  return typeof value == "number" && value == toInteger$1(value);
7223
6264
  }
7224
- function isObject$2(value) {
6265
+ function isObject$1(value) {
7225
6266
  var type = typeof value;
7226
6267
  return !!value && (type == "object" || type == "function");
7227
6268
  }
7228
- function isObjectLike$6(value) {
6269
+ function isObjectLike$5(value) {
7229
6270
  return !!value && typeof value == "object";
7230
6271
  }
7231
6272
  function isSymbol$1(value) {
7232
- return typeof value == "symbol" || isObjectLike$6(value) && objectToString$4.call(value) == symbolTag$1;
6273
+ return typeof value == "symbol" || isObjectLike$5(value) && objectToString$4.call(value) == symbolTag$1;
7233
6274
  }
7234
6275
  function toFinite$1(value) {
7235
6276
  if (!value) {
@@ -7253,9 +6294,9 @@ function toNumber$1(value) {
7253
6294
  if (isSymbol$1(value)) {
7254
6295
  return NAN$1;
7255
6296
  }
7256
- if (isObject$2(value)) {
6297
+ if (isObject$1(value)) {
7257
6298
  var other = typeof value.valueOf == "function" ? value.valueOf() : value;
7258
- value = isObject$2(other) ? other + "" : other;
6299
+ value = isObject$1(other) ? other + "" : other;
7259
6300
  }
7260
6301
  if (typeof value != "string") {
7261
6302
  return value === 0 ? value : +value;
@@ -7268,11 +6309,11 @@ var lodash_isinteger = isInteger$1;
7268
6309
  var numberTag = "[object Number]";
7269
6310
  var objectProto$3 = Object.prototype;
7270
6311
  var objectToString$3 = objectProto$3.toString;
7271
- function isObjectLike$5(value) {
6312
+ function isObjectLike$4(value) {
7272
6313
  return !!value && typeof value == "object";
7273
6314
  }
7274
6315
  function isNumber$1(value) {
7275
- return typeof value == "number" || isObjectLike$5(value) && objectToString$3.call(value) == numberTag;
6316
+ return typeof value == "number" || isObjectLike$4(value) && objectToString$3.call(value) == numberTag;
7276
6317
  }
7277
6318
  var lodash_isnumber = isNumber$1;
7278
6319
  var objectTag = "[object Object]";
@@ -7297,11 +6338,11 @@ var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
7297
6338
  var objectCtorString = funcToString.call(Object);
7298
6339
  var objectToString$2 = objectProto$2.toString;
7299
6340
  var getPrototype = overArg(Object.getPrototypeOf, Object);
7300
- function isObjectLike$4(value) {
6341
+ function isObjectLike$3(value) {
7301
6342
  return !!value && typeof value == "object";
7302
6343
  }
7303
6344
  function isPlainObject$2(value) {
7304
- if (!isObjectLike$4(value) || objectToString$2.call(value) != objectTag || isHostObject(value)) {
6345
+ if (!isObjectLike$3(value) || objectToString$2.call(value) != objectTag || isHostObject(value)) {
7305
6346
  return false;
7306
6347
  }
7307
6348
  var proto = getPrototype(value);
@@ -7316,11 +6357,11 @@ var stringTag = "[object String]";
7316
6357
  var objectProto$1 = Object.prototype;
7317
6358
  var objectToString$1 = objectProto$1.toString;
7318
6359
  var isArray$1 = Array.isArray;
7319
- function isObjectLike$3(value) {
6360
+ function isObjectLike$2(value) {
7320
6361
  return !!value && typeof value == "object";
7321
6362
  }
7322
6363
  function isString$1(value) {
7323
- return typeof value == "string" || !isArray$1(value) && isObjectLike$3(value) && objectToString$1.call(value) == stringTag;
6364
+ return typeof value == "string" || !isArray$1(value) && isObjectLike$2(value) && objectToString$1.call(value) == stringTag;
7324
6365
  }
7325
6366
  var lodash_isstring = isString$1;
7326
6367
  var FUNC_ERROR_TEXT = "Expected a function";
@@ -7352,15 +6393,15 @@ function before(n, func) {
7352
6393
  function once$1(func) {
7353
6394
  return before(2, func);
7354
6395
  }
7355
- function isObject$1(value) {
6396
+ function isObject(value) {
7356
6397
  var type = typeof value;
7357
6398
  return !!value && (type == "object" || type == "function");
7358
6399
  }
7359
- function isObjectLike$2(value) {
6400
+ function isObjectLike$1(value) {
7360
6401
  return !!value && typeof value == "object";
7361
6402
  }
7362
6403
  function isSymbol(value) {
7363
- return typeof value == "symbol" || isObjectLike$2(value) && objectToString.call(value) == symbolTag;
6404
+ return typeof value == "symbol" || isObjectLike$1(value) && objectToString.call(value) == symbolTag;
7364
6405
  }
7365
6406
  function toFinite(value) {
7366
6407
  if (!value) {
@@ -7384,9 +6425,9 @@ function toNumber(value) {
7384
6425
  if (isSymbol(value)) {
7385
6426
  return NAN;
7386
6427
  }
7387
- if (isObject$1(value)) {
6428
+ if (isObject(value)) {
7388
6429
  var other = typeof value.valueOf == "function" ? value.valueOf() : value;
7389
- value = isObject$1(other) ? other + "" : other;
6430
+ value = isObject(other) ? other + "" : other;
7390
6431
  }
7391
6432
  if (typeof value != "string") {
7392
6433
  return value === 0 ? value : +value;
@@ -7477,7 +6518,7 @@ const options_for_objects = [
7477
6518
  "subject",
7478
6519
  "jwtid"
7479
6520
  ];
7480
- var sign$4 = function(payload, secretOrPrivateKey, options2, callback) {
6521
+ var sign$3 = function(payload, secretOrPrivateKey, options2, callback) {
7481
6522
  if (typeof options2 === "function") {
7482
6523
  callback = options2;
7483
6524
  options2 = {};
@@ -7616,9 +6657,9 @@ var sign$4 = function(payload, secretOrPrivateKey, options2, callback) {
7616
6657
  }
7617
6658
  };
7618
6659
  var jsonwebtoken = {
7619
- decode: decode$3,
6660
+ decode: decode$2,
7620
6661
  verify: verify2,
7621
- sign: sign$4,
6662
+ sign: sign$3,
7622
6663
  JsonWebTokenError: JsonWebTokenError_1,
7623
6664
  NotBeforeError: NotBeforeError_1,
7624
6665
  TokenExpiredError: TokenExpiredError_1
@@ -8069,7 +7110,7 @@ function formatData(data) {
8069
7110
  }
8070
7111
  function createLogger(defaultFields = {}) {
8071
7112
  const minLevel = getMinLevel();
8072
- function emit(level, message2, data) {
7113
+ function emit(level, message, data) {
8073
7114
  if (LOG_PRIORITY[level] < LOG_PRIORITY[minLevel]) return;
8074
7115
  const merged = {
8075
7116
  ...defaultFields,
@@ -8078,7 +7119,7 @@ function createLogger(defaultFields = {}) {
8078
7119
  if (isProduction$1()) {
8079
7120
  const entry = {
8080
7121
  severity: GCP_SEVERITY[level],
8081
- message: message2,
7122
+ message,
8082
7123
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
8083
7124
  ...merged
8084
7125
  };
@@ -8091,7 +7132,7 @@ function createLogger(defaultFields = {}) {
8091
7132
  } else {
8092
7133
  const prefix = level === "error" ? "❌" : level === "warn" ? "⚠️" : level === "info" ? "ℹ️" : "🐛";
8093
7134
  const extra = Object.keys(merged).length > 0 ? ` ${JSON.stringify(merged)}` : "";
8094
- const out = `${prefix} [${level.toUpperCase()}] ${message2}${extra}`;
7135
+ const out = `${prefix} [${level.toUpperCase()}] ${message}${extra}`;
8095
7136
  if (level === "error") {
8096
7137
  console.error(out);
8097
7138
  } else if (level === "warn") {
@@ -8452,9 +7493,9 @@ util$3.pkg = require$$0$1;
8452
7493
  }
8453
7494
  return Function.prototype[Symbol.hasInstance].call(GaxiosError, instance);
8454
7495
  }
8455
- constructor(message2, config, response, error2) {
7496
+ constructor(message, config, response, error2) {
8456
7497
  var _b2;
8457
- super(message2);
7498
+ super(message);
8458
7499
  this.config = config;
8459
7500
  this.response = response;
8460
7501
  this.error = error2;
@@ -14350,8 +13391,8 @@ const readFile$2 = fs$3.readFile ? (0, util_1$5.promisify)(fs$3.readFile) : asyn
14350
13391
  const GOOGLE_TOKEN_URL = "https://www.googleapis.com/oauth2/v4/token";
14351
13392
  const GOOGLE_REVOKE_TOKEN_URL = "https://accounts.google.com/o/oauth2/revoke?token=";
14352
13393
  class ErrorWithCode extends Error {
14353
- constructor(message2, code2) {
14354
- super(message2);
13394
+ constructor(message, code2) {
13395
+ super(message);
14355
13396
  this.code = code2;
14356
13397
  }
14357
13398
  }
@@ -15207,13 +14248,13 @@ class Impersonated extends oauth2client_1.OAuth2Client {
15207
14248
  if (!(error2 instanceof Error))
15208
14249
  throw error2;
15209
14250
  let status = 0;
15210
- let message2 = "";
14251
+ let message = "";
15211
14252
  if (error2 instanceof gaxios_1$2.GaxiosError) {
15212
14253
  status = (_c2 = (_b2 = (_a2 = error2 === null || error2 === void 0 ? void 0 : error2.response) === null || _a2 === void 0 ? void 0 : _a2.data) === null || _b2 === void 0 ? void 0 : _b2.error) === null || _c2 === void 0 ? void 0 : _c2.status;
15213
- message2 = (_f = (_e = (_d = error2 === null || error2 === void 0 ? void 0 : error2.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.message;
14254
+ message = (_f = (_e = (_d = error2 === null || error2 === void 0 ? void 0 : error2.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.message;
15214
14255
  }
15215
- if (status && message2) {
15216
- error2.message = `${status}: unable to impersonate: ${message2}`;
14256
+ if (status && message) {
14257
+ error2.message = `${status}: unable to impersonate: ${message}`;
15217
14258
  throw error2;
15218
14259
  } else {
15219
14260
  error2.message = `unable to impersonate: ${error2}`;
@@ -15375,14 +14416,14 @@ function getErrorFromOAuthErrorResponse(resp, err) {
15375
14416
  const errorCode = resp.error;
15376
14417
  const errorDescription = resp.error_description;
15377
14418
  const errorUri = resp.error_uri;
15378
- let message2 = `Error code ${errorCode}`;
14419
+ let message = `Error code ${errorCode}`;
15379
14420
  if (typeof errorDescription !== "undefined") {
15380
- message2 += `: ${errorDescription}`;
14421
+ message += `: ${errorDescription}`;
15381
14422
  }
15382
14423
  if (typeof errorUri !== "undefined") {
15383
- message2 += ` - ${errorUri}`;
14424
+ message += ` - ${errorUri}`;
15384
14425
  }
15385
- const newError = new Error(message2);
14426
+ const newError = new Error(message);
15386
14427
  if (err) {
15387
14428
  const keys2 = Object.keys(err);
15388
14429
  if (err.stack) {
@@ -16110,14 +15151,14 @@ class AwsRequestSigner {
16110
15151
  }
16111
15152
  }
16112
15153
  awsrequestsigner.AwsRequestSigner = AwsRequestSigner;
16113
- async function sign$3(crypto2, key, msg) {
15154
+ async function sign$2(crypto2, key, msg) {
16114
15155
  return await crypto2.signWithHmacSha256(key, msg);
16115
15156
  }
16116
15157
  async function getSigningKey(crypto2, key, dateStamp, region, serviceName) {
16117
- const kDate = await sign$3(crypto2, `AWS4${key}`, dateStamp);
16118
- const kRegion = await sign$3(crypto2, kDate, region);
16119
- const kService = await sign$3(crypto2, kRegion, serviceName);
16120
- const kSigning = await sign$3(crypto2, kService, "aws4_request");
15158
+ const kDate = await sign$2(crypto2, `AWS4${key}`, dateStamp);
15159
+ const kRegion = await sign$2(crypto2, kDate, region);
15160
+ const kService = await sign$2(crypto2, kRegion, serviceName);
15161
+ const kSigning = await sign$2(crypto2, kService, "aws4_request");
16121
15162
  return kSigning;
16122
15163
  }
16123
15164
  async function generateAuthenticationHeaderMap(options2) {
@@ -16163,7 +15204,7 @@ ${amzDate}
16163
15204
  ${credentialScope}
16164
15205
  ` + await options2.crypto.sha256DigestHex(canonicalRequest);
16165
15206
  const signingKey = await getSigningKey(options2.crypto, options2.securityCredentials.secretAccessKey, dateStamp, options2.region, serviceName);
16166
- const signature = await sign$3(options2.crypto, signingKey, stringToSign);
15207
+ const signature = await sign$2(options2.crypto, signingKey, stringToSign);
16167
15208
  const authorizationHeader = `${AWS_ALGORITHM} Credential=${options2.securityCredentials.accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${(0, crypto_1.fromArrayBufferToHex)(signature)}`;
16168
15209
  return {
16169
15210
  // Do not return x-amz-date if date is available.
@@ -16494,8 +15535,8 @@ class ExecutableResponse {
16494
15535
  }
16495
15536
  executableResponse.ExecutableResponse = ExecutableResponse;
16496
15537
  class ExecutableResponseError extends Error {
16497
- constructor(message2) {
16498
- super(message2);
15538
+ constructor(message) {
15539
+ super(message);
16499
15540
  Object.setPrototypeOf(this, new.target.prototype);
16500
15541
  }
16501
15542
  }
@@ -16658,8 +15699,8 @@ function requirePluggableAuthClient() {
16658
15699
  const executable_response_1 = executableResponse;
16659
15700
  const pluggable_auth_handler_1 = requirePluggableAuthHandler();
16660
15701
  class ExecutableError extends Error {
16661
- constructor(message2, code2) {
16662
- super(`The executable failed with exit code: ${code2} and error message: ${message2}.`);
15702
+ constructor(message, code2) {
15703
+ super(`The executable failed with exit code: ${code2} and error message: ${message}.`);
16663
15704
  this.code = code2;
16664
15705
  Object.setPrototypeOf(this, new.target.prototype);
16665
15706
  }
@@ -18307,104 +17348,104 @@ ZodError.create = (issues) => {
18307
17348
  return error2;
18308
17349
  };
18309
17350
  const errorMap = (issue, _ctx) => {
18310
- let message2;
17351
+ let message;
18311
17352
  switch (issue.code) {
18312
17353
  case ZodIssueCode.invalid_type:
18313
17354
  if (issue.received === ZodParsedType.undefined) {
18314
- message2 = "Required";
17355
+ message = "Required";
18315
17356
  } else {
18316
- message2 = `Expected ${issue.expected}, received ${issue.received}`;
17357
+ message = `Expected ${issue.expected}, received ${issue.received}`;
18317
17358
  }
18318
17359
  break;
18319
17360
  case ZodIssueCode.invalid_literal:
18320
- message2 = `Invalid literal value, expected ${JSON.stringify(issue.expected, util$1.jsonStringifyReplacer)}`;
17361
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util$1.jsonStringifyReplacer)}`;
18321
17362
  break;
18322
17363
  case ZodIssueCode.unrecognized_keys:
18323
- message2 = `Unrecognized key(s) in object: ${util$1.joinValues(issue.keys, ", ")}`;
17364
+ message = `Unrecognized key(s) in object: ${util$1.joinValues(issue.keys, ", ")}`;
18324
17365
  break;
18325
17366
  case ZodIssueCode.invalid_union:
18326
- message2 = `Invalid input`;
17367
+ message = `Invalid input`;
18327
17368
  break;
18328
17369
  case ZodIssueCode.invalid_union_discriminator:
18329
- message2 = `Invalid discriminator value. Expected ${util$1.joinValues(issue.options)}`;
17370
+ message = `Invalid discriminator value. Expected ${util$1.joinValues(issue.options)}`;
18330
17371
  break;
18331
17372
  case ZodIssueCode.invalid_enum_value:
18332
- message2 = `Invalid enum value. Expected ${util$1.joinValues(issue.options)}, received '${issue.received}'`;
17373
+ message = `Invalid enum value. Expected ${util$1.joinValues(issue.options)}, received '${issue.received}'`;
18333
17374
  break;
18334
17375
  case ZodIssueCode.invalid_arguments:
18335
- message2 = `Invalid function arguments`;
17376
+ message = `Invalid function arguments`;
18336
17377
  break;
18337
17378
  case ZodIssueCode.invalid_return_type:
18338
- message2 = `Invalid function return type`;
17379
+ message = `Invalid function return type`;
18339
17380
  break;
18340
17381
  case ZodIssueCode.invalid_date:
18341
- message2 = `Invalid date`;
17382
+ message = `Invalid date`;
18342
17383
  break;
18343
17384
  case ZodIssueCode.invalid_string:
18344
17385
  if (typeof issue.validation === "object") {
18345
17386
  if ("includes" in issue.validation) {
18346
- message2 = `Invalid input: must include "${issue.validation.includes}"`;
17387
+ message = `Invalid input: must include "${issue.validation.includes}"`;
18347
17388
  if (typeof issue.validation.position === "number") {
18348
- message2 = `${message2} at one or more positions greater than or equal to ${issue.validation.position}`;
17389
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
18349
17390
  }
18350
17391
  } else if ("startsWith" in issue.validation) {
18351
- message2 = `Invalid input: must start with "${issue.validation.startsWith}"`;
17392
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
18352
17393
  } else if ("endsWith" in issue.validation) {
18353
- message2 = `Invalid input: must end with "${issue.validation.endsWith}"`;
17394
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
18354
17395
  } else {
18355
17396
  util$1.assertNever(issue.validation);
18356
17397
  }
18357
17398
  } else if (issue.validation !== "regex") {
18358
- message2 = `Invalid ${issue.validation}`;
17399
+ message = `Invalid ${issue.validation}`;
18359
17400
  } else {
18360
- message2 = "Invalid";
17401
+ message = "Invalid";
18361
17402
  }
18362
17403
  break;
18363
17404
  case ZodIssueCode.too_small:
18364
17405
  if (issue.type === "array")
18365
- message2 = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
17406
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
18366
17407
  else if (issue.type === "string")
18367
- message2 = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
17408
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
18368
17409
  else if (issue.type === "number")
18369
- message2 = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
17410
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
18370
17411
  else if (issue.type === "bigint")
18371
- message2 = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
17412
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
18372
17413
  else if (issue.type === "date")
18373
- message2 = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
17414
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
18374
17415
  else
18375
- message2 = "Invalid input";
17416
+ message = "Invalid input";
18376
17417
  break;
18377
17418
  case ZodIssueCode.too_big:
18378
17419
  if (issue.type === "array")
18379
- message2 = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
17420
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
18380
17421
  else if (issue.type === "string")
18381
- message2 = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
17422
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
18382
17423
  else if (issue.type === "number")
18383
- message2 = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
17424
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
18384
17425
  else if (issue.type === "bigint")
18385
- message2 = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
17426
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
18386
17427
  else if (issue.type === "date")
18387
- message2 = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
17428
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
18388
17429
  else
18389
- message2 = "Invalid input";
17430
+ message = "Invalid input";
18390
17431
  break;
18391
17432
  case ZodIssueCode.custom:
18392
- message2 = `Invalid input`;
17433
+ message = `Invalid input`;
18393
17434
  break;
18394
17435
  case ZodIssueCode.invalid_intersection_types:
18395
- message2 = `Intersection results could not be merged`;
17436
+ message = `Intersection results could not be merged`;
18396
17437
  break;
18397
17438
  case ZodIssueCode.not_multiple_of:
18398
- message2 = `Number must be a multiple of ${issue.multipleOf}`;
17439
+ message = `Number must be a multiple of ${issue.multipleOf}`;
18399
17440
  break;
18400
17441
  case ZodIssueCode.not_finite:
18401
- message2 = "Number must be finite";
17442
+ message = "Number must be finite";
18402
17443
  break;
18403
17444
  default:
18404
- message2 = _ctx.defaultError;
17445
+ message = _ctx.defaultError;
18405
17446
  util$1.assertNever(issue);
18406
17447
  }
18407
- return { message: message2 };
17448
+ return { message };
18408
17449
  };
18409
17450
  let overrideErrorMap = errorMap;
18410
17451
  function getErrorMap() {
@@ -18519,8 +17560,8 @@ const isValid = (x) => x.status === "valid";
18519
17560
  const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
18520
17561
  var errorUtil;
18521
17562
  (function(errorUtil2) {
18522
- errorUtil2.errToObj = (message2) => typeof message2 === "string" ? { message: message2 } : message2 || {};
18523
- errorUtil2.toString = (message2) => typeof message2 === "string" ? message2 : message2?.message;
17563
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
17564
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
18524
17565
  })(errorUtil || (errorUtil = {}));
18525
17566
  class ParseInputLazyPath {
18526
17567
  constructor(parent, value, path2, key) {
@@ -18570,16 +17611,16 @@ function processCreateParams(params) {
18570
17611
  if (errorMap2)
18571
17612
  return { errorMap: errorMap2, description: description2 };
18572
17613
  const customMap = (iss, ctx) => {
18573
- const { message: message2 } = params;
17614
+ const { message } = params;
18574
17615
  if (iss.code === "invalid_enum_value") {
18575
- return { message: message2 ?? ctx.defaultError };
17616
+ return { message: message ?? ctx.defaultError };
18576
17617
  }
18577
17618
  if (typeof ctx.data === "undefined") {
18578
- return { message: message2 ?? required_error ?? ctx.defaultError };
17619
+ return { message: message ?? required_error ?? ctx.defaultError };
18579
17620
  }
18580
17621
  if (iss.code !== "invalid_type")
18581
17622
  return { message: ctx.defaultError };
18582
- return { message: message2 ?? invalid_type_error ?? ctx.defaultError };
17623
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
18583
17624
  };
18584
17625
  return { errorMap: customMap, description: description2 };
18585
17626
  }
@@ -18705,14 +17746,14 @@ class ZodType {
18705
17746
  const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
18706
17747
  return handleResult(ctx, result);
18707
17748
  }
18708
- refine(check, message2) {
17749
+ refine(check, message) {
18709
17750
  const getIssueProperties = (val) => {
18710
- if (typeof message2 === "string" || typeof message2 === "undefined") {
18711
- return { message: message2 };
18712
- } else if (typeof message2 === "function") {
18713
- return message2(val);
17751
+ if (typeof message === "string" || typeof message === "undefined") {
17752
+ return { message };
17753
+ } else if (typeof message === "function") {
17754
+ return message(val);
18714
17755
  } else {
18715
- return message2;
17756
+ return message;
18716
17757
  }
18717
17758
  };
18718
17759
  return this._refinement((val, ctx) => {
@@ -19248,11 +18289,11 @@ class ZodString extends ZodType {
19248
18289
  }
19249
18290
  return { status: status.value, value: input.data };
19250
18291
  }
19251
- _regex(regex2, validation, message2) {
18292
+ _regex(regex2, validation, message) {
19252
18293
  return this.refinement((data) => regex2.test(data), {
19253
18294
  validation,
19254
18295
  code: ZodIssueCode.invalid_string,
19255
- ...errorUtil.errToObj(message2)
18296
+ ...errorUtil.errToObj(message)
19256
18297
  });
19257
18298
  }
19258
18299
  _addCheck(check) {
@@ -19261,37 +18302,37 @@ class ZodString extends ZodType {
19261
18302
  checks: [...this._def.checks, check]
19262
18303
  });
19263
18304
  }
19264
- email(message2) {
19265
- return this._addCheck({ kind: "email", ...errorUtil.errToObj(message2) });
18305
+ email(message) {
18306
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
19266
18307
  }
19267
- url(message2) {
19268
- return this._addCheck({ kind: "url", ...errorUtil.errToObj(message2) });
18308
+ url(message) {
18309
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
19269
18310
  }
19270
- emoji(message2) {
19271
- return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message2) });
18311
+ emoji(message) {
18312
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
19272
18313
  }
19273
- uuid(message2) {
19274
- return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message2) });
18314
+ uuid(message) {
18315
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
19275
18316
  }
19276
- nanoid(message2) {
19277
- return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message2) });
18317
+ nanoid(message) {
18318
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
19278
18319
  }
19279
- cuid(message2) {
19280
- return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message2) });
18320
+ cuid(message) {
18321
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
19281
18322
  }
19282
- cuid2(message2) {
19283
- return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message2) });
18323
+ cuid2(message) {
18324
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
19284
18325
  }
19285
- ulid(message2) {
19286
- return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message2) });
18326
+ ulid(message) {
18327
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
19287
18328
  }
19288
- base64(message2) {
19289
- return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message2) });
18329
+ base64(message) {
18330
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
19290
18331
  }
19291
- base64url(message2) {
18332
+ base64url(message) {
19292
18333
  return this._addCheck({
19293
18334
  kind: "base64url",
19294
- ...errorUtil.errToObj(message2)
18335
+ ...errorUtil.errToObj(message)
19295
18336
  });
19296
18337
  }
19297
18338
  jwt(options2) {
@@ -19321,8 +18362,8 @@ class ZodString extends ZodType {
19321
18362
  ...errorUtil.errToObj(options2?.message)
19322
18363
  });
19323
18364
  }
19324
- date(message2) {
19325
- return this._addCheck({ kind: "date", message: message2 });
18365
+ date(message) {
18366
+ return this._addCheck({ kind: "date", message });
19326
18367
  }
19327
18368
  time(options2) {
19328
18369
  if (typeof options2 === "string") {
@@ -19338,14 +18379,14 @@ class ZodString extends ZodType {
19338
18379
  ...errorUtil.errToObj(options2?.message)
19339
18380
  });
19340
18381
  }
19341
- duration(message2) {
19342
- return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message2) });
18382
+ duration(message) {
18383
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
19343
18384
  }
19344
- regex(regex2, message2) {
18385
+ regex(regex2, message) {
19345
18386
  return this._addCheck({
19346
18387
  kind: "regex",
19347
18388
  regex: regex2,
19348
- ...errorUtil.errToObj(message2)
18389
+ ...errorUtil.errToObj(message)
19349
18390
  });
19350
18391
  }
19351
18392
  includes(value, options2) {
@@ -19356,46 +18397,46 @@ class ZodString extends ZodType {
19356
18397
  ...errorUtil.errToObj(options2?.message)
19357
18398
  });
19358
18399
  }
19359
- startsWith(value, message2) {
18400
+ startsWith(value, message) {
19360
18401
  return this._addCheck({
19361
18402
  kind: "startsWith",
19362
18403
  value,
19363
- ...errorUtil.errToObj(message2)
18404
+ ...errorUtil.errToObj(message)
19364
18405
  });
19365
18406
  }
19366
- endsWith(value, message2) {
18407
+ endsWith(value, message) {
19367
18408
  return this._addCheck({
19368
18409
  kind: "endsWith",
19369
18410
  value,
19370
- ...errorUtil.errToObj(message2)
18411
+ ...errorUtil.errToObj(message)
19371
18412
  });
19372
18413
  }
19373
- min(minLength, message2) {
18414
+ min(minLength, message) {
19374
18415
  return this._addCheck({
19375
18416
  kind: "min",
19376
18417
  value: minLength,
19377
- ...errorUtil.errToObj(message2)
18418
+ ...errorUtil.errToObj(message)
19378
18419
  });
19379
18420
  }
19380
- max(maxLength, message2) {
18421
+ max(maxLength, message) {
19381
18422
  return this._addCheck({
19382
18423
  kind: "max",
19383
18424
  value: maxLength,
19384
- ...errorUtil.errToObj(message2)
18425
+ ...errorUtil.errToObj(message)
19385
18426
  });
19386
18427
  }
19387
- length(len, message2) {
18428
+ length(len, message) {
19388
18429
  return this._addCheck({
19389
18430
  kind: "length",
19390
18431
  value: len,
19391
- ...errorUtil.errToObj(message2)
18432
+ ...errorUtil.errToObj(message)
19392
18433
  });
19393
18434
  }
19394
18435
  /**
19395
18436
  * Equivalent to `.min(1)`
19396
18437
  */
19397
- nonempty(message2) {
19398
- return this.min(1, errorUtil.errToObj(message2));
18438
+ nonempty(message) {
18439
+ return this.min(1, errorUtil.errToObj(message));
19399
18440
  }
19400
18441
  trim() {
19401
18442
  return new ZodString({
@@ -19588,19 +18629,19 @@ class ZodNumber extends ZodType {
19588
18629
  }
19589
18630
  return { status: status.value, value: input.data };
19590
18631
  }
19591
- gte(value, message2) {
19592
- return this.setLimit("min", value, true, errorUtil.toString(message2));
18632
+ gte(value, message) {
18633
+ return this.setLimit("min", value, true, errorUtil.toString(message));
19593
18634
  }
19594
- gt(value, message2) {
19595
- return this.setLimit("min", value, false, errorUtil.toString(message2));
18635
+ gt(value, message) {
18636
+ return this.setLimit("min", value, false, errorUtil.toString(message));
19596
18637
  }
19597
- lte(value, message2) {
19598
- return this.setLimit("max", value, true, errorUtil.toString(message2));
18638
+ lte(value, message) {
18639
+ return this.setLimit("max", value, true, errorUtil.toString(message));
19599
18640
  }
19600
- lt(value, message2) {
19601
- return this.setLimit("max", value, false, errorUtil.toString(message2));
18641
+ lt(value, message) {
18642
+ return this.setLimit("max", value, false, errorUtil.toString(message));
19602
18643
  }
19603
- setLimit(kind, value, inclusive, message2) {
18644
+ setLimit(kind, value, inclusive, message) {
19604
18645
  return new ZodNumber({
19605
18646
  ...this._def,
19606
18647
  checks: [
@@ -19609,7 +18650,7 @@ class ZodNumber extends ZodType {
19609
18650
  kind,
19610
18651
  value,
19611
18652
  inclusive,
19612
- message: errorUtil.toString(message2)
18653
+ message: errorUtil.toString(message)
19613
18654
  }
19614
18655
  ]
19615
18656
  });
@@ -19620,68 +18661,68 @@ class ZodNumber extends ZodType {
19620
18661
  checks: [...this._def.checks, check]
19621
18662
  });
19622
18663
  }
19623
- int(message2) {
18664
+ int(message) {
19624
18665
  return this._addCheck({
19625
18666
  kind: "int",
19626
- message: errorUtil.toString(message2)
18667
+ message: errorUtil.toString(message)
19627
18668
  });
19628
18669
  }
19629
- positive(message2) {
18670
+ positive(message) {
19630
18671
  return this._addCheck({
19631
18672
  kind: "min",
19632
18673
  value: 0,
19633
18674
  inclusive: false,
19634
- message: errorUtil.toString(message2)
18675
+ message: errorUtil.toString(message)
19635
18676
  });
19636
18677
  }
19637
- negative(message2) {
18678
+ negative(message) {
19638
18679
  return this._addCheck({
19639
18680
  kind: "max",
19640
18681
  value: 0,
19641
18682
  inclusive: false,
19642
- message: errorUtil.toString(message2)
18683
+ message: errorUtil.toString(message)
19643
18684
  });
19644
18685
  }
19645
- nonpositive(message2) {
18686
+ nonpositive(message) {
19646
18687
  return this._addCheck({
19647
18688
  kind: "max",
19648
18689
  value: 0,
19649
18690
  inclusive: true,
19650
- message: errorUtil.toString(message2)
18691
+ message: errorUtil.toString(message)
19651
18692
  });
19652
18693
  }
19653
- nonnegative(message2) {
18694
+ nonnegative(message) {
19654
18695
  return this._addCheck({
19655
18696
  kind: "min",
19656
18697
  value: 0,
19657
18698
  inclusive: true,
19658
- message: errorUtil.toString(message2)
18699
+ message: errorUtil.toString(message)
19659
18700
  });
19660
18701
  }
19661
- multipleOf(value, message2) {
18702
+ multipleOf(value, message) {
19662
18703
  return this._addCheck({
19663
18704
  kind: "multipleOf",
19664
18705
  value,
19665
- message: errorUtil.toString(message2)
18706
+ message: errorUtil.toString(message)
19666
18707
  });
19667
18708
  }
19668
- finite(message2) {
18709
+ finite(message) {
19669
18710
  return this._addCheck({
19670
18711
  kind: "finite",
19671
- message: errorUtil.toString(message2)
18712
+ message: errorUtil.toString(message)
19672
18713
  });
19673
18714
  }
19674
- safe(message2) {
18715
+ safe(message) {
19675
18716
  return this._addCheck({
19676
18717
  kind: "min",
19677
18718
  inclusive: true,
19678
18719
  value: Number.MIN_SAFE_INTEGER,
19679
- message: errorUtil.toString(message2)
18720
+ message: errorUtil.toString(message)
19680
18721
  })._addCheck({
19681
18722
  kind: "max",
19682
18723
  inclusive: true,
19683
18724
  value: Number.MAX_SAFE_INTEGER,
19684
- message: errorUtil.toString(message2)
18725
+ message: errorUtil.toString(message)
19685
18726
  });
19686
18727
  }
19687
18728
  get minValue() {
@@ -19804,19 +18845,19 @@ class ZodBigInt extends ZodType {
19804
18845
  });
19805
18846
  return INVALID;
19806
18847
  }
19807
- gte(value, message2) {
19808
- return this.setLimit("min", value, true, errorUtil.toString(message2));
18848
+ gte(value, message) {
18849
+ return this.setLimit("min", value, true, errorUtil.toString(message));
19809
18850
  }
19810
- gt(value, message2) {
19811
- return this.setLimit("min", value, false, errorUtil.toString(message2));
18851
+ gt(value, message) {
18852
+ return this.setLimit("min", value, false, errorUtil.toString(message));
19812
18853
  }
19813
- lte(value, message2) {
19814
- return this.setLimit("max", value, true, errorUtil.toString(message2));
18854
+ lte(value, message) {
18855
+ return this.setLimit("max", value, true, errorUtil.toString(message));
19815
18856
  }
19816
- lt(value, message2) {
19817
- return this.setLimit("max", value, false, errorUtil.toString(message2));
18857
+ lt(value, message) {
18858
+ return this.setLimit("max", value, false, errorUtil.toString(message));
19818
18859
  }
19819
- setLimit(kind, value, inclusive, message2) {
18860
+ setLimit(kind, value, inclusive, message) {
19820
18861
  return new ZodBigInt({
19821
18862
  ...this._def,
19822
18863
  checks: [
@@ -19825,7 +18866,7 @@ class ZodBigInt extends ZodType {
19825
18866
  kind,
19826
18867
  value,
19827
18868
  inclusive,
19828
- message: errorUtil.toString(message2)
18869
+ message: errorUtil.toString(message)
19829
18870
  }
19830
18871
  ]
19831
18872
  });
@@ -19836,43 +18877,43 @@ class ZodBigInt extends ZodType {
19836
18877
  checks: [...this._def.checks, check]
19837
18878
  });
19838
18879
  }
19839
- positive(message2) {
18880
+ positive(message) {
19840
18881
  return this._addCheck({
19841
18882
  kind: "min",
19842
18883
  value: BigInt(0),
19843
18884
  inclusive: false,
19844
- message: errorUtil.toString(message2)
18885
+ message: errorUtil.toString(message)
19845
18886
  });
19846
18887
  }
19847
- negative(message2) {
18888
+ negative(message) {
19848
18889
  return this._addCheck({
19849
18890
  kind: "max",
19850
18891
  value: BigInt(0),
19851
18892
  inclusive: false,
19852
- message: errorUtil.toString(message2)
18893
+ message: errorUtil.toString(message)
19853
18894
  });
19854
18895
  }
19855
- nonpositive(message2) {
18896
+ nonpositive(message) {
19856
18897
  return this._addCheck({
19857
18898
  kind: "max",
19858
18899
  value: BigInt(0),
19859
18900
  inclusive: true,
19860
- message: errorUtil.toString(message2)
18901
+ message: errorUtil.toString(message)
19861
18902
  });
19862
18903
  }
19863
- nonnegative(message2) {
18904
+ nonnegative(message) {
19864
18905
  return this._addCheck({
19865
18906
  kind: "min",
19866
18907
  value: BigInt(0),
19867
18908
  inclusive: true,
19868
- message: errorUtil.toString(message2)
18909
+ message: errorUtil.toString(message)
19869
18910
  });
19870
18911
  }
19871
- multipleOf(value, message2) {
18912
+ multipleOf(value, message) {
19872
18913
  return this._addCheck({
19873
18914
  kind: "multipleOf",
19874
18915
  value,
19875
- message: errorUtil.toString(message2)
18916
+ message: errorUtil.toString(message)
19876
18917
  });
19877
18918
  }
19878
18919
  get minValue() {
@@ -19995,18 +19036,18 @@ class ZodDate extends ZodType {
19995
19036
  checks: [...this._def.checks, check]
19996
19037
  });
19997
19038
  }
19998
- min(minDate, message2) {
19039
+ min(minDate, message) {
19999
19040
  return this._addCheck({
20000
19041
  kind: "min",
20001
19042
  value: minDate.getTime(),
20002
- message: errorUtil.toString(message2)
19043
+ message: errorUtil.toString(message)
20003
19044
  });
20004
19045
  }
20005
- max(maxDate, message2) {
19046
+ max(maxDate, message) {
20006
19047
  return this._addCheck({
20007
19048
  kind: "max",
20008
19049
  value: maxDate.getTime(),
20009
- message: errorUtil.toString(message2)
19050
+ message: errorUtil.toString(message)
20010
19051
  });
20011
19052
  }
20012
19053
  get minDate() {
@@ -20238,26 +19279,26 @@ class ZodArray extends ZodType {
20238
19279
  get element() {
20239
19280
  return this._def.type;
20240
19281
  }
20241
- min(minLength, message2) {
19282
+ min(minLength, message) {
20242
19283
  return new ZodArray({
20243
19284
  ...this._def,
20244
- minLength: { value: minLength, message: errorUtil.toString(message2) }
19285
+ minLength: { value: minLength, message: errorUtil.toString(message) }
20245
19286
  });
20246
19287
  }
20247
- max(maxLength, message2) {
19288
+ max(maxLength, message) {
20248
19289
  return new ZodArray({
20249
19290
  ...this._def,
20250
- maxLength: { value: maxLength, message: errorUtil.toString(message2) }
19291
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
20251
19292
  });
20252
19293
  }
20253
- length(len, message2) {
19294
+ length(len, message) {
20254
19295
  return new ZodArray({
20255
19296
  ...this._def,
20256
- exactLength: { value: len, message: errorUtil.toString(message2) }
19297
+ exactLength: { value: len, message: errorUtil.toString(message) }
20257
19298
  });
20258
19299
  }
20259
- nonempty(message2) {
20260
- return this.min(1, message2);
19300
+ nonempty(message) {
19301
+ return this.min(1, message);
20261
19302
  }
20262
19303
  }
20263
19304
  ZodArray.create = (schema, params) => {
@@ -20400,17 +19441,17 @@ class ZodObject extends ZodType {
20400
19441
  get shape() {
20401
19442
  return this._def.shape();
20402
19443
  }
20403
- strict(message2) {
19444
+ strict(message) {
20404
19445
  errorUtil.errToObj;
20405
19446
  return new ZodObject({
20406
19447
  ...this._def,
20407
19448
  unknownKeys: "strict",
20408
- ...message2 !== void 0 ? {
19449
+ ...message !== void 0 ? {
20409
19450
  errorMap: (issue, ctx) => {
20410
19451
  const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
20411
19452
  if (issue.code === "unrecognized_keys")
20412
19453
  return {
20413
- message: errorUtil.errToObj(message2).message ?? defaultError
19454
+ message: errorUtil.errToObj(message).message ?? defaultError
20414
19455
  };
20415
19456
  return {
20416
19457
  message: defaultError
@@ -21006,23 +20047,23 @@ class ZodSet extends ZodType {
21006
20047
  return finalizeSet(elements);
21007
20048
  }
21008
20049
  }
21009
- min(minSize, message2) {
20050
+ min(minSize, message) {
21010
20051
  return new ZodSet({
21011
20052
  ...this._def,
21012
- minSize: { value: minSize, message: errorUtil.toString(message2) }
20053
+ minSize: { value: minSize, message: errorUtil.toString(message) }
21013
20054
  });
21014
20055
  }
21015
- max(maxSize, message2) {
20056
+ max(maxSize, message) {
21016
20057
  return new ZodSet({
21017
20058
  ...this._def,
21018
- maxSize: { value: maxSize, message: errorUtil.toString(message2) }
20059
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
21019
20060
  });
21020
20061
  }
21021
- size(size, message2) {
21022
- return this.min(size, message2).max(size, message2);
20062
+ size(size, message) {
20063
+ return this.min(size, message).max(size, message);
21023
20064
  }
21024
- nonempty(message2) {
21025
- return this.min(1, message2);
20065
+ nonempty(message) {
20066
+ return this.min(1, message);
21026
20067
  }
21027
20068
  }
21028
20069
  ZodSet.create = (valueType, params) => {
@@ -21632,32 +20673,125 @@ ZodEnum.create;
21632
20673
  ZodPromise.create;
21633
20674
  ZodOptional.create;
21634
20675
  ZodNullable.create;
21635
- function createGoogleProvider(clientId) {
21636
- const googleClient = new src$4.OAuth2Client(clientId);
20676
+ function createGoogleProvider(config) {
20677
+ const clientId = typeof config === "string" ? config : config.clientId;
20678
+ const clientSecret = typeof config === "string" ? void 0 : config.clientSecret;
20679
+ const googleClient = new src$4.OAuth2Client(clientId, clientSecret);
21637
20680
  return {
21638
20681
  id: "google",
21639
20682
  schema: objectType({
21640
- idToken: stringType().min(1, "ID token is required")
20683
+ idToken: stringType().min(1).optional(),
20684
+ accessToken: stringType().min(1).optional(),
20685
+ code: stringType().min(1).optional(),
20686
+ redirectUri: stringType().min(1).optional()
20687
+ }).refine((data) => data.idToken || data.accessToken || data.code && data.redirectUri, {
20688
+ message: "One of idToken, accessToken, or code+redirectUri is required"
21641
20689
  }),
21642
20690
  verify: async (payload) => {
21643
20691
  try {
21644
- const ticket = await googleClient.verifyIdToken({
21645
- idToken: payload.idToken,
21646
- audience: clientId
21647
- });
21648
- const content = ticket.getPayload();
21649
- if (!content) {
21650
- return null;
20692
+ if (payload.idToken) {
20693
+ const ticket = await googleClient.verifyIdToken({
20694
+ idToken: payload.idToken,
20695
+ audience: clientId
20696
+ });
20697
+ const content = ticket.getPayload();
20698
+ if (!content) {
20699
+ throw new Error("Google ID token payload was empty");
20700
+ }
20701
+ return {
20702
+ providerId: content.sub,
20703
+ email: content.email || "",
20704
+ displayName: content.name || null,
20705
+ photoUrl: content.picture || null
20706
+ };
21651
20707
  }
21652
- return {
21653
- providerId: content.sub,
21654
- email: content.email || "",
21655
- displayName: content.name || null,
21656
- photoUrl: content.picture || null
21657
- };
20708
+ if (payload.accessToken) {
20709
+ const res = await fetch("https://www.googleapis.com/oauth2/v3/userinfo", {
20710
+ headers: {
20711
+ Authorization: `Bearer ${payload.accessToken}`
20712
+ }
20713
+ });
20714
+ if (!res.ok) {
20715
+ throw new Error(`Google userinfo request failed with status ${res.status}`);
20716
+ }
20717
+ const info = await res.json();
20718
+ if (!info.sub || !info.email) {
20719
+ throw new Error("Google userinfo response missing sub or email");
20720
+ }
20721
+ return {
20722
+ providerId: info.sub,
20723
+ email: info.email,
20724
+ displayName: info.name || null,
20725
+ photoUrl: info.picture || null
20726
+ };
20727
+ }
20728
+ if (payload.code && payload.redirectUri) {
20729
+ if (!clientSecret) {
20730
+ throw new Error("Google authorization code flow requires clientSecret. Configure GOOGLE_CLIENT_SECRET in your environment.");
20731
+ }
20732
+ const tokenResponse = await fetch("https://oauth2.googleapis.com/token", {
20733
+ method: "POST",
20734
+ headers: {
20735
+ "Content-Type": "application/x-www-form-urlencoded"
20736
+ },
20737
+ body: new URLSearchParams({
20738
+ code: payload.code,
20739
+ client_id: clientId,
20740
+ client_secret: clientSecret,
20741
+ redirect_uri: payload.redirectUri,
20742
+ grant_type: "authorization_code"
20743
+ })
20744
+ });
20745
+ if (!tokenResponse.ok) {
20746
+ const errorBody = await tokenResponse.text();
20747
+ throw new Error(`Google token exchange failed (${tokenResponse.status}): ${errorBody}`);
20748
+ }
20749
+ const tokenData = await tokenResponse.json();
20750
+ if (tokenData.error) {
20751
+ throw new Error(`Google token exchange error: ${tokenData.error} – ${tokenData.error_description || "no details"}`);
20752
+ }
20753
+ if (tokenData.id_token) {
20754
+ const ticket = await googleClient.verifyIdToken({
20755
+ idToken: tokenData.id_token,
20756
+ audience: clientId
20757
+ });
20758
+ const content = ticket.getPayload();
20759
+ if (!content) {
20760
+ throw new Error("Google ID token payload was empty after code exchange");
20761
+ }
20762
+ return {
20763
+ providerId: content.sub,
20764
+ email: content.email || "",
20765
+ displayName: content.name || null,
20766
+ photoUrl: content.picture || null
20767
+ };
20768
+ }
20769
+ if (tokenData.access_token) {
20770
+ const userInfoRes = await fetch("https://www.googleapis.com/oauth2/v3/userinfo", {
20771
+ headers: {
20772
+ Authorization: `Bearer ${tokenData.access_token}`
20773
+ }
20774
+ });
20775
+ if (!userInfoRes.ok) {
20776
+ throw new Error(`Google userinfo request failed after code exchange (${userInfoRes.status})`);
20777
+ }
20778
+ const info = await userInfoRes.json();
20779
+ if (!info.sub || !info.email) {
20780
+ return null;
20781
+ }
20782
+ return {
20783
+ providerId: info.sub,
20784
+ email: info.email,
20785
+ displayName: info.name || null,
20786
+ photoUrl: info.picture || null
20787
+ };
20788
+ }
20789
+ throw new Error("Google token exchange returned neither id_token nor access_token");
20790
+ }
20791
+ throw new Error("No valid Google credential provided (expected idToken, accessToken, or code+redirectUri)");
21658
20792
  } catch (error2) {
21659
- console.error("Failed to verify Google ID token:", error2);
21660
- return null;
20793
+ console.error("Google OAuth verification failed:", error2);
20794
+ throw error2;
21661
20795
  }
21662
20796
  }
21663
20797
  };
@@ -21849,1002 +20983,16 @@ function createMicrosoftProvider(config) {
21849
20983
  }
21850
20984
  };
21851
20985
  }
21852
- const encoder = new TextEncoder();
21853
- const decoder = new TextDecoder();
21854
- function concat(...buffers) {
21855
- const size = buffers.reduce((acc, { length }) => acc + length, 0);
21856
- const buf = new Uint8Array(size);
21857
- let i = 0;
21858
- for (const buffer of buffers) {
21859
- buf.set(buffer, i);
21860
- i += buffer.length;
21861
- }
21862
- return buf;
21863
- }
21864
- function encode$4(string) {
21865
- const bytes = new Uint8Array(string.length);
21866
- for (let i = 0; i < string.length; i++) {
21867
- const code2 = string.charCodeAt(i);
21868
- if (code2 > 127) {
21869
- throw new TypeError("non-ASCII string encountered in encode()");
21870
- }
21871
- bytes[i] = code2;
21872
- }
21873
- return bytes;
21874
- }
21875
- function encodeBase64(input) {
21876
- if (Uint8Array.prototype.toBase64) {
21877
- return input.toBase64();
21878
- }
21879
- const CHUNK_SIZE = 32768;
21880
- const arr = [];
21881
- for (let i = 0; i < input.length; i += CHUNK_SIZE) {
21882
- arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
21883
- }
21884
- return btoa(arr.join(""));
21885
- }
21886
- function decodeBase64(encoded) {
21887
- if (Uint8Array.fromBase64) {
21888
- return Uint8Array.fromBase64(encoded);
21889
- }
21890
- const binary = atob(encoded);
21891
- const bytes = new Uint8Array(binary.length);
21892
- for (let i = 0; i < binary.length; i++) {
21893
- bytes[i] = binary.charCodeAt(i);
21894
- }
21895
- return bytes;
21896
- }
21897
- function decode$1(input) {
21898
- if (Uint8Array.fromBase64) {
21899
- return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
21900
- alphabet: "base64url"
21901
- });
21902
- }
21903
- let encoded = input;
21904
- if (encoded instanceof Uint8Array) {
21905
- encoded = decoder.decode(encoded);
21906
- }
21907
- encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
21908
- try {
21909
- return decodeBase64(encoded);
21910
- } catch {
21911
- throw new TypeError("The input to be decoded is not correctly encoded.");
21912
- }
21913
- }
21914
- function encode$3(input) {
21915
- let unencoded = input;
21916
- if (typeof unencoded === "string") {
21917
- unencoded = encoder.encode(unencoded);
21918
- }
21919
- if (Uint8Array.prototype.toBase64) {
21920
- return unencoded.toBase64({ alphabet: "base64url", omitPadding: true });
21921
- }
21922
- return encodeBase64(unencoded).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
21923
- }
21924
- const unusable = (name2, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name2}`);
21925
- const isAlgorithm = (algorithm, name2) => algorithm.name === name2;
21926
- function getHashLength(hash) {
21927
- return parseInt(hash.name.slice(4), 10);
21928
- }
21929
- function checkHashLength(algorithm, expected) {
21930
- const actual = getHashLength(algorithm.hash);
21931
- if (actual !== expected)
21932
- throw unusable(`SHA-${expected}`, "algorithm.hash");
21933
- }
21934
- function getNamedCurve(alg) {
21935
- switch (alg) {
21936
- case "ES256":
21937
- return "P-256";
21938
- case "ES384":
21939
- return "P-384";
21940
- case "ES512":
21941
- return "P-521";
21942
- default:
21943
- throw new Error("unreachable");
21944
- }
21945
- }
21946
- function checkUsage(key, usage) {
21947
- if (!key.usages.includes(usage)) {
21948
- throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
21949
- }
21950
- }
21951
- function checkSigCryptoKey(key, alg, usage) {
21952
- switch (alg) {
21953
- case "HS256":
21954
- case "HS384":
21955
- case "HS512": {
21956
- if (!isAlgorithm(key.algorithm, "HMAC"))
21957
- throw unusable("HMAC");
21958
- checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
21959
- break;
21960
- }
21961
- case "RS256":
21962
- case "RS384":
21963
- case "RS512": {
21964
- if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
21965
- throw unusable("RSASSA-PKCS1-v1_5");
21966
- checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
21967
- break;
21968
- }
21969
- case "PS256":
21970
- case "PS384":
21971
- case "PS512": {
21972
- if (!isAlgorithm(key.algorithm, "RSA-PSS"))
21973
- throw unusable("RSA-PSS");
21974
- checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
21975
- break;
21976
- }
21977
- case "Ed25519":
21978
- case "EdDSA": {
21979
- if (!isAlgorithm(key.algorithm, "Ed25519"))
21980
- throw unusable("Ed25519");
21981
- break;
21982
- }
21983
- case "ML-DSA-44":
21984
- case "ML-DSA-65":
21985
- case "ML-DSA-87": {
21986
- if (!isAlgorithm(key.algorithm, alg))
21987
- throw unusable(alg);
21988
- break;
21989
- }
21990
- case "ES256":
21991
- case "ES384":
21992
- case "ES512": {
21993
- if (!isAlgorithm(key.algorithm, "ECDSA"))
21994
- throw unusable("ECDSA");
21995
- const expected = getNamedCurve(alg);
21996
- const actual = key.algorithm.namedCurve;
21997
- if (actual !== expected)
21998
- throw unusable(expected, "algorithm.namedCurve");
21999
- break;
22000
- }
22001
- default:
22002
- throw new TypeError("CryptoKey does not support this operation");
22003
- }
22004
- checkUsage(key, usage);
22005
- }
22006
- function message(msg, actual, ...types2) {
22007
- types2 = types2.filter(Boolean);
22008
- if (types2.length > 2) {
22009
- const last = types2.pop();
22010
- msg += `one of type ${types2.join(", ")}, or ${last}.`;
22011
- } else if (types2.length === 2) {
22012
- msg += `one of type ${types2[0]} or ${types2[1]}.`;
22013
- } else {
22014
- msg += `of type ${types2[0]}.`;
22015
- }
22016
- if (actual == null) {
22017
- msg += ` Received ${actual}`;
22018
- } else if (typeof actual === "function" && actual.name) {
22019
- msg += ` Received function ${actual.name}`;
22020
- } else if (typeof actual === "object" && actual != null) {
22021
- if (actual.constructor?.name) {
22022
- msg += ` Received an instance of ${actual.constructor.name}`;
22023
- }
22024
- }
22025
- return msg;
22026
- }
22027
- const invalidKeyInput = (actual, ...types2) => message("Key must be ", actual, ...types2);
22028
- const withAlg = (alg, actual, ...types2) => message(`Key for the ${alg} algorithm must be `, actual, ...types2);
22029
- class JOSEError extends Error {
22030
- static code = "ERR_JOSE_GENERIC";
22031
- code = "ERR_JOSE_GENERIC";
22032
- constructor(message2, options2) {
22033
- super(message2, options2);
22034
- this.name = this.constructor.name;
22035
- Error.captureStackTrace?.(this, this.constructor);
22036
- }
22037
- }
22038
- class JOSENotSupported extends JOSEError {
22039
- static code = "ERR_JOSE_NOT_SUPPORTED";
22040
- code = "ERR_JOSE_NOT_SUPPORTED";
22041
- }
22042
- class JWSInvalid extends JOSEError {
22043
- static code = "ERR_JWS_INVALID";
22044
- code = "ERR_JWS_INVALID";
22045
- }
22046
- class JWTInvalid extends JOSEError {
22047
- static code = "ERR_JWT_INVALID";
22048
- code = "ERR_JWT_INVALID";
22049
- }
22050
- const isCryptoKey = (key) => {
22051
- if (key?.[Symbol.toStringTag] === "CryptoKey")
22052
- return true;
22053
- try {
22054
- return key instanceof CryptoKey;
22055
- } catch {
22056
- return false;
22057
- }
22058
- };
22059
- const isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
22060
- const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
22061
- function assertNotSet(value, name2) {
22062
- if (value) {
22063
- throw new TypeError(`${name2} can only be called once`);
22064
- }
22065
- }
22066
- const isObjectLike$1 = (value) => typeof value === "object" && value !== null;
22067
- function isObject(input) {
22068
- if (!isObjectLike$1(input) || Object.prototype.toString.call(input) !== "[object Object]") {
22069
- return false;
22070
- }
22071
- if (Object.getPrototypeOf(input) === null) {
22072
- return true;
22073
- }
22074
- let proto = input;
22075
- while (Object.getPrototypeOf(proto) !== null) {
22076
- proto = Object.getPrototypeOf(proto);
22077
- }
22078
- return Object.getPrototypeOf(input) === proto;
22079
- }
22080
- function isDisjoint(...headers) {
22081
- const sources = headers.filter(Boolean);
22082
- if (sources.length === 0 || sources.length === 1) {
22083
- return true;
22084
- }
22085
- let acc;
22086
- for (const header of sources) {
22087
- const parameters = Object.keys(header);
22088
- if (!acc || acc.size === 0) {
22089
- acc = new Set(parameters);
22090
- continue;
22091
- }
22092
- for (const parameter of parameters) {
22093
- if (acc.has(parameter)) {
22094
- return false;
22095
- }
22096
- acc.add(parameter);
22097
- }
22098
- }
22099
- return true;
22100
- }
22101
- const isJWK = (key) => isObject(key) && typeof key.kty === "string";
22102
- const isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
22103
- const isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
22104
- const isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
22105
- function checkKeyLength(alg, key) {
22106
- if (alg.startsWith("RS") || alg.startsWith("PS")) {
22107
- const { modulusLength } = key.algorithm;
22108
- if (typeof modulusLength !== "number" || modulusLength < 2048) {
22109
- throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
22110
- }
22111
- }
22112
- }
22113
- function subtleAlgorithm(alg, algorithm) {
22114
- const hash = `SHA-${alg.slice(-3)}`;
22115
- switch (alg) {
22116
- case "HS256":
22117
- case "HS384":
22118
- case "HS512":
22119
- return { hash, name: "HMAC" };
22120
- case "PS256":
22121
- case "PS384":
22122
- case "PS512":
22123
- return { hash, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
22124
- case "RS256":
22125
- case "RS384":
22126
- case "RS512":
22127
- return { hash, name: "RSASSA-PKCS1-v1_5" };
22128
- case "ES256":
22129
- case "ES384":
22130
- case "ES512":
22131
- return { hash, name: "ECDSA", namedCurve: algorithm.namedCurve };
22132
- case "Ed25519":
22133
- case "EdDSA":
22134
- return { name: "Ed25519" };
22135
- case "ML-DSA-44":
22136
- case "ML-DSA-65":
22137
- case "ML-DSA-87":
22138
- return { name: alg };
22139
- default:
22140
- throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
22141
- }
22142
- }
22143
- async function getSigKey(alg, key, usage) {
22144
- if (key instanceof Uint8Array) {
22145
- if (!alg.startsWith("HS")) {
22146
- throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
22147
- }
22148
- return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
22149
- }
22150
- checkSigCryptoKey(key, alg, usage);
22151
- return key;
22152
- }
22153
- async function sign$2(alg, key, data) {
22154
- const cryptoKey = await getSigKey(alg, key, "sign");
22155
- checkKeyLength(alg, cryptoKey);
22156
- const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm), cryptoKey, data);
22157
- return new Uint8Array(signature);
22158
- }
22159
- const unsupportedAlg = 'Invalid or unsupported JWK "alg" (Algorithm) Parameter value';
22160
- function subtleMapping(jwk) {
22161
- let algorithm;
22162
- let keyUsages;
22163
- switch (jwk.kty) {
22164
- case "AKP": {
22165
- switch (jwk.alg) {
22166
- case "ML-DSA-44":
22167
- case "ML-DSA-65":
22168
- case "ML-DSA-87":
22169
- algorithm = { name: jwk.alg };
22170
- keyUsages = jwk.priv ? ["sign"] : ["verify"];
22171
- break;
22172
- default:
22173
- throw new JOSENotSupported(unsupportedAlg);
22174
- }
22175
- break;
22176
- }
22177
- case "RSA": {
22178
- switch (jwk.alg) {
22179
- case "PS256":
22180
- case "PS384":
22181
- case "PS512":
22182
- algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
22183
- keyUsages = jwk.d ? ["sign"] : ["verify"];
22184
- break;
22185
- case "RS256":
22186
- case "RS384":
22187
- case "RS512":
22188
- algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
22189
- keyUsages = jwk.d ? ["sign"] : ["verify"];
22190
- break;
22191
- case "RSA-OAEP":
22192
- case "RSA-OAEP-256":
22193
- case "RSA-OAEP-384":
22194
- case "RSA-OAEP-512":
22195
- algorithm = {
22196
- name: "RSA-OAEP",
22197
- hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
22198
- };
22199
- keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
22200
- break;
22201
- default:
22202
- throw new JOSENotSupported(unsupportedAlg);
22203
- }
22204
- break;
22205
- }
22206
- case "EC": {
22207
- switch (jwk.alg) {
22208
- case "ES256":
22209
- case "ES384":
22210
- case "ES512":
22211
- algorithm = {
22212
- name: "ECDSA",
22213
- namedCurve: { ES256: "P-256", ES384: "P-384", ES512: "P-521" }[jwk.alg]
22214
- };
22215
- keyUsages = jwk.d ? ["sign"] : ["verify"];
22216
- break;
22217
- case "ECDH-ES":
22218
- case "ECDH-ES+A128KW":
22219
- case "ECDH-ES+A192KW":
22220
- case "ECDH-ES+A256KW":
22221
- algorithm = { name: "ECDH", namedCurve: jwk.crv };
22222
- keyUsages = jwk.d ? ["deriveBits"] : [];
22223
- break;
22224
- default:
22225
- throw new JOSENotSupported(unsupportedAlg);
22226
- }
22227
- break;
22228
- }
22229
- case "OKP": {
22230
- switch (jwk.alg) {
22231
- case "Ed25519":
22232
- case "EdDSA":
22233
- algorithm = { name: "Ed25519" };
22234
- keyUsages = jwk.d ? ["sign"] : ["verify"];
22235
- break;
22236
- case "ECDH-ES":
22237
- case "ECDH-ES+A128KW":
22238
- case "ECDH-ES+A192KW":
22239
- case "ECDH-ES+A256KW":
22240
- algorithm = { name: jwk.crv };
22241
- keyUsages = jwk.d ? ["deriveBits"] : [];
22242
- break;
22243
- default:
22244
- throw new JOSENotSupported(unsupportedAlg);
22245
- }
22246
- break;
22247
- }
22248
- default:
22249
- throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
22250
- }
22251
- return { algorithm, keyUsages };
22252
- }
22253
- async function jwkToKey(jwk) {
22254
- if (!jwk.alg) {
22255
- throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
22256
- }
22257
- const { algorithm, keyUsages } = subtleMapping(jwk);
22258
- const keyData = { ...jwk };
22259
- if (keyData.kty !== "AKP") {
22260
- delete keyData.alg;
22261
- }
22262
- delete keyData.use;
22263
- return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
22264
- }
22265
- const unusableForAlg = "given KeyObject instance cannot be used for this algorithm";
22266
- let cache;
22267
- const handleJWK = async (key, jwk, alg, freeze = false) => {
22268
- cache ||= /* @__PURE__ */ new WeakMap();
22269
- let cached = cache.get(key);
22270
- if (cached?.[alg]) {
22271
- return cached[alg];
22272
- }
22273
- const cryptoKey = await jwkToKey({ ...jwk, alg });
22274
- if (freeze)
22275
- Object.freeze(key);
22276
- if (!cached) {
22277
- cache.set(key, { [alg]: cryptoKey });
22278
- } else {
22279
- cached[alg] = cryptoKey;
22280
- }
22281
- return cryptoKey;
22282
- };
22283
- const handleKeyObject = (keyObject, alg) => {
22284
- cache ||= /* @__PURE__ */ new WeakMap();
22285
- let cached = cache.get(keyObject);
22286
- if (cached?.[alg]) {
22287
- return cached[alg];
22288
- }
22289
- const isPublic = keyObject.type === "public";
22290
- const extractable = isPublic ? true : false;
22291
- let cryptoKey;
22292
- if (keyObject.asymmetricKeyType === "x25519") {
22293
- switch (alg) {
22294
- case "ECDH-ES":
22295
- case "ECDH-ES+A128KW":
22296
- case "ECDH-ES+A192KW":
22297
- case "ECDH-ES+A256KW":
22298
- break;
22299
- default:
22300
- throw new TypeError(unusableForAlg);
22301
- }
22302
- cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
22303
- }
22304
- if (keyObject.asymmetricKeyType === "ed25519") {
22305
- if (alg !== "EdDSA" && alg !== "Ed25519") {
22306
- throw new TypeError(unusableForAlg);
22307
- }
22308
- cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
22309
- isPublic ? "verify" : "sign"
22310
- ]);
22311
- }
22312
- switch (keyObject.asymmetricKeyType) {
22313
- case "ml-dsa-44":
22314
- case "ml-dsa-65":
22315
- case "ml-dsa-87": {
22316
- if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
22317
- throw new TypeError(unusableForAlg);
22318
- }
22319
- cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
22320
- isPublic ? "verify" : "sign"
22321
- ]);
22322
- }
22323
- }
22324
- if (keyObject.asymmetricKeyType === "rsa") {
22325
- let hash;
22326
- switch (alg) {
22327
- case "RSA-OAEP":
22328
- hash = "SHA-1";
22329
- break;
22330
- case "RS256":
22331
- case "PS256":
22332
- case "RSA-OAEP-256":
22333
- hash = "SHA-256";
22334
- break;
22335
- case "RS384":
22336
- case "PS384":
22337
- case "RSA-OAEP-384":
22338
- hash = "SHA-384";
22339
- break;
22340
- case "RS512":
22341
- case "PS512":
22342
- case "RSA-OAEP-512":
22343
- hash = "SHA-512";
22344
- break;
22345
- default:
22346
- throw new TypeError(unusableForAlg);
22347
- }
22348
- if (alg.startsWith("RSA-OAEP")) {
22349
- return keyObject.toCryptoKey({
22350
- name: "RSA-OAEP",
22351
- hash
22352
- }, extractable, isPublic ? ["encrypt"] : ["decrypt"]);
22353
- }
22354
- cryptoKey = keyObject.toCryptoKey({
22355
- name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
22356
- hash
22357
- }, extractable, [isPublic ? "verify" : "sign"]);
22358
- }
22359
- if (keyObject.asymmetricKeyType === "ec") {
22360
- const nist = /* @__PURE__ */ new Map([
22361
- ["prime256v1", "P-256"],
22362
- ["secp384r1", "P-384"],
22363
- ["secp521r1", "P-521"]
22364
- ]);
22365
- const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
22366
- if (!namedCurve) {
22367
- throw new TypeError(unusableForAlg);
22368
- }
22369
- const expectedCurve = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
22370
- if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {
22371
- cryptoKey = keyObject.toCryptoKey({
22372
- name: "ECDSA",
22373
- namedCurve
22374
- }, extractable, [isPublic ? "verify" : "sign"]);
22375
- }
22376
- if (alg.startsWith("ECDH-ES")) {
22377
- cryptoKey = keyObject.toCryptoKey({
22378
- name: "ECDH",
22379
- namedCurve
22380
- }, extractable, isPublic ? [] : ["deriveBits"]);
22381
- }
22382
- }
22383
- if (!cryptoKey) {
22384
- throw new TypeError(unusableForAlg);
22385
- }
22386
- if (!cached) {
22387
- cache.set(keyObject, { [alg]: cryptoKey });
22388
- } else {
22389
- cached[alg] = cryptoKey;
22390
- }
22391
- return cryptoKey;
22392
- };
22393
- async function normalizeKey$1(key, alg) {
22394
- if (key instanceof Uint8Array) {
22395
- return key;
22396
- }
22397
- if (isCryptoKey(key)) {
22398
- return key;
22399
- }
22400
- if (isKeyObject(key)) {
22401
- if (key.type === "secret") {
22402
- return key.export();
22403
- }
22404
- if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") {
22405
- try {
22406
- return handleKeyObject(key, alg);
22407
- } catch (err) {
22408
- if (err instanceof TypeError) {
22409
- throw err;
22410
- }
22411
- }
22412
- }
22413
- let jwk = key.export({ format: "jwk" });
22414
- return handleJWK(key, jwk, alg);
22415
- }
22416
- if (isJWK(key)) {
22417
- if (key.k) {
22418
- return decode$1(key.k);
22419
- }
22420
- return handleJWK(key, key, alg, true);
22421
- }
22422
- throw new Error("unreachable");
22423
- }
22424
- function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
22425
- if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) {
22426
- throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
22427
- }
22428
- if (!protectedHeader || protectedHeader.crit === void 0) {
22429
- return /* @__PURE__ */ new Set();
22430
- }
22431
- if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
22432
- throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
22433
- }
22434
- let recognized;
22435
- if (recognizedOption !== void 0) {
22436
- recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
22437
- } else {
22438
- recognized = recognizedDefault;
22439
- }
22440
- for (const parameter of protectedHeader.crit) {
22441
- if (!recognized.has(parameter)) {
22442
- throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
22443
- }
22444
- if (joseHeader[parameter] === void 0) {
22445
- throw new Err(`Extension Header Parameter "${parameter}" is missing`);
22446
- }
22447
- if (recognized.get(parameter) && protectedHeader[parameter] === void 0) {
22448
- throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
22449
- }
22450
- }
22451
- return new Set(protectedHeader.crit);
22452
- }
22453
- const tag = (key) => key?.[Symbol.toStringTag];
22454
- const jwkMatchesOp = (alg, key, usage) => {
22455
- if (key.use !== void 0) {
22456
- let expected;
22457
- switch (usage) {
22458
- case "sign":
22459
- case "verify":
22460
- expected = "sig";
22461
- break;
22462
- case "encrypt":
22463
- case "decrypt":
22464
- expected = "enc";
22465
- break;
22466
- }
22467
- if (key.use !== expected) {
22468
- throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
22469
- }
22470
- }
22471
- if (key.alg !== void 0 && key.alg !== alg) {
22472
- throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
22473
- }
22474
- if (Array.isArray(key.key_ops)) {
22475
- let expectedKeyOp;
22476
- switch (true) {
22477
- case usage === "sign":
22478
- case alg === "dir":
22479
- case alg.includes("CBC-HS"):
22480
- expectedKeyOp = usage;
22481
- break;
22482
- case alg.startsWith("PBES2"):
22483
- expectedKeyOp = "deriveBits";
22484
- break;
22485
- case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
22486
- if (!alg.includes("GCM") && alg.endsWith("KW")) {
22487
- expectedKeyOp = "unwrapKey";
22488
- } else {
22489
- expectedKeyOp = usage;
22490
- }
22491
- break;
22492
- case usage === "encrypt":
22493
- expectedKeyOp = "wrapKey";
22494
- break;
22495
- case usage === "decrypt":
22496
- expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
22497
- break;
22498
- }
22499
- if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {
22500
- throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
22501
- }
22502
- }
22503
- return true;
22504
- };
22505
- const symmetricTypeCheck = (alg, key, usage) => {
22506
- if (key instanceof Uint8Array)
22507
- return;
22508
- if (isJWK(key)) {
22509
- if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage))
22510
- return;
22511
- throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`);
22512
- }
22513
- if (!isKeyLike(key)) {
22514
- throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
22515
- }
22516
- if (key.type !== "secret") {
22517
- throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
22518
- }
22519
- };
22520
- const asymmetricTypeCheck = (alg, key, usage) => {
22521
- if (isJWK(key)) {
22522
- switch (usage) {
22523
- case "decrypt":
22524
- case "sign":
22525
- if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
22526
- return;
22527
- throw new TypeError(`JSON Web Key for this operation must be a private JWK`);
22528
- case "encrypt":
22529
- case "verify":
22530
- if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
22531
- return;
22532
- throw new TypeError(`JSON Web Key for this operation must be a public JWK`);
22533
- }
22534
- }
22535
- if (!isKeyLike(key)) {
22536
- throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
22537
- }
22538
- if (key.type === "secret") {
22539
- throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
22540
- }
22541
- if (key.type === "public") {
22542
- switch (usage) {
22543
- case "sign":
22544
- throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
22545
- case "decrypt":
22546
- throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
22547
- }
22548
- }
22549
- if (key.type === "private") {
22550
- switch (usage) {
22551
- case "verify":
22552
- throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
22553
- case "encrypt":
22554
- throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
22555
- }
22556
- }
22557
- };
22558
- function checkKeyType(alg, key, usage) {
22559
- switch (alg.substring(0, 2)) {
22560
- case "A1":
22561
- case "A2":
22562
- case "di":
22563
- case "HS":
22564
- case "PB":
22565
- symmetricTypeCheck(alg, key, usage);
22566
- break;
22567
- default:
22568
- asymmetricTypeCheck(alg, key, usage);
22569
- }
22570
- }
22571
- const epoch = (date) => Math.floor(date.getTime() / 1e3);
22572
- const minute = 60;
22573
- const hour = minute * 60;
22574
- const day = hour * 24;
22575
- const week = day * 7;
22576
- const year = day * 365.25;
22577
- const REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
22578
- function secs(str) {
22579
- const matched = REGEX.exec(str);
22580
- if (!matched || matched[4] && matched[1]) {
22581
- throw new TypeError("Invalid time period format");
22582
- }
22583
- const value = parseFloat(matched[2]);
22584
- const unit = matched[3].toLowerCase();
22585
- let numericDate;
22586
- switch (unit) {
22587
- case "sec":
22588
- case "secs":
22589
- case "second":
22590
- case "seconds":
22591
- case "s":
22592
- numericDate = Math.round(value);
22593
- break;
22594
- case "minute":
22595
- case "minutes":
22596
- case "min":
22597
- case "mins":
22598
- case "m":
22599
- numericDate = Math.round(value * minute);
22600
- break;
22601
- case "hour":
22602
- case "hours":
22603
- case "hr":
22604
- case "hrs":
22605
- case "h":
22606
- numericDate = Math.round(value * hour);
22607
- break;
22608
- case "day":
22609
- case "days":
22610
- case "d":
22611
- numericDate = Math.round(value * day);
22612
- break;
22613
- case "week":
22614
- case "weeks":
22615
- case "w":
22616
- numericDate = Math.round(value * week);
22617
- break;
22618
- default:
22619
- numericDate = Math.round(value * year);
22620
- break;
22621
- }
22622
- if (matched[1] === "-" || matched[4] === "ago") {
22623
- return -numericDate;
22624
- }
22625
- return numericDate;
22626
- }
22627
- function validateInput(label, input) {
22628
- if (!Number.isFinite(input)) {
22629
- throw new TypeError(`Invalid ${label} input`);
22630
- }
22631
- return input;
22632
- }
22633
- class JWTClaimsBuilder {
22634
- #payload;
22635
- constructor(payload) {
22636
- if (!isObject(payload)) {
22637
- throw new TypeError("JWT Claims Set MUST be an object");
22638
- }
22639
- this.#payload = structuredClone(payload);
22640
- }
22641
- data() {
22642
- return encoder.encode(JSON.stringify(this.#payload));
22643
- }
22644
- get iss() {
22645
- return this.#payload.iss;
22646
- }
22647
- set iss(value) {
22648
- this.#payload.iss = value;
22649
- }
22650
- get sub() {
22651
- return this.#payload.sub;
22652
- }
22653
- set sub(value) {
22654
- this.#payload.sub = value;
22655
- }
22656
- get aud() {
22657
- return this.#payload.aud;
22658
- }
22659
- set aud(value) {
22660
- this.#payload.aud = value;
22661
- }
22662
- set jti(value) {
22663
- this.#payload.jti = value;
22664
- }
22665
- set nbf(value) {
22666
- if (typeof value === "number") {
22667
- this.#payload.nbf = validateInput("setNotBefore", value);
22668
- } else if (value instanceof Date) {
22669
- this.#payload.nbf = validateInput("setNotBefore", epoch(value));
22670
- } else {
22671
- this.#payload.nbf = epoch(/* @__PURE__ */ new Date()) + secs(value);
22672
- }
22673
- }
22674
- set exp(value) {
22675
- if (typeof value === "number") {
22676
- this.#payload.exp = validateInput("setExpirationTime", value);
22677
- } else if (value instanceof Date) {
22678
- this.#payload.exp = validateInput("setExpirationTime", epoch(value));
22679
- } else {
22680
- this.#payload.exp = epoch(/* @__PURE__ */ new Date()) + secs(value);
22681
- }
22682
- }
22683
- set iat(value) {
22684
- if (value === void 0) {
22685
- this.#payload.iat = epoch(/* @__PURE__ */ new Date());
22686
- } else if (value instanceof Date) {
22687
- this.#payload.iat = validateInput("setIssuedAt", epoch(value));
22688
- } else if (typeof value === "string") {
22689
- this.#payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value));
22690
- } else {
22691
- this.#payload.iat = validateInput("setIssuedAt", value);
22692
- }
22693
- }
22694
- }
22695
- class FlattenedSign {
22696
- #payload;
22697
- #protectedHeader;
22698
- #unprotectedHeader;
22699
- constructor(payload) {
22700
- if (!(payload instanceof Uint8Array)) {
22701
- throw new TypeError("payload must be an instance of Uint8Array");
22702
- }
22703
- this.#payload = payload;
22704
- }
22705
- setProtectedHeader(protectedHeader) {
22706
- assertNotSet(this.#protectedHeader, "setProtectedHeader");
22707
- this.#protectedHeader = protectedHeader;
22708
- return this;
22709
- }
22710
- setUnprotectedHeader(unprotectedHeader) {
22711
- assertNotSet(this.#unprotectedHeader, "setUnprotectedHeader");
22712
- this.#unprotectedHeader = unprotectedHeader;
22713
- return this;
22714
- }
22715
- async sign(key, options2) {
22716
- if (!this.#protectedHeader && !this.#unprotectedHeader) {
22717
- throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
22718
- }
22719
- if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader)) {
22720
- throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
22721
- }
22722
- const joseHeader = {
22723
- ...this.#protectedHeader,
22724
- ...this.#unprotectedHeader
22725
- };
22726
- const extensions2 = validateCrit(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options2?.crit, this.#protectedHeader, joseHeader);
22727
- let b64 = true;
22728
- if (extensions2.has("b64")) {
22729
- b64 = this.#protectedHeader.b64;
22730
- if (typeof b64 !== "boolean") {
22731
- throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
22732
- }
22733
- }
22734
- const { alg } = joseHeader;
22735
- if (typeof alg !== "string" || !alg) {
22736
- throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
22737
- }
22738
- checkKeyType(alg, key, "sign");
22739
- let payloadS;
22740
- let payloadB;
22741
- if (b64) {
22742
- payloadS = encode$3(this.#payload);
22743
- payloadB = encode$4(payloadS);
22744
- } else {
22745
- payloadB = this.#payload;
22746
- payloadS = "";
22747
- }
22748
- let protectedHeaderString;
22749
- let protectedHeaderBytes;
22750
- if (this.#protectedHeader) {
22751
- protectedHeaderString = encode$3(JSON.stringify(this.#protectedHeader));
22752
- protectedHeaderBytes = encode$4(protectedHeaderString);
22753
- } else {
22754
- protectedHeaderString = "";
22755
- protectedHeaderBytes = new Uint8Array();
22756
- }
22757
- const data = concat(protectedHeaderBytes, encode$4("."), payloadB);
22758
- const k = await normalizeKey$1(key, alg);
22759
- const signature = await sign$2(alg, k, data);
22760
- const jws2 = {
22761
- signature: encode$3(signature),
22762
- payload: payloadS
22763
- };
22764
- if (this.#unprotectedHeader) {
22765
- jws2.header = this.#unprotectedHeader;
22766
- }
22767
- if (this.#protectedHeader) {
22768
- jws2.protected = protectedHeaderString;
22769
- }
22770
- return jws2;
22771
- }
22772
- }
22773
- class CompactSign {
22774
- #flattened;
22775
- constructor(payload) {
22776
- this.#flattened = new FlattenedSign(payload);
22777
- }
22778
- setProtectedHeader(protectedHeader) {
22779
- this.#flattened.setProtectedHeader(protectedHeader);
22780
- return this;
22781
- }
22782
- async sign(key, options2) {
22783
- const jws2 = await this.#flattened.sign(key, options2);
22784
- if (jws2.payload === void 0) {
22785
- throw new TypeError("use the flattened module for creating JWS with b64: false");
22786
- }
22787
- return `${jws2.protected}.${jws2.payload}.${jws2.signature}`;
22788
- }
22789
- }
22790
- class SignJWT {
22791
- #protectedHeader;
22792
- #jwt;
22793
- constructor(payload = {}) {
22794
- this.#jwt = new JWTClaimsBuilder(payload);
22795
- }
22796
- setIssuer(issuer) {
22797
- this.#jwt.iss = issuer;
22798
- return this;
22799
- }
22800
- setSubject(subject) {
22801
- this.#jwt.sub = subject;
22802
- return this;
22803
- }
22804
- setAudience(audience) {
22805
- this.#jwt.aud = audience;
22806
- return this;
22807
- }
22808
- setJti(jwtId) {
22809
- this.#jwt.jti = jwtId;
22810
- return this;
22811
- }
22812
- setNotBefore(input) {
22813
- this.#jwt.nbf = input;
22814
- return this;
22815
- }
22816
- setExpirationTime(input) {
22817
- this.#jwt.exp = input;
22818
- return this;
22819
- }
22820
- setIssuedAt(input) {
22821
- this.#jwt.iat = input;
22822
- return this;
22823
- }
22824
- setProtectedHeader(protectedHeader) {
22825
- this.#protectedHeader = protectedHeader;
22826
- return this;
22827
- }
22828
- async sign(key, options2) {
22829
- const sig = new CompactSign(this.#jwt.data());
22830
- sig.setProtectedHeader(this.#protectedHeader);
22831
- if (Array.isArray(this.#protectedHeader?.crit) && this.#protectedHeader.crit.includes("b64") && this.#protectedHeader.b64 === false) {
22832
- throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
22833
- }
22834
- return sig.sign(key, options2);
22835
- }
22836
- }
22837
20986
  function createAppleProvider(config) {
22838
20987
  async function generateClientSecret() {
22839
- const key = createPrivateKey$1({
22840
- key: config.privateKey,
22841
- format: "pem"
20988
+ return jwt.sign({}, config.privateKey, {
20989
+ algorithm: "ES256",
20990
+ keyid: config.keyId,
20991
+ issuer: config.teamId,
20992
+ expiresIn: "180d",
20993
+ audience: "https://appleid.apple.com",
20994
+ subject: config.clientId
22842
20995
  });
22843
- const now = Math.floor(Date.now() / 1e3);
22844
- return new SignJWT({}).setProtectedHeader({
22845
- alg: "ES256",
22846
- kid: config.keyId
22847
- }).setIssuer(config.teamId).setIssuedAt(now).setExpirationTime(now + 86400 * 180).setAudience("https://appleid.apple.com").setSubject(config.clientId).sign(key);
22848
20996
  }
22849
20997
  return {
22850
20998
  id: "apple",
@@ -23652,7 +21800,7 @@ function createRateLimiter(options2 = {}) {
23652
21800
  windowMs = 15 * 60 * 1e3,
23653
21801
  limit = 100,
23654
21802
  keyGenerator = defaultKeyGenerator,
23655
- message: message2 = "Too many requests, please try again later."
21803
+ message = "Too many requests, please try again later."
23656
21804
  } = options2;
23657
21805
  const store = /* @__PURE__ */ new Map();
23658
21806
  const cleanupInterval = setInterval(() => {
@@ -23687,7 +21835,7 @@ function createRateLimiter(options2 = {}) {
23687
21835
  c.header("X-RateLimit-Reset", String(Math.ceil((now + retryAfterMs) / 1e3)));
23688
21836
  return c.json({
23689
21837
  error: {
23690
- message: message2,
21838
+ message,
23691
21839
  code: "RATE_LIMITED"
23692
21840
  }
23693
21841
  }, 429);
@@ -23851,7 +21999,11 @@ function createAuthRoutes(config) {
23851
21999
  passwordHash,
23852
22000
  displayName: displayName || void 0
23853
22001
  });
23854
- if (config.defaultRole) {
22002
+ const existingUsers = await authRepo.listUsers();
22003
+ const isFirstUser = existingUsers.length === 1 && existingUsers[0].id === user.id;
22004
+ if (isFirstUser) {
22005
+ await authRepo.setUserRoles(user.id, ["admin"]);
22006
+ } else if (config.defaultRole) {
23855
22007
  await authRepo.assignDefaultRole(user.id, config.defaultRole);
23856
22008
  }
23857
22009
  const {
@@ -23892,7 +22044,13 @@ function createAuthRoutes(config) {
23892
22044
  for (const provider of config.oauthProviders) {
23893
22045
  router.post(`/${provider.id}`, defaultAuthLimiter, async (c) => {
23894
22046
  const payload = parseBody2(provider.schema, await c.req.json());
23895
- const externalUser = await provider.verify(payload);
22047
+ let externalUser;
22048
+ try {
22049
+ externalUser = await provider.verify(payload);
22050
+ } catch (err) {
22051
+ const msg = err instanceof Error ? err.message : String(err);
22052
+ throw ApiError.unauthorized(`${provider.id} login failed: ${msg}`, "OAUTH_ERROR");
22053
+ }
23896
22054
  if (!externalUser) {
23897
22055
  throw ApiError.unauthorized(`Invalid ${provider.id} credentials`, "INVALID_TOKEN");
23898
22056
  }
@@ -23916,7 +22074,11 @@ function createAuthRoutes(config) {
23916
22074
  await authRepo.linkUserIdentity(user.id, provider.id, externalUser.providerId, {
23917
22075
  email: externalUser.email
23918
22076
  });
23919
- if (config.defaultRole) {
22077
+ const allUsers = await authRepo.listUsers();
22078
+ const isFirstUser = allUsers.length === 1 && allUsers[0].id === user.id;
22079
+ if (isFirstUser) {
22080
+ await authRepo.setUserRoles(user.id, ["admin"]);
22081
+ } else if (config.defaultRole) {
23920
22082
  await authRepo.assignDefaultRole(user.id, config.defaultRole);
23921
22083
  }
23922
22084
  sendWelcomeEmail({
@@ -24928,17 +23090,34 @@ class LocalStorageController {
24928
23090
  }
24929
23091
  }
24930
23092
  resolvedPath = normalizeStoragePath(resolvedPath);
23093
+ if (!resolvedPath) {
23094
+ return;
23095
+ }
24931
23096
  const fullPath = this.getFullPath(resolvedPath, resolvedBucket);
24932
23097
  try {
24933
- await unlink(fullPath);
24934
- try {
24935
- await unlink(`${fullPath}.metadata.json`);
24936
- } catch {
23098
+ await access(fullPath, fs$4.constants.F_OK);
23099
+ } catch {
23100
+ return;
23101
+ }
23102
+ try {
23103
+ const stats = await stat(fullPath);
23104
+ if (stats.isDirectory()) {
23105
+ await fs$4.promises.rmdir(fullPath);
23106
+ } else {
23107
+ await unlink(fullPath);
23108
+ try {
23109
+ await unlink(`${fullPath}.metadata.json`);
23110
+ } catch {
23111
+ }
24937
23112
  }
24938
23113
  } catch (error2) {
24939
- if (error2 instanceof Error && error2.code !== "ENOENT") {
24940
- throw error2;
23114
+ if (error2 instanceof Error) {
23115
+ const code2 = error2.code;
23116
+ if (code2 === "ENOENT" || code2 === "ENOTEMPTY") {
23117
+ return;
23118
+ }
24941
23119
  }
23120
+ throw error2;
24942
23121
  }
24943
23122
  }
24944
23123
  async listObjects(prefix, options2) {
@@ -25045,7 +23224,8 @@ class S3StorageController {
25045
23224
  * Get the bucket name - either from parameter or config
25046
23225
  */
25047
23226
  getBucket(bucket) {
25048
- return bucket ?? this.config.bucket;
23227
+ if (!bucket || bucket === "default") return this.config.bucket;
23228
+ return bucket;
25049
23229
  }
25050
23230
  async putObject({
25051
23231
  file,
@@ -25333,11 +23513,18 @@ function createStorageRoutes(config) {
25333
23513
  const fileContent = fs$4.readFileSync(absolutePath);
25334
23514
  return c.body(new Uint8Array(fileContent));
25335
23515
  }
25336
- const downloadConfig = await controller.getSignedUrl(filePath);
25337
- if (downloadConfig.fileNotFound || !downloadConfig.url) {
23516
+ const {
23517
+ bucket: parsedBucket,
23518
+ resolvedPath: parsedPath
23519
+ } = parseBucketAndPath(filePath);
23520
+ const fileObject = await controller.getObject(parsedPath, parsedBucket);
23521
+ if (!fileObject) {
25338
23522
  throw ApiError.notFound("File not found");
25339
23523
  }
25340
- return c.redirect(downloadConfig.url);
23524
+ c.header("Content-Type", fileObject.type || "application/octet-stream");
23525
+ c.header("Cache-Control", "public, max-age=3600, immutable");
23526
+ const buf = await fileObject.arrayBuffer();
23527
+ return c.body(new Uint8Array(buf));
25341
23528
  });
25342
23529
  router.get("/metadata/*", readAuthMiddleware, async (c) => {
25343
23530
  const rawPath = extractWildcardPath(c);
@@ -25387,7 +23574,7 @@ function createStorageRoutes(config) {
25387
23574
  const maxResults = c.req.query("maxResults");
25388
23575
  const pageToken = c.req.query("pageToken");
25389
23576
  const result = await controller.listObjects(storagePrefix, {
25390
- bucket,
23577
+ bucket: bucket ?? (controller.getType() === "local" ? "default" : void 0),
25391
23578
  maxResults: maxResults ? parseInt(maxResults, 10) : void 0,
25392
23579
  pageToken
25393
23580
  });
@@ -25396,6 +23583,40 @@ function createStorageRoutes(config) {
25396
23583
  data: result
25397
23584
  });
25398
23585
  });
23586
+ router.post("/folder", writeAuthMiddleware, async (c) => {
23587
+ const body = await c.req.json();
23588
+ const folderPath = body.path;
23589
+ if (!folderPath || typeof folderPath !== "string") {
23590
+ throw ApiError.badRequest("Folder path is required");
23591
+ }
23592
+ const {
23593
+ bucket,
23594
+ resolvedPath
23595
+ } = parseBucketAndPath(folderPath);
23596
+ if (!resolvedPath || resolvedPath.trim() === "") {
23597
+ throw ApiError.badRequest("Invalid folder path");
23598
+ }
23599
+ if (controller.getType() === "local") {
23600
+ const localController = controller;
23601
+ const absolutePath = localController.getAbsolutePath(resolvedPath, bucket);
23602
+ fs$4.mkdirSync(absolutePath, {
23603
+ recursive: true
23604
+ });
23605
+ } else {
23606
+ const key = resolvedPath.endsWith("/") ? resolvedPath : resolvedPath + "/";
23607
+ const emptyFile = new File([], key, {
23608
+ type: "application/x-directory"
23609
+ });
23610
+ await controller.putObject({
23611
+ file: emptyFile,
23612
+ key
23613
+ });
23614
+ }
23615
+ return c.json({
23616
+ success: true,
23617
+ message: "Folder created"
23618
+ }, 201);
23619
+ });
25399
23620
  return router;
25400
23621
  }
25401
23622
  const DEFAULT_STORAGE_ID = "(default)";
@@ -25519,8 +23740,8 @@ class RebaseApiError extends Error {
25519
23740
  status;
25520
23741
  code;
25521
23742
  details;
25522
- constructor(status, message2, code2, details) {
25523
- super(message2);
23743
+ constructor(status, message, code2, details) {
23744
+ super(message);
25524
23745
  this.name = "RebaseApiError";
25525
23746
  this.status = status;
25526
23747
  this.code = code2;
@@ -25850,20 +24071,21 @@ function createAuth(transport, options2) {
25850
24071
  refreshToken: session.refreshToken
25851
24072
  };
25852
24073
  }
25853
- async function signInWithGoogle(idToken) {
24074
+ async function signInWithGoogle(tokenOrPayload) {
25854
24075
  const fetchFn = getFetch();
24076
+ const body = typeof tokenOrPayload === "string" ? {
24077
+ idToken: tokenOrPayload
24078
+ } : tokenOrPayload;
25855
24079
  const res = await fetchFn(authUrl("/google"), {
25856
24080
  method: "POST",
25857
24081
  headers: {
25858
24082
  "Content-Type": "application/json"
25859
24083
  },
25860
- body: JSON.stringify({
25861
- idToken
25862
- })
24084
+ body: JSON.stringify(body)
25863
24085
  });
25864
- const body = await res.json().catch(() => ({}));
25865
- if (!res.ok) throwApiError(res.status, body, res.statusText);
25866
- const session = handleAuthResponse(body, "SIGNED_IN");
24086
+ const responseBody = await res.json().catch(() => ({}));
24087
+ if (!res.ok) throwApiError(res.status, responseBody, res.statusText);
24088
+ const session = handleAuthResponse(responseBody, "SIGNED_IN");
25867
24089
  return {
25868
24090
  user: session.user,
25869
24091
  accessToken: session.accessToken,
@@ -26525,6 +24747,25 @@ function createCollectionClient(transport, slug, ws) {
26525
24747
  };
26526
24748
  return client;
26527
24749
  }
24750
+ function createFunctionsClient(transport) {
24751
+ return {
24752
+ async invoke(name2, payload, options2) {
24753
+ const method = options2?.method ?? "POST";
24754
+ const subPath = options2?.path ? `/${options2.path.replace(/^\//, "")}` : "";
24755
+ const routePath = `/functions/${encodeURIComponent(name2)}${subPath}`;
24756
+ const init = {
24757
+ method
24758
+ };
24759
+ if (payload !== void 0 && method !== "GET") {
24760
+ init.body = JSON.stringify(payload);
24761
+ }
24762
+ if (options2?.headers) {
24763
+ init.headers = options2.headers;
24764
+ }
24765
+ return transport.request(routePath, init);
24766
+ }
24767
+ };
24768
+ }
26528
24769
  function createStorage(transport) {
26529
24770
  const urlsCache = /* @__PURE__ */ new Map();
26530
24771
  async function putObject({
@@ -26658,6 +24899,7 @@ function createRebaseClient(options2) {
26658
24899
  const admin = createAdmin(transport, options2.admin);
26659
24900
  const cron = createCron(transport, options2.cron);
26660
24901
  const storage = createStorage(transport);
24902
+ const functions = createFunctionsClient(transport);
26661
24903
  let ws;
26662
24904
  if (!options2.onUnauthorized) {
26663
24905
  transport.setOnUnauthorized(async () => {
@@ -26696,6 +24938,7 @@ function createRebaseClient(options2) {
26696
24938
  auth,
26697
24939
  admin,
26698
24940
  cron,
24941
+ functions,
26699
24942
  storage,
26700
24943
  ws,
26701
24944
  setToken: transport.setToken,
@@ -27509,7 +25752,7 @@ var fetchExports = fetch$1.exports;
27509
25752
  });
27510
25753
  return options2;
27511
25754
  };
27512
- module.exports._logFunc = (logger2, level, defaults, data, message2, ...args) => {
25755
+ module.exports._logFunc = (logger2, level, defaults, data, message, ...args) => {
27513
25756
  let entry = {};
27514
25757
  Object.keys(defaults || {}).forEach((key) => {
27515
25758
  if (key !== "level") {
@@ -27521,7 +25764,7 @@ var fetchExports = fetch$1.exports;
27521
25764
  entry[key] = data[key];
27522
25765
  }
27523
25766
  });
27524
- logger2[level](entry, message2, ...args);
25767
+ logger2[level](entry, message, ...args);
27525
25768
  };
27526
25769
  module.exports.getLogger = (options2, defaults) => {
27527
25770
  options2 = options2 || {};
@@ -27538,8 +25781,8 @@ var fetchExports = fetch$1.exports;
27538
25781
  logger2 = createDefaultLogger(levels);
27539
25782
  }
27540
25783
  levels.forEach((level) => {
27541
- response[level] = (data, message2, ...args) => {
27542
- module.exports._logFunc(logger2, level, defaults, data, message2, ...args);
25784
+ response[level] = (data, message, ...args) => {
25785
+ module.exports._logFunc(logger2, level, defaults, data, message, ...args);
27543
25786
  };
27544
25787
  });
27545
25788
  return response;
@@ -27722,7 +25965,7 @@ var fetchExports = fetch$1.exports;
27722
25965
  }
27723
25966
  levelNames.set(level, levelName);
27724
25967
  });
27725
- let print2 = (level, entry, message2, ...args) => {
25968
+ let print2 = (level, entry, message, ...args) => {
27726
25969
  let prefix = "";
27727
25970
  if (entry) {
27728
25971
  if (entry.tnx === "server") {
@@ -27737,8 +25980,8 @@ var fetchExports = fetch$1.exports;
27737
25980
  prefix = "[#" + entry.cid + "] " + prefix;
27738
25981
  }
27739
25982
  }
27740
- message2 = util2.format(message2, ...args);
27741
- message2.split(/\r?\n/).forEach((line) => {
25983
+ message = util2.format(message, ...args);
25984
+ message.split(/\r?\n/).forEach((line) => {
27742
25985
  console.log("[%s] %s %s", (/* @__PURE__ */ new Date()).toISOString().substr(0, 19).replace(/T/, " "), levelNames.get(level), prefix + line);
27743
25986
  });
27744
25987
  };
@@ -34234,8 +32477,8 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
34234
32477
  * @param {Object} message String, Buffer or a Stream
34235
32478
  * @param {Function} callback Callback to return once sending is completed
34236
32479
  */
34237
- send(envelope, message2, done) {
34238
- if (!message2) {
32480
+ send(envelope, message, done) {
32481
+ if (!message) {
34239
32482
  return done(this._formatError("Empty message", "EMESSAGE", false, "API"));
34240
32483
  }
34241
32484
  const isDestroyedMessage = this._isDestroyedMessage("send message");
@@ -34255,17 +32498,17 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
34255
32498
  returned = true;
34256
32499
  done(...arguments);
34257
32500
  };
34258
- if (typeof message2.on === "function") {
34259
- message2.on("error", (err) => callback(this._formatError(err, "ESTREAM", false, "API")));
32501
+ if (typeof message.on === "function") {
32502
+ message.on("error", (err) => callback(this._formatError(err, "ESTREAM", false, "API")));
34260
32503
  }
34261
32504
  let startTime = Date.now();
34262
32505
  this._setEnvelope(envelope, (err, info) => {
34263
32506
  if (err) {
34264
32507
  let stream3 = new PassThrough();
34265
- if (typeof message2.pipe === "function") {
34266
- message2.pipe(stream3);
32508
+ if (typeof message.pipe === "function") {
32509
+ message.pipe(stream3);
34267
32510
  } else {
34268
- stream3.write(message2);
32511
+ stream3.write(message);
34269
32512
  stream3.end();
34270
32513
  }
34271
32514
  return callback(err);
@@ -34281,10 +32524,10 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
34281
32524
  info.response = str;
34282
32525
  return callback(null, info);
34283
32526
  });
34284
- if (typeof message2.pipe === "function") {
34285
- message2.pipe(stream2);
32527
+ if (typeof message.pipe === "function") {
32528
+ message.pipe(stream2);
34286
32529
  } else {
34287
- stream2.write(message2);
32530
+ stream2.write(message);
34288
32531
  stream2.end();
34289
32532
  }
34290
32533
  });
@@ -34397,12 +32640,12 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
34397
32640
  this.emit("error", err);
34398
32641
  this.close();
34399
32642
  }
34400
- _formatError(message2, type, response, command) {
32643
+ _formatError(message, type, response, command) {
34401
32644
  let err;
34402
- if (/Error\]$/i.test(Object.prototype.toString.call(message2))) {
34403
- err = message2;
32645
+ if (/Error\]$/i.test(Object.prototype.toString.call(message))) {
32646
+ err = message;
34404
32647
  } else {
34405
- err = new Error(message2);
32648
+ err = new Error(message);
34406
32649
  }
34407
32650
  if (type && type !== "Error") {
34408
32651
  err.code = type;
@@ -35045,14 +33288,14 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
35045
33288
  * @param {String} str Message from the server
35046
33289
  */
35047
33290
  _actionMAIL(str, callback) {
35048
- let message2, curRecipient;
33291
+ let message, curRecipient;
35049
33292
  if (Number(str.charAt(0)) !== 2) {
35050
33293
  if (this._usingSmtpUtf8 && /^550 /.test(str) && /[\x80-\uFFFF]/.test(this._envelope.from)) {
35051
- message2 = "Internationalized mailbox name not allowed";
33294
+ message = "Internationalized mailbox name not allowed";
35052
33295
  } else {
35053
- message2 = "Mail command failed";
33296
+ message = "Mail command failed";
35054
33297
  }
35055
- return callback(this._formatError(message2, "EENVELOPE", str, "MAIL FROM"));
33298
+ return callback(this._formatError(message, "EENVELOPE", str, "MAIL FROM"));
35056
33299
  }
35057
33300
  if (!this._envelope.rcptQueue.length) {
35058
33301
  return callback(this._formatError("Can't send mail - no recipients defined", "EENVELOPE", false, "API"));
@@ -35083,15 +33326,15 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
35083
33326
  * @param {String} str Message from the server
35084
33327
  */
35085
33328
  _actionRCPT(str, callback) {
35086
- let message2, err, curRecipient = this._recipientQueue.shift();
33329
+ let message, err, curRecipient = this._recipientQueue.shift();
35087
33330
  if (Number(str.charAt(0)) !== 2) {
35088
33331
  if (this._usingSmtpUtf8 && /^553 /.test(str) && /[\x80-\uFFFF]/.test(curRecipient)) {
35089
- message2 = "Internationalized mailbox name not allowed";
33332
+ message = "Internationalized mailbox name not allowed";
35090
33333
  } else {
35091
- message2 = "Recipient command failed";
33334
+ message = "Recipient command failed";
35092
33335
  }
35093
33336
  this._envelope.rejected.push(curRecipient);
35094
- err = this._formatError(message2, "EENVELOPE", str, "RCPT TO");
33337
+ err = this._formatError(message, "EENVELOPE", str, "RCPT TO");
35095
33338
  err.recipient = curRecipient;
35096
33339
  this._envelope.rejectedErrors.push(err);
35097
33340
  } else {
@@ -37807,9 +36050,9 @@ class SMTPEmailService {
37807
36050
  replyTo: options2.replyTo
37808
36051
  });
37809
36052
  } catch (error2) {
37810
- const message2 = error2 instanceof Error ? error2.message : String(error2);
37811
- console.error("Failed to send email:", message2);
37812
- throw new Error(`Failed to send email: ${message2}`);
36053
+ const message = error2 instanceof Error ? error2.message : String(error2);
36054
+ console.error("Failed to send email:", message);
36055
+ throw new Error(`Failed to send email: ${message}`);
37813
36056
  }
37814
36057
  }
37815
36058
  /**
@@ -37823,8 +36066,8 @@ class SMTPEmailService {
37823
36066
  await this.transporter.verify();
37824
36067
  return true;
37825
36068
  } catch (error2) {
37826
- const message2 = error2 instanceof Error ? error2.message : String(error2);
37827
- console.error("SMTP connection verification failed:", message2);
36069
+ const message = error2 instanceof Error ? error2.message : String(error2);
36070
+ console.error("SMTP connection verification failed:", message);
37828
36071
  return false;
37829
36072
  }
37830
36073
  }
@@ -38023,7 +36266,7 @@ async function _initializeRebaseBackend(config) {
38023
36266
  const {
38024
36267
  createGoogleProvider: createGoogleProvider2
38025
36268
  } = await import("./index-DXVBFp5V.js");
38026
- oauthProviders.push(createGoogleProvider2(config.auth.google.clientId));
36269
+ oauthProviders.push(createGoogleProvider2(config.auth.google));
38027
36270
  }
38028
36271
  if (config.auth.linkedin?.clientId && config.auth.linkedin?.clientSecret) {
38029
36272
  const {
@@ -38224,6 +36467,13 @@ async function _initializeRebaseBackend(config) {
38224
36467
  }
38225
36468
  _initRebase(serverClient);
38226
36469
  logger.info("Rebase singleton initialized");
36470
+ if (defaultDriverResult.internals) {
36471
+ const internals = defaultDriverResult.internals;
36472
+ const driver = internals.driver;
36473
+ if (driver && "client" in driver) {
36474
+ driver.client = serverClient;
36475
+ }
36476
+ }
38227
36477
  if (config.functionsDir) {
38228
36478
  const {
38229
36479
  loadFunctionsFromDirectory: loadFunctionsFromDirectory2
@@ -38357,10 +36607,10 @@ async function _initializeRebaseBackend(config) {
38357
36607
  shutdown
38358
36608
  };
38359
36609
  }
38360
- function devAssert(condition, message2) {
36610
+ function devAssert(condition, message) {
38361
36611
  const booleanCondition = Boolean(condition);
38362
36612
  if (!booleanCondition) {
38363
- throw new Error(message2);
36613
+ throw new Error(message);
38364
36614
  }
38365
36615
  }
38366
36616
  function isPromise(value) {
@@ -38369,11 +36619,11 @@ function isPromise(value) {
38369
36619
  function isObjectLike(value) {
38370
36620
  return typeof value == "object" && value !== null;
38371
36621
  }
38372
- function invariant(condition, message2) {
36622
+ function invariant(condition, message) {
38373
36623
  const booleanCondition = Boolean(condition);
38374
36624
  if (!booleanCondition) {
38375
36625
  throw new Error(
38376
- message2 != null ? message2 : "Unexpected invariant triggered."
36626
+ message != null ? message : "Unexpected invariant triggered."
38377
36627
  );
38378
36628
  }
38379
36629
  }
@@ -38492,10 +36742,10 @@ class GraphQLError extends Error {
38492
36742
  /**
38493
36743
  * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
38494
36744
  */
38495
- constructor(message2, ...rawArgs) {
36745
+ constructor(message, ...rawArgs) {
38496
36746
  var _this$nodes, _nodeLocations$, _ref;
38497
36747
  const { nodes, source, positions, path: path2, originalError, extensions: extensions2 } = toNormalizedOptions(rawArgs);
38498
- super(message2);
36748
+ super(message);
38499
36749
  this.name = "GraphQLError";
38500
36750
  this.path = path2 !== null && path2 !== void 0 ? path2 : void 0;
38501
36751
  this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
@@ -39513,14 +37763,14 @@ function formatArray(array, seenValues) {
39513
37763
  return "[" + items.join(", ") + "]";
39514
37764
  }
39515
37765
  function getObjectTag(object) {
39516
- const tag2 = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
39517
- if (tag2 === "Object" && typeof object.constructor === "function") {
37766
+ const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
37767
+ if (tag === "Object" && typeof object.constructor === "function") {
39518
37768
  const name2 = object.constructor.name;
39519
37769
  if (typeof name2 === "string" && name2 !== "") {
39520
37770
  return name2;
39521
37771
  }
39522
37772
  }
39523
- return tag2;
37773
+ return tag;
39524
37774
  }
39525
37775
  const isProduction = globalThis.process && // eslint-disable-next-line no-undef
39526
37776
  process.env.NODE_ENV === "production";
@@ -40918,22 +39168,22 @@ function getTokenKindDesc(kind) {
40918
39168
  const MAX_SUGGESTIONS = 5;
40919
39169
  function didYouMean(firstArg, secondArg) {
40920
39170
  const [subMessage, suggestionsArg] = secondArg ? [firstArg, secondArg] : [void 0, firstArg];
40921
- let message2 = " Did you mean ";
39171
+ let message = " Did you mean ";
40922
39172
  if (subMessage) {
40923
- message2 += subMessage + " ";
39173
+ message += subMessage + " ";
40924
39174
  }
40925
39175
  const suggestions = suggestionsArg.map((x) => `"${x}"`);
40926
39176
  switch (suggestions.length) {
40927
39177
  case 0:
40928
39178
  return "";
40929
39179
  case 1:
40930
- return message2 + suggestions[0] + "?";
39180
+ return message + suggestions[0] + "?";
40931
39181
  case 2:
40932
- return message2 + suggestions[0] + " or " + suggestions[1] + "?";
39182
+ return message + suggestions[0] + " or " + suggestions[1] + "?";
40933
39183
  }
40934
39184
  const selected = suggestions.slice(0, MAX_SUGGESTIONS);
40935
39185
  const lastItem = selected.pop();
40936
- return message2 + selected.join(", ") + ", or " + lastItem + "?";
39186
+ return message + selected.join(", ") + ", or " + lastItem + "?";
40937
39187
  }
40938
39188
  function identityFunc(x) {
40939
39189
  return x;
@@ -41279,17 +39529,17 @@ const escapeSequences = [
41279
39529
  "\\u009F"
41280
39530
  ];
41281
39531
  const BREAK = Object.freeze({});
41282
- function visit(root2, visitor, visitorKeys = QueryDocumentKeys) {
39532
+ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
41283
39533
  const enterLeaveMap = /* @__PURE__ */ new Map();
41284
39534
  for (const kind of Object.values(Kind)) {
41285
39535
  enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));
41286
39536
  }
41287
39537
  let stack = void 0;
41288
- let inArray = Array.isArray(root2);
41289
- let keys2 = [root2];
39538
+ let inArray = Array.isArray(root);
39539
+ let keys2 = [root];
41290
39540
  let index = -1;
41291
39541
  let edits = [];
41292
- let node = root2;
39542
+ let node = root;
41293
39543
  let key = void 0;
41294
39544
  let parent = void 0;
41295
39545
  const path2 = [];
@@ -41388,7 +39638,7 @@ function visit(root2, visitor, visitorKeys = QueryDocumentKeys) {
41388
39638
  if (edits.length !== 0) {
41389
39639
  return edits[edits.length - 1][1];
41390
39640
  }
41391
- return root2;
39641
+ return root;
41392
39642
  }
41393
39643
  function visitInParallel(visitors) {
41394
39644
  const skipping = new Array(visitors.length).fill(null);
@@ -43577,10 +41827,10 @@ class SchemaValidationContext {
43577
41827
  this._errors = [];
43578
41828
  this.schema = schema;
43579
41829
  }
43580
- reportError(message2, nodes) {
41830
+ reportError(message, nodes) {
43581
41831
  const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
43582
41832
  this._errors.push(
43583
- new GraphQLError(message2, {
41833
+ new GraphQLError(message, {
43584
41834
  nodes: _nodes
43585
41835
  })
43586
41836
  );
@@ -47955,9 +46205,9 @@ var errorMessages = (messages, graphqlErrors) => {
47955
46205
  };
47956
46206
  }
47957
46207
  return {
47958
- errors: messages.map((message2) => {
46208
+ errors: messages.map((message) => {
47959
46209
  return {
47960
- message: message2
46210
+ message
47961
46211
  };
47962
46212
  })
47963
46213
  };
@@ -49094,7 +47344,9 @@ class RebaseApiServer {
49094
47344
  * Setup Hono middleware
49095
47345
  */
49096
47346
  setupMiddleware() {
49097
- this.router.use("/*", secureHeaders());
47347
+ this.router.use("/*", secureHeaders({
47348
+ crossOriginOpenerPolicy: "same-origin-allow-popups"
47349
+ }));
49098
47350
  if (this.config.cors) {
49099
47351
  const origin = this.config.cors.origin;
49100
47352
  this.router.use("/*", cors({
@@ -49297,8 +47549,8 @@ async function loadFunctionsFromDirectory(directory) {
49297
47549
  Hint: ensure the function exports a Hono app created with the same hono version as the server.
49298
47550
  The loader checks for .fetch() and .routes — any Hono-compatible app will work.`);
49299
47551
  } catch (err) {
49300
- const message2 = err instanceof Error ? err.message : String(err);
49301
- console.error(`[functions] Failed to load ${file}: ${message2}`);
47552
+ const message = err instanceof Error ? err.message : String(err);
47553
+ console.error(`[functions] Failed to load ${file}: ${message}`);
49302
47554
  }
49303
47555
  }
49304
47556
  }
@@ -49370,8 +47622,8 @@ async function loadCronJobsFromDirectory(directory) {
49370
47622
  });
49371
47623
  console.log(`⏰ Loaded cron job: ${id} (${definition.schedule})`);
49372
47624
  } catch (err) {
49373
- const message2 = err instanceof Error ? err.message : String(err);
49374
- console.error(`[cron] Failed to load ${file}: ${message2}`);
47625
+ const message = err instanceof Error ? err.message : String(err);
47626
+ console.error(`[cron] Failed to load ${file}: ${message}`);
49375
47627
  }
49376
47628
  }
49377
47629
  }
@@ -49481,9 +47733,9 @@ function parseCronExpression(expression, after) {
49481
47733
  const month = candidate.getMonth() + 1;
49482
47734
  const dom = candidate.getDate();
49483
47735
  const dow = candidate.getDay();
49484
- const hour2 = candidate.getHours();
49485
- const minute2 = candidate.getMinutes();
49486
- if (months.includes(month) && doms.includes(dom) && dows.includes(dow) && hours.includes(hour2) && minutes.includes(minute2)) {
47736
+ const hour = candidate.getHours();
47737
+ const minute = candidate.getMinutes();
47738
+ if (months.includes(month) && doms.includes(dom) && dows.includes(dow) && hours.includes(hour) && minutes.includes(minute)) {
49487
47739
  return candidate;
49488
47740
  }
49489
47741
  candidate.setMinutes(candidate.getMinutes() + 1);