@rebasepro/server-core 0.0.1-canary.0e2f892 → 0.0.1-canary.3263433
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +1050 -1654
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1049 -1653
- package/dist/index.umd.js.map +1 -1
- package/dist/server-core/src/api/rest/api-generator.d.ts +15 -3
- package/dist/server-core/src/auth/admin-routes.d.ts +5 -0
- package/dist/server-core/src/auth/google-oauth.d.ts +5 -2
- package/dist/server-core/src/cron/cron-scheduler.d.ts +45 -0
- package/dist/server-core/src/cron/index.d.ts +1 -1
- package/dist/server-core/src/init.d.ts +10 -1
- package/dist/types/src/controllers/auth.d.ts +2 -2
- package/dist/types/src/controllers/collection_registry.d.ts +2 -1
- package/dist/types/src/controllers/data_driver.d.ts +36 -1
- package/dist/types/src/types/backend_hooks.d.ts +187 -0
- package/dist/types/src/types/collections.d.ts +11 -10
- package/dist/types/src/types/cron.d.ts +1 -1
- package/dist/types/src/types/entity_views.d.ts +4 -6
- package/dist/types/src/types/formex.d.ts +40 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/plugins.d.ts +6 -3
- package/dist/types/src/types/properties.d.ts +61 -89
- package/dist/types/src/types/slots.d.ts +20 -10
- package/dist/types/src/types/translations.d.ts +4 -0
- package/package.json +9 -9
- package/src/api/rest/api-generator-count.test.ts +113 -0
- package/src/api/rest/api-generator.ts +123 -22
- package/src/api/server.ts +3 -2
- package/src/auth/admin-routes.ts +133 -57
- package/src/auth/apple-oauth.ts +8 -18
- package/src/auth/google-oauth.ts +59 -20
- package/src/auth/rate-limiter.ts +9 -5
- package/src/cron/cron-scheduler.test.ts +301 -175
- package/src/cron/cron-scheduler.ts +220 -57
- package/src/cron/index.ts +1 -1
- package/src/init.ts +13 -3
- package/src/storage/LocalStorageController.ts +29 -13
- package/src/storage/S3StorageController.ts +4 -1
- package/src/storage/routes.ts +51 -5
- package/test/backend-hooks-admin.test.ts +394 -0
- package/test/backend-hooks-data.test.ts +408 -0
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
|
|
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";
|
|
@@ -1026,7 +1026,7 @@ const toSnakeCase = (str) => {
|
|
|
1026
1026
|
if (!regExpMatchArray) return "";
|
|
1027
1027
|
return regExpMatchArray.map((x) => x.toLowerCase()).join("_");
|
|
1028
1028
|
};
|
|
1029
|
-
function isObject$
|
|
1029
|
+
function isObject$a(item) {
|
|
1030
1030
|
return !!item && typeof item === "object" && !Array.isArray(item);
|
|
1031
1031
|
}
|
|
1032
1032
|
function isPlainObject$3(obj) {
|
|
@@ -1037,13 +1037,13 @@ function isPlainObject$3(obj) {
|
|
|
1037
1037
|
return proto === Object.prototype;
|
|
1038
1038
|
}
|
|
1039
1039
|
function mergeDeep(target, source, ignoreUndefined = false) {
|
|
1040
|
-
if (!isObject$
|
|
1040
|
+
if (!isObject$a(target)) {
|
|
1041
1041
|
return target;
|
|
1042
1042
|
}
|
|
1043
1043
|
const output = {
|
|
1044
1044
|
...target
|
|
1045
1045
|
};
|
|
1046
|
-
if (!isObject$
|
|
1046
|
+
if (!isObject$a(source)) {
|
|
1047
1047
|
return output;
|
|
1048
1048
|
}
|
|
1049
1049
|
for (const key in source) {
|
|
@@ -1084,7 +1084,7 @@ function mergeDeep(target, source, ignoreUndefined = false) {
|
|
|
1084
1084
|
} else {
|
|
1085
1085
|
output[key] = sourceValue;
|
|
1086
1086
|
}
|
|
1087
|
-
} else if (isObject$
|
|
1087
|
+
} else if (isObject$a(sourceValue)) {
|
|
1088
1088
|
output[key] = sourceValue;
|
|
1089
1089
|
} else {
|
|
1090
1090
|
output[key] = sourceValue;
|
|
@@ -1721,8 +1721,8 @@ var logic = { exports: {} };
|
|
|
1721
1721
|
return jsonLogic;
|
|
1722
1722
|
});
|
|
1723
1723
|
})(logic);
|
|
1724
|
-
|
|
1725
|
-
|
|
1724
|
+
const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
1725
|
+
const { hasOwnProperty: hasOwnProperty$d } = Object.prototype;
|
|
1726
1726
|
function combineComparators(comparatorA, comparatorB) {
|
|
1727
1727
|
return function isEqual(a2, b, state) {
|
|
1728
1728
|
return comparatorA(a2, b, state) && comparatorB(a2, b, state);
|
|
@@ -1733,38 +1733,45 @@ function createIsCircular(areItemsEqual) {
|
|
|
1733
1733
|
if (!a2 || !b || typeof a2 !== "object" || typeof b !== "object") {
|
|
1734
1734
|
return areItemsEqual(a2, b, state);
|
|
1735
1735
|
}
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1736
|
+
const { cache } = state;
|
|
1737
|
+
const cachedA = cache.get(a2);
|
|
1738
|
+
const cachedB = cache.get(b);
|
|
1739
1739
|
if (cachedA && cachedB) {
|
|
1740
1740
|
return cachedA === b && cachedB === a2;
|
|
1741
1741
|
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1742
|
+
cache.set(a2, b);
|
|
1743
|
+
cache.set(b, a2);
|
|
1744
|
+
const result = areItemsEqual(a2, b, state);
|
|
1745
|
+
cache.delete(a2);
|
|
1746
|
+
cache.delete(b);
|
|
1747
1747
|
return result;
|
|
1748
1748
|
};
|
|
1749
1749
|
}
|
|
1750
|
-
function getShortTag(value) {
|
|
1751
|
-
return value != null ? value[Symbol.toStringTag] : void 0;
|
|
1752
|
-
}
|
|
1753
1750
|
function getStrictProperties(object) {
|
|
1754
1751
|
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
|
|
1755
1752
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1753
|
+
const hasOwn$1 = (
|
|
1754
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1755
|
+
Object.hasOwn || ((object, property) => hasOwnProperty$d.call(object, property))
|
|
1756
|
+
);
|
|
1757
|
+
const PREACT_VNODE = "__v";
|
|
1758
|
+
const PREACT_OWNER = "__o";
|
|
1759
|
+
const REACT_OWNER = "_owner";
|
|
1760
|
+
const { getOwnPropertyDescriptor, keys: keys$5 } = Object;
|
|
1761
|
+
const sameValueEqual = (
|
|
1762
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1763
|
+
Object.is || function sameValueEqual2(a2, b) {
|
|
1764
|
+
return a2 === b ? a2 !== 0 || 1 / a2 === 1 / b : a2 !== a2 && b !== b;
|
|
1765
|
+
}
|
|
1766
|
+
);
|
|
1767
|
+
function strictEqual(a2, b) {
|
|
1768
|
+
return a2 === b;
|
|
1769
|
+
}
|
|
1770
|
+
function areArrayBuffersEqual(a2, b) {
|
|
1771
|
+
return a2.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a2), new Uint8Array(b));
|
|
1761
1772
|
}
|
|
1762
|
-
var PREACT_VNODE = "__v";
|
|
1763
|
-
var PREACT_OWNER = "__o";
|
|
1764
|
-
var REACT_OWNER = "_owner";
|
|
1765
|
-
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, keys$5 = Object.keys;
|
|
1766
1773
|
function areArraysEqual(a2, b, state) {
|
|
1767
|
-
|
|
1774
|
+
let index = a2.length;
|
|
1768
1775
|
if (b.length !== index) {
|
|
1769
1776
|
return false;
|
|
1770
1777
|
}
|
|
@@ -1775,35 +1782,35 @@ function areArraysEqual(a2, b, state) {
|
|
|
1775
1782
|
}
|
|
1776
1783
|
return true;
|
|
1777
1784
|
}
|
|
1785
|
+
function areDataViewsEqual(a2, b) {
|
|
1786
|
+
return a2.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a2.buffer, a2.byteOffset, a2.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength));
|
|
1787
|
+
}
|
|
1778
1788
|
function areDatesEqual(a2, b) {
|
|
1779
|
-
return
|
|
1789
|
+
return sameValueEqual(a2.getTime(), b.getTime());
|
|
1780
1790
|
}
|
|
1781
1791
|
function areErrorsEqual(a2, b) {
|
|
1782
1792
|
return a2.name === b.name && a2.message === b.message && a2.cause === b.cause && a2.stack === b.stack;
|
|
1783
1793
|
}
|
|
1784
|
-
function areFunctionsEqual(a2, b) {
|
|
1785
|
-
return a2 === b;
|
|
1786
|
-
}
|
|
1787
1794
|
function areMapsEqual(a2, b, state) {
|
|
1788
|
-
|
|
1795
|
+
const size = a2.size;
|
|
1789
1796
|
if (size !== b.size) {
|
|
1790
1797
|
return false;
|
|
1791
1798
|
}
|
|
1792
1799
|
if (!size) {
|
|
1793
1800
|
return true;
|
|
1794
1801
|
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1802
|
+
const matchedIndices = new Array(size);
|
|
1803
|
+
const aIterable = a2.entries();
|
|
1804
|
+
let aResult;
|
|
1805
|
+
let bResult;
|
|
1806
|
+
let index = 0;
|
|
1800
1807
|
while (aResult = aIterable.next()) {
|
|
1801
1808
|
if (aResult.done) {
|
|
1802
1809
|
break;
|
|
1803
1810
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1811
|
+
const bIterable = b.entries();
|
|
1812
|
+
let hasMatch = false;
|
|
1813
|
+
let matchIndex = 0;
|
|
1807
1814
|
while (bResult = bIterable.next()) {
|
|
1808
1815
|
if (bResult.done) {
|
|
1809
1816
|
break;
|
|
@@ -1812,8 +1819,8 @@ function areMapsEqual(a2, b, state) {
|
|
|
1812
1819
|
matchIndex++;
|
|
1813
1820
|
continue;
|
|
1814
1821
|
}
|
|
1815
|
-
|
|
1816
|
-
|
|
1822
|
+
const aEntry = aResult.value;
|
|
1823
|
+
const bEntry = bResult.value;
|
|
1817
1824
|
if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a2, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a2, b, state)) {
|
|
1818
1825
|
hasMatch = matchedIndices[matchIndex] = true;
|
|
1819
1826
|
break;
|
|
@@ -1827,10 +1834,9 @@ function areMapsEqual(a2, b, state) {
|
|
|
1827
1834
|
}
|
|
1828
1835
|
return true;
|
|
1829
1836
|
}
|
|
1830
|
-
var areNumbersEqual = sameValueZeroEqual;
|
|
1831
1837
|
function areObjectsEqual(a2, b, state) {
|
|
1832
|
-
|
|
1833
|
-
|
|
1838
|
+
const properties = keys$5(a2);
|
|
1839
|
+
let index = properties.length;
|
|
1834
1840
|
if (keys$5(b).length !== index) {
|
|
1835
1841
|
return false;
|
|
1836
1842
|
}
|
|
@@ -1842,14 +1848,14 @@ function areObjectsEqual(a2, b, state) {
|
|
|
1842
1848
|
return true;
|
|
1843
1849
|
}
|
|
1844
1850
|
function areObjectsEqualStrict(a2, b, state) {
|
|
1845
|
-
|
|
1846
|
-
|
|
1851
|
+
const properties = getStrictProperties(a2);
|
|
1852
|
+
let index = properties.length;
|
|
1847
1853
|
if (getStrictProperties(b).length !== index) {
|
|
1848
1854
|
return false;
|
|
1849
1855
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1856
|
+
let property;
|
|
1857
|
+
let descriptorA;
|
|
1858
|
+
let descriptorB;
|
|
1853
1859
|
while (index-- > 0) {
|
|
1854
1860
|
property = properties[index];
|
|
1855
1861
|
if (!isPropertyEqual(a2, b, state, property)) {
|
|
@@ -1864,30 +1870,30 @@ function areObjectsEqualStrict(a2, b, state) {
|
|
|
1864
1870
|
return true;
|
|
1865
1871
|
}
|
|
1866
1872
|
function arePrimitiveWrappersEqual(a2, b) {
|
|
1867
|
-
return
|
|
1873
|
+
return sameValueEqual(a2.valueOf(), b.valueOf());
|
|
1868
1874
|
}
|
|
1869
1875
|
function areRegExpsEqual(a2, b) {
|
|
1870
1876
|
return a2.source === b.source && a2.flags === b.flags;
|
|
1871
1877
|
}
|
|
1872
1878
|
function areSetsEqual(a2, b, state) {
|
|
1873
|
-
|
|
1879
|
+
const size = a2.size;
|
|
1874
1880
|
if (size !== b.size) {
|
|
1875
1881
|
return false;
|
|
1876
1882
|
}
|
|
1877
1883
|
if (!size) {
|
|
1878
1884
|
return true;
|
|
1879
1885
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1886
|
+
const matchedIndices = new Array(size);
|
|
1887
|
+
const aIterable = a2.values();
|
|
1888
|
+
let aResult;
|
|
1889
|
+
let bResult;
|
|
1884
1890
|
while (aResult = aIterable.next()) {
|
|
1885
1891
|
if (aResult.done) {
|
|
1886
1892
|
break;
|
|
1887
1893
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1894
|
+
const bIterable = b.values();
|
|
1895
|
+
let hasMatch = false;
|
|
1896
|
+
let matchIndex = 0;
|
|
1891
1897
|
while (bResult = bIterable.next()) {
|
|
1892
1898
|
if (bResult.done) {
|
|
1893
1899
|
break;
|
|
@@ -1905,8 +1911,8 @@ function areSetsEqual(a2, b, state) {
|
|
|
1905
1911
|
return true;
|
|
1906
1912
|
}
|
|
1907
1913
|
function areTypedArraysEqual(a2, b) {
|
|
1908
|
-
|
|
1909
|
-
if (b.
|
|
1914
|
+
let index = a2.byteLength;
|
|
1915
|
+
if (b.byteLength !== index || a2.byteOffset !== b.byteOffset) {
|
|
1910
1916
|
return false;
|
|
1911
1917
|
}
|
|
1912
1918
|
while (index-- > 0) {
|
|
@@ -1925,23 +1931,10 @@ function isPropertyEqual(a2, b, state, property) {
|
|
|
1925
1931
|
}
|
|
1926
1932
|
return hasOwn$1(b, property) && state.equals(a2[property], b[property], property, property, a2, b, state);
|
|
1927
1933
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
var MAP_TAG = "[object Map]";
|
|
1933
|
-
var NUMBER_TAG = "[object Number]";
|
|
1934
|
-
var OBJECT_TAG = "[object Object]";
|
|
1935
|
-
var REG_EXP_TAG = "[object RegExp]";
|
|
1936
|
-
var SET_TAG = "[object Set]";
|
|
1937
|
-
var STRING_TAG = "[object String]";
|
|
1938
|
-
var URL_TAG = "[object URL]";
|
|
1939
|
-
var isArray$7 = Array.isArray;
|
|
1940
|
-
var isTypedArray$2 = typeof ArrayBuffer === "function" && ArrayBuffer.isView ? ArrayBuffer.isView : null;
|
|
1941
|
-
var assign$1 = Object.assign;
|
|
1942
|
-
var getTag$4 = Object.prototype.toString.call.bind(Object.prototype.toString);
|
|
1943
|
-
function createEqualityComparator(_a2) {
|
|
1944
|
-
var areArraysEqual2 = _a2.areArraysEqual, areDatesEqual2 = _a2.areDatesEqual, areErrorsEqual2 = _a2.areErrorsEqual, areFunctionsEqual2 = _a2.areFunctionsEqual, areMapsEqual2 = _a2.areMapsEqual, areNumbersEqual2 = _a2.areNumbersEqual, areObjectsEqual2 = _a2.areObjectsEqual, arePrimitiveWrappersEqual2 = _a2.arePrimitiveWrappersEqual, areRegExpsEqual2 = _a2.areRegExpsEqual, areSetsEqual2 = _a2.areSetsEqual, areTypedArraysEqual2 = _a2.areTypedArraysEqual, areUrlsEqual2 = _a2.areUrlsEqual, unknownTagComparators = _a2.unknownTagComparators;
|
|
1934
|
+
const toString$2 = Object.prototype.toString;
|
|
1935
|
+
function createEqualityComparator(config) {
|
|
1936
|
+
const supportedComparatorMap = createSupportedComparatorMap(config);
|
|
1937
|
+
const { areArraysEqual: areArraysEqual2, areDatesEqual: areDatesEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, getUnsupportedCustomComparator } = config;
|
|
1945
1938
|
return function comparator2(a2, b, state) {
|
|
1946
1939
|
if (a2 === b) {
|
|
1947
1940
|
return true;
|
|
@@ -1949,32 +1942,29 @@ function createEqualityComparator(_a2) {
|
|
|
1949
1942
|
if (a2 == null || b == null) {
|
|
1950
1943
|
return false;
|
|
1951
1944
|
}
|
|
1952
|
-
|
|
1945
|
+
const type = typeof a2;
|
|
1953
1946
|
if (type !== typeof b) {
|
|
1954
1947
|
return false;
|
|
1955
1948
|
}
|
|
1956
1949
|
if (type !== "object") {
|
|
1957
|
-
if (type === "number") {
|
|
1958
|
-
return
|
|
1950
|
+
if (type === "number" || type === "bigint") {
|
|
1951
|
+
return areNumbersEqual(a2, b, state);
|
|
1959
1952
|
}
|
|
1960
1953
|
if (type === "function") {
|
|
1961
|
-
return
|
|
1954
|
+
return areFunctionsEqual(a2, b, state);
|
|
1962
1955
|
}
|
|
1963
1956
|
return false;
|
|
1964
1957
|
}
|
|
1965
|
-
|
|
1958
|
+
const constructor = a2.constructor;
|
|
1966
1959
|
if (constructor !== b.constructor) {
|
|
1967
1960
|
return false;
|
|
1968
1961
|
}
|
|
1969
1962
|
if (constructor === Object) {
|
|
1970
1963
|
return areObjectsEqual2(a2, b, state);
|
|
1971
1964
|
}
|
|
1972
|
-
if (
|
|
1965
|
+
if (constructor === Array) {
|
|
1973
1966
|
return areArraysEqual2(a2, b, state);
|
|
1974
1967
|
}
|
|
1975
|
-
if (isTypedArray$2 != null && isTypedArray$2(a2)) {
|
|
1976
|
-
return areTypedArraysEqual2(a2, b, state);
|
|
1977
|
-
}
|
|
1978
1968
|
if (constructor === Date) {
|
|
1979
1969
|
return areDatesEqual2(a2, b, state);
|
|
1980
1970
|
}
|
|
@@ -1987,79 +1977,55 @@ function createEqualityComparator(_a2) {
|
|
|
1987
1977
|
if (constructor === Set) {
|
|
1988
1978
|
return areSetsEqual2(a2, b, state);
|
|
1989
1979
|
}
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
return areDatesEqual2(a2, b, state);
|
|
1993
|
-
}
|
|
1994
|
-
if (tag2 === REG_EXP_TAG) {
|
|
1995
|
-
return areRegExpsEqual2(a2, b, state);
|
|
1996
|
-
}
|
|
1997
|
-
if (tag2 === MAP_TAG) {
|
|
1998
|
-
return areMapsEqual2(a2, b, state);
|
|
1999
|
-
}
|
|
2000
|
-
if (tag2 === SET_TAG) {
|
|
2001
|
-
return areSetsEqual2(a2, b, state);
|
|
2002
|
-
}
|
|
2003
|
-
if (tag2 === OBJECT_TAG) {
|
|
2004
|
-
return typeof a2.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a2, b, state);
|
|
2005
|
-
}
|
|
2006
|
-
if (tag2 === URL_TAG) {
|
|
2007
|
-
return areUrlsEqual2(a2, b, state);
|
|
2008
|
-
}
|
|
2009
|
-
if (tag2 === ERROR_TAG) {
|
|
2010
|
-
return areErrorsEqual2(a2, b, state);
|
|
1980
|
+
if (constructor === Promise) {
|
|
1981
|
+
return false;
|
|
2011
1982
|
}
|
|
2012
|
-
if (
|
|
2013
|
-
return
|
|
1983
|
+
if (Array.isArray(a2)) {
|
|
1984
|
+
return areArraysEqual2(a2, b, state);
|
|
2014
1985
|
}
|
|
2015
|
-
|
|
2016
|
-
|
|
1986
|
+
const tag = toString$2.call(a2);
|
|
1987
|
+
const supportedComparator = supportedComparatorMap[tag];
|
|
1988
|
+
if (supportedComparator) {
|
|
1989
|
+
return supportedComparator(a2, b, state);
|
|
2017
1990
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
var shortTag = getShortTag(a2);
|
|
2022
|
-
if (shortTag) {
|
|
2023
|
-
unknownTagComparator = unknownTagComparators[shortTag];
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
if (unknownTagComparator) {
|
|
2027
|
-
return unknownTagComparator(a2, b, state);
|
|
2028
|
-
}
|
|
1991
|
+
const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a2, b, state, tag);
|
|
1992
|
+
if (unsupportedCustomComparator) {
|
|
1993
|
+
return unsupportedCustomComparator(a2, b, state);
|
|
2029
1994
|
}
|
|
2030
1995
|
return false;
|
|
2031
1996
|
};
|
|
2032
1997
|
}
|
|
2033
|
-
function createEqualityComparatorConfig(
|
|
2034
|
-
|
|
2035
|
-
|
|
1998
|
+
function createEqualityComparatorConfig({ circular, createCustomConfig, strict }) {
|
|
1999
|
+
let config = {
|
|
2000
|
+
areArrayBuffersEqual,
|
|
2036
2001
|
areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
|
|
2002
|
+
areDataViewsEqual,
|
|
2037
2003
|
areDatesEqual,
|
|
2038
2004
|
areErrorsEqual,
|
|
2039
|
-
areFunctionsEqual,
|
|
2005
|
+
areFunctionsEqual: strictEqual,
|
|
2040
2006
|
areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
|
|
2041
|
-
areNumbersEqual,
|
|
2007
|
+
areNumbersEqual: sameValueEqual,
|
|
2042
2008
|
areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
|
|
2043
2009
|
arePrimitiveWrappersEqual,
|
|
2044
2010
|
areRegExpsEqual,
|
|
2045
2011
|
areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
|
|
2046
|
-
areTypedArraysEqual: strict ? areObjectsEqualStrict : areTypedArraysEqual,
|
|
2012
|
+
areTypedArraysEqual: strict ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict) : areTypedArraysEqual,
|
|
2047
2013
|
areUrlsEqual,
|
|
2048
|
-
|
|
2014
|
+
getUnsupportedCustomComparator: void 0
|
|
2049
2015
|
};
|
|
2050
2016
|
if (createCustomConfig) {
|
|
2051
|
-
config = assign
|
|
2017
|
+
config = Object.assign({}, config, createCustomConfig(config));
|
|
2052
2018
|
}
|
|
2053
2019
|
if (circular) {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
config = assign
|
|
2059
|
-
areArraysEqual:
|
|
2060
|
-
areMapsEqual:
|
|
2061
|
-
areObjectsEqual:
|
|
2062
|
-
areSetsEqual:
|
|
2020
|
+
const areArraysEqual2 = createIsCircular(config.areArraysEqual);
|
|
2021
|
+
const areMapsEqual2 = createIsCircular(config.areMapsEqual);
|
|
2022
|
+
const areObjectsEqual2 = createIsCircular(config.areObjectsEqual);
|
|
2023
|
+
const areSetsEqual2 = createIsCircular(config.areSetsEqual);
|
|
2024
|
+
config = Object.assign({}, config, {
|
|
2025
|
+
areArraysEqual: areArraysEqual2,
|
|
2026
|
+
areMapsEqual: areMapsEqual2,
|
|
2027
|
+
areObjectsEqual: areObjectsEqual2,
|
|
2028
|
+
areSetsEqual: areSetsEqual2
|
|
2063
2029
|
});
|
|
2064
2030
|
}
|
|
2065
2031
|
return config;
|
|
@@ -2069,13 +2035,12 @@ function createInternalEqualityComparator(compare2) {
|
|
|
2069
2035
|
return compare2(a2, b, state);
|
|
2070
2036
|
};
|
|
2071
2037
|
}
|
|
2072
|
-
function createIsEqual(
|
|
2073
|
-
var circular = _a2.circular, comparator2 = _a2.comparator, createState = _a2.createState, equals = _a2.equals, strict = _a2.strict;
|
|
2038
|
+
function createIsEqual({ circular, comparator: comparator2, createState, equals, strict }) {
|
|
2074
2039
|
if (createState) {
|
|
2075
2040
|
return function isEqual(a2, b) {
|
|
2076
|
-
|
|
2041
|
+
const { cache = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
|
|
2077
2042
|
return comparator2(a2, b, {
|
|
2078
|
-
cache
|
|
2043
|
+
cache,
|
|
2079
2044
|
equals,
|
|
2080
2045
|
meta,
|
|
2081
2046
|
strict
|
|
@@ -2092,7 +2057,7 @@ function createIsEqual(_a2) {
|
|
|
2092
2057
|
});
|
|
2093
2058
|
};
|
|
2094
2059
|
}
|
|
2095
|
-
|
|
2060
|
+
const state = {
|
|
2096
2061
|
cache: void 0,
|
|
2097
2062
|
equals,
|
|
2098
2063
|
meta: void 0,
|
|
@@ -2102,7 +2067,50 @@ function createIsEqual(_a2) {
|
|
|
2102
2067
|
return comparator2(a2, b, state);
|
|
2103
2068
|
};
|
|
2104
2069
|
}
|
|
2105
|
-
|
|
2070
|
+
function createSupportedComparatorMap({ areArrayBuffersEqual: areArrayBuffersEqual2, areArraysEqual: areArraysEqual2, areDataViewsEqual: areDataViewsEqual2, areDatesEqual: areDatesEqual2, areErrorsEqual: areErrorsEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, arePrimitiveWrappersEqual: arePrimitiveWrappersEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, areTypedArraysEqual: areTypedArraysEqual2, areUrlsEqual: areUrlsEqual2 }) {
|
|
2071
|
+
return {
|
|
2072
|
+
"[object Arguments]": areObjectsEqual2,
|
|
2073
|
+
"[object Array]": areArraysEqual2,
|
|
2074
|
+
"[object ArrayBuffer]": areArrayBuffersEqual2,
|
|
2075
|
+
"[object AsyncGeneratorFunction]": areFunctionsEqual,
|
|
2076
|
+
"[object BigInt]": areNumbersEqual,
|
|
2077
|
+
"[object BigInt64Array]": areTypedArraysEqual2,
|
|
2078
|
+
"[object BigUint64Array]": areTypedArraysEqual2,
|
|
2079
|
+
"[object Boolean]": arePrimitiveWrappersEqual2,
|
|
2080
|
+
"[object DataView]": areDataViewsEqual2,
|
|
2081
|
+
"[object Date]": areDatesEqual2,
|
|
2082
|
+
// If an error tag, it should be tested explicitly. Like RegExp, the properties are not
|
|
2083
|
+
// enumerable, and therefore will give false positives if tested like a standard object.
|
|
2084
|
+
"[object Error]": areErrorsEqual2,
|
|
2085
|
+
"[object Float16Array]": areTypedArraysEqual2,
|
|
2086
|
+
"[object Float32Array]": areTypedArraysEqual2,
|
|
2087
|
+
"[object Float64Array]": areTypedArraysEqual2,
|
|
2088
|
+
"[object Function]": areFunctionsEqual,
|
|
2089
|
+
"[object GeneratorFunction]": areFunctionsEqual,
|
|
2090
|
+
"[object Int8Array]": areTypedArraysEqual2,
|
|
2091
|
+
"[object Int16Array]": areTypedArraysEqual2,
|
|
2092
|
+
"[object Int32Array]": areTypedArraysEqual2,
|
|
2093
|
+
"[object Map]": areMapsEqual2,
|
|
2094
|
+
"[object Number]": arePrimitiveWrappersEqual2,
|
|
2095
|
+
"[object Object]": (a2, b, state) => (
|
|
2096
|
+
// The exception for value comparison is custom `Promise`-like class instances. These should
|
|
2097
|
+
// be treated the same as standard `Promise` objects, which means strict equality, and if
|
|
2098
|
+
// it reaches this point then that strict equality comparison has already failed.
|
|
2099
|
+
typeof a2.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a2, b, state)
|
|
2100
|
+
),
|
|
2101
|
+
// For RegExp, the properties are not enumerable, and therefore will give false positives if
|
|
2102
|
+
// tested like a standard object.
|
|
2103
|
+
"[object RegExp]": areRegExpsEqual2,
|
|
2104
|
+
"[object Set]": areSetsEqual2,
|
|
2105
|
+
"[object String]": arePrimitiveWrappersEqual2,
|
|
2106
|
+
"[object URL]": areUrlsEqual2,
|
|
2107
|
+
"[object Uint8Array]": areTypedArraysEqual2,
|
|
2108
|
+
"[object Uint8ClampedArray]": areTypedArraysEqual2,
|
|
2109
|
+
"[object Uint16Array]": areTypedArraysEqual2,
|
|
2110
|
+
"[object Uint32Array]": areTypedArraysEqual2
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
const deepEqual = createCustomEqual();
|
|
2106
2114
|
createCustomEqual({ strict: true });
|
|
2107
2115
|
createCustomEqual({ circular: true });
|
|
2108
2116
|
createCustomEqual({
|
|
@@ -2110,37 +2118,26 @@ createCustomEqual({
|
|
|
2110
2118
|
strict: true
|
|
2111
2119
|
});
|
|
2112
2120
|
createCustomEqual({
|
|
2113
|
-
createInternalComparator:
|
|
2114
|
-
return sameValueZeroEqual;
|
|
2115
|
-
}
|
|
2121
|
+
createInternalComparator: () => sameValueEqual
|
|
2116
2122
|
});
|
|
2117
2123
|
createCustomEqual({
|
|
2118
2124
|
strict: true,
|
|
2119
|
-
createInternalComparator:
|
|
2120
|
-
return sameValueZeroEqual;
|
|
2121
|
-
}
|
|
2125
|
+
createInternalComparator: () => sameValueEqual
|
|
2122
2126
|
});
|
|
2123
2127
|
createCustomEqual({
|
|
2124
2128
|
circular: true,
|
|
2125
|
-
createInternalComparator:
|
|
2126
|
-
return sameValueZeroEqual;
|
|
2127
|
-
}
|
|
2129
|
+
createInternalComparator: () => sameValueEqual
|
|
2128
2130
|
});
|
|
2129
2131
|
createCustomEqual({
|
|
2130
2132
|
circular: true,
|
|
2131
|
-
createInternalComparator:
|
|
2132
|
-
return sameValueZeroEqual;
|
|
2133
|
-
},
|
|
2133
|
+
createInternalComparator: () => sameValueEqual,
|
|
2134
2134
|
strict: true
|
|
2135
2135
|
});
|
|
2136
|
-
function createCustomEqual(options2) {
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
var config = createEqualityComparatorConfig(options2);
|
|
2142
|
-
var comparator2 = createEqualityComparator(config);
|
|
2143
|
-
var equals = createCustomInternalComparator ? createCustomInternalComparator(comparator2) : createInternalEqualityComparator(comparator2);
|
|
2136
|
+
function createCustomEqual(options2 = {}) {
|
|
2137
|
+
const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false } = options2;
|
|
2138
|
+
const config = createEqualityComparatorConfig(options2);
|
|
2139
|
+
const comparator2 = createEqualityComparator(config);
|
|
2140
|
+
const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator2) : createInternalEqualityComparator(comparator2);
|
|
2144
2141
|
return createIsEqual({ circular, comparator: comparator2, createState, equals, strict });
|
|
2145
2142
|
}
|
|
2146
2143
|
function listCacheClear$1() {
|
|
@@ -2254,7 +2251,7 @@ var hasOwnProperty$c = objectProto$j.hasOwnProperty;
|
|
|
2254
2251
|
var nativeObjectToString$1 = objectProto$j.toString;
|
|
2255
2252
|
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
2256
2253
|
function getRawTag$1(value) {
|
|
2257
|
-
var isOwn = hasOwnProperty$c.call(value, symToStringTag$1),
|
|
2254
|
+
var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
2258
2255
|
try {
|
|
2259
2256
|
value[symToStringTag$1] = void 0;
|
|
2260
2257
|
var unmasked = true;
|
|
@@ -2263,7 +2260,7 @@ function getRawTag$1(value) {
|
|
|
2263
2260
|
var result = nativeObjectToString$1.call(value);
|
|
2264
2261
|
if (unmasked) {
|
|
2265
2262
|
if (isOwn) {
|
|
2266
|
-
value[symToStringTag$1] =
|
|
2263
|
+
value[symToStringTag$1] = tag;
|
|
2267
2264
|
} else {
|
|
2268
2265
|
delete value[symToStringTag$1];
|
|
2269
2266
|
}
|
|
@@ -2287,19 +2284,19 @@ function baseGetTag$4(value) {
|
|
|
2287
2284
|
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString$7(value);
|
|
2288
2285
|
}
|
|
2289
2286
|
var _baseGetTag = baseGetTag$4;
|
|
2290
|
-
function isObject$
|
|
2287
|
+
function isObject$9(value) {
|
|
2291
2288
|
var type = typeof value;
|
|
2292
2289
|
return value != null && (type == "object" || type == "function");
|
|
2293
2290
|
}
|
|
2294
|
-
var isObject_1 = isObject$
|
|
2295
|
-
var baseGetTag$3 = _baseGetTag, isObject$
|
|
2291
|
+
var isObject_1 = isObject$9;
|
|
2292
|
+
var baseGetTag$3 = _baseGetTag, isObject$8 = isObject_1;
|
|
2296
2293
|
var asyncTag = "[object AsyncFunction]", funcTag$3 = "[object Function]", genTag$2 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
2297
2294
|
function isFunction$3(value) {
|
|
2298
|
-
if (!isObject$
|
|
2295
|
+
if (!isObject$8(value)) {
|
|
2299
2296
|
return false;
|
|
2300
2297
|
}
|
|
2301
|
-
var
|
|
2302
|
-
return
|
|
2298
|
+
var tag = baseGetTag$3(value);
|
|
2299
|
+
return tag == funcTag$3 || tag == genTag$2 || tag == asyncTag || tag == proxyTag;
|
|
2303
2300
|
}
|
|
2304
2301
|
var isFunction_1 = isFunction$3;
|
|
2305
2302
|
var root$6 = _root;
|
|
@@ -2330,7 +2327,7 @@ function toSource$2(func) {
|
|
|
2330
2327
|
return "";
|
|
2331
2328
|
}
|
|
2332
2329
|
var _toSource = toSource$2;
|
|
2333
|
-
var isFunction$2 = isFunction_1, isMasked = _isMasked, isObject$
|
|
2330
|
+
var isFunction$2 = isFunction_1, isMasked = _isMasked, isObject$7 = isObject_1, toSource$1 = _toSource;
|
|
2334
2331
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
2335
2332
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
2336
2333
|
var funcProto$1 = Function.prototype, objectProto$h = Object.prototype;
|
|
@@ -2340,7 +2337,7 @@ var reIsNative = RegExp(
|
|
|
2340
2337
|
"^" + funcToString$1.call(hasOwnProperty$b).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
2341
2338
|
);
|
|
2342
2339
|
function baseIsNative$1(value) {
|
|
2343
|
-
if (!isObject$
|
|
2340
|
+
if (!isObject$7(value) || isMasked(value)) {
|
|
2344
2341
|
return false;
|
|
2345
2342
|
}
|
|
2346
2343
|
var pattern = isFunction$2(value) ? reIsNative : reIsHostCtor;
|
|
@@ -2582,24 +2579,24 @@ function baseTimes$2(n, iteratee) {
|
|
|
2582
2579
|
return result;
|
|
2583
2580
|
}
|
|
2584
2581
|
var _baseTimes = baseTimes$2;
|
|
2585
|
-
function isObjectLike$
|
|
2582
|
+
function isObjectLike$d(value) {
|
|
2586
2583
|
return value != null && typeof value == "object";
|
|
2587
2584
|
}
|
|
2588
|
-
var isObjectLike_1 = isObjectLike$
|
|
2589
|
-
var baseGetTag$2 = _baseGetTag, isObjectLike$
|
|
2585
|
+
var isObjectLike_1 = isObjectLike$d;
|
|
2586
|
+
var baseGetTag$2 = _baseGetTag, isObjectLike$c = isObjectLike_1;
|
|
2590
2587
|
var argsTag$3 = "[object Arguments]";
|
|
2591
2588
|
function baseIsArguments$1(value) {
|
|
2592
|
-
return isObjectLike$
|
|
2589
|
+
return isObjectLike$c(value) && baseGetTag$2(value) == argsTag$3;
|
|
2593
2590
|
}
|
|
2594
2591
|
var _baseIsArguments = baseIsArguments$1;
|
|
2595
|
-
var baseIsArguments = _baseIsArguments, isObjectLike$
|
|
2592
|
+
var baseIsArguments = _baseIsArguments, isObjectLike$b = isObjectLike_1;
|
|
2596
2593
|
var objectProto$d = Object.prototype;
|
|
2597
2594
|
var hasOwnProperty$7 = objectProto$d.hasOwnProperty;
|
|
2598
2595
|
var propertyIsEnumerable$2 = objectProto$d.propertyIsEnumerable;
|
|
2599
2596
|
var isArguments$2 = baseIsArguments(/* @__PURE__ */ function() {
|
|
2600
2597
|
return arguments;
|
|
2601
2598
|
}()) ? baseIsArguments : function(value) {
|
|
2602
|
-
return isObjectLike$
|
|
2599
|
+
return isObjectLike$b(value) && hasOwnProperty$7.call(value, "callee") && !propertyIsEnumerable$2.call(value, "callee");
|
|
2603
2600
|
};
|
|
2604
2601
|
var isArguments_1 = isArguments$2;
|
|
2605
2602
|
var isArray$6 = Array.isArray;
|
|
@@ -2634,14 +2631,14 @@ function isLength$3(value) {
|
|
|
2634
2631
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$3;
|
|
2635
2632
|
}
|
|
2636
2633
|
var isLength_1 = isLength$3;
|
|
2637
|
-
var baseGetTag$1 = _baseGetTag, isLength$2 = isLength_1, isObjectLike$
|
|
2634
|
+
var baseGetTag$1 = _baseGetTag, isLength$2 = isLength_1, isObjectLike$a = isObjectLike_1;
|
|
2638
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]";
|
|
2639
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]";
|
|
2640
2637
|
var typedArrayTags = {};
|
|
2641
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;
|
|
2642
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;
|
|
2643
2640
|
function baseIsTypedArray$1(value) {
|
|
2644
|
-
return isObjectLike$
|
|
2641
|
+
return isObjectLike$a(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$1(value)];
|
|
2645
2642
|
}
|
|
2646
2643
|
var _baseIsTypedArray = baseIsTypedArray$1;
|
|
2647
2644
|
function baseUnary$3(func) {
|
|
@@ -2748,11 +2745,11 @@ function nativeKeysIn$1(object) {
|
|
|
2748
2745
|
return result;
|
|
2749
2746
|
}
|
|
2750
2747
|
var _nativeKeysIn = nativeKeysIn$1;
|
|
2751
|
-
var isObject$
|
|
2748
|
+
var isObject$6 = isObject_1, isPrototype$2 = _isPrototype, nativeKeysIn = _nativeKeysIn;
|
|
2752
2749
|
var objectProto$9 = Object.prototype;
|
|
2753
2750
|
var hasOwnProperty$4 = objectProto$9.hasOwnProperty;
|
|
2754
2751
|
function baseKeysIn$1(object) {
|
|
2755
|
-
if (!isObject$
|
|
2752
|
+
if (!isObject$6(object)) {
|
|
2756
2753
|
return nativeKeysIn(object);
|
|
2757
2754
|
}
|
|
2758
2755
|
var isProto = isPrototype$2(object), result = [];
|
|
@@ -2966,9 +2963,9 @@ var _cloneTypedArray = cloneTypedArray$1;
|
|
|
2966
2963
|
var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
|
|
2967
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]";
|
|
2968
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]";
|
|
2969
|
-
function initCloneByTag$1(object,
|
|
2966
|
+
function initCloneByTag$1(object, tag, isDeep) {
|
|
2970
2967
|
var Ctor = object.constructor;
|
|
2971
|
-
switch (
|
|
2968
|
+
switch (tag) {
|
|
2972
2969
|
case arrayBufferTag$1:
|
|
2973
2970
|
return cloneArrayBuffer(object);
|
|
2974
2971
|
case boolTag$2:
|
|
@@ -3000,13 +2997,13 @@ function initCloneByTag$1(object, tag2, isDeep) {
|
|
|
3000
2997
|
}
|
|
3001
2998
|
}
|
|
3002
2999
|
var _initCloneByTag = initCloneByTag$1;
|
|
3003
|
-
var isObject$
|
|
3000
|
+
var isObject$5 = isObject_1;
|
|
3004
3001
|
var objectCreate = Object.create;
|
|
3005
3002
|
var baseCreate$1 = /* @__PURE__ */ function() {
|
|
3006
3003
|
function object() {
|
|
3007
3004
|
}
|
|
3008
3005
|
return function(proto) {
|
|
3009
|
-
if (!isObject$
|
|
3006
|
+
if (!isObject$5(proto)) {
|
|
3010
3007
|
return {};
|
|
3011
3008
|
}
|
|
3012
3009
|
if (objectCreate) {
|
|
@@ -3024,27 +3021,27 @@ function initCloneObject$1(object) {
|
|
|
3024
3021
|
return typeof object.constructor == "function" && !isPrototype$1(object) ? baseCreate(getPrototype$1(object)) : {};
|
|
3025
3022
|
}
|
|
3026
3023
|
var _initCloneObject = initCloneObject$1;
|
|
3027
|
-
var getTag$2 = _getTag, isObjectLike$
|
|
3024
|
+
var getTag$2 = _getTag, isObjectLike$9 = isObjectLike_1;
|
|
3028
3025
|
var mapTag$1 = "[object Map]";
|
|
3029
3026
|
function baseIsMap$1(value) {
|
|
3030
|
-
return isObjectLike$
|
|
3027
|
+
return isObjectLike$9(value) && getTag$2(value) == mapTag$1;
|
|
3031
3028
|
}
|
|
3032
3029
|
var _baseIsMap = baseIsMap$1;
|
|
3033
3030
|
var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtilExports;
|
|
3034
3031
|
var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
|
|
3035
3032
|
var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
|
|
3036
3033
|
var isMap_1 = isMap$1;
|
|
3037
|
-
var getTag$1 = _getTag, isObjectLike$
|
|
3034
|
+
var getTag$1 = _getTag, isObjectLike$8 = isObjectLike_1;
|
|
3038
3035
|
var setTag$1 = "[object Set]";
|
|
3039
3036
|
function baseIsSet$1(value) {
|
|
3040
|
-
return isObjectLike$
|
|
3037
|
+
return isObjectLike$8(value) && getTag$1(value) == setTag$1;
|
|
3041
3038
|
}
|
|
3042
3039
|
var _baseIsSet = baseIsSet$1;
|
|
3043
3040
|
var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
|
|
3044
3041
|
var nodeIsSet = nodeUtil && nodeUtil.isSet;
|
|
3045
3042
|
var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
|
|
3046
3043
|
var isSet_1 = isSet$1;
|
|
3047
|
-
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$
|
|
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$4 = isObject_1, isSet = isSet_1, keys$1 = keys_1, keysIn = keysIn_1;
|
|
3048
3045
|
var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
|
|
3049
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]";
|
|
3050
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]";
|
|
@@ -3059,7 +3056,7 @@ function baseClone$1(value, bitmask, customizer, key, object, stack) {
|
|
|
3059
3056
|
if (result !== void 0) {
|
|
3060
3057
|
return result;
|
|
3061
3058
|
}
|
|
3062
|
-
if (!isObject$
|
|
3059
|
+
if (!isObject$4(value)) {
|
|
3063
3060
|
return value;
|
|
3064
3061
|
}
|
|
3065
3062
|
var isArr = isArray$3(value);
|
|
@@ -3069,20 +3066,20 @@ function baseClone$1(value, bitmask, customizer, key, object, stack) {
|
|
|
3069
3066
|
return copyArray(value, result);
|
|
3070
3067
|
}
|
|
3071
3068
|
} else {
|
|
3072
|
-
var
|
|
3069
|
+
var tag = getTag(value), isFunc = tag == funcTag$1 || tag == genTag$1;
|
|
3073
3070
|
if (isBuffer(value)) {
|
|
3074
3071
|
return cloneBuffer(value, isDeep);
|
|
3075
3072
|
}
|
|
3076
|
-
if (
|
|
3073
|
+
if (tag == objectTag$1 || tag == argsTag$1 || isFunc && !object) {
|
|
3077
3074
|
result = isFlat || isFunc ? {} : initCloneObject(value);
|
|
3078
3075
|
if (!isDeep) {
|
|
3079
3076
|
return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
|
|
3080
3077
|
}
|
|
3081
3078
|
} else {
|
|
3082
|
-
if (!cloneableTags[
|
|
3079
|
+
if (!cloneableTags[tag]) {
|
|
3083
3080
|
return object ? value : {};
|
|
3084
3081
|
}
|
|
3085
|
-
result = initCloneByTag(value,
|
|
3082
|
+
result = initCloneByTag(value, tag, isDeep);
|
|
3086
3083
|
}
|
|
3087
3084
|
}
|
|
3088
3085
|
stack || (stack = new Stack());
|
|
@@ -3390,7 +3387,10 @@ class CollectionRegistry {
|
|
|
3390
3387
|
if (!relation) {
|
|
3391
3388
|
throw new Error(`Relation '${relationKey}' not found in collection '${currentCollection.slug}'`);
|
|
3392
3389
|
}
|
|
3393
|
-
|
|
3390
|
+
const target = relation.target();
|
|
3391
|
+
const targetRelationKey = relation.relationName || target.slug;
|
|
3392
|
+
const targetSlug = relation.overrides?.slug ?? targetRelationKey;
|
|
3393
|
+
currentCollection = this.get(targetSlug) || this.normalizeCollection(target);
|
|
3394
3394
|
if (i + 1 < pathSegments.length) ;
|
|
3395
3395
|
}
|
|
3396
3396
|
return currentCollection;
|
|
@@ -3439,7 +3439,7 @@ class CollectionRegistry {
|
|
|
3439
3439
|
if (!subcollection) {
|
|
3440
3440
|
throw new Error(`Subcollection '${subcollectionSlug}' not found in ${currentCollection.slug}`);
|
|
3441
3441
|
}
|
|
3442
|
-
currentCollection = subcollection;
|
|
3442
|
+
currentCollection = this.get(subcollection.slug) || this.normalizeCollection(subcollection);
|
|
3443
3443
|
collections.push(currentCollection);
|
|
3444
3444
|
}
|
|
3445
3445
|
}
|
|
@@ -3482,8 +3482,8 @@ async function loadCollectionsFromDirectory(directory) {
|
|
|
3482
3482
|
console.warn(`[loadCollectionsFromDirectory] File ${file} does not have a default export. Skipping.`);
|
|
3483
3483
|
}
|
|
3484
3484
|
} catch (err) {
|
|
3485
|
-
const
|
|
3486
|
-
console.error(`[loadCollectionsFromDirectory] Failed to load collection from ${file}: ${
|
|
3485
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3486
|
+
console.error(`[loadCollectionsFromDirectory] Failed to load collection from ${file}: ${message}`);
|
|
3487
3487
|
}
|
|
3488
3488
|
}
|
|
3489
3489
|
}
|
|
@@ -3566,34 +3566,34 @@ class ApiError extends Error {
|
|
|
3566
3566
|
statusCode;
|
|
3567
3567
|
code;
|
|
3568
3568
|
details;
|
|
3569
|
-
constructor(statusCode, code2,
|
|
3570
|
-
super(
|
|
3569
|
+
constructor(statusCode, code2, message, details) {
|
|
3570
|
+
super(message);
|
|
3571
3571
|
this.name = "ApiError";
|
|
3572
3572
|
this.statusCode = statusCode;
|
|
3573
3573
|
this.code = code2;
|
|
3574
3574
|
this.details = details;
|
|
3575
3575
|
}
|
|
3576
3576
|
// ── Factory methods ──────────────────────────────────────────────
|
|
3577
|
-
static badRequest(
|
|
3578
|
-
return new ApiError(400, code2,
|
|
3577
|
+
static badRequest(message, code2 = "BAD_REQUEST", details) {
|
|
3578
|
+
return new ApiError(400, code2, message, details);
|
|
3579
3579
|
}
|
|
3580
|
-
static unauthorized(
|
|
3581
|
-
return new ApiError(401, code2,
|
|
3580
|
+
static unauthorized(message, code2 = "UNAUTHORIZED") {
|
|
3581
|
+
return new ApiError(401, code2, message);
|
|
3582
3582
|
}
|
|
3583
|
-
static forbidden(
|
|
3584
|
-
return new ApiError(403, code2,
|
|
3583
|
+
static forbidden(message, code2 = "FORBIDDEN") {
|
|
3584
|
+
return new ApiError(403, code2, message);
|
|
3585
3585
|
}
|
|
3586
|
-
static notFound(
|
|
3587
|
-
return new ApiError(404, code2,
|
|
3586
|
+
static notFound(message, code2 = "NOT_FOUND") {
|
|
3587
|
+
return new ApiError(404, code2, message);
|
|
3588
3588
|
}
|
|
3589
|
-
static conflict(
|
|
3590
|
-
return new ApiError(409, code2,
|
|
3589
|
+
static conflict(message, code2 = "CONFLICT") {
|
|
3590
|
+
return new ApiError(409, code2, message);
|
|
3591
3591
|
}
|
|
3592
|
-
static internal(
|
|
3593
|
-
return new ApiError(500, code2,
|
|
3592
|
+
static internal(message, code2 = "INTERNAL_ERROR") {
|
|
3593
|
+
return new ApiError(500, code2, message);
|
|
3594
3594
|
}
|
|
3595
|
-
static serviceUnavailable(
|
|
3596
|
-
return new ApiError(503, code2,
|
|
3595
|
+
static serviceUnavailable(message, code2 = "SERVICE_UNAVAILABLE") {
|
|
3596
|
+
return new ApiError(503, code2, message);
|
|
3597
3597
|
}
|
|
3598
3598
|
}
|
|
3599
3599
|
const errorHandler = (err, c) => {
|
|
@@ -3721,8 +3721,8 @@ function parseQueryOptions(query) {
|
|
|
3721
3721
|
}
|
|
3722
3722
|
Object.assign(options2.where, parsedWhere);
|
|
3723
3723
|
} catch (e) {
|
|
3724
|
-
const
|
|
3725
|
-
const err = new Error(`Invalid 'where' filter: ${
|
|
3724
|
+
const message = e instanceof Error ? e.message : "malformed JSON";
|
|
3725
|
+
const err = new Error(`Invalid 'where' filter: ${message}`);
|
|
3726
3726
|
err.code = "BAD_REQUEST";
|
|
3727
3727
|
err.statusCode = 400;
|
|
3728
3728
|
throw err;
|
|
@@ -3806,11 +3806,24 @@ class RestApiGenerator {
|
|
|
3806
3806
|
collections;
|
|
3807
3807
|
router;
|
|
3808
3808
|
driver;
|
|
3809
|
-
|
|
3809
|
+
dataHooks;
|
|
3810
|
+
constructor(collections, driver, dataHooks) {
|
|
3810
3811
|
this.collections = collections;
|
|
3811
3812
|
this.driver = driver;
|
|
3813
|
+
this.dataHooks = dataHooks;
|
|
3812
3814
|
this.router = new Hono();
|
|
3813
3815
|
}
|
|
3816
|
+
/** Build a BackendHookContext from a Hono context */
|
|
3817
|
+
buildHookContext(c, method) {
|
|
3818
|
+
const user = c.get("user");
|
|
3819
|
+
return {
|
|
3820
|
+
requestUser: user ? {
|
|
3821
|
+
userId: user.userId,
|
|
3822
|
+
roles: user.roles ?? []
|
|
3823
|
+
} : void 0,
|
|
3824
|
+
method
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3814
3827
|
/**
|
|
3815
3828
|
* Generate REST routes using existing DataDriver
|
|
3816
3829
|
*/
|
|
@@ -3822,16 +3835,10 @@ class RestApiGenerator {
|
|
|
3822
3835
|
return this.router;
|
|
3823
3836
|
}
|
|
3824
3837
|
/**
|
|
3825
|
-
* Get the
|
|
3838
|
+
* Get the typed RestFetchService from a driver if it exposes one (for include support).
|
|
3826
3839
|
*/
|
|
3827
3840
|
getFetchService(driver) {
|
|
3828
|
-
|
|
3829
|
-
const es = driver.entityService;
|
|
3830
|
-
if (typeof es.getFetchService === "function") {
|
|
3831
|
-
return es.getFetchService();
|
|
3832
|
-
}
|
|
3833
|
-
}
|
|
3834
|
-
return null;
|
|
3841
|
+
return driver.restFetchService;
|
|
3835
3842
|
}
|
|
3836
3843
|
/**
|
|
3837
3844
|
* Create REST routes for a collection using existing Rebase patterns
|
|
@@ -3839,15 +3846,26 @@ class RestApiGenerator {
|
|
|
3839
3846
|
createCollectionRoutes(collection) {
|
|
3840
3847
|
const basePath = `/${collection.slug}`;
|
|
3841
3848
|
const resolvedCollection = collection;
|
|
3849
|
+
this.router.get(`${basePath}/count`, async (c) => {
|
|
3850
|
+
const queryDict = c.req.query();
|
|
3851
|
+
const queryOptions = parseQueryOptions(queryDict);
|
|
3852
|
+
const searchString = queryDict.searchString;
|
|
3853
|
+
const driver = c.get("driver") || this.driver;
|
|
3854
|
+
const total = await this.countRawEntities(driver, resolvedCollection, queryOptions, searchString);
|
|
3855
|
+
return c.json({
|
|
3856
|
+
count: total
|
|
3857
|
+
});
|
|
3858
|
+
});
|
|
3842
3859
|
this.router.get(basePath, async (c) => {
|
|
3843
3860
|
const queryDict = c.req.query();
|
|
3844
3861
|
const queryOptions = parseQueryOptions(queryDict);
|
|
3845
3862
|
const searchString = queryDict.searchString;
|
|
3846
3863
|
const driver = c.get("driver") || this.driver;
|
|
3847
3864
|
const fetchService = this.getFetchService(driver);
|
|
3865
|
+
const hookCtx = this.buildHookContext(c, "GET");
|
|
3848
3866
|
if (fetchService) {
|
|
3849
3867
|
const collectionPath = collection.slug;
|
|
3850
|
-
|
|
3868
|
+
let entities2 = await fetchService.fetchCollectionForRest(collectionPath, {
|
|
3851
3869
|
filter: queryOptions.where,
|
|
3852
3870
|
limit: queryOptions.limit,
|
|
3853
3871
|
offset: queryOptions.offset,
|
|
@@ -3855,6 +3873,7 @@ class RestApiGenerator {
|
|
|
3855
3873
|
order: queryOptions.orderBy?.[0]?.direction === "desc" ? "desc" : "asc",
|
|
3856
3874
|
searchString
|
|
3857
3875
|
}, queryOptions.include);
|
|
3876
|
+
entities2 = await this.applyAfterReadBatch(collection.slug, entities2, hookCtx);
|
|
3858
3877
|
const total2 = await this.countRawEntities(driver, resolvedCollection, queryOptions, searchString);
|
|
3859
3878
|
return c.json({
|
|
3860
3879
|
data: entities2,
|
|
@@ -3866,7 +3885,8 @@ class RestApiGenerator {
|
|
|
3866
3885
|
}
|
|
3867
3886
|
});
|
|
3868
3887
|
}
|
|
3869
|
-
|
|
3888
|
+
let entities = await this.fetchRawCollection(driver, resolvedCollection, queryOptions, searchString);
|
|
3889
|
+
entities = await this.applyAfterReadBatch(collection.slug, entities, hookCtx);
|
|
3870
3890
|
const total = await this.countRawEntities(driver, resolvedCollection, queryOptions, searchString);
|
|
3871
3891
|
return c.json({
|
|
3872
3892
|
data: entities,
|
|
@@ -3884,15 +3904,24 @@ class RestApiGenerator {
|
|
|
3884
3904
|
const queryOptions = parseQueryOptions(queryDict);
|
|
3885
3905
|
const driver = c.get("driver") || this.driver;
|
|
3886
3906
|
const fetchService = this.getFetchService(driver);
|
|
3907
|
+
const hookCtx = this.buildHookContext(c, "GET");
|
|
3887
3908
|
if (fetchService) {
|
|
3888
3909
|
const collectionPath = collection.slug;
|
|
3889
|
-
|
|
3910
|
+
let entity2 = await fetchService.fetchEntityForRest(collectionPath, String(id), queryOptions.include);
|
|
3911
|
+
if (!entity2) {
|
|
3912
|
+
throw ApiError.notFound("Entity not found");
|
|
3913
|
+
}
|
|
3914
|
+
entity2 = await this.applyAfterRead(collection.slug, entity2, hookCtx);
|
|
3890
3915
|
if (!entity2) {
|
|
3891
3916
|
throw ApiError.notFound("Entity not found");
|
|
3892
3917
|
}
|
|
3893
3918
|
return c.json(entity2);
|
|
3894
3919
|
}
|
|
3895
|
-
|
|
3920
|
+
let entity = await this.fetchRawEntity(driver, resolvedCollection, String(id));
|
|
3921
|
+
if (!entity) {
|
|
3922
|
+
throw ApiError.notFound("Entity not found");
|
|
3923
|
+
}
|
|
3924
|
+
entity = await this.applyAfterRead(collection.slug, entity, hookCtx);
|
|
3896
3925
|
if (!entity) {
|
|
3897
3926
|
throw ApiError.notFound("Entity not found");
|
|
3898
3927
|
}
|
|
@@ -3902,14 +3931,24 @@ class RestApiGenerator {
|
|
|
3902
3931
|
try {
|
|
3903
3932
|
const driver = c.get("driver") || this.driver;
|
|
3904
3933
|
const path2 = collection.slug;
|
|
3905
|
-
const
|
|
3934
|
+
const hookCtx = this.buildHookContext(c, "POST");
|
|
3935
|
+
let body = await c.req.json().catch(() => ({}));
|
|
3936
|
+
if (this.dataHooks?.beforeSave) {
|
|
3937
|
+
body = await this.dataHooks.beforeSave(path2, body, void 0, hookCtx);
|
|
3938
|
+
}
|
|
3906
3939
|
const entity = await driver.saveEntity({
|
|
3907
3940
|
path: path2,
|
|
3908
3941
|
values: body,
|
|
3909
3942
|
collection: resolvedCollection,
|
|
3910
3943
|
status: "new"
|
|
3911
3944
|
});
|
|
3912
|
-
|
|
3945
|
+
const response = this.formatResponse(entity);
|
|
3946
|
+
if (this.dataHooks?.afterSave) {
|
|
3947
|
+
Promise.resolve(this.dataHooks.afterSave(path2, response, hookCtx)).catch((err) => {
|
|
3948
|
+
console.error("[BackendHooks] data.afterSave error:", err instanceof Error ? err.message : err);
|
|
3949
|
+
});
|
|
3950
|
+
}
|
|
3951
|
+
return c.json(response, 201);
|
|
3913
3952
|
} catch (error2) {
|
|
3914
3953
|
const err = error2;
|
|
3915
3954
|
err.code = err.code || "BAD_REQUEST";
|
|
@@ -3920,6 +3959,7 @@ class RestApiGenerator {
|
|
|
3920
3959
|
try {
|
|
3921
3960
|
const id = c.req.param("id");
|
|
3922
3961
|
const driver = c.get("driver") || this.driver;
|
|
3962
|
+
const hookCtx = this.buildHookContext(c, "PUT");
|
|
3923
3963
|
const existingEntity = await driver.fetchEntity({
|
|
3924
3964
|
path: collection.slug,
|
|
3925
3965
|
entityId: String(id),
|
|
@@ -3928,7 +3968,10 @@ class RestApiGenerator {
|
|
|
3928
3968
|
if (!existingEntity) {
|
|
3929
3969
|
throw ApiError.notFound("Entity not found");
|
|
3930
3970
|
}
|
|
3931
|
-
|
|
3971
|
+
let body = await c.req.json().catch(() => ({}));
|
|
3972
|
+
if (this.dataHooks?.beforeSave) {
|
|
3973
|
+
body = await this.dataHooks.beforeSave(collection.slug, body, String(id), hookCtx);
|
|
3974
|
+
}
|
|
3932
3975
|
const entity = await driver.saveEntity({
|
|
3933
3976
|
path: collection.slug,
|
|
3934
3977
|
entityId: String(id),
|
|
@@ -3936,7 +3979,13 @@ class RestApiGenerator {
|
|
|
3936
3979
|
collection: resolvedCollection,
|
|
3937
3980
|
status: "existing"
|
|
3938
3981
|
});
|
|
3939
|
-
|
|
3982
|
+
const response = this.formatResponse(entity);
|
|
3983
|
+
if (this.dataHooks?.afterSave) {
|
|
3984
|
+
Promise.resolve(this.dataHooks.afterSave(collection.slug, response, hookCtx)).catch((err) => {
|
|
3985
|
+
console.error("[BackendHooks] data.afterSave error:", err instanceof Error ? err.message : err);
|
|
3986
|
+
});
|
|
3987
|
+
}
|
|
3988
|
+
return c.json(response);
|
|
3940
3989
|
} catch (error2) {
|
|
3941
3990
|
const err = error2;
|
|
3942
3991
|
err.code = err.code || "BAD_REQUEST";
|
|
@@ -3946,6 +3995,7 @@ class RestApiGenerator {
|
|
|
3946
3995
|
this.router.delete(`${basePath}/:id`, async (c) => {
|
|
3947
3996
|
const id = c.req.param("id");
|
|
3948
3997
|
const driver = c.get("driver") || this.driver;
|
|
3998
|
+
const hookCtx = this.buildHookContext(c, "DELETE");
|
|
3949
3999
|
const existingEntity = await driver.fetchEntity({
|
|
3950
4000
|
path: collection.slug,
|
|
3951
4001
|
entityId: String(id),
|
|
@@ -3954,10 +4004,18 @@ class RestApiGenerator {
|
|
|
3954
4004
|
if (!existingEntity) {
|
|
3955
4005
|
throw ApiError.notFound("Entity not found");
|
|
3956
4006
|
}
|
|
4007
|
+
if (this.dataHooks?.beforeDelete) {
|
|
4008
|
+
await this.dataHooks.beforeDelete(collection.slug, String(id), hookCtx);
|
|
4009
|
+
}
|
|
3957
4010
|
await driver.deleteEntity({
|
|
3958
4011
|
entity: existingEntity,
|
|
3959
4012
|
collection: resolvedCollection
|
|
3960
4013
|
});
|
|
4014
|
+
if (this.dataHooks?.afterDelete) {
|
|
4015
|
+
Promise.resolve(this.dataHooks.afterDelete(collection.slug, String(id), hookCtx)).catch((err) => {
|
|
4016
|
+
console.error("[BackendHooks] data.afterDelete error:", err instanceof Error ? err.message : err);
|
|
4017
|
+
});
|
|
4018
|
+
}
|
|
3961
4019
|
return new Response(null, {
|
|
3962
4020
|
status: 204
|
|
3963
4021
|
});
|
|
@@ -4006,7 +4064,18 @@ class RestApiGenerator {
|
|
|
4006
4064
|
const parsed = parseSubPath(rawPath);
|
|
4007
4065
|
if (!parsed) return next();
|
|
4008
4066
|
const driver = c.get("driver") || this.driver;
|
|
4009
|
-
if (parsed.entityId) {
|
|
4067
|
+
if (parsed.entityId === "count") {
|
|
4068
|
+
const queryDict = c.req.query();
|
|
4069
|
+
const queryOptions = parseQueryOptions(queryDict);
|
|
4070
|
+
const total = driver.countEntities ? await driver.countEntities({
|
|
4071
|
+
path: parsed.collectionPath,
|
|
4072
|
+
filter: queryOptions.where,
|
|
4073
|
+
searchString: queryDict.searchString
|
|
4074
|
+
}) : 0;
|
|
4075
|
+
return c.json({
|
|
4076
|
+
count: total
|
|
4077
|
+
});
|
|
4078
|
+
} else if (parsed.entityId) {
|
|
4010
4079
|
const entity = await driver.fetchEntity({
|
|
4011
4080
|
path: parsed.collectionPath,
|
|
4012
4081
|
entityId: parsed.entityId
|
|
@@ -4164,6 +4233,22 @@ class RestApiGenerator {
|
|
|
4164
4233
|
});
|
|
4165
4234
|
return entity ? this.flattenEntity(entity) : null;
|
|
4166
4235
|
}
|
|
4236
|
+
/**
|
|
4237
|
+
* Apply data.afterRead hook to a single entity.
|
|
4238
|
+
* Returns the transformed entity, or null to filter it out.
|
|
4239
|
+
*/
|
|
4240
|
+
async applyAfterRead(slug, entity, ctx) {
|
|
4241
|
+
if (!this.dataHooks?.afterRead) return entity;
|
|
4242
|
+
return this.dataHooks.afterRead(slug, entity, ctx);
|
|
4243
|
+
}
|
|
4244
|
+
/**
|
|
4245
|
+
* Apply data.afterRead hook to an array of entities, filtering out nulls.
|
|
4246
|
+
*/
|
|
4247
|
+
async applyAfterReadBatch(slug, entities, ctx) {
|
|
4248
|
+
if (!this.dataHooks?.afterRead) return entities;
|
|
4249
|
+
const results = await Promise.all(entities.map((e) => this.applyAfterRead(slug, e, ctx)));
|
|
4250
|
+
return results.filter((e) => e !== null);
|
|
4251
|
+
}
|
|
4167
4252
|
}
|
|
4168
4253
|
var jws$5 = {};
|
|
4169
4254
|
var safeBuffer = { exports: {} };
|
|
@@ -4745,11 +4830,11 @@ var Stream$1 = require$$0$3;
|
|
|
4745
4830
|
var toString2 = tostring;
|
|
4746
4831
|
var util$4 = require$$5;
|
|
4747
4832
|
var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
|
|
4748
|
-
function isObject$
|
|
4833
|
+
function isObject$3(thing) {
|
|
4749
4834
|
return Object.prototype.toString.call(thing) === "[object Object]";
|
|
4750
4835
|
}
|
|
4751
4836
|
function safeJsonParse(thing) {
|
|
4752
|
-
if (isObject$
|
|
4837
|
+
if (isObject$3(thing))
|
|
4753
4838
|
return thing;
|
|
4754
4839
|
try {
|
|
4755
4840
|
return JSON.parse(thing);
|
|
@@ -4875,7 +4960,7 @@ jws$5.createVerify = function createVerify(opts) {
|
|
|
4875
4960
|
return new VerifyStream(opts);
|
|
4876
4961
|
};
|
|
4877
4962
|
var jws$4 = jws$5;
|
|
4878
|
-
var decode$
|
|
4963
|
+
var decode$2 = function(jwt2, options2) {
|
|
4879
4964
|
options2 = options2 || {};
|
|
4880
4965
|
var decoded = jws$4.decode(jwt2, options2);
|
|
4881
4966
|
if (!decoded) {
|
|
@@ -4900,21 +4985,21 @@ var decode$3 = function(jwt2, options2) {
|
|
|
4900
4985
|
}
|
|
4901
4986
|
return payload;
|
|
4902
4987
|
};
|
|
4903
|
-
var JsonWebTokenError$3 = function(
|
|
4904
|
-
Error.call(this,
|
|
4988
|
+
var JsonWebTokenError$3 = function(message, error2) {
|
|
4989
|
+
Error.call(this, message);
|
|
4905
4990
|
if (Error.captureStackTrace) {
|
|
4906
4991
|
Error.captureStackTrace(this, this.constructor);
|
|
4907
4992
|
}
|
|
4908
4993
|
this.name = "JsonWebTokenError";
|
|
4909
|
-
this.message =
|
|
4994
|
+
this.message = message;
|
|
4910
4995
|
if (error2) this.inner = error2;
|
|
4911
4996
|
};
|
|
4912
4997
|
JsonWebTokenError$3.prototype = Object.create(Error.prototype);
|
|
4913
4998
|
JsonWebTokenError$3.prototype.constructor = JsonWebTokenError$3;
|
|
4914
4999
|
var JsonWebTokenError_1 = JsonWebTokenError$3;
|
|
4915
5000
|
var JsonWebTokenError$2 = JsonWebTokenError_1;
|
|
4916
|
-
var NotBeforeError$1 = function(
|
|
4917
|
-
JsonWebTokenError$2.call(this,
|
|
5001
|
+
var NotBeforeError$1 = function(message, date) {
|
|
5002
|
+
JsonWebTokenError$2.call(this, message);
|
|
4918
5003
|
this.name = "NotBeforeError";
|
|
4919
5004
|
this.date = date;
|
|
4920
5005
|
};
|
|
@@ -4922,8 +5007,8 @@ NotBeforeError$1.prototype = Object.create(JsonWebTokenError$2.prototype);
|
|
|
4922
5007
|
NotBeforeError$1.prototype.constructor = NotBeforeError$1;
|
|
4923
5008
|
var NotBeforeError_1 = NotBeforeError$1;
|
|
4924
5009
|
var JsonWebTokenError$1 = JsonWebTokenError_1;
|
|
4925
|
-
var TokenExpiredError$1 = function(
|
|
4926
|
-
JsonWebTokenError$1.call(this,
|
|
5010
|
+
var TokenExpiredError$1 = function(message, expiredAt) {
|
|
5011
|
+
JsonWebTokenError$1.call(this, message);
|
|
4927
5012
|
this.name = "TokenExpiredError";
|
|
4928
5013
|
this.expiredAt = expiredAt;
|
|
4929
5014
|
};
|
|
@@ -5788,7 +5873,7 @@ function requireRange() {
|
|
|
5788
5873
|
parseRange(range2) {
|
|
5789
5874
|
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
5790
5875
|
const memoKey = memoOpts + ":" + range2;
|
|
5791
|
-
const cached =
|
|
5876
|
+
const cached = cache.get(memoKey);
|
|
5792
5877
|
if (cached) {
|
|
5793
5878
|
return cached;
|
|
5794
5879
|
}
|
|
@@ -5822,7 +5907,7 @@ function requireRange() {
|
|
|
5822
5907
|
rangeMap.delete("");
|
|
5823
5908
|
}
|
|
5824
5909
|
const result = [...rangeMap.values()];
|
|
5825
|
-
|
|
5910
|
+
cache.set(memoKey, result);
|
|
5826
5911
|
return result;
|
|
5827
5912
|
}
|
|
5828
5913
|
intersects(range2, options2) {
|
|
@@ -5861,7 +5946,7 @@ function requireRange() {
|
|
|
5861
5946
|
}
|
|
5862
5947
|
range = Range2;
|
|
5863
5948
|
const LRU = lrucache;
|
|
5864
|
-
const
|
|
5949
|
+
const cache = new LRU();
|
|
5865
5950
|
const parseOptions2 = parseOptions_1;
|
|
5866
5951
|
const Comparator2 = requireComparator();
|
|
5867
5952
|
const debug2 = debug_1;
|
|
@@ -6738,7 +6823,7 @@ var psSupported = semver.satisfies(process.version, "^6.12.0 || >=8.0.0");
|
|
|
6738
6823
|
const JsonWebTokenError = JsonWebTokenError_1;
|
|
6739
6824
|
const NotBeforeError = NotBeforeError_1;
|
|
6740
6825
|
const TokenExpiredError = TokenExpiredError_1;
|
|
6741
|
-
const decode$
|
|
6826
|
+
const decode$1 = decode$2;
|
|
6742
6827
|
const timespan$1 = timespan$2;
|
|
6743
6828
|
const validateAsymmetricKey$1 = validateAsymmetricKey$2;
|
|
6744
6829
|
const PS_SUPPORTED$1 = psSupported;
|
|
@@ -6792,7 +6877,7 @@ var verify2 = function(jwtString, secretOrPublicKey, options2, callback) {
|
|
|
6792
6877
|
}
|
|
6793
6878
|
let decodedToken;
|
|
6794
6879
|
try {
|
|
6795
|
-
decodedToken = decode$
|
|
6880
|
+
decodedToken = decode$1(jwtString, { complete: true });
|
|
6796
6881
|
} catch (err) {
|
|
6797
6882
|
return done(err);
|
|
6798
6883
|
}
|
|
@@ -7052,27 +7137,27 @@ function isArrayLike(value) {
|
|
|
7052
7137
|
return value != null && isLength(value.length) && !isFunction(value);
|
|
7053
7138
|
}
|
|
7054
7139
|
function isArrayLikeObject(value) {
|
|
7055
|
-
return isObjectLike$
|
|
7140
|
+
return isObjectLike$7(value) && isArrayLike(value);
|
|
7056
7141
|
}
|
|
7057
7142
|
function isFunction(value) {
|
|
7058
|
-
var
|
|
7059
|
-
return
|
|
7143
|
+
var tag = isObject$2(value) ? objectToString$6.call(value) : "";
|
|
7144
|
+
return tag == funcTag || tag == genTag;
|
|
7060
7145
|
}
|
|
7061
7146
|
function isLength(value) {
|
|
7062
7147
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
7063
7148
|
}
|
|
7064
|
-
function isObject$
|
|
7149
|
+
function isObject$2(value) {
|
|
7065
7150
|
var type = typeof value;
|
|
7066
7151
|
return !!value && (type == "object" || type == "function");
|
|
7067
7152
|
}
|
|
7068
|
-
function isObjectLike$
|
|
7153
|
+
function isObjectLike$7(value) {
|
|
7069
7154
|
return !!value && typeof value == "object";
|
|
7070
7155
|
}
|
|
7071
7156
|
function isString$2(value) {
|
|
7072
|
-
return typeof value == "string" || !isArray$2(value) && isObjectLike$
|
|
7157
|
+
return typeof value == "string" || !isArray$2(value) && isObjectLike$7(value) && objectToString$6.call(value) == stringTag$1;
|
|
7073
7158
|
}
|
|
7074
7159
|
function isSymbol$2(value) {
|
|
7075
|
-
return typeof value == "symbol" || isObjectLike$
|
|
7160
|
+
return typeof value == "symbol" || isObjectLike$7(value) && objectToString$6.call(value) == symbolTag$2;
|
|
7076
7161
|
}
|
|
7077
7162
|
function toFinite$2(value) {
|
|
7078
7163
|
if (!value) {
|
|
@@ -7096,9 +7181,9 @@ function toNumber$2(value) {
|
|
|
7096
7181
|
if (isSymbol$2(value)) {
|
|
7097
7182
|
return NAN$2;
|
|
7098
7183
|
}
|
|
7099
|
-
if (isObject$
|
|
7184
|
+
if (isObject$2(value)) {
|
|
7100
7185
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
7101
|
-
value = isObject$
|
|
7186
|
+
value = isObject$2(other) ? other + "" : other;
|
|
7102
7187
|
}
|
|
7103
7188
|
if (typeof value != "string") {
|
|
7104
7189
|
return value === 0 ? value : +value;
|
|
@@ -7118,9 +7203,9 @@ var boolTag = "[object Boolean]";
|
|
|
7118
7203
|
var objectProto$5 = Object.prototype;
|
|
7119
7204
|
var objectToString$5 = objectProto$5.toString;
|
|
7120
7205
|
function isBoolean$1(value) {
|
|
7121
|
-
return value === true || value === false || isObjectLike$
|
|
7206
|
+
return value === true || value === false || isObjectLike$6(value) && objectToString$5.call(value) == boolTag;
|
|
7122
7207
|
}
|
|
7123
|
-
function isObjectLike$
|
|
7208
|
+
function isObjectLike$6(value) {
|
|
7124
7209
|
return !!value && typeof value == "object";
|
|
7125
7210
|
}
|
|
7126
7211
|
var lodash_isboolean = isBoolean$1;
|
|
@@ -7136,15 +7221,15 @@ var objectToString$4 = objectProto$4.toString;
|
|
|
7136
7221
|
function isInteger$1(value) {
|
|
7137
7222
|
return typeof value == "number" && value == toInteger$1(value);
|
|
7138
7223
|
}
|
|
7139
|
-
function isObject$
|
|
7224
|
+
function isObject$1(value) {
|
|
7140
7225
|
var type = typeof value;
|
|
7141
7226
|
return !!value && (type == "object" || type == "function");
|
|
7142
7227
|
}
|
|
7143
|
-
function isObjectLike$
|
|
7228
|
+
function isObjectLike$5(value) {
|
|
7144
7229
|
return !!value && typeof value == "object";
|
|
7145
7230
|
}
|
|
7146
7231
|
function isSymbol$1(value) {
|
|
7147
|
-
return typeof value == "symbol" || isObjectLike$
|
|
7232
|
+
return typeof value == "symbol" || isObjectLike$5(value) && objectToString$4.call(value) == symbolTag$1;
|
|
7148
7233
|
}
|
|
7149
7234
|
function toFinite$1(value) {
|
|
7150
7235
|
if (!value) {
|
|
@@ -7168,9 +7253,9 @@ function toNumber$1(value) {
|
|
|
7168
7253
|
if (isSymbol$1(value)) {
|
|
7169
7254
|
return NAN$1;
|
|
7170
7255
|
}
|
|
7171
|
-
if (isObject$
|
|
7256
|
+
if (isObject$1(value)) {
|
|
7172
7257
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
7173
|
-
value = isObject$
|
|
7258
|
+
value = isObject$1(other) ? other + "" : other;
|
|
7174
7259
|
}
|
|
7175
7260
|
if (typeof value != "string") {
|
|
7176
7261
|
return value === 0 ? value : +value;
|
|
@@ -7183,11 +7268,11 @@ var lodash_isinteger = isInteger$1;
|
|
|
7183
7268
|
var numberTag = "[object Number]";
|
|
7184
7269
|
var objectProto$3 = Object.prototype;
|
|
7185
7270
|
var objectToString$3 = objectProto$3.toString;
|
|
7186
|
-
function isObjectLike$
|
|
7271
|
+
function isObjectLike$4(value) {
|
|
7187
7272
|
return !!value && typeof value == "object";
|
|
7188
7273
|
}
|
|
7189
7274
|
function isNumber$1(value) {
|
|
7190
|
-
return typeof value == "number" || isObjectLike$
|
|
7275
|
+
return typeof value == "number" || isObjectLike$4(value) && objectToString$3.call(value) == numberTag;
|
|
7191
7276
|
}
|
|
7192
7277
|
var lodash_isnumber = isNumber$1;
|
|
7193
7278
|
var objectTag = "[object Object]";
|
|
@@ -7212,11 +7297,11 @@ var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
|
|
7212
7297
|
var objectCtorString = funcToString.call(Object);
|
|
7213
7298
|
var objectToString$2 = objectProto$2.toString;
|
|
7214
7299
|
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
7215
|
-
function isObjectLike$
|
|
7300
|
+
function isObjectLike$3(value) {
|
|
7216
7301
|
return !!value && typeof value == "object";
|
|
7217
7302
|
}
|
|
7218
7303
|
function isPlainObject$2(value) {
|
|
7219
|
-
if (!isObjectLike$
|
|
7304
|
+
if (!isObjectLike$3(value) || objectToString$2.call(value) != objectTag || isHostObject(value)) {
|
|
7220
7305
|
return false;
|
|
7221
7306
|
}
|
|
7222
7307
|
var proto = getPrototype(value);
|
|
@@ -7231,11 +7316,11 @@ var stringTag = "[object String]";
|
|
|
7231
7316
|
var objectProto$1 = Object.prototype;
|
|
7232
7317
|
var objectToString$1 = objectProto$1.toString;
|
|
7233
7318
|
var isArray$1 = Array.isArray;
|
|
7234
|
-
function isObjectLike$
|
|
7319
|
+
function isObjectLike$2(value) {
|
|
7235
7320
|
return !!value && typeof value == "object";
|
|
7236
7321
|
}
|
|
7237
7322
|
function isString$1(value) {
|
|
7238
|
-
return typeof value == "string" || !isArray$1(value) && isObjectLike$
|
|
7323
|
+
return typeof value == "string" || !isArray$1(value) && isObjectLike$2(value) && objectToString$1.call(value) == stringTag;
|
|
7239
7324
|
}
|
|
7240
7325
|
var lodash_isstring = isString$1;
|
|
7241
7326
|
var FUNC_ERROR_TEXT = "Expected a function";
|
|
@@ -7267,15 +7352,15 @@ function before(n, func) {
|
|
|
7267
7352
|
function once$1(func) {
|
|
7268
7353
|
return before(2, func);
|
|
7269
7354
|
}
|
|
7270
|
-
function isObject
|
|
7355
|
+
function isObject(value) {
|
|
7271
7356
|
var type = typeof value;
|
|
7272
7357
|
return !!value && (type == "object" || type == "function");
|
|
7273
7358
|
}
|
|
7274
|
-
function isObjectLike$
|
|
7359
|
+
function isObjectLike$1(value) {
|
|
7275
7360
|
return !!value && typeof value == "object";
|
|
7276
7361
|
}
|
|
7277
7362
|
function isSymbol(value) {
|
|
7278
|
-
return typeof value == "symbol" || isObjectLike$
|
|
7363
|
+
return typeof value == "symbol" || isObjectLike$1(value) && objectToString.call(value) == symbolTag;
|
|
7279
7364
|
}
|
|
7280
7365
|
function toFinite(value) {
|
|
7281
7366
|
if (!value) {
|
|
@@ -7299,9 +7384,9 @@ function toNumber(value) {
|
|
|
7299
7384
|
if (isSymbol(value)) {
|
|
7300
7385
|
return NAN;
|
|
7301
7386
|
}
|
|
7302
|
-
if (isObject
|
|
7387
|
+
if (isObject(value)) {
|
|
7303
7388
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
7304
|
-
value = isObject
|
|
7389
|
+
value = isObject(other) ? other + "" : other;
|
|
7305
7390
|
}
|
|
7306
7391
|
if (typeof value != "string") {
|
|
7307
7392
|
return value === 0 ? value : +value;
|
|
@@ -7392,7 +7477,7 @@ const options_for_objects = [
|
|
|
7392
7477
|
"subject",
|
|
7393
7478
|
"jwtid"
|
|
7394
7479
|
];
|
|
7395
|
-
var sign$
|
|
7480
|
+
var sign$3 = function(payload, secretOrPrivateKey, options2, callback) {
|
|
7396
7481
|
if (typeof options2 === "function") {
|
|
7397
7482
|
callback = options2;
|
|
7398
7483
|
options2 = {};
|
|
@@ -7531,9 +7616,9 @@ var sign$4 = function(payload, secretOrPrivateKey, options2, callback) {
|
|
|
7531
7616
|
}
|
|
7532
7617
|
};
|
|
7533
7618
|
var jsonwebtoken = {
|
|
7534
|
-
decode: decode$
|
|
7619
|
+
decode: decode$2,
|
|
7535
7620
|
verify: verify2,
|
|
7536
|
-
sign: sign$
|
|
7621
|
+
sign: sign$3,
|
|
7537
7622
|
JsonWebTokenError: JsonWebTokenError_1,
|
|
7538
7623
|
NotBeforeError: NotBeforeError_1,
|
|
7539
7624
|
TokenExpiredError: TokenExpiredError_1
|
|
@@ -7984,7 +8069,7 @@ function formatData(data) {
|
|
|
7984
8069
|
}
|
|
7985
8070
|
function createLogger(defaultFields = {}) {
|
|
7986
8071
|
const minLevel = getMinLevel();
|
|
7987
|
-
function emit(level,
|
|
8072
|
+
function emit(level, message, data) {
|
|
7988
8073
|
if (LOG_PRIORITY[level] < LOG_PRIORITY[minLevel]) return;
|
|
7989
8074
|
const merged = {
|
|
7990
8075
|
...defaultFields,
|
|
@@ -7993,7 +8078,7 @@ function createLogger(defaultFields = {}) {
|
|
|
7993
8078
|
if (isProduction$1()) {
|
|
7994
8079
|
const entry = {
|
|
7995
8080
|
severity: GCP_SEVERITY[level],
|
|
7996
|
-
message
|
|
8081
|
+
message,
|
|
7997
8082
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7998
8083
|
...merged
|
|
7999
8084
|
};
|
|
@@ -8006,7 +8091,7 @@ function createLogger(defaultFields = {}) {
|
|
|
8006
8091
|
} else {
|
|
8007
8092
|
const prefix = level === "error" ? "❌" : level === "warn" ? "⚠️" : level === "info" ? "ℹ️" : "🐛";
|
|
8008
8093
|
const extra = Object.keys(merged).length > 0 ? ` ${JSON.stringify(merged)}` : "";
|
|
8009
|
-
const out = `${prefix} [${level.toUpperCase()}] ${
|
|
8094
|
+
const out = `${prefix} [${level.toUpperCase()}] ${message}${extra}`;
|
|
8010
8095
|
if (level === "error") {
|
|
8011
8096
|
console.error(out);
|
|
8012
8097
|
} else if (level === "warn") {
|
|
@@ -8367,9 +8452,9 @@ util$3.pkg = require$$0$1;
|
|
|
8367
8452
|
}
|
|
8368
8453
|
return Function.prototype[Symbol.hasInstance].call(GaxiosError, instance);
|
|
8369
8454
|
}
|
|
8370
|
-
constructor(
|
|
8455
|
+
constructor(message, config, response, error2) {
|
|
8371
8456
|
var _b2;
|
|
8372
|
-
super(
|
|
8457
|
+
super(message);
|
|
8373
8458
|
this.config = config;
|
|
8374
8459
|
this.response = response;
|
|
8375
8460
|
this.error = error2;
|
|
@@ -14265,8 +14350,8 @@ const readFile$2 = fs$3.readFile ? (0, util_1$5.promisify)(fs$3.readFile) : asyn
|
|
|
14265
14350
|
const GOOGLE_TOKEN_URL = "https://www.googleapis.com/oauth2/v4/token";
|
|
14266
14351
|
const GOOGLE_REVOKE_TOKEN_URL = "https://accounts.google.com/o/oauth2/revoke?token=";
|
|
14267
14352
|
class ErrorWithCode extends Error {
|
|
14268
|
-
constructor(
|
|
14269
|
-
super(
|
|
14353
|
+
constructor(message, code2) {
|
|
14354
|
+
super(message);
|
|
14270
14355
|
this.code = code2;
|
|
14271
14356
|
}
|
|
14272
14357
|
}
|
|
@@ -15122,13 +15207,13 @@ class Impersonated extends oauth2client_1.OAuth2Client {
|
|
|
15122
15207
|
if (!(error2 instanceof Error))
|
|
15123
15208
|
throw error2;
|
|
15124
15209
|
let status = 0;
|
|
15125
|
-
let
|
|
15210
|
+
let message = "";
|
|
15126
15211
|
if (error2 instanceof gaxios_1$2.GaxiosError) {
|
|
15127
15212
|
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;
|
|
15128
|
-
|
|
15213
|
+
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;
|
|
15129
15214
|
}
|
|
15130
|
-
if (status &&
|
|
15131
|
-
error2.message = `${status}: unable to impersonate: ${
|
|
15215
|
+
if (status && message) {
|
|
15216
|
+
error2.message = `${status}: unable to impersonate: ${message}`;
|
|
15132
15217
|
throw error2;
|
|
15133
15218
|
} else {
|
|
15134
15219
|
error2.message = `unable to impersonate: ${error2}`;
|
|
@@ -15290,14 +15375,14 @@ function getErrorFromOAuthErrorResponse(resp, err) {
|
|
|
15290
15375
|
const errorCode = resp.error;
|
|
15291
15376
|
const errorDescription = resp.error_description;
|
|
15292
15377
|
const errorUri = resp.error_uri;
|
|
15293
|
-
let
|
|
15378
|
+
let message = `Error code ${errorCode}`;
|
|
15294
15379
|
if (typeof errorDescription !== "undefined") {
|
|
15295
|
-
|
|
15380
|
+
message += `: ${errorDescription}`;
|
|
15296
15381
|
}
|
|
15297
15382
|
if (typeof errorUri !== "undefined") {
|
|
15298
|
-
|
|
15383
|
+
message += ` - ${errorUri}`;
|
|
15299
15384
|
}
|
|
15300
|
-
const newError = new Error(
|
|
15385
|
+
const newError = new Error(message);
|
|
15301
15386
|
if (err) {
|
|
15302
15387
|
const keys2 = Object.keys(err);
|
|
15303
15388
|
if (err.stack) {
|
|
@@ -16025,14 +16110,14 @@ class AwsRequestSigner {
|
|
|
16025
16110
|
}
|
|
16026
16111
|
}
|
|
16027
16112
|
awsrequestsigner.AwsRequestSigner = AwsRequestSigner;
|
|
16028
|
-
async function sign$
|
|
16113
|
+
async function sign$2(crypto2, key, msg) {
|
|
16029
16114
|
return await crypto2.signWithHmacSha256(key, msg);
|
|
16030
16115
|
}
|
|
16031
16116
|
async function getSigningKey(crypto2, key, dateStamp, region, serviceName) {
|
|
16032
|
-
const kDate = await sign$
|
|
16033
|
-
const kRegion = await sign$
|
|
16034
|
-
const kService = await sign$
|
|
16035
|
-
const kSigning = await sign$
|
|
16117
|
+
const kDate = await sign$2(crypto2, `AWS4${key}`, dateStamp);
|
|
16118
|
+
const kRegion = await sign$2(crypto2, kDate, region);
|
|
16119
|
+
const kService = await sign$2(crypto2, kRegion, serviceName);
|
|
16120
|
+
const kSigning = await sign$2(crypto2, kService, "aws4_request");
|
|
16036
16121
|
return kSigning;
|
|
16037
16122
|
}
|
|
16038
16123
|
async function generateAuthenticationHeaderMap(options2) {
|
|
@@ -16078,7 +16163,7 @@ ${amzDate}
|
|
|
16078
16163
|
${credentialScope}
|
|
16079
16164
|
` + await options2.crypto.sha256DigestHex(canonicalRequest);
|
|
16080
16165
|
const signingKey = await getSigningKey(options2.crypto, options2.securityCredentials.secretAccessKey, dateStamp, options2.region, serviceName);
|
|
16081
|
-
const signature = await sign$
|
|
16166
|
+
const signature = await sign$2(options2.crypto, signingKey, stringToSign);
|
|
16082
16167
|
const authorizationHeader = `${AWS_ALGORITHM} Credential=${options2.securityCredentials.accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${(0, crypto_1.fromArrayBufferToHex)(signature)}`;
|
|
16083
16168
|
return {
|
|
16084
16169
|
// Do not return x-amz-date if date is available.
|
|
@@ -16409,8 +16494,8 @@ class ExecutableResponse {
|
|
|
16409
16494
|
}
|
|
16410
16495
|
executableResponse.ExecutableResponse = ExecutableResponse;
|
|
16411
16496
|
class ExecutableResponseError extends Error {
|
|
16412
|
-
constructor(
|
|
16413
|
-
super(
|
|
16497
|
+
constructor(message) {
|
|
16498
|
+
super(message);
|
|
16414
16499
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
16415
16500
|
}
|
|
16416
16501
|
}
|
|
@@ -16573,8 +16658,8 @@ function requirePluggableAuthClient() {
|
|
|
16573
16658
|
const executable_response_1 = executableResponse;
|
|
16574
16659
|
const pluggable_auth_handler_1 = requirePluggableAuthHandler();
|
|
16575
16660
|
class ExecutableError extends Error {
|
|
16576
|
-
constructor(
|
|
16577
|
-
super(`The executable failed with exit code: ${code2} and error message: ${
|
|
16661
|
+
constructor(message, code2) {
|
|
16662
|
+
super(`The executable failed with exit code: ${code2} and error message: ${message}.`);
|
|
16578
16663
|
this.code = code2;
|
|
16579
16664
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
16580
16665
|
}
|
|
@@ -18222,104 +18307,104 @@ ZodError.create = (issues) => {
|
|
|
18222
18307
|
return error2;
|
|
18223
18308
|
};
|
|
18224
18309
|
const errorMap = (issue, _ctx) => {
|
|
18225
|
-
let
|
|
18310
|
+
let message;
|
|
18226
18311
|
switch (issue.code) {
|
|
18227
18312
|
case ZodIssueCode.invalid_type:
|
|
18228
18313
|
if (issue.received === ZodParsedType.undefined) {
|
|
18229
|
-
|
|
18314
|
+
message = "Required";
|
|
18230
18315
|
} else {
|
|
18231
|
-
|
|
18316
|
+
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
18232
18317
|
}
|
|
18233
18318
|
break;
|
|
18234
18319
|
case ZodIssueCode.invalid_literal:
|
|
18235
|
-
|
|
18320
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util$1.jsonStringifyReplacer)}`;
|
|
18236
18321
|
break;
|
|
18237
18322
|
case ZodIssueCode.unrecognized_keys:
|
|
18238
|
-
|
|
18323
|
+
message = `Unrecognized key(s) in object: ${util$1.joinValues(issue.keys, ", ")}`;
|
|
18239
18324
|
break;
|
|
18240
18325
|
case ZodIssueCode.invalid_union:
|
|
18241
|
-
|
|
18326
|
+
message = `Invalid input`;
|
|
18242
18327
|
break;
|
|
18243
18328
|
case ZodIssueCode.invalid_union_discriminator:
|
|
18244
|
-
|
|
18329
|
+
message = `Invalid discriminator value. Expected ${util$1.joinValues(issue.options)}`;
|
|
18245
18330
|
break;
|
|
18246
18331
|
case ZodIssueCode.invalid_enum_value:
|
|
18247
|
-
|
|
18332
|
+
message = `Invalid enum value. Expected ${util$1.joinValues(issue.options)}, received '${issue.received}'`;
|
|
18248
18333
|
break;
|
|
18249
18334
|
case ZodIssueCode.invalid_arguments:
|
|
18250
|
-
|
|
18335
|
+
message = `Invalid function arguments`;
|
|
18251
18336
|
break;
|
|
18252
18337
|
case ZodIssueCode.invalid_return_type:
|
|
18253
|
-
|
|
18338
|
+
message = `Invalid function return type`;
|
|
18254
18339
|
break;
|
|
18255
18340
|
case ZodIssueCode.invalid_date:
|
|
18256
|
-
|
|
18341
|
+
message = `Invalid date`;
|
|
18257
18342
|
break;
|
|
18258
18343
|
case ZodIssueCode.invalid_string:
|
|
18259
18344
|
if (typeof issue.validation === "object") {
|
|
18260
18345
|
if ("includes" in issue.validation) {
|
|
18261
|
-
|
|
18346
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
18262
18347
|
if (typeof issue.validation.position === "number") {
|
|
18263
|
-
|
|
18348
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
18264
18349
|
}
|
|
18265
18350
|
} else if ("startsWith" in issue.validation) {
|
|
18266
|
-
|
|
18351
|
+
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
18267
18352
|
} else if ("endsWith" in issue.validation) {
|
|
18268
|
-
|
|
18353
|
+
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
18269
18354
|
} else {
|
|
18270
18355
|
util$1.assertNever(issue.validation);
|
|
18271
18356
|
}
|
|
18272
18357
|
} else if (issue.validation !== "regex") {
|
|
18273
|
-
|
|
18358
|
+
message = `Invalid ${issue.validation}`;
|
|
18274
18359
|
} else {
|
|
18275
|
-
|
|
18360
|
+
message = "Invalid";
|
|
18276
18361
|
}
|
|
18277
18362
|
break;
|
|
18278
18363
|
case ZodIssueCode.too_small:
|
|
18279
18364
|
if (issue.type === "array")
|
|
18280
|
-
|
|
18365
|
+
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
18281
18366
|
else if (issue.type === "string")
|
|
18282
|
-
|
|
18367
|
+
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
18283
18368
|
else if (issue.type === "number")
|
|
18284
|
-
|
|
18369
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
18285
18370
|
else if (issue.type === "bigint")
|
|
18286
|
-
|
|
18371
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
18287
18372
|
else if (issue.type === "date")
|
|
18288
|
-
|
|
18373
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
18289
18374
|
else
|
|
18290
|
-
|
|
18375
|
+
message = "Invalid input";
|
|
18291
18376
|
break;
|
|
18292
18377
|
case ZodIssueCode.too_big:
|
|
18293
18378
|
if (issue.type === "array")
|
|
18294
|
-
|
|
18379
|
+
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
18295
18380
|
else if (issue.type === "string")
|
|
18296
|
-
|
|
18381
|
+
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
18297
18382
|
else if (issue.type === "number")
|
|
18298
|
-
|
|
18383
|
+
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
18299
18384
|
else if (issue.type === "bigint")
|
|
18300
|
-
|
|
18385
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
18301
18386
|
else if (issue.type === "date")
|
|
18302
|
-
|
|
18387
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
18303
18388
|
else
|
|
18304
|
-
|
|
18389
|
+
message = "Invalid input";
|
|
18305
18390
|
break;
|
|
18306
18391
|
case ZodIssueCode.custom:
|
|
18307
|
-
|
|
18392
|
+
message = `Invalid input`;
|
|
18308
18393
|
break;
|
|
18309
18394
|
case ZodIssueCode.invalid_intersection_types:
|
|
18310
|
-
|
|
18395
|
+
message = `Intersection results could not be merged`;
|
|
18311
18396
|
break;
|
|
18312
18397
|
case ZodIssueCode.not_multiple_of:
|
|
18313
|
-
|
|
18398
|
+
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
18314
18399
|
break;
|
|
18315
18400
|
case ZodIssueCode.not_finite:
|
|
18316
|
-
|
|
18401
|
+
message = "Number must be finite";
|
|
18317
18402
|
break;
|
|
18318
18403
|
default:
|
|
18319
|
-
|
|
18404
|
+
message = _ctx.defaultError;
|
|
18320
18405
|
util$1.assertNever(issue);
|
|
18321
18406
|
}
|
|
18322
|
-
return { message
|
|
18407
|
+
return { message };
|
|
18323
18408
|
};
|
|
18324
18409
|
let overrideErrorMap = errorMap;
|
|
18325
18410
|
function getErrorMap() {
|
|
@@ -18434,8 +18519,8 @@ const isValid = (x) => x.status === "valid";
|
|
|
18434
18519
|
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
18435
18520
|
var errorUtil;
|
|
18436
18521
|
(function(errorUtil2) {
|
|
18437
|
-
errorUtil2.errToObj = (
|
|
18438
|
-
errorUtil2.toString = (
|
|
18522
|
+
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
18523
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
18439
18524
|
})(errorUtil || (errorUtil = {}));
|
|
18440
18525
|
class ParseInputLazyPath {
|
|
18441
18526
|
constructor(parent, value, path2, key) {
|
|
@@ -18485,16 +18570,16 @@ function processCreateParams(params) {
|
|
|
18485
18570
|
if (errorMap2)
|
|
18486
18571
|
return { errorMap: errorMap2, description: description2 };
|
|
18487
18572
|
const customMap = (iss, ctx) => {
|
|
18488
|
-
const { message
|
|
18573
|
+
const { message } = params;
|
|
18489
18574
|
if (iss.code === "invalid_enum_value") {
|
|
18490
|
-
return { message:
|
|
18575
|
+
return { message: message ?? ctx.defaultError };
|
|
18491
18576
|
}
|
|
18492
18577
|
if (typeof ctx.data === "undefined") {
|
|
18493
|
-
return { message:
|
|
18578
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
18494
18579
|
}
|
|
18495
18580
|
if (iss.code !== "invalid_type")
|
|
18496
18581
|
return { message: ctx.defaultError };
|
|
18497
|
-
return { message:
|
|
18582
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
18498
18583
|
};
|
|
18499
18584
|
return { errorMap: customMap, description: description2 };
|
|
18500
18585
|
}
|
|
@@ -18620,14 +18705,14 @@ class ZodType {
|
|
|
18620
18705
|
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
18621
18706
|
return handleResult(ctx, result);
|
|
18622
18707
|
}
|
|
18623
|
-
refine(check,
|
|
18708
|
+
refine(check, message) {
|
|
18624
18709
|
const getIssueProperties = (val) => {
|
|
18625
|
-
if (typeof
|
|
18626
|
-
return { message
|
|
18627
|
-
} else if (typeof
|
|
18628
|
-
return
|
|
18710
|
+
if (typeof message === "string" || typeof message === "undefined") {
|
|
18711
|
+
return { message };
|
|
18712
|
+
} else if (typeof message === "function") {
|
|
18713
|
+
return message(val);
|
|
18629
18714
|
} else {
|
|
18630
|
-
return
|
|
18715
|
+
return message;
|
|
18631
18716
|
}
|
|
18632
18717
|
};
|
|
18633
18718
|
return this._refinement((val, ctx) => {
|
|
@@ -19163,11 +19248,11 @@ class ZodString extends ZodType {
|
|
|
19163
19248
|
}
|
|
19164
19249
|
return { status: status.value, value: input.data };
|
|
19165
19250
|
}
|
|
19166
|
-
_regex(regex2, validation,
|
|
19251
|
+
_regex(regex2, validation, message) {
|
|
19167
19252
|
return this.refinement((data) => regex2.test(data), {
|
|
19168
19253
|
validation,
|
|
19169
19254
|
code: ZodIssueCode.invalid_string,
|
|
19170
|
-
...errorUtil.errToObj(
|
|
19255
|
+
...errorUtil.errToObj(message)
|
|
19171
19256
|
});
|
|
19172
19257
|
}
|
|
19173
19258
|
_addCheck(check) {
|
|
@@ -19176,37 +19261,37 @@ class ZodString extends ZodType {
|
|
|
19176
19261
|
checks: [...this._def.checks, check]
|
|
19177
19262
|
});
|
|
19178
19263
|
}
|
|
19179
|
-
email(
|
|
19180
|
-
return this._addCheck({ kind: "email", ...errorUtil.errToObj(
|
|
19264
|
+
email(message) {
|
|
19265
|
+
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
|
|
19181
19266
|
}
|
|
19182
|
-
url(
|
|
19183
|
-
return this._addCheck({ kind: "url", ...errorUtil.errToObj(
|
|
19267
|
+
url(message) {
|
|
19268
|
+
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
19184
19269
|
}
|
|
19185
|
-
emoji(
|
|
19186
|
-
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(
|
|
19270
|
+
emoji(message) {
|
|
19271
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
19187
19272
|
}
|
|
19188
|
-
uuid(
|
|
19189
|
-
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(
|
|
19273
|
+
uuid(message) {
|
|
19274
|
+
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
19190
19275
|
}
|
|
19191
|
-
nanoid(
|
|
19192
|
-
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(
|
|
19276
|
+
nanoid(message) {
|
|
19277
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
19193
19278
|
}
|
|
19194
|
-
cuid(
|
|
19195
|
-
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(
|
|
19279
|
+
cuid(message) {
|
|
19280
|
+
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
19196
19281
|
}
|
|
19197
|
-
cuid2(
|
|
19198
|
-
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(
|
|
19282
|
+
cuid2(message) {
|
|
19283
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
19199
19284
|
}
|
|
19200
|
-
ulid(
|
|
19201
|
-
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(
|
|
19285
|
+
ulid(message) {
|
|
19286
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
19202
19287
|
}
|
|
19203
|
-
base64(
|
|
19204
|
-
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(
|
|
19288
|
+
base64(message) {
|
|
19289
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
19205
19290
|
}
|
|
19206
|
-
base64url(
|
|
19291
|
+
base64url(message) {
|
|
19207
19292
|
return this._addCheck({
|
|
19208
19293
|
kind: "base64url",
|
|
19209
|
-
...errorUtil.errToObj(
|
|
19294
|
+
...errorUtil.errToObj(message)
|
|
19210
19295
|
});
|
|
19211
19296
|
}
|
|
19212
19297
|
jwt(options2) {
|
|
@@ -19236,8 +19321,8 @@ class ZodString extends ZodType {
|
|
|
19236
19321
|
...errorUtil.errToObj(options2?.message)
|
|
19237
19322
|
});
|
|
19238
19323
|
}
|
|
19239
|
-
date(
|
|
19240
|
-
return this._addCheck({ kind: "date", message
|
|
19324
|
+
date(message) {
|
|
19325
|
+
return this._addCheck({ kind: "date", message });
|
|
19241
19326
|
}
|
|
19242
19327
|
time(options2) {
|
|
19243
19328
|
if (typeof options2 === "string") {
|
|
@@ -19253,14 +19338,14 @@ class ZodString extends ZodType {
|
|
|
19253
19338
|
...errorUtil.errToObj(options2?.message)
|
|
19254
19339
|
});
|
|
19255
19340
|
}
|
|
19256
|
-
duration(
|
|
19257
|
-
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(
|
|
19341
|
+
duration(message) {
|
|
19342
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
19258
19343
|
}
|
|
19259
|
-
regex(regex2,
|
|
19344
|
+
regex(regex2, message) {
|
|
19260
19345
|
return this._addCheck({
|
|
19261
19346
|
kind: "regex",
|
|
19262
19347
|
regex: regex2,
|
|
19263
|
-
...errorUtil.errToObj(
|
|
19348
|
+
...errorUtil.errToObj(message)
|
|
19264
19349
|
});
|
|
19265
19350
|
}
|
|
19266
19351
|
includes(value, options2) {
|
|
@@ -19271,46 +19356,46 @@ class ZodString extends ZodType {
|
|
|
19271
19356
|
...errorUtil.errToObj(options2?.message)
|
|
19272
19357
|
});
|
|
19273
19358
|
}
|
|
19274
|
-
startsWith(value,
|
|
19359
|
+
startsWith(value, message) {
|
|
19275
19360
|
return this._addCheck({
|
|
19276
19361
|
kind: "startsWith",
|
|
19277
19362
|
value,
|
|
19278
|
-
...errorUtil.errToObj(
|
|
19363
|
+
...errorUtil.errToObj(message)
|
|
19279
19364
|
});
|
|
19280
19365
|
}
|
|
19281
|
-
endsWith(value,
|
|
19366
|
+
endsWith(value, message) {
|
|
19282
19367
|
return this._addCheck({
|
|
19283
19368
|
kind: "endsWith",
|
|
19284
19369
|
value,
|
|
19285
|
-
...errorUtil.errToObj(
|
|
19370
|
+
...errorUtil.errToObj(message)
|
|
19286
19371
|
});
|
|
19287
19372
|
}
|
|
19288
|
-
min(minLength,
|
|
19373
|
+
min(minLength, message) {
|
|
19289
19374
|
return this._addCheck({
|
|
19290
19375
|
kind: "min",
|
|
19291
19376
|
value: minLength,
|
|
19292
|
-
...errorUtil.errToObj(
|
|
19377
|
+
...errorUtil.errToObj(message)
|
|
19293
19378
|
});
|
|
19294
19379
|
}
|
|
19295
|
-
max(maxLength,
|
|
19380
|
+
max(maxLength, message) {
|
|
19296
19381
|
return this._addCheck({
|
|
19297
19382
|
kind: "max",
|
|
19298
19383
|
value: maxLength,
|
|
19299
|
-
...errorUtil.errToObj(
|
|
19384
|
+
...errorUtil.errToObj(message)
|
|
19300
19385
|
});
|
|
19301
19386
|
}
|
|
19302
|
-
length(len,
|
|
19387
|
+
length(len, message) {
|
|
19303
19388
|
return this._addCheck({
|
|
19304
19389
|
kind: "length",
|
|
19305
19390
|
value: len,
|
|
19306
|
-
...errorUtil.errToObj(
|
|
19391
|
+
...errorUtil.errToObj(message)
|
|
19307
19392
|
});
|
|
19308
19393
|
}
|
|
19309
19394
|
/**
|
|
19310
19395
|
* Equivalent to `.min(1)`
|
|
19311
19396
|
*/
|
|
19312
|
-
nonempty(
|
|
19313
|
-
return this.min(1, errorUtil.errToObj(
|
|
19397
|
+
nonempty(message) {
|
|
19398
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
19314
19399
|
}
|
|
19315
19400
|
trim() {
|
|
19316
19401
|
return new ZodString({
|
|
@@ -19503,19 +19588,19 @@ class ZodNumber extends ZodType {
|
|
|
19503
19588
|
}
|
|
19504
19589
|
return { status: status.value, value: input.data };
|
|
19505
19590
|
}
|
|
19506
|
-
gte(value,
|
|
19507
|
-
return this.setLimit("min", value, true, errorUtil.toString(
|
|
19591
|
+
gte(value, message) {
|
|
19592
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
19508
19593
|
}
|
|
19509
|
-
gt(value,
|
|
19510
|
-
return this.setLimit("min", value, false, errorUtil.toString(
|
|
19594
|
+
gt(value, message) {
|
|
19595
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
19511
19596
|
}
|
|
19512
|
-
lte(value,
|
|
19513
|
-
return this.setLimit("max", value, true, errorUtil.toString(
|
|
19597
|
+
lte(value, message) {
|
|
19598
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
19514
19599
|
}
|
|
19515
|
-
lt(value,
|
|
19516
|
-
return this.setLimit("max", value, false, errorUtil.toString(
|
|
19600
|
+
lt(value, message) {
|
|
19601
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
19517
19602
|
}
|
|
19518
|
-
setLimit(kind, value, inclusive,
|
|
19603
|
+
setLimit(kind, value, inclusive, message) {
|
|
19519
19604
|
return new ZodNumber({
|
|
19520
19605
|
...this._def,
|
|
19521
19606
|
checks: [
|
|
@@ -19524,7 +19609,7 @@ class ZodNumber extends ZodType {
|
|
|
19524
19609
|
kind,
|
|
19525
19610
|
value,
|
|
19526
19611
|
inclusive,
|
|
19527
|
-
message: errorUtil.toString(
|
|
19612
|
+
message: errorUtil.toString(message)
|
|
19528
19613
|
}
|
|
19529
19614
|
]
|
|
19530
19615
|
});
|
|
@@ -19535,68 +19620,68 @@ class ZodNumber extends ZodType {
|
|
|
19535
19620
|
checks: [...this._def.checks, check]
|
|
19536
19621
|
});
|
|
19537
19622
|
}
|
|
19538
|
-
int(
|
|
19623
|
+
int(message) {
|
|
19539
19624
|
return this._addCheck({
|
|
19540
19625
|
kind: "int",
|
|
19541
|
-
message: errorUtil.toString(
|
|
19626
|
+
message: errorUtil.toString(message)
|
|
19542
19627
|
});
|
|
19543
19628
|
}
|
|
19544
|
-
positive(
|
|
19629
|
+
positive(message) {
|
|
19545
19630
|
return this._addCheck({
|
|
19546
19631
|
kind: "min",
|
|
19547
19632
|
value: 0,
|
|
19548
19633
|
inclusive: false,
|
|
19549
|
-
message: errorUtil.toString(
|
|
19634
|
+
message: errorUtil.toString(message)
|
|
19550
19635
|
});
|
|
19551
19636
|
}
|
|
19552
|
-
negative(
|
|
19637
|
+
negative(message) {
|
|
19553
19638
|
return this._addCheck({
|
|
19554
19639
|
kind: "max",
|
|
19555
19640
|
value: 0,
|
|
19556
19641
|
inclusive: false,
|
|
19557
|
-
message: errorUtil.toString(
|
|
19642
|
+
message: errorUtil.toString(message)
|
|
19558
19643
|
});
|
|
19559
19644
|
}
|
|
19560
|
-
nonpositive(
|
|
19645
|
+
nonpositive(message) {
|
|
19561
19646
|
return this._addCheck({
|
|
19562
19647
|
kind: "max",
|
|
19563
19648
|
value: 0,
|
|
19564
19649
|
inclusive: true,
|
|
19565
|
-
message: errorUtil.toString(
|
|
19650
|
+
message: errorUtil.toString(message)
|
|
19566
19651
|
});
|
|
19567
19652
|
}
|
|
19568
|
-
nonnegative(
|
|
19653
|
+
nonnegative(message) {
|
|
19569
19654
|
return this._addCheck({
|
|
19570
19655
|
kind: "min",
|
|
19571
19656
|
value: 0,
|
|
19572
19657
|
inclusive: true,
|
|
19573
|
-
message: errorUtil.toString(
|
|
19658
|
+
message: errorUtil.toString(message)
|
|
19574
19659
|
});
|
|
19575
19660
|
}
|
|
19576
|
-
multipleOf(value,
|
|
19661
|
+
multipleOf(value, message) {
|
|
19577
19662
|
return this._addCheck({
|
|
19578
19663
|
kind: "multipleOf",
|
|
19579
19664
|
value,
|
|
19580
|
-
message: errorUtil.toString(
|
|
19665
|
+
message: errorUtil.toString(message)
|
|
19581
19666
|
});
|
|
19582
19667
|
}
|
|
19583
|
-
finite(
|
|
19668
|
+
finite(message) {
|
|
19584
19669
|
return this._addCheck({
|
|
19585
19670
|
kind: "finite",
|
|
19586
|
-
message: errorUtil.toString(
|
|
19671
|
+
message: errorUtil.toString(message)
|
|
19587
19672
|
});
|
|
19588
19673
|
}
|
|
19589
|
-
safe(
|
|
19674
|
+
safe(message) {
|
|
19590
19675
|
return this._addCheck({
|
|
19591
19676
|
kind: "min",
|
|
19592
19677
|
inclusive: true,
|
|
19593
19678
|
value: Number.MIN_SAFE_INTEGER,
|
|
19594
|
-
message: errorUtil.toString(
|
|
19679
|
+
message: errorUtil.toString(message)
|
|
19595
19680
|
})._addCheck({
|
|
19596
19681
|
kind: "max",
|
|
19597
19682
|
inclusive: true,
|
|
19598
19683
|
value: Number.MAX_SAFE_INTEGER,
|
|
19599
|
-
message: errorUtil.toString(
|
|
19684
|
+
message: errorUtil.toString(message)
|
|
19600
19685
|
});
|
|
19601
19686
|
}
|
|
19602
19687
|
get minValue() {
|
|
@@ -19719,19 +19804,19 @@ class ZodBigInt extends ZodType {
|
|
|
19719
19804
|
});
|
|
19720
19805
|
return INVALID;
|
|
19721
19806
|
}
|
|
19722
|
-
gte(value,
|
|
19723
|
-
return this.setLimit("min", value, true, errorUtil.toString(
|
|
19807
|
+
gte(value, message) {
|
|
19808
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
19724
19809
|
}
|
|
19725
|
-
gt(value,
|
|
19726
|
-
return this.setLimit("min", value, false, errorUtil.toString(
|
|
19810
|
+
gt(value, message) {
|
|
19811
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
19727
19812
|
}
|
|
19728
|
-
lte(value,
|
|
19729
|
-
return this.setLimit("max", value, true, errorUtil.toString(
|
|
19813
|
+
lte(value, message) {
|
|
19814
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
19730
19815
|
}
|
|
19731
|
-
lt(value,
|
|
19732
|
-
return this.setLimit("max", value, false, errorUtil.toString(
|
|
19816
|
+
lt(value, message) {
|
|
19817
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
19733
19818
|
}
|
|
19734
|
-
setLimit(kind, value, inclusive,
|
|
19819
|
+
setLimit(kind, value, inclusive, message) {
|
|
19735
19820
|
return new ZodBigInt({
|
|
19736
19821
|
...this._def,
|
|
19737
19822
|
checks: [
|
|
@@ -19740,7 +19825,7 @@ class ZodBigInt extends ZodType {
|
|
|
19740
19825
|
kind,
|
|
19741
19826
|
value,
|
|
19742
19827
|
inclusive,
|
|
19743
|
-
message: errorUtil.toString(
|
|
19828
|
+
message: errorUtil.toString(message)
|
|
19744
19829
|
}
|
|
19745
19830
|
]
|
|
19746
19831
|
});
|
|
@@ -19751,43 +19836,43 @@ class ZodBigInt extends ZodType {
|
|
|
19751
19836
|
checks: [...this._def.checks, check]
|
|
19752
19837
|
});
|
|
19753
19838
|
}
|
|
19754
|
-
positive(
|
|
19839
|
+
positive(message) {
|
|
19755
19840
|
return this._addCheck({
|
|
19756
19841
|
kind: "min",
|
|
19757
19842
|
value: BigInt(0),
|
|
19758
19843
|
inclusive: false,
|
|
19759
|
-
message: errorUtil.toString(
|
|
19844
|
+
message: errorUtil.toString(message)
|
|
19760
19845
|
});
|
|
19761
19846
|
}
|
|
19762
|
-
negative(
|
|
19847
|
+
negative(message) {
|
|
19763
19848
|
return this._addCheck({
|
|
19764
19849
|
kind: "max",
|
|
19765
19850
|
value: BigInt(0),
|
|
19766
19851
|
inclusive: false,
|
|
19767
|
-
message: errorUtil.toString(
|
|
19852
|
+
message: errorUtil.toString(message)
|
|
19768
19853
|
});
|
|
19769
19854
|
}
|
|
19770
|
-
nonpositive(
|
|
19855
|
+
nonpositive(message) {
|
|
19771
19856
|
return this._addCheck({
|
|
19772
19857
|
kind: "max",
|
|
19773
19858
|
value: BigInt(0),
|
|
19774
19859
|
inclusive: true,
|
|
19775
|
-
message: errorUtil.toString(
|
|
19860
|
+
message: errorUtil.toString(message)
|
|
19776
19861
|
});
|
|
19777
19862
|
}
|
|
19778
|
-
nonnegative(
|
|
19863
|
+
nonnegative(message) {
|
|
19779
19864
|
return this._addCheck({
|
|
19780
19865
|
kind: "min",
|
|
19781
19866
|
value: BigInt(0),
|
|
19782
19867
|
inclusive: true,
|
|
19783
|
-
message: errorUtil.toString(
|
|
19868
|
+
message: errorUtil.toString(message)
|
|
19784
19869
|
});
|
|
19785
19870
|
}
|
|
19786
|
-
multipleOf(value,
|
|
19871
|
+
multipleOf(value, message) {
|
|
19787
19872
|
return this._addCheck({
|
|
19788
19873
|
kind: "multipleOf",
|
|
19789
19874
|
value,
|
|
19790
|
-
message: errorUtil.toString(
|
|
19875
|
+
message: errorUtil.toString(message)
|
|
19791
19876
|
});
|
|
19792
19877
|
}
|
|
19793
19878
|
get minValue() {
|
|
@@ -19910,18 +19995,18 @@ class ZodDate extends ZodType {
|
|
|
19910
19995
|
checks: [...this._def.checks, check]
|
|
19911
19996
|
});
|
|
19912
19997
|
}
|
|
19913
|
-
min(minDate,
|
|
19998
|
+
min(minDate, message) {
|
|
19914
19999
|
return this._addCheck({
|
|
19915
20000
|
kind: "min",
|
|
19916
20001
|
value: minDate.getTime(),
|
|
19917
|
-
message: errorUtil.toString(
|
|
20002
|
+
message: errorUtil.toString(message)
|
|
19918
20003
|
});
|
|
19919
20004
|
}
|
|
19920
|
-
max(maxDate,
|
|
20005
|
+
max(maxDate, message) {
|
|
19921
20006
|
return this._addCheck({
|
|
19922
20007
|
kind: "max",
|
|
19923
20008
|
value: maxDate.getTime(),
|
|
19924
|
-
message: errorUtil.toString(
|
|
20009
|
+
message: errorUtil.toString(message)
|
|
19925
20010
|
});
|
|
19926
20011
|
}
|
|
19927
20012
|
get minDate() {
|
|
@@ -20153,26 +20238,26 @@ class ZodArray extends ZodType {
|
|
|
20153
20238
|
get element() {
|
|
20154
20239
|
return this._def.type;
|
|
20155
20240
|
}
|
|
20156
|
-
min(minLength,
|
|
20241
|
+
min(minLength, message) {
|
|
20157
20242
|
return new ZodArray({
|
|
20158
20243
|
...this._def,
|
|
20159
|
-
minLength: { value: minLength, message: errorUtil.toString(
|
|
20244
|
+
minLength: { value: minLength, message: errorUtil.toString(message) }
|
|
20160
20245
|
});
|
|
20161
20246
|
}
|
|
20162
|
-
max(maxLength,
|
|
20247
|
+
max(maxLength, message) {
|
|
20163
20248
|
return new ZodArray({
|
|
20164
20249
|
...this._def,
|
|
20165
|
-
maxLength: { value: maxLength, message: errorUtil.toString(
|
|
20250
|
+
maxLength: { value: maxLength, message: errorUtil.toString(message) }
|
|
20166
20251
|
});
|
|
20167
20252
|
}
|
|
20168
|
-
length(len,
|
|
20253
|
+
length(len, message) {
|
|
20169
20254
|
return new ZodArray({
|
|
20170
20255
|
...this._def,
|
|
20171
|
-
exactLength: { value: len, message: errorUtil.toString(
|
|
20256
|
+
exactLength: { value: len, message: errorUtil.toString(message) }
|
|
20172
20257
|
});
|
|
20173
20258
|
}
|
|
20174
|
-
nonempty(
|
|
20175
|
-
return this.min(1,
|
|
20259
|
+
nonempty(message) {
|
|
20260
|
+
return this.min(1, message);
|
|
20176
20261
|
}
|
|
20177
20262
|
}
|
|
20178
20263
|
ZodArray.create = (schema, params) => {
|
|
@@ -20315,17 +20400,17 @@ class ZodObject extends ZodType {
|
|
|
20315
20400
|
get shape() {
|
|
20316
20401
|
return this._def.shape();
|
|
20317
20402
|
}
|
|
20318
|
-
strict(
|
|
20403
|
+
strict(message) {
|
|
20319
20404
|
errorUtil.errToObj;
|
|
20320
20405
|
return new ZodObject({
|
|
20321
20406
|
...this._def,
|
|
20322
20407
|
unknownKeys: "strict",
|
|
20323
|
-
...
|
|
20408
|
+
...message !== void 0 ? {
|
|
20324
20409
|
errorMap: (issue, ctx) => {
|
|
20325
20410
|
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
20326
20411
|
if (issue.code === "unrecognized_keys")
|
|
20327
20412
|
return {
|
|
20328
|
-
message: errorUtil.errToObj(
|
|
20413
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
|
20329
20414
|
};
|
|
20330
20415
|
return {
|
|
20331
20416
|
message: defaultError
|
|
@@ -20921,23 +21006,23 @@ class ZodSet extends ZodType {
|
|
|
20921
21006
|
return finalizeSet(elements);
|
|
20922
21007
|
}
|
|
20923
21008
|
}
|
|
20924
|
-
min(minSize,
|
|
21009
|
+
min(minSize, message) {
|
|
20925
21010
|
return new ZodSet({
|
|
20926
21011
|
...this._def,
|
|
20927
|
-
minSize: { value: minSize, message: errorUtil.toString(
|
|
21012
|
+
minSize: { value: minSize, message: errorUtil.toString(message) }
|
|
20928
21013
|
});
|
|
20929
21014
|
}
|
|
20930
|
-
max(maxSize,
|
|
21015
|
+
max(maxSize, message) {
|
|
20931
21016
|
return new ZodSet({
|
|
20932
21017
|
...this._def,
|
|
20933
|
-
maxSize: { value: maxSize, message: errorUtil.toString(
|
|
21018
|
+
maxSize: { value: maxSize, message: errorUtil.toString(message) }
|
|
20934
21019
|
});
|
|
20935
21020
|
}
|
|
20936
|
-
size(size,
|
|
20937
|
-
return this.min(size,
|
|
21021
|
+
size(size, message) {
|
|
21022
|
+
return this.min(size, message).max(size, message);
|
|
20938
21023
|
}
|
|
20939
|
-
nonempty(
|
|
20940
|
-
return this.min(1,
|
|
21024
|
+
nonempty(message) {
|
|
21025
|
+
return this.min(1, message);
|
|
20941
21026
|
}
|
|
20942
21027
|
}
|
|
20943
21028
|
ZodSet.create = (valueType, params) => {
|
|
@@ -21552,26 +21637,53 @@ function createGoogleProvider(clientId) {
|
|
|
21552
21637
|
return {
|
|
21553
21638
|
id: "google",
|
|
21554
21639
|
schema: objectType({
|
|
21555
|
-
idToken: stringType().min(1,
|
|
21640
|
+
idToken: stringType().min(1).optional(),
|
|
21641
|
+
accessToken: stringType().min(1).optional()
|
|
21642
|
+
}).refine((data) => data.idToken || data.accessToken, {
|
|
21643
|
+
message: "Either idToken or accessToken is required"
|
|
21556
21644
|
}),
|
|
21557
21645
|
verify: async (payload) => {
|
|
21558
21646
|
try {
|
|
21559
|
-
|
|
21560
|
-
|
|
21561
|
-
|
|
21562
|
-
|
|
21563
|
-
|
|
21564
|
-
|
|
21565
|
-
|
|
21647
|
+
if (payload.idToken) {
|
|
21648
|
+
const ticket = await googleClient.verifyIdToken({
|
|
21649
|
+
idToken: payload.idToken,
|
|
21650
|
+
audience: clientId
|
|
21651
|
+
});
|
|
21652
|
+
const content = ticket.getPayload();
|
|
21653
|
+
if (!content) {
|
|
21654
|
+
return null;
|
|
21655
|
+
}
|
|
21656
|
+
return {
|
|
21657
|
+
providerId: content.sub,
|
|
21658
|
+
email: content.email || "",
|
|
21659
|
+
displayName: content.name || null,
|
|
21660
|
+
photoUrl: content.picture || null
|
|
21661
|
+
};
|
|
21566
21662
|
}
|
|
21567
|
-
|
|
21568
|
-
|
|
21569
|
-
|
|
21570
|
-
|
|
21571
|
-
|
|
21572
|
-
|
|
21663
|
+
if (payload.accessToken) {
|
|
21664
|
+
const res = await fetch("https://www.googleapis.com/oauth2/v3/userinfo", {
|
|
21665
|
+
headers: {
|
|
21666
|
+
Authorization: `Bearer ${payload.accessToken}`
|
|
21667
|
+
}
|
|
21668
|
+
});
|
|
21669
|
+
if (!res.ok) {
|
|
21670
|
+
console.error("Google userinfo request failed:", res.status);
|
|
21671
|
+
return null;
|
|
21672
|
+
}
|
|
21673
|
+
const info = await res.json();
|
|
21674
|
+
if (!info.sub || !info.email) {
|
|
21675
|
+
return null;
|
|
21676
|
+
}
|
|
21677
|
+
return {
|
|
21678
|
+
providerId: info.sub,
|
|
21679
|
+
email: info.email,
|
|
21680
|
+
displayName: info.name || null,
|
|
21681
|
+
photoUrl: info.picture || null
|
|
21682
|
+
};
|
|
21683
|
+
}
|
|
21684
|
+
return null;
|
|
21573
21685
|
} catch (error2) {
|
|
21574
|
-
console.error("Failed to verify Google
|
|
21686
|
+
console.error("Failed to verify Google token:", error2);
|
|
21575
21687
|
return null;
|
|
21576
21688
|
}
|
|
21577
21689
|
}
|
|
@@ -21764,1002 +21876,16 @@ function createMicrosoftProvider(config) {
|
|
|
21764
21876
|
}
|
|
21765
21877
|
};
|
|
21766
21878
|
}
|
|
21767
|
-
const encoder = new TextEncoder();
|
|
21768
|
-
const decoder = new TextDecoder();
|
|
21769
|
-
function concat(...buffers) {
|
|
21770
|
-
const size = buffers.reduce((acc, { length }) => acc + length, 0);
|
|
21771
|
-
const buf = new Uint8Array(size);
|
|
21772
|
-
let i = 0;
|
|
21773
|
-
for (const buffer of buffers) {
|
|
21774
|
-
buf.set(buffer, i);
|
|
21775
|
-
i += buffer.length;
|
|
21776
|
-
}
|
|
21777
|
-
return buf;
|
|
21778
|
-
}
|
|
21779
|
-
function encode$4(string) {
|
|
21780
|
-
const bytes = new Uint8Array(string.length);
|
|
21781
|
-
for (let i = 0; i < string.length; i++) {
|
|
21782
|
-
const code2 = string.charCodeAt(i);
|
|
21783
|
-
if (code2 > 127) {
|
|
21784
|
-
throw new TypeError("non-ASCII string encountered in encode()");
|
|
21785
|
-
}
|
|
21786
|
-
bytes[i] = code2;
|
|
21787
|
-
}
|
|
21788
|
-
return bytes;
|
|
21789
|
-
}
|
|
21790
|
-
function encodeBase64(input) {
|
|
21791
|
-
if (Uint8Array.prototype.toBase64) {
|
|
21792
|
-
return input.toBase64();
|
|
21793
|
-
}
|
|
21794
|
-
const CHUNK_SIZE = 32768;
|
|
21795
|
-
const arr = [];
|
|
21796
|
-
for (let i = 0; i < input.length; i += CHUNK_SIZE) {
|
|
21797
|
-
arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
|
|
21798
|
-
}
|
|
21799
|
-
return btoa(arr.join(""));
|
|
21800
|
-
}
|
|
21801
|
-
function decodeBase64(encoded) {
|
|
21802
|
-
if (Uint8Array.fromBase64) {
|
|
21803
|
-
return Uint8Array.fromBase64(encoded);
|
|
21804
|
-
}
|
|
21805
|
-
const binary = atob(encoded);
|
|
21806
|
-
const bytes = new Uint8Array(binary.length);
|
|
21807
|
-
for (let i = 0; i < binary.length; i++) {
|
|
21808
|
-
bytes[i] = binary.charCodeAt(i);
|
|
21809
|
-
}
|
|
21810
|
-
return bytes;
|
|
21811
|
-
}
|
|
21812
|
-
function decode$1(input) {
|
|
21813
|
-
if (Uint8Array.fromBase64) {
|
|
21814
|
-
return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
|
|
21815
|
-
alphabet: "base64url"
|
|
21816
|
-
});
|
|
21817
|
-
}
|
|
21818
|
-
let encoded = input;
|
|
21819
|
-
if (encoded instanceof Uint8Array) {
|
|
21820
|
-
encoded = decoder.decode(encoded);
|
|
21821
|
-
}
|
|
21822
|
-
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
21823
|
-
try {
|
|
21824
|
-
return decodeBase64(encoded);
|
|
21825
|
-
} catch {
|
|
21826
|
-
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
21827
|
-
}
|
|
21828
|
-
}
|
|
21829
|
-
function encode$3(input) {
|
|
21830
|
-
let unencoded = input;
|
|
21831
|
-
if (typeof unencoded === "string") {
|
|
21832
|
-
unencoded = encoder.encode(unencoded);
|
|
21833
|
-
}
|
|
21834
|
-
if (Uint8Array.prototype.toBase64) {
|
|
21835
|
-
return unencoded.toBase64({ alphabet: "base64url", omitPadding: true });
|
|
21836
|
-
}
|
|
21837
|
-
return encodeBase64(unencoded).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
21838
|
-
}
|
|
21839
|
-
const unusable = (name2, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name2}`);
|
|
21840
|
-
const isAlgorithm = (algorithm, name2) => algorithm.name === name2;
|
|
21841
|
-
function getHashLength(hash) {
|
|
21842
|
-
return parseInt(hash.name.slice(4), 10);
|
|
21843
|
-
}
|
|
21844
|
-
function checkHashLength(algorithm, expected) {
|
|
21845
|
-
const actual = getHashLength(algorithm.hash);
|
|
21846
|
-
if (actual !== expected)
|
|
21847
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
21848
|
-
}
|
|
21849
|
-
function getNamedCurve(alg) {
|
|
21850
|
-
switch (alg) {
|
|
21851
|
-
case "ES256":
|
|
21852
|
-
return "P-256";
|
|
21853
|
-
case "ES384":
|
|
21854
|
-
return "P-384";
|
|
21855
|
-
case "ES512":
|
|
21856
|
-
return "P-521";
|
|
21857
|
-
default:
|
|
21858
|
-
throw new Error("unreachable");
|
|
21859
|
-
}
|
|
21860
|
-
}
|
|
21861
|
-
function checkUsage(key, usage) {
|
|
21862
|
-
if (!key.usages.includes(usage)) {
|
|
21863
|
-
throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
21864
|
-
}
|
|
21865
|
-
}
|
|
21866
|
-
function checkSigCryptoKey(key, alg, usage) {
|
|
21867
|
-
switch (alg) {
|
|
21868
|
-
case "HS256":
|
|
21869
|
-
case "HS384":
|
|
21870
|
-
case "HS512": {
|
|
21871
|
-
if (!isAlgorithm(key.algorithm, "HMAC"))
|
|
21872
|
-
throw unusable("HMAC");
|
|
21873
|
-
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
21874
|
-
break;
|
|
21875
|
-
}
|
|
21876
|
-
case "RS256":
|
|
21877
|
-
case "RS384":
|
|
21878
|
-
case "RS512": {
|
|
21879
|
-
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
21880
|
-
throw unusable("RSASSA-PKCS1-v1_5");
|
|
21881
|
-
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
21882
|
-
break;
|
|
21883
|
-
}
|
|
21884
|
-
case "PS256":
|
|
21885
|
-
case "PS384":
|
|
21886
|
-
case "PS512": {
|
|
21887
|
-
if (!isAlgorithm(key.algorithm, "RSA-PSS"))
|
|
21888
|
-
throw unusable("RSA-PSS");
|
|
21889
|
-
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
21890
|
-
break;
|
|
21891
|
-
}
|
|
21892
|
-
case "Ed25519":
|
|
21893
|
-
case "EdDSA": {
|
|
21894
|
-
if (!isAlgorithm(key.algorithm, "Ed25519"))
|
|
21895
|
-
throw unusable("Ed25519");
|
|
21896
|
-
break;
|
|
21897
|
-
}
|
|
21898
|
-
case "ML-DSA-44":
|
|
21899
|
-
case "ML-DSA-65":
|
|
21900
|
-
case "ML-DSA-87": {
|
|
21901
|
-
if (!isAlgorithm(key.algorithm, alg))
|
|
21902
|
-
throw unusable(alg);
|
|
21903
|
-
break;
|
|
21904
|
-
}
|
|
21905
|
-
case "ES256":
|
|
21906
|
-
case "ES384":
|
|
21907
|
-
case "ES512": {
|
|
21908
|
-
if (!isAlgorithm(key.algorithm, "ECDSA"))
|
|
21909
|
-
throw unusable("ECDSA");
|
|
21910
|
-
const expected = getNamedCurve(alg);
|
|
21911
|
-
const actual = key.algorithm.namedCurve;
|
|
21912
|
-
if (actual !== expected)
|
|
21913
|
-
throw unusable(expected, "algorithm.namedCurve");
|
|
21914
|
-
break;
|
|
21915
|
-
}
|
|
21916
|
-
default:
|
|
21917
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
21918
|
-
}
|
|
21919
|
-
checkUsage(key, usage);
|
|
21920
|
-
}
|
|
21921
|
-
function message(msg, actual, ...types2) {
|
|
21922
|
-
types2 = types2.filter(Boolean);
|
|
21923
|
-
if (types2.length > 2) {
|
|
21924
|
-
const last = types2.pop();
|
|
21925
|
-
msg += `one of type ${types2.join(", ")}, or ${last}.`;
|
|
21926
|
-
} else if (types2.length === 2) {
|
|
21927
|
-
msg += `one of type ${types2[0]} or ${types2[1]}.`;
|
|
21928
|
-
} else {
|
|
21929
|
-
msg += `of type ${types2[0]}.`;
|
|
21930
|
-
}
|
|
21931
|
-
if (actual == null) {
|
|
21932
|
-
msg += ` Received ${actual}`;
|
|
21933
|
-
} else if (typeof actual === "function" && actual.name) {
|
|
21934
|
-
msg += ` Received function ${actual.name}`;
|
|
21935
|
-
} else if (typeof actual === "object" && actual != null) {
|
|
21936
|
-
if (actual.constructor?.name) {
|
|
21937
|
-
msg += ` Received an instance of ${actual.constructor.name}`;
|
|
21938
|
-
}
|
|
21939
|
-
}
|
|
21940
|
-
return msg;
|
|
21941
|
-
}
|
|
21942
|
-
const invalidKeyInput = (actual, ...types2) => message("Key must be ", actual, ...types2);
|
|
21943
|
-
const withAlg = (alg, actual, ...types2) => message(`Key for the ${alg} algorithm must be `, actual, ...types2);
|
|
21944
|
-
class JOSEError extends Error {
|
|
21945
|
-
static code = "ERR_JOSE_GENERIC";
|
|
21946
|
-
code = "ERR_JOSE_GENERIC";
|
|
21947
|
-
constructor(message2, options2) {
|
|
21948
|
-
super(message2, options2);
|
|
21949
|
-
this.name = this.constructor.name;
|
|
21950
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
21951
|
-
}
|
|
21952
|
-
}
|
|
21953
|
-
class JOSENotSupported extends JOSEError {
|
|
21954
|
-
static code = "ERR_JOSE_NOT_SUPPORTED";
|
|
21955
|
-
code = "ERR_JOSE_NOT_SUPPORTED";
|
|
21956
|
-
}
|
|
21957
|
-
class JWSInvalid extends JOSEError {
|
|
21958
|
-
static code = "ERR_JWS_INVALID";
|
|
21959
|
-
code = "ERR_JWS_INVALID";
|
|
21960
|
-
}
|
|
21961
|
-
class JWTInvalid extends JOSEError {
|
|
21962
|
-
static code = "ERR_JWT_INVALID";
|
|
21963
|
-
code = "ERR_JWT_INVALID";
|
|
21964
|
-
}
|
|
21965
|
-
const isCryptoKey = (key) => {
|
|
21966
|
-
if (key?.[Symbol.toStringTag] === "CryptoKey")
|
|
21967
|
-
return true;
|
|
21968
|
-
try {
|
|
21969
|
-
return key instanceof CryptoKey;
|
|
21970
|
-
} catch {
|
|
21971
|
-
return false;
|
|
21972
|
-
}
|
|
21973
|
-
};
|
|
21974
|
-
const isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
|
|
21975
|
-
const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
21976
|
-
function assertNotSet(value, name2) {
|
|
21977
|
-
if (value) {
|
|
21978
|
-
throw new TypeError(`${name2} can only be called once`);
|
|
21979
|
-
}
|
|
21980
|
-
}
|
|
21981
|
-
const isObjectLike$1 = (value) => typeof value === "object" && value !== null;
|
|
21982
|
-
function isObject(input) {
|
|
21983
|
-
if (!isObjectLike$1(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
21984
|
-
return false;
|
|
21985
|
-
}
|
|
21986
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
21987
|
-
return true;
|
|
21988
|
-
}
|
|
21989
|
-
let proto = input;
|
|
21990
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
21991
|
-
proto = Object.getPrototypeOf(proto);
|
|
21992
|
-
}
|
|
21993
|
-
return Object.getPrototypeOf(input) === proto;
|
|
21994
|
-
}
|
|
21995
|
-
function isDisjoint(...headers) {
|
|
21996
|
-
const sources = headers.filter(Boolean);
|
|
21997
|
-
if (sources.length === 0 || sources.length === 1) {
|
|
21998
|
-
return true;
|
|
21999
|
-
}
|
|
22000
|
-
let acc;
|
|
22001
|
-
for (const header of sources) {
|
|
22002
|
-
const parameters = Object.keys(header);
|
|
22003
|
-
if (!acc || acc.size === 0) {
|
|
22004
|
-
acc = new Set(parameters);
|
|
22005
|
-
continue;
|
|
22006
|
-
}
|
|
22007
|
-
for (const parameter of parameters) {
|
|
22008
|
-
if (acc.has(parameter)) {
|
|
22009
|
-
return false;
|
|
22010
|
-
}
|
|
22011
|
-
acc.add(parameter);
|
|
22012
|
-
}
|
|
22013
|
-
}
|
|
22014
|
-
return true;
|
|
22015
|
-
}
|
|
22016
|
-
const isJWK = (key) => isObject(key) && typeof key.kty === "string";
|
|
22017
|
-
const isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
22018
|
-
const isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
|
|
22019
|
-
const isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
22020
|
-
function checkKeyLength(alg, key) {
|
|
22021
|
-
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
22022
|
-
const { modulusLength } = key.algorithm;
|
|
22023
|
-
if (typeof modulusLength !== "number" || modulusLength < 2048) {
|
|
22024
|
-
throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
22025
|
-
}
|
|
22026
|
-
}
|
|
22027
|
-
}
|
|
22028
|
-
function subtleAlgorithm(alg, algorithm) {
|
|
22029
|
-
const hash = `SHA-${alg.slice(-3)}`;
|
|
22030
|
-
switch (alg) {
|
|
22031
|
-
case "HS256":
|
|
22032
|
-
case "HS384":
|
|
22033
|
-
case "HS512":
|
|
22034
|
-
return { hash, name: "HMAC" };
|
|
22035
|
-
case "PS256":
|
|
22036
|
-
case "PS384":
|
|
22037
|
-
case "PS512":
|
|
22038
|
-
return { hash, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
|
|
22039
|
-
case "RS256":
|
|
22040
|
-
case "RS384":
|
|
22041
|
-
case "RS512":
|
|
22042
|
-
return { hash, name: "RSASSA-PKCS1-v1_5" };
|
|
22043
|
-
case "ES256":
|
|
22044
|
-
case "ES384":
|
|
22045
|
-
case "ES512":
|
|
22046
|
-
return { hash, name: "ECDSA", namedCurve: algorithm.namedCurve };
|
|
22047
|
-
case "Ed25519":
|
|
22048
|
-
case "EdDSA":
|
|
22049
|
-
return { name: "Ed25519" };
|
|
22050
|
-
case "ML-DSA-44":
|
|
22051
|
-
case "ML-DSA-65":
|
|
22052
|
-
case "ML-DSA-87":
|
|
22053
|
-
return { name: alg };
|
|
22054
|
-
default:
|
|
22055
|
-
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
22056
|
-
}
|
|
22057
|
-
}
|
|
22058
|
-
async function getSigKey(alg, key, usage) {
|
|
22059
|
-
if (key instanceof Uint8Array) {
|
|
22060
|
-
if (!alg.startsWith("HS")) {
|
|
22061
|
-
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
22062
|
-
}
|
|
22063
|
-
return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
|
|
22064
|
-
}
|
|
22065
|
-
checkSigCryptoKey(key, alg, usage);
|
|
22066
|
-
return key;
|
|
22067
|
-
}
|
|
22068
|
-
async function sign$2(alg, key, data) {
|
|
22069
|
-
const cryptoKey = await getSigKey(alg, key, "sign");
|
|
22070
|
-
checkKeyLength(alg, cryptoKey);
|
|
22071
|
-
const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm), cryptoKey, data);
|
|
22072
|
-
return new Uint8Array(signature);
|
|
22073
|
-
}
|
|
22074
|
-
const unsupportedAlg = 'Invalid or unsupported JWK "alg" (Algorithm) Parameter value';
|
|
22075
|
-
function subtleMapping(jwk) {
|
|
22076
|
-
let algorithm;
|
|
22077
|
-
let keyUsages;
|
|
22078
|
-
switch (jwk.kty) {
|
|
22079
|
-
case "AKP": {
|
|
22080
|
-
switch (jwk.alg) {
|
|
22081
|
-
case "ML-DSA-44":
|
|
22082
|
-
case "ML-DSA-65":
|
|
22083
|
-
case "ML-DSA-87":
|
|
22084
|
-
algorithm = { name: jwk.alg };
|
|
22085
|
-
keyUsages = jwk.priv ? ["sign"] : ["verify"];
|
|
22086
|
-
break;
|
|
22087
|
-
default:
|
|
22088
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
22089
|
-
}
|
|
22090
|
-
break;
|
|
22091
|
-
}
|
|
22092
|
-
case "RSA": {
|
|
22093
|
-
switch (jwk.alg) {
|
|
22094
|
-
case "PS256":
|
|
22095
|
-
case "PS384":
|
|
22096
|
-
case "PS512":
|
|
22097
|
-
algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
22098
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
22099
|
-
break;
|
|
22100
|
-
case "RS256":
|
|
22101
|
-
case "RS384":
|
|
22102
|
-
case "RS512":
|
|
22103
|
-
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
22104
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
22105
|
-
break;
|
|
22106
|
-
case "RSA-OAEP":
|
|
22107
|
-
case "RSA-OAEP-256":
|
|
22108
|
-
case "RSA-OAEP-384":
|
|
22109
|
-
case "RSA-OAEP-512":
|
|
22110
|
-
algorithm = {
|
|
22111
|
-
name: "RSA-OAEP",
|
|
22112
|
-
hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
|
|
22113
|
-
};
|
|
22114
|
-
keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
22115
|
-
break;
|
|
22116
|
-
default:
|
|
22117
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
22118
|
-
}
|
|
22119
|
-
break;
|
|
22120
|
-
}
|
|
22121
|
-
case "EC": {
|
|
22122
|
-
switch (jwk.alg) {
|
|
22123
|
-
case "ES256":
|
|
22124
|
-
case "ES384":
|
|
22125
|
-
case "ES512":
|
|
22126
|
-
algorithm = {
|
|
22127
|
-
name: "ECDSA",
|
|
22128
|
-
namedCurve: { ES256: "P-256", ES384: "P-384", ES512: "P-521" }[jwk.alg]
|
|
22129
|
-
};
|
|
22130
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
22131
|
-
break;
|
|
22132
|
-
case "ECDH-ES":
|
|
22133
|
-
case "ECDH-ES+A128KW":
|
|
22134
|
-
case "ECDH-ES+A192KW":
|
|
22135
|
-
case "ECDH-ES+A256KW":
|
|
22136
|
-
algorithm = { name: "ECDH", namedCurve: jwk.crv };
|
|
22137
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
22138
|
-
break;
|
|
22139
|
-
default:
|
|
22140
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
22141
|
-
}
|
|
22142
|
-
break;
|
|
22143
|
-
}
|
|
22144
|
-
case "OKP": {
|
|
22145
|
-
switch (jwk.alg) {
|
|
22146
|
-
case "Ed25519":
|
|
22147
|
-
case "EdDSA":
|
|
22148
|
-
algorithm = { name: "Ed25519" };
|
|
22149
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
22150
|
-
break;
|
|
22151
|
-
case "ECDH-ES":
|
|
22152
|
-
case "ECDH-ES+A128KW":
|
|
22153
|
-
case "ECDH-ES+A192KW":
|
|
22154
|
-
case "ECDH-ES+A256KW":
|
|
22155
|
-
algorithm = { name: jwk.crv };
|
|
22156
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
22157
|
-
break;
|
|
22158
|
-
default:
|
|
22159
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
22160
|
-
}
|
|
22161
|
-
break;
|
|
22162
|
-
}
|
|
22163
|
-
default:
|
|
22164
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
22165
|
-
}
|
|
22166
|
-
return { algorithm, keyUsages };
|
|
22167
|
-
}
|
|
22168
|
-
async function jwkToKey(jwk) {
|
|
22169
|
-
if (!jwk.alg) {
|
|
22170
|
-
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
22171
|
-
}
|
|
22172
|
-
const { algorithm, keyUsages } = subtleMapping(jwk);
|
|
22173
|
-
const keyData = { ...jwk };
|
|
22174
|
-
if (keyData.kty !== "AKP") {
|
|
22175
|
-
delete keyData.alg;
|
|
22176
|
-
}
|
|
22177
|
-
delete keyData.use;
|
|
22178
|
-
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
22179
|
-
}
|
|
22180
|
-
const unusableForAlg = "given KeyObject instance cannot be used for this algorithm";
|
|
22181
|
-
let cache;
|
|
22182
|
-
const handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
22183
|
-
cache ||= /* @__PURE__ */ new WeakMap();
|
|
22184
|
-
let cached = cache.get(key);
|
|
22185
|
-
if (cached?.[alg]) {
|
|
22186
|
-
return cached[alg];
|
|
22187
|
-
}
|
|
22188
|
-
const cryptoKey = await jwkToKey({ ...jwk, alg });
|
|
22189
|
-
if (freeze)
|
|
22190
|
-
Object.freeze(key);
|
|
22191
|
-
if (!cached) {
|
|
22192
|
-
cache.set(key, { [alg]: cryptoKey });
|
|
22193
|
-
} else {
|
|
22194
|
-
cached[alg] = cryptoKey;
|
|
22195
|
-
}
|
|
22196
|
-
return cryptoKey;
|
|
22197
|
-
};
|
|
22198
|
-
const handleKeyObject = (keyObject, alg) => {
|
|
22199
|
-
cache ||= /* @__PURE__ */ new WeakMap();
|
|
22200
|
-
let cached = cache.get(keyObject);
|
|
22201
|
-
if (cached?.[alg]) {
|
|
22202
|
-
return cached[alg];
|
|
22203
|
-
}
|
|
22204
|
-
const isPublic = keyObject.type === "public";
|
|
22205
|
-
const extractable = isPublic ? true : false;
|
|
22206
|
-
let cryptoKey;
|
|
22207
|
-
if (keyObject.asymmetricKeyType === "x25519") {
|
|
22208
|
-
switch (alg) {
|
|
22209
|
-
case "ECDH-ES":
|
|
22210
|
-
case "ECDH-ES+A128KW":
|
|
22211
|
-
case "ECDH-ES+A192KW":
|
|
22212
|
-
case "ECDH-ES+A256KW":
|
|
22213
|
-
break;
|
|
22214
|
-
default:
|
|
22215
|
-
throw new TypeError(unusableForAlg);
|
|
22216
|
-
}
|
|
22217
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
|
|
22218
|
-
}
|
|
22219
|
-
if (keyObject.asymmetricKeyType === "ed25519") {
|
|
22220
|
-
if (alg !== "EdDSA" && alg !== "Ed25519") {
|
|
22221
|
-
throw new TypeError(unusableForAlg);
|
|
22222
|
-
}
|
|
22223
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
22224
|
-
isPublic ? "verify" : "sign"
|
|
22225
|
-
]);
|
|
22226
|
-
}
|
|
22227
|
-
switch (keyObject.asymmetricKeyType) {
|
|
22228
|
-
case "ml-dsa-44":
|
|
22229
|
-
case "ml-dsa-65":
|
|
22230
|
-
case "ml-dsa-87": {
|
|
22231
|
-
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
|
|
22232
|
-
throw new TypeError(unusableForAlg);
|
|
22233
|
-
}
|
|
22234
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
22235
|
-
isPublic ? "verify" : "sign"
|
|
22236
|
-
]);
|
|
22237
|
-
}
|
|
22238
|
-
}
|
|
22239
|
-
if (keyObject.asymmetricKeyType === "rsa") {
|
|
22240
|
-
let hash;
|
|
22241
|
-
switch (alg) {
|
|
22242
|
-
case "RSA-OAEP":
|
|
22243
|
-
hash = "SHA-1";
|
|
22244
|
-
break;
|
|
22245
|
-
case "RS256":
|
|
22246
|
-
case "PS256":
|
|
22247
|
-
case "RSA-OAEP-256":
|
|
22248
|
-
hash = "SHA-256";
|
|
22249
|
-
break;
|
|
22250
|
-
case "RS384":
|
|
22251
|
-
case "PS384":
|
|
22252
|
-
case "RSA-OAEP-384":
|
|
22253
|
-
hash = "SHA-384";
|
|
22254
|
-
break;
|
|
22255
|
-
case "RS512":
|
|
22256
|
-
case "PS512":
|
|
22257
|
-
case "RSA-OAEP-512":
|
|
22258
|
-
hash = "SHA-512";
|
|
22259
|
-
break;
|
|
22260
|
-
default:
|
|
22261
|
-
throw new TypeError(unusableForAlg);
|
|
22262
|
-
}
|
|
22263
|
-
if (alg.startsWith("RSA-OAEP")) {
|
|
22264
|
-
return keyObject.toCryptoKey({
|
|
22265
|
-
name: "RSA-OAEP",
|
|
22266
|
-
hash
|
|
22267
|
-
}, extractable, isPublic ? ["encrypt"] : ["decrypt"]);
|
|
22268
|
-
}
|
|
22269
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
22270
|
-
name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
22271
|
-
hash
|
|
22272
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
22273
|
-
}
|
|
22274
|
-
if (keyObject.asymmetricKeyType === "ec") {
|
|
22275
|
-
const nist = /* @__PURE__ */ new Map([
|
|
22276
|
-
["prime256v1", "P-256"],
|
|
22277
|
-
["secp384r1", "P-384"],
|
|
22278
|
-
["secp521r1", "P-521"]
|
|
22279
|
-
]);
|
|
22280
|
-
const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
|
|
22281
|
-
if (!namedCurve) {
|
|
22282
|
-
throw new TypeError(unusableForAlg);
|
|
22283
|
-
}
|
|
22284
|
-
const expectedCurve = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
|
|
22285
|
-
if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {
|
|
22286
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
22287
|
-
name: "ECDSA",
|
|
22288
|
-
namedCurve
|
|
22289
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
22290
|
-
}
|
|
22291
|
-
if (alg.startsWith("ECDH-ES")) {
|
|
22292
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
22293
|
-
name: "ECDH",
|
|
22294
|
-
namedCurve
|
|
22295
|
-
}, extractable, isPublic ? [] : ["deriveBits"]);
|
|
22296
|
-
}
|
|
22297
|
-
}
|
|
22298
|
-
if (!cryptoKey) {
|
|
22299
|
-
throw new TypeError(unusableForAlg);
|
|
22300
|
-
}
|
|
22301
|
-
if (!cached) {
|
|
22302
|
-
cache.set(keyObject, { [alg]: cryptoKey });
|
|
22303
|
-
} else {
|
|
22304
|
-
cached[alg] = cryptoKey;
|
|
22305
|
-
}
|
|
22306
|
-
return cryptoKey;
|
|
22307
|
-
};
|
|
22308
|
-
async function normalizeKey$1(key, alg) {
|
|
22309
|
-
if (key instanceof Uint8Array) {
|
|
22310
|
-
return key;
|
|
22311
|
-
}
|
|
22312
|
-
if (isCryptoKey(key)) {
|
|
22313
|
-
return key;
|
|
22314
|
-
}
|
|
22315
|
-
if (isKeyObject(key)) {
|
|
22316
|
-
if (key.type === "secret") {
|
|
22317
|
-
return key.export();
|
|
22318
|
-
}
|
|
22319
|
-
if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") {
|
|
22320
|
-
try {
|
|
22321
|
-
return handleKeyObject(key, alg);
|
|
22322
|
-
} catch (err) {
|
|
22323
|
-
if (err instanceof TypeError) {
|
|
22324
|
-
throw err;
|
|
22325
|
-
}
|
|
22326
|
-
}
|
|
22327
|
-
}
|
|
22328
|
-
let jwk = key.export({ format: "jwk" });
|
|
22329
|
-
return handleJWK(key, jwk, alg);
|
|
22330
|
-
}
|
|
22331
|
-
if (isJWK(key)) {
|
|
22332
|
-
if (key.k) {
|
|
22333
|
-
return decode$1(key.k);
|
|
22334
|
-
}
|
|
22335
|
-
return handleJWK(key, key, alg, true);
|
|
22336
|
-
}
|
|
22337
|
-
throw new Error("unreachable");
|
|
22338
|
-
}
|
|
22339
|
-
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
22340
|
-
if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) {
|
|
22341
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
22342
|
-
}
|
|
22343
|
-
if (!protectedHeader || protectedHeader.crit === void 0) {
|
|
22344
|
-
return /* @__PURE__ */ new Set();
|
|
22345
|
-
}
|
|
22346
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
|
|
22347
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
22348
|
-
}
|
|
22349
|
-
let recognized;
|
|
22350
|
-
if (recognizedOption !== void 0) {
|
|
22351
|
-
recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
|
|
22352
|
-
} else {
|
|
22353
|
-
recognized = recognizedDefault;
|
|
22354
|
-
}
|
|
22355
|
-
for (const parameter of protectedHeader.crit) {
|
|
22356
|
-
if (!recognized.has(parameter)) {
|
|
22357
|
-
throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
22358
|
-
}
|
|
22359
|
-
if (joseHeader[parameter] === void 0) {
|
|
22360
|
-
throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
22361
|
-
}
|
|
22362
|
-
if (recognized.get(parameter) && protectedHeader[parameter] === void 0) {
|
|
22363
|
-
throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
22364
|
-
}
|
|
22365
|
-
}
|
|
22366
|
-
return new Set(protectedHeader.crit);
|
|
22367
|
-
}
|
|
22368
|
-
const tag = (key) => key?.[Symbol.toStringTag];
|
|
22369
|
-
const jwkMatchesOp = (alg, key, usage) => {
|
|
22370
|
-
if (key.use !== void 0) {
|
|
22371
|
-
let expected;
|
|
22372
|
-
switch (usage) {
|
|
22373
|
-
case "sign":
|
|
22374
|
-
case "verify":
|
|
22375
|
-
expected = "sig";
|
|
22376
|
-
break;
|
|
22377
|
-
case "encrypt":
|
|
22378
|
-
case "decrypt":
|
|
22379
|
-
expected = "enc";
|
|
22380
|
-
break;
|
|
22381
|
-
}
|
|
22382
|
-
if (key.use !== expected) {
|
|
22383
|
-
throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
|
|
22384
|
-
}
|
|
22385
|
-
}
|
|
22386
|
-
if (key.alg !== void 0 && key.alg !== alg) {
|
|
22387
|
-
throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
|
|
22388
|
-
}
|
|
22389
|
-
if (Array.isArray(key.key_ops)) {
|
|
22390
|
-
let expectedKeyOp;
|
|
22391
|
-
switch (true) {
|
|
22392
|
-
case usage === "sign":
|
|
22393
|
-
case alg === "dir":
|
|
22394
|
-
case alg.includes("CBC-HS"):
|
|
22395
|
-
expectedKeyOp = usage;
|
|
22396
|
-
break;
|
|
22397
|
-
case alg.startsWith("PBES2"):
|
|
22398
|
-
expectedKeyOp = "deriveBits";
|
|
22399
|
-
break;
|
|
22400
|
-
case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
|
|
22401
|
-
if (!alg.includes("GCM") && alg.endsWith("KW")) {
|
|
22402
|
-
expectedKeyOp = "unwrapKey";
|
|
22403
|
-
} else {
|
|
22404
|
-
expectedKeyOp = usage;
|
|
22405
|
-
}
|
|
22406
|
-
break;
|
|
22407
|
-
case usage === "encrypt":
|
|
22408
|
-
expectedKeyOp = "wrapKey";
|
|
22409
|
-
break;
|
|
22410
|
-
case usage === "decrypt":
|
|
22411
|
-
expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
|
|
22412
|
-
break;
|
|
22413
|
-
}
|
|
22414
|
-
if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {
|
|
22415
|
-
throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
|
|
22416
|
-
}
|
|
22417
|
-
}
|
|
22418
|
-
return true;
|
|
22419
|
-
};
|
|
22420
|
-
const symmetricTypeCheck = (alg, key, usage) => {
|
|
22421
|
-
if (key instanceof Uint8Array)
|
|
22422
|
-
return;
|
|
22423
|
-
if (isJWK(key)) {
|
|
22424
|
-
if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
22425
|
-
return;
|
|
22426
|
-
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`);
|
|
22427
|
-
}
|
|
22428
|
-
if (!isKeyLike(key)) {
|
|
22429
|
-
throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
|
|
22430
|
-
}
|
|
22431
|
-
if (key.type !== "secret") {
|
|
22432
|
-
throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
|
|
22433
|
-
}
|
|
22434
|
-
};
|
|
22435
|
-
const asymmetricTypeCheck = (alg, key, usage) => {
|
|
22436
|
-
if (isJWK(key)) {
|
|
22437
|
-
switch (usage) {
|
|
22438
|
-
case "decrypt":
|
|
22439
|
-
case "sign":
|
|
22440
|
-
if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
22441
|
-
return;
|
|
22442
|
-
throw new TypeError(`JSON Web Key for this operation must be a private JWK`);
|
|
22443
|
-
case "encrypt":
|
|
22444
|
-
case "verify":
|
|
22445
|
-
if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
22446
|
-
return;
|
|
22447
|
-
throw new TypeError(`JSON Web Key for this operation must be a public JWK`);
|
|
22448
|
-
}
|
|
22449
|
-
}
|
|
22450
|
-
if (!isKeyLike(key)) {
|
|
22451
|
-
throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
22452
|
-
}
|
|
22453
|
-
if (key.type === "secret") {
|
|
22454
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
22455
|
-
}
|
|
22456
|
-
if (key.type === "public") {
|
|
22457
|
-
switch (usage) {
|
|
22458
|
-
case "sign":
|
|
22459
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
22460
|
-
case "decrypt":
|
|
22461
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
22462
|
-
}
|
|
22463
|
-
}
|
|
22464
|
-
if (key.type === "private") {
|
|
22465
|
-
switch (usage) {
|
|
22466
|
-
case "verify":
|
|
22467
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
22468
|
-
case "encrypt":
|
|
22469
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
22470
|
-
}
|
|
22471
|
-
}
|
|
22472
|
-
};
|
|
22473
|
-
function checkKeyType(alg, key, usage) {
|
|
22474
|
-
switch (alg.substring(0, 2)) {
|
|
22475
|
-
case "A1":
|
|
22476
|
-
case "A2":
|
|
22477
|
-
case "di":
|
|
22478
|
-
case "HS":
|
|
22479
|
-
case "PB":
|
|
22480
|
-
symmetricTypeCheck(alg, key, usage);
|
|
22481
|
-
break;
|
|
22482
|
-
default:
|
|
22483
|
-
asymmetricTypeCheck(alg, key, usage);
|
|
22484
|
-
}
|
|
22485
|
-
}
|
|
22486
|
-
const epoch = (date) => Math.floor(date.getTime() / 1e3);
|
|
22487
|
-
const minute = 60;
|
|
22488
|
-
const hour = minute * 60;
|
|
22489
|
-
const day = hour * 24;
|
|
22490
|
-
const week = day * 7;
|
|
22491
|
-
const year = day * 365.25;
|
|
22492
|
-
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;
|
|
22493
|
-
function secs(str) {
|
|
22494
|
-
const matched = REGEX.exec(str);
|
|
22495
|
-
if (!matched || matched[4] && matched[1]) {
|
|
22496
|
-
throw new TypeError("Invalid time period format");
|
|
22497
|
-
}
|
|
22498
|
-
const value = parseFloat(matched[2]);
|
|
22499
|
-
const unit = matched[3].toLowerCase();
|
|
22500
|
-
let numericDate;
|
|
22501
|
-
switch (unit) {
|
|
22502
|
-
case "sec":
|
|
22503
|
-
case "secs":
|
|
22504
|
-
case "second":
|
|
22505
|
-
case "seconds":
|
|
22506
|
-
case "s":
|
|
22507
|
-
numericDate = Math.round(value);
|
|
22508
|
-
break;
|
|
22509
|
-
case "minute":
|
|
22510
|
-
case "minutes":
|
|
22511
|
-
case "min":
|
|
22512
|
-
case "mins":
|
|
22513
|
-
case "m":
|
|
22514
|
-
numericDate = Math.round(value * minute);
|
|
22515
|
-
break;
|
|
22516
|
-
case "hour":
|
|
22517
|
-
case "hours":
|
|
22518
|
-
case "hr":
|
|
22519
|
-
case "hrs":
|
|
22520
|
-
case "h":
|
|
22521
|
-
numericDate = Math.round(value * hour);
|
|
22522
|
-
break;
|
|
22523
|
-
case "day":
|
|
22524
|
-
case "days":
|
|
22525
|
-
case "d":
|
|
22526
|
-
numericDate = Math.round(value * day);
|
|
22527
|
-
break;
|
|
22528
|
-
case "week":
|
|
22529
|
-
case "weeks":
|
|
22530
|
-
case "w":
|
|
22531
|
-
numericDate = Math.round(value * week);
|
|
22532
|
-
break;
|
|
22533
|
-
default:
|
|
22534
|
-
numericDate = Math.round(value * year);
|
|
22535
|
-
break;
|
|
22536
|
-
}
|
|
22537
|
-
if (matched[1] === "-" || matched[4] === "ago") {
|
|
22538
|
-
return -numericDate;
|
|
22539
|
-
}
|
|
22540
|
-
return numericDate;
|
|
22541
|
-
}
|
|
22542
|
-
function validateInput(label, input) {
|
|
22543
|
-
if (!Number.isFinite(input)) {
|
|
22544
|
-
throw new TypeError(`Invalid ${label} input`);
|
|
22545
|
-
}
|
|
22546
|
-
return input;
|
|
22547
|
-
}
|
|
22548
|
-
class JWTClaimsBuilder {
|
|
22549
|
-
#payload;
|
|
22550
|
-
constructor(payload) {
|
|
22551
|
-
if (!isObject(payload)) {
|
|
22552
|
-
throw new TypeError("JWT Claims Set MUST be an object");
|
|
22553
|
-
}
|
|
22554
|
-
this.#payload = structuredClone(payload);
|
|
22555
|
-
}
|
|
22556
|
-
data() {
|
|
22557
|
-
return encoder.encode(JSON.stringify(this.#payload));
|
|
22558
|
-
}
|
|
22559
|
-
get iss() {
|
|
22560
|
-
return this.#payload.iss;
|
|
22561
|
-
}
|
|
22562
|
-
set iss(value) {
|
|
22563
|
-
this.#payload.iss = value;
|
|
22564
|
-
}
|
|
22565
|
-
get sub() {
|
|
22566
|
-
return this.#payload.sub;
|
|
22567
|
-
}
|
|
22568
|
-
set sub(value) {
|
|
22569
|
-
this.#payload.sub = value;
|
|
22570
|
-
}
|
|
22571
|
-
get aud() {
|
|
22572
|
-
return this.#payload.aud;
|
|
22573
|
-
}
|
|
22574
|
-
set aud(value) {
|
|
22575
|
-
this.#payload.aud = value;
|
|
22576
|
-
}
|
|
22577
|
-
set jti(value) {
|
|
22578
|
-
this.#payload.jti = value;
|
|
22579
|
-
}
|
|
22580
|
-
set nbf(value) {
|
|
22581
|
-
if (typeof value === "number") {
|
|
22582
|
-
this.#payload.nbf = validateInput("setNotBefore", value);
|
|
22583
|
-
} else if (value instanceof Date) {
|
|
22584
|
-
this.#payload.nbf = validateInput("setNotBefore", epoch(value));
|
|
22585
|
-
} else {
|
|
22586
|
-
this.#payload.nbf = epoch(/* @__PURE__ */ new Date()) + secs(value);
|
|
22587
|
-
}
|
|
22588
|
-
}
|
|
22589
|
-
set exp(value) {
|
|
22590
|
-
if (typeof value === "number") {
|
|
22591
|
-
this.#payload.exp = validateInput("setExpirationTime", value);
|
|
22592
|
-
} else if (value instanceof Date) {
|
|
22593
|
-
this.#payload.exp = validateInput("setExpirationTime", epoch(value));
|
|
22594
|
-
} else {
|
|
22595
|
-
this.#payload.exp = epoch(/* @__PURE__ */ new Date()) + secs(value);
|
|
22596
|
-
}
|
|
22597
|
-
}
|
|
22598
|
-
set iat(value) {
|
|
22599
|
-
if (value === void 0) {
|
|
22600
|
-
this.#payload.iat = epoch(/* @__PURE__ */ new Date());
|
|
22601
|
-
} else if (value instanceof Date) {
|
|
22602
|
-
this.#payload.iat = validateInput("setIssuedAt", epoch(value));
|
|
22603
|
-
} else if (typeof value === "string") {
|
|
22604
|
-
this.#payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value));
|
|
22605
|
-
} else {
|
|
22606
|
-
this.#payload.iat = validateInput("setIssuedAt", value);
|
|
22607
|
-
}
|
|
22608
|
-
}
|
|
22609
|
-
}
|
|
22610
|
-
class FlattenedSign {
|
|
22611
|
-
#payload;
|
|
22612
|
-
#protectedHeader;
|
|
22613
|
-
#unprotectedHeader;
|
|
22614
|
-
constructor(payload) {
|
|
22615
|
-
if (!(payload instanceof Uint8Array)) {
|
|
22616
|
-
throw new TypeError("payload must be an instance of Uint8Array");
|
|
22617
|
-
}
|
|
22618
|
-
this.#payload = payload;
|
|
22619
|
-
}
|
|
22620
|
-
setProtectedHeader(protectedHeader) {
|
|
22621
|
-
assertNotSet(this.#protectedHeader, "setProtectedHeader");
|
|
22622
|
-
this.#protectedHeader = protectedHeader;
|
|
22623
|
-
return this;
|
|
22624
|
-
}
|
|
22625
|
-
setUnprotectedHeader(unprotectedHeader) {
|
|
22626
|
-
assertNotSet(this.#unprotectedHeader, "setUnprotectedHeader");
|
|
22627
|
-
this.#unprotectedHeader = unprotectedHeader;
|
|
22628
|
-
return this;
|
|
22629
|
-
}
|
|
22630
|
-
async sign(key, options2) {
|
|
22631
|
-
if (!this.#protectedHeader && !this.#unprotectedHeader) {
|
|
22632
|
-
throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
22633
|
-
}
|
|
22634
|
-
if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader)) {
|
|
22635
|
-
throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
22636
|
-
}
|
|
22637
|
-
const joseHeader = {
|
|
22638
|
-
...this.#protectedHeader,
|
|
22639
|
-
...this.#unprotectedHeader
|
|
22640
|
-
};
|
|
22641
|
-
const extensions2 = validateCrit(JWSInvalid, /* @__PURE__ */ new Map([["b64", true]]), options2?.crit, this.#protectedHeader, joseHeader);
|
|
22642
|
-
let b64 = true;
|
|
22643
|
-
if (extensions2.has("b64")) {
|
|
22644
|
-
b64 = this.#protectedHeader.b64;
|
|
22645
|
-
if (typeof b64 !== "boolean") {
|
|
22646
|
-
throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
22647
|
-
}
|
|
22648
|
-
}
|
|
22649
|
-
const { alg } = joseHeader;
|
|
22650
|
-
if (typeof alg !== "string" || !alg) {
|
|
22651
|
-
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
22652
|
-
}
|
|
22653
|
-
checkKeyType(alg, key, "sign");
|
|
22654
|
-
let payloadS;
|
|
22655
|
-
let payloadB;
|
|
22656
|
-
if (b64) {
|
|
22657
|
-
payloadS = encode$3(this.#payload);
|
|
22658
|
-
payloadB = encode$4(payloadS);
|
|
22659
|
-
} else {
|
|
22660
|
-
payloadB = this.#payload;
|
|
22661
|
-
payloadS = "";
|
|
22662
|
-
}
|
|
22663
|
-
let protectedHeaderString;
|
|
22664
|
-
let protectedHeaderBytes;
|
|
22665
|
-
if (this.#protectedHeader) {
|
|
22666
|
-
protectedHeaderString = encode$3(JSON.stringify(this.#protectedHeader));
|
|
22667
|
-
protectedHeaderBytes = encode$4(protectedHeaderString);
|
|
22668
|
-
} else {
|
|
22669
|
-
protectedHeaderString = "";
|
|
22670
|
-
protectedHeaderBytes = new Uint8Array();
|
|
22671
|
-
}
|
|
22672
|
-
const data = concat(protectedHeaderBytes, encode$4("."), payloadB);
|
|
22673
|
-
const k = await normalizeKey$1(key, alg);
|
|
22674
|
-
const signature = await sign$2(alg, k, data);
|
|
22675
|
-
const jws2 = {
|
|
22676
|
-
signature: encode$3(signature),
|
|
22677
|
-
payload: payloadS
|
|
22678
|
-
};
|
|
22679
|
-
if (this.#unprotectedHeader) {
|
|
22680
|
-
jws2.header = this.#unprotectedHeader;
|
|
22681
|
-
}
|
|
22682
|
-
if (this.#protectedHeader) {
|
|
22683
|
-
jws2.protected = protectedHeaderString;
|
|
22684
|
-
}
|
|
22685
|
-
return jws2;
|
|
22686
|
-
}
|
|
22687
|
-
}
|
|
22688
|
-
class CompactSign {
|
|
22689
|
-
#flattened;
|
|
22690
|
-
constructor(payload) {
|
|
22691
|
-
this.#flattened = new FlattenedSign(payload);
|
|
22692
|
-
}
|
|
22693
|
-
setProtectedHeader(protectedHeader) {
|
|
22694
|
-
this.#flattened.setProtectedHeader(protectedHeader);
|
|
22695
|
-
return this;
|
|
22696
|
-
}
|
|
22697
|
-
async sign(key, options2) {
|
|
22698
|
-
const jws2 = await this.#flattened.sign(key, options2);
|
|
22699
|
-
if (jws2.payload === void 0) {
|
|
22700
|
-
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
22701
|
-
}
|
|
22702
|
-
return `${jws2.protected}.${jws2.payload}.${jws2.signature}`;
|
|
22703
|
-
}
|
|
22704
|
-
}
|
|
22705
|
-
class SignJWT {
|
|
22706
|
-
#protectedHeader;
|
|
22707
|
-
#jwt;
|
|
22708
|
-
constructor(payload = {}) {
|
|
22709
|
-
this.#jwt = new JWTClaimsBuilder(payload);
|
|
22710
|
-
}
|
|
22711
|
-
setIssuer(issuer) {
|
|
22712
|
-
this.#jwt.iss = issuer;
|
|
22713
|
-
return this;
|
|
22714
|
-
}
|
|
22715
|
-
setSubject(subject) {
|
|
22716
|
-
this.#jwt.sub = subject;
|
|
22717
|
-
return this;
|
|
22718
|
-
}
|
|
22719
|
-
setAudience(audience) {
|
|
22720
|
-
this.#jwt.aud = audience;
|
|
22721
|
-
return this;
|
|
22722
|
-
}
|
|
22723
|
-
setJti(jwtId) {
|
|
22724
|
-
this.#jwt.jti = jwtId;
|
|
22725
|
-
return this;
|
|
22726
|
-
}
|
|
22727
|
-
setNotBefore(input) {
|
|
22728
|
-
this.#jwt.nbf = input;
|
|
22729
|
-
return this;
|
|
22730
|
-
}
|
|
22731
|
-
setExpirationTime(input) {
|
|
22732
|
-
this.#jwt.exp = input;
|
|
22733
|
-
return this;
|
|
22734
|
-
}
|
|
22735
|
-
setIssuedAt(input) {
|
|
22736
|
-
this.#jwt.iat = input;
|
|
22737
|
-
return this;
|
|
22738
|
-
}
|
|
22739
|
-
setProtectedHeader(protectedHeader) {
|
|
22740
|
-
this.#protectedHeader = protectedHeader;
|
|
22741
|
-
return this;
|
|
22742
|
-
}
|
|
22743
|
-
async sign(key, options2) {
|
|
22744
|
-
const sig = new CompactSign(this.#jwt.data());
|
|
22745
|
-
sig.setProtectedHeader(this.#protectedHeader);
|
|
22746
|
-
if (Array.isArray(this.#protectedHeader?.crit) && this.#protectedHeader.crit.includes("b64") && this.#protectedHeader.b64 === false) {
|
|
22747
|
-
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
22748
|
-
}
|
|
22749
|
-
return sig.sign(key, options2);
|
|
22750
|
-
}
|
|
22751
|
-
}
|
|
22752
21879
|
function createAppleProvider(config) {
|
|
22753
21880
|
async function generateClientSecret() {
|
|
22754
|
-
|
|
22755
|
-
|
|
22756
|
-
|
|
21881
|
+
return jwt.sign({}, config.privateKey, {
|
|
21882
|
+
algorithm: "ES256",
|
|
21883
|
+
keyid: config.keyId,
|
|
21884
|
+
issuer: config.teamId,
|
|
21885
|
+
expiresIn: "180d",
|
|
21886
|
+
audience: "https://appleid.apple.com",
|
|
21887
|
+
subject: config.clientId
|
|
22757
21888
|
});
|
|
22758
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
22759
|
-
return new SignJWT({}).setProtectedHeader({
|
|
22760
|
-
alg: "ES256",
|
|
22761
|
-
kid: config.keyId
|
|
22762
|
-
}).setIssuer(config.teamId).setIssuedAt(now).setExpirationTime(now + 86400 * 180).setAudience("https://appleid.apple.com").setSubject(config.clientId).sign(key);
|
|
22763
21889
|
}
|
|
22764
21890
|
return {
|
|
22765
21891
|
id: "apple",
|
|
@@ -23567,7 +22693,7 @@ function createRateLimiter(options2 = {}) {
|
|
|
23567
22693
|
windowMs = 15 * 60 * 1e3,
|
|
23568
22694
|
limit = 100,
|
|
23569
22695
|
keyGenerator = defaultKeyGenerator,
|
|
23570
|
-
message
|
|
22696
|
+
message = "Too many requests, please try again later."
|
|
23571
22697
|
} = options2;
|
|
23572
22698
|
const store = /* @__PURE__ */ new Map();
|
|
23573
22699
|
const cleanupInterval = setInterval(() => {
|
|
@@ -23602,7 +22728,7 @@ function createRateLimiter(options2 = {}) {
|
|
|
23602
22728
|
c.header("X-RateLimit-Reset", String(Math.ceil((now + retryAfterMs) / 1e3)));
|
|
23603
22729
|
return c.json({
|
|
23604
22730
|
error: {
|
|
23605
|
-
message
|
|
22731
|
+
message,
|
|
23606
22732
|
code: "RATE_LIMITED"
|
|
23607
22733
|
}
|
|
23608
22734
|
}, 429);
|
|
@@ -23614,7 +22740,12 @@ function createRateLimiter(options2 = {}) {
|
|
|
23614
22740
|
};
|
|
23615
22741
|
}
|
|
23616
22742
|
function defaultKeyGenerator(c) {
|
|
23617
|
-
|
|
22743
|
+
const forwardedFor = c.req.header("x-forwarded-for");
|
|
22744
|
+
if (forwardedFor) {
|
|
22745
|
+
const ips = forwardedFor.split(",");
|
|
22746
|
+
return ips[ips.length - 1].trim();
|
|
22747
|
+
}
|
|
22748
|
+
return c.req.header("x-real-ip") || "unknown";
|
|
23618
22749
|
}
|
|
23619
22750
|
const defaultAuthLimiter = createRateLimiter({
|
|
23620
22751
|
windowMs: 15 * 60 * 1e3,
|
|
@@ -24182,8 +23313,45 @@ function createAdminRoutes(config) {
|
|
|
24182
23313
|
const authRepo = config.authRepo;
|
|
24183
23314
|
const {
|
|
24184
23315
|
emailService,
|
|
24185
|
-
emailConfig
|
|
23316
|
+
emailConfig,
|
|
23317
|
+
hooks
|
|
24186
23318
|
} = config;
|
|
23319
|
+
function buildHookContext(c, method) {
|
|
23320
|
+
const user = c.get("user");
|
|
23321
|
+
return {
|
|
23322
|
+
requestUser: user ? {
|
|
23323
|
+
userId: user.userId,
|
|
23324
|
+
roles: user.roles ?? []
|
|
23325
|
+
} : void 0,
|
|
23326
|
+
method
|
|
23327
|
+
};
|
|
23328
|
+
}
|
|
23329
|
+
async function applyUserAfterRead(user, ctx) {
|
|
23330
|
+
if (!hooks?.users?.afterRead) return user;
|
|
23331
|
+
return hooks.users.afterRead(user, ctx);
|
|
23332
|
+
}
|
|
23333
|
+
async function applyUserAfterReadBatch(users, ctx) {
|
|
23334
|
+
if (!hooks?.users?.afterRead) return users;
|
|
23335
|
+
const results = await Promise.all(users.map((u) => applyUserAfterRead(u, ctx)));
|
|
23336
|
+
return results.filter((u) => u !== null);
|
|
23337
|
+
}
|
|
23338
|
+
async function applyRoleAfterReadBatch(roles, ctx) {
|
|
23339
|
+
if (!hooks?.roles?.afterRead) return roles;
|
|
23340
|
+
const results = await Promise.all(roles.map((r) => hooks.roles.afterRead(r, ctx)));
|
|
23341
|
+
return results.filter((r) => r !== null);
|
|
23342
|
+
}
|
|
23343
|
+
function toAdminUser(u, roles) {
|
|
23344
|
+
return {
|
|
23345
|
+
uid: u.id,
|
|
23346
|
+
email: u.email,
|
|
23347
|
+
displayName: u.displayName ?? null,
|
|
23348
|
+
photoURL: u.photoUrl ?? null,
|
|
23349
|
+
provider: "custom",
|
|
23350
|
+
roles,
|
|
23351
|
+
createdAt: u.createdAt instanceof Date ? u.createdAt.toISOString() : u.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
23352
|
+
updatedAt: u.updatedAt instanceof Date ? u.updatedAt.toISOString() : u.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
23353
|
+
};
|
|
23354
|
+
}
|
|
24187
23355
|
router.onError(errorHandler);
|
|
24188
23356
|
router.use("/*", createRequireAuth({
|
|
24189
23357
|
serviceKey: config.serviceKey
|
|
@@ -24234,6 +23402,7 @@ function createAdminRoutes(config) {
|
|
|
24234
23402
|
const search = c.req.query("search");
|
|
24235
23403
|
const orderBy = c.req.query("orderBy");
|
|
24236
23404
|
const orderDir = c.req.query("orderDir");
|
|
23405
|
+
const hookCtx = buildHookContext(c, "GET");
|
|
24237
23406
|
if (limitParam !== void 0 || search) {
|
|
24238
23407
|
const limit = limitParam ? parseInt(limitParam, 10) : 25;
|
|
24239
23408
|
const offset = offsetParam ? parseInt(offsetParam, 10) : 0;
|
|
@@ -24245,18 +23414,11 @@ function createAdminRoutes(config) {
|
|
|
24245
23414
|
orderDir: orderDir || void 0,
|
|
24246
23415
|
roleId: c.req.query("role") || void 0
|
|
24247
23416
|
});
|
|
24248
|
-
|
|
23417
|
+
let usersWithRoles2 = await Promise.all(result.users.map(async (u) => {
|
|
24249
23418
|
const roles = await authRepo.getUserRoleIds(u.id);
|
|
24250
|
-
return
|
|
24251
|
-
uid: u.id,
|
|
24252
|
-
email: u.email,
|
|
24253
|
-
displayName: u.displayName,
|
|
24254
|
-
photoURL: u.photoUrl,
|
|
24255
|
-
roles,
|
|
24256
|
-
createdAt: u.createdAt,
|
|
24257
|
-
updatedAt: u.updatedAt
|
|
24258
|
-
};
|
|
23419
|
+
return toAdminUser(u, roles);
|
|
24259
23420
|
}));
|
|
23421
|
+
usersWithRoles2 = await applyUserAfterReadBatch(usersWithRoles2, hookCtx);
|
|
24260
23422
|
return c.json({
|
|
24261
23423
|
users: usersWithRoles2,
|
|
24262
23424
|
total: result.total,
|
|
@@ -24265,18 +23427,11 @@ function createAdminRoutes(config) {
|
|
|
24265
23427
|
});
|
|
24266
23428
|
}
|
|
24267
23429
|
const users = await authRepo.listUsers();
|
|
24268
|
-
|
|
23430
|
+
let usersWithRoles = await Promise.all(users.map(async (u) => {
|
|
24269
23431
|
const roles = await authRepo.getUserRoleIds(u.id);
|
|
24270
|
-
return
|
|
24271
|
-
uid: u.id,
|
|
24272
|
-
email: u.email,
|
|
24273
|
-
displayName: u.displayName,
|
|
24274
|
-
photoURL: u.photoUrl,
|
|
24275
|
-
roles,
|
|
24276
|
-
createdAt: u.createdAt,
|
|
24277
|
-
updatedAt: u.updatedAt
|
|
24278
|
-
};
|
|
23432
|
+
return toAdminUser(u, roles);
|
|
24279
23433
|
}));
|
|
23434
|
+
usersWithRoles = await applyUserAfterReadBatch(usersWithRoles, hookCtx);
|
|
24280
23435
|
return c.json({
|
|
24281
23436
|
users: usersWithRoles
|
|
24282
23437
|
});
|
|
@@ -24287,21 +23442,19 @@ function createAdminRoutes(config) {
|
|
|
24287
23442
|
if (!result) {
|
|
24288
23443
|
throw ApiError.notFound("User not found");
|
|
24289
23444
|
}
|
|
23445
|
+
const hookCtx = buildHookContext(c, "GET");
|
|
23446
|
+
let adminUser = toAdminUser(result.user, result.roles.map((r) => r.id));
|
|
23447
|
+
adminUser = await applyUserAfterRead(adminUser, hookCtx);
|
|
23448
|
+
if (!adminUser) {
|
|
23449
|
+
throw ApiError.notFound("User not found");
|
|
23450
|
+
}
|
|
24290
23451
|
return c.json({
|
|
24291
|
-
user:
|
|
24292
|
-
uid: result.user.id,
|
|
24293
|
-
email: result.user.email,
|
|
24294
|
-
displayName: result.user.displayName,
|
|
24295
|
-
photoURL: result.user.photoUrl,
|
|
24296
|
-
roles: result.roles.map((r) => r.id),
|
|
24297
|
-
createdAt: result.user.createdAt,
|
|
24298
|
-
updatedAt: result.user.updatedAt
|
|
24299
|
-
}
|
|
23452
|
+
user: adminUser
|
|
24300
23453
|
});
|
|
24301
23454
|
});
|
|
24302
23455
|
router.post("/users", requireAdmin, async (c) => {
|
|
24303
23456
|
const body = await c.req.json();
|
|
24304
|
-
|
|
23457
|
+
let {
|
|
24305
23458
|
email,
|
|
24306
23459
|
displayName,
|
|
24307
23460
|
password,
|
|
@@ -24310,6 +23463,17 @@ function createAdminRoutes(config) {
|
|
|
24310
23463
|
if (!email) {
|
|
24311
23464
|
throw ApiError.badRequest("Email is required", "INVALID_INPUT");
|
|
24312
23465
|
}
|
|
23466
|
+
const hookCtx = buildHookContext(c, "POST");
|
|
23467
|
+
if (hooks?.users?.beforeSave) {
|
|
23468
|
+
const hooked = await hooks.users.beforeSave({
|
|
23469
|
+
email,
|
|
23470
|
+
displayName,
|
|
23471
|
+
roles
|
|
23472
|
+
}, hookCtx);
|
|
23473
|
+
email = hooked.email ?? email;
|
|
23474
|
+
displayName = hooked.displayName ?? displayName;
|
|
23475
|
+
roles = hooked.roles ?? roles;
|
|
23476
|
+
}
|
|
24313
23477
|
const existing = await authRepo.getUserByEmail(email);
|
|
24314
23478
|
if (existing) {
|
|
24315
23479
|
throw ApiError.conflict("Email already exists", "EMAIL_EXISTS");
|
|
@@ -24365,13 +23529,14 @@ function createAdminRoutes(config) {
|
|
|
24365
23529
|
} else if (!password) {
|
|
24366
23530
|
temporaryPassword = clearPassword;
|
|
24367
23531
|
}
|
|
23532
|
+
const createdAdminUser = toAdminUser(user, userRoles);
|
|
23533
|
+
if (hooks?.users?.afterSave) {
|
|
23534
|
+
Promise.resolve(hooks.users.afterSave(createdAdminUser, hookCtx)).catch((err) => {
|
|
23535
|
+
console.error("[BackendHooks] users.afterSave error:", err instanceof Error ? err.message : err);
|
|
23536
|
+
});
|
|
23537
|
+
}
|
|
24368
23538
|
return c.json({
|
|
24369
|
-
user:
|
|
24370
|
-
uid: user.id,
|
|
24371
|
-
email: user.email,
|
|
24372
|
-
displayName: user.displayName,
|
|
24373
|
-
roles: userRoles
|
|
24374
|
-
},
|
|
23539
|
+
user: createdAdminUser,
|
|
24375
23540
|
invitationSent,
|
|
24376
23541
|
...temporaryPassword ? {
|
|
24377
23542
|
temporaryPassword
|
|
@@ -24441,7 +23606,7 @@ function createAdminRoutes(config) {
|
|
|
24441
23606
|
router.put("/users/:userId", requireAdmin, async (c) => {
|
|
24442
23607
|
const userId = c.req.param("userId");
|
|
24443
23608
|
const body = await c.req.json();
|
|
24444
|
-
|
|
23609
|
+
let {
|
|
24445
23610
|
email,
|
|
24446
23611
|
displayName,
|
|
24447
23612
|
password,
|
|
@@ -24451,6 +23616,17 @@ function createAdminRoutes(config) {
|
|
|
24451
23616
|
if (!existing) {
|
|
24452
23617
|
throw ApiError.notFound("User not found");
|
|
24453
23618
|
}
|
|
23619
|
+
const hookCtx = buildHookContext(c, "PUT");
|
|
23620
|
+
if (hooks?.users?.beforeSave) {
|
|
23621
|
+
const hooked = await hooks.users.beforeSave({
|
|
23622
|
+
email,
|
|
23623
|
+
displayName,
|
|
23624
|
+
roles
|
|
23625
|
+
}, hookCtx);
|
|
23626
|
+
email = hooked.email ?? email;
|
|
23627
|
+
displayName = hooked.displayName ?? displayName;
|
|
23628
|
+
roles = hooked.roles ?? roles;
|
|
23629
|
+
}
|
|
24454
23630
|
const updates = {};
|
|
24455
23631
|
if (email !== void 0) updates.email = email.toLowerCase();
|
|
24456
23632
|
if (displayName !== void 0) updates.displayName = displayName;
|
|
@@ -24468,13 +23644,14 @@ function createAdminRoutes(config) {
|
|
|
24468
23644
|
await authRepo.setUserRoles(userId, roles);
|
|
24469
23645
|
}
|
|
24470
23646
|
const result = await authRepo.getUserWithRoles(userId);
|
|
23647
|
+
const updatedAdminUser = toAdminUser(result.user, result.roles.map((r) => r.id));
|
|
23648
|
+
if (hooks?.users?.afterSave) {
|
|
23649
|
+
Promise.resolve(hooks.users.afterSave(updatedAdminUser, hookCtx)).catch((err) => {
|
|
23650
|
+
console.error("[BackendHooks] users.afterSave error:", err instanceof Error ? err.message : err);
|
|
23651
|
+
});
|
|
23652
|
+
}
|
|
24471
23653
|
return c.json({
|
|
24472
|
-
user:
|
|
24473
|
-
uid: result.user.id,
|
|
24474
|
-
email: result.user.email,
|
|
24475
|
-
displayName: result.user.displayName,
|
|
24476
|
-
roles: result.roles.map((r) => r.id)
|
|
24477
|
-
}
|
|
23654
|
+
user: updatedAdminUser
|
|
24478
23655
|
});
|
|
24479
23656
|
});
|
|
24480
23657
|
router.delete("/users/:userId", requireAdmin, async (c) => {
|
|
@@ -24488,21 +23665,33 @@ function createAdminRoutes(config) {
|
|
|
24488
23665
|
if (!existing) {
|
|
24489
23666
|
throw ApiError.notFound("User not found");
|
|
24490
23667
|
}
|
|
23668
|
+
const hookCtx = buildHookContext(c, "DELETE");
|
|
23669
|
+
if (hooks?.users?.beforeDelete) {
|
|
23670
|
+
await hooks.users.beforeDelete(userId, hookCtx);
|
|
23671
|
+
}
|
|
24491
23672
|
await authRepo.deleteUser(userId);
|
|
23673
|
+
if (hooks?.users?.afterDelete) {
|
|
23674
|
+
Promise.resolve(hooks.users.afterDelete(userId, hookCtx)).catch((err) => {
|
|
23675
|
+
console.error("[BackendHooks] users.afterDelete error:", err instanceof Error ? err.message : err);
|
|
23676
|
+
});
|
|
23677
|
+
}
|
|
24492
23678
|
return c.json({
|
|
24493
23679
|
success: true
|
|
24494
23680
|
});
|
|
24495
23681
|
});
|
|
24496
23682
|
router.get("/roles", requireAdmin, async (c) => {
|
|
24497
23683
|
const roles = await authRepo.listRoles();
|
|
23684
|
+
const hookCtx = buildHookContext(c, "GET");
|
|
23685
|
+
let adminRoles = roles.map((r) => ({
|
|
23686
|
+
id: r.id,
|
|
23687
|
+
name: r.name,
|
|
23688
|
+
isAdmin: r.isAdmin,
|
|
23689
|
+
defaultPermissions: r.defaultPermissions,
|
|
23690
|
+
config: r.config
|
|
23691
|
+
}));
|
|
23692
|
+
adminRoles = await applyRoleAfterReadBatch(adminRoles, hookCtx);
|
|
24498
23693
|
return c.json({
|
|
24499
|
-
roles:
|
|
24500
|
-
id: r.id,
|
|
24501
|
-
name: r.name,
|
|
24502
|
-
isAdmin: r.isAdmin,
|
|
24503
|
-
defaultPermissions: r.defaultPermissions,
|
|
24504
|
-
config: r.config
|
|
24505
|
-
}))
|
|
23694
|
+
roles: adminRoles
|
|
24506
23695
|
});
|
|
24507
23696
|
});
|
|
24508
23697
|
router.get("/roles/:roleId", requireAdmin, async (c) => {
|
|
@@ -24630,10 +23819,10 @@ class LocalStorageController {
|
|
|
24630
23819
|
* Includes a path traversal guard to prevent escaping the base directory.
|
|
24631
23820
|
*/
|
|
24632
23821
|
getFullPath(storagePath, bucket) {
|
|
24633
|
-
const
|
|
24634
|
-
const resolved = path$3.resolve(path$3.join(
|
|
24635
|
-
if (!resolved.startsWith(
|
|
24636
|
-
throw new Error("Path traversal detected: resolved storage path is outside the
|
|
23822
|
+
const bucketPath = bucket ? path$3.join(this.basePath, bucket) : this.basePath;
|
|
23823
|
+
const resolved = path$3.resolve(path$3.join(bucketPath, storagePath));
|
|
23824
|
+
if (!resolved.startsWith(bucketPath + path$3.sep) && resolved !== bucketPath) {
|
|
23825
|
+
throw new Error("Path traversal detected: resolved storage path is outside the bucket directory.");
|
|
24637
23826
|
}
|
|
24638
23827
|
return resolved;
|
|
24639
23828
|
}
|
|
@@ -24780,17 +23969,29 @@ class LocalStorageController {
|
|
|
24780
23969
|
}
|
|
24781
23970
|
}
|
|
24782
23971
|
resolvedPath = normalizeStoragePath(resolvedPath);
|
|
23972
|
+
if (!resolvedPath) {
|
|
23973
|
+
return;
|
|
23974
|
+
}
|
|
24783
23975
|
const fullPath = this.getFullPath(resolvedPath, resolvedBucket);
|
|
24784
23976
|
try {
|
|
24785
|
-
await
|
|
24786
|
-
|
|
24787
|
-
await
|
|
24788
|
-
}
|
|
23977
|
+
const stats = await stat(fullPath);
|
|
23978
|
+
if (stats.isDirectory()) {
|
|
23979
|
+
await fs$4.promises.rmdir(fullPath);
|
|
23980
|
+
} else {
|
|
23981
|
+
await unlink(fullPath);
|
|
23982
|
+
try {
|
|
23983
|
+
await unlink(`${fullPath}.metadata.json`);
|
|
23984
|
+
} catch {
|
|
23985
|
+
}
|
|
24789
23986
|
}
|
|
24790
23987
|
} catch (error2) {
|
|
24791
|
-
if (error2 instanceof Error
|
|
24792
|
-
|
|
23988
|
+
if (error2 instanceof Error) {
|
|
23989
|
+
const code2 = error2.code;
|
|
23990
|
+
if (code2 === "ENOENT" || code2 === "ENOTEMPTY") {
|
|
23991
|
+
return;
|
|
23992
|
+
}
|
|
24793
23993
|
}
|
|
23994
|
+
throw error2;
|
|
24794
23995
|
}
|
|
24795
23996
|
}
|
|
24796
23997
|
async listObjects(prefix, options2) {
|
|
@@ -24897,7 +24098,8 @@ class S3StorageController {
|
|
|
24897
24098
|
* Get the bucket name - either from parameter or config
|
|
24898
24099
|
*/
|
|
24899
24100
|
getBucket(bucket) {
|
|
24900
|
-
|
|
24101
|
+
if (!bucket || bucket === "default") return this.config.bucket;
|
|
24102
|
+
return bucket;
|
|
24901
24103
|
}
|
|
24902
24104
|
async putObject({
|
|
24903
24105
|
file,
|
|
@@ -25185,11 +24387,18 @@ function createStorageRoutes(config) {
|
|
|
25185
24387
|
const fileContent = fs$4.readFileSync(absolutePath);
|
|
25186
24388
|
return c.body(new Uint8Array(fileContent));
|
|
25187
24389
|
}
|
|
25188
|
-
const
|
|
25189
|
-
|
|
24390
|
+
const {
|
|
24391
|
+
bucket: parsedBucket,
|
|
24392
|
+
resolvedPath: parsedPath
|
|
24393
|
+
} = parseBucketAndPath(filePath);
|
|
24394
|
+
const fileObject = await controller.getObject(parsedPath, parsedBucket);
|
|
24395
|
+
if (!fileObject) {
|
|
25190
24396
|
throw ApiError.notFound("File not found");
|
|
25191
24397
|
}
|
|
25192
|
-
|
|
24398
|
+
c.header("Content-Type", fileObject.type || "application/octet-stream");
|
|
24399
|
+
c.header("Cache-Control", "public, max-age=3600, immutable");
|
|
24400
|
+
const buf = await fileObject.arrayBuffer();
|
|
24401
|
+
return c.body(new Uint8Array(buf));
|
|
25193
24402
|
});
|
|
25194
24403
|
router.get("/metadata/*", readAuthMiddleware, async (c) => {
|
|
25195
24404
|
const rawPath = extractWildcardPath(c);
|
|
@@ -25239,7 +24448,7 @@ function createStorageRoutes(config) {
|
|
|
25239
24448
|
const maxResults = c.req.query("maxResults");
|
|
25240
24449
|
const pageToken = c.req.query("pageToken");
|
|
25241
24450
|
const result = await controller.listObjects(storagePrefix, {
|
|
25242
|
-
bucket,
|
|
24451
|
+
bucket: bucket ?? (controller.getType() === "local" ? "default" : void 0),
|
|
25243
24452
|
maxResults: maxResults ? parseInt(maxResults, 10) : void 0,
|
|
25244
24453
|
pageToken
|
|
25245
24454
|
});
|
|
@@ -25248,6 +24457,40 @@ function createStorageRoutes(config) {
|
|
|
25248
24457
|
data: result
|
|
25249
24458
|
});
|
|
25250
24459
|
});
|
|
24460
|
+
router.post("/folder", writeAuthMiddleware, async (c) => {
|
|
24461
|
+
const body = await c.req.json();
|
|
24462
|
+
const folderPath = body.path;
|
|
24463
|
+
if (!folderPath || typeof folderPath !== "string") {
|
|
24464
|
+
throw ApiError.badRequest("Folder path is required");
|
|
24465
|
+
}
|
|
24466
|
+
const {
|
|
24467
|
+
bucket,
|
|
24468
|
+
resolvedPath
|
|
24469
|
+
} = parseBucketAndPath(folderPath);
|
|
24470
|
+
if (!resolvedPath || resolvedPath.trim() === "") {
|
|
24471
|
+
throw ApiError.badRequest("Invalid folder path");
|
|
24472
|
+
}
|
|
24473
|
+
if (controller.getType() === "local") {
|
|
24474
|
+
const localController = controller;
|
|
24475
|
+
const absolutePath = localController.getAbsolutePath(resolvedPath, bucket);
|
|
24476
|
+
fs$4.mkdirSync(absolutePath, {
|
|
24477
|
+
recursive: true
|
|
24478
|
+
});
|
|
24479
|
+
} else {
|
|
24480
|
+
const key = resolvedPath.endsWith("/") ? resolvedPath : resolvedPath + "/";
|
|
24481
|
+
const emptyFile = new File([], key, {
|
|
24482
|
+
type: "application/x-directory"
|
|
24483
|
+
});
|
|
24484
|
+
await controller.putObject({
|
|
24485
|
+
file: emptyFile,
|
|
24486
|
+
key
|
|
24487
|
+
});
|
|
24488
|
+
}
|
|
24489
|
+
return c.json({
|
|
24490
|
+
success: true,
|
|
24491
|
+
message: "Folder created"
|
|
24492
|
+
}, 201);
|
|
24493
|
+
});
|
|
25251
24494
|
return router;
|
|
25252
24495
|
}
|
|
25253
24496
|
const DEFAULT_STORAGE_ID = "(default)";
|
|
@@ -25371,8 +24614,8 @@ class RebaseApiError extends Error {
|
|
|
25371
24614
|
status;
|
|
25372
24615
|
code;
|
|
25373
24616
|
details;
|
|
25374
|
-
constructor(status,
|
|
25375
|
-
super(
|
|
24617
|
+
constructor(status, message, code2, details) {
|
|
24618
|
+
super(message);
|
|
25376
24619
|
this.name = "RebaseApiError";
|
|
25377
24620
|
this.status = status;
|
|
25378
24621
|
this.code = code2;
|
|
@@ -26343,6 +25586,18 @@ function createCollectionClient(transport, slug, ws) {
|
|
|
26343
25586
|
method: "DELETE"
|
|
26344
25587
|
});
|
|
26345
25588
|
},
|
|
25589
|
+
async count(params) {
|
|
25590
|
+
const countParams = {
|
|
25591
|
+
...params,
|
|
25592
|
+
limit: void 0,
|
|
25593
|
+
offset: void 0
|
|
25594
|
+
};
|
|
25595
|
+
const qs = buildQueryString(countParams);
|
|
25596
|
+
const raw = await transport.request(basePath + "/count" + qs, {
|
|
25597
|
+
method: "GET"
|
|
25598
|
+
});
|
|
25599
|
+
return raw.count ?? 0;
|
|
25600
|
+
},
|
|
26346
25601
|
// Fluent builder instantiation
|
|
26347
25602
|
where(column, operator, value) {
|
|
26348
25603
|
return new QueryBuilder(client).where(column, operator, value);
|
|
@@ -27349,7 +26604,7 @@ var fetchExports = fetch$1.exports;
|
|
|
27349
26604
|
});
|
|
27350
26605
|
return options2;
|
|
27351
26606
|
};
|
|
27352
|
-
module.exports._logFunc = (logger2, level, defaults, data,
|
|
26607
|
+
module.exports._logFunc = (logger2, level, defaults, data, message, ...args) => {
|
|
27353
26608
|
let entry = {};
|
|
27354
26609
|
Object.keys(defaults || {}).forEach((key) => {
|
|
27355
26610
|
if (key !== "level") {
|
|
@@ -27361,7 +26616,7 @@ var fetchExports = fetch$1.exports;
|
|
|
27361
26616
|
entry[key] = data[key];
|
|
27362
26617
|
}
|
|
27363
26618
|
});
|
|
27364
|
-
logger2[level](entry,
|
|
26619
|
+
logger2[level](entry, message, ...args);
|
|
27365
26620
|
};
|
|
27366
26621
|
module.exports.getLogger = (options2, defaults) => {
|
|
27367
26622
|
options2 = options2 || {};
|
|
@@ -27378,8 +26633,8 @@ var fetchExports = fetch$1.exports;
|
|
|
27378
26633
|
logger2 = createDefaultLogger(levels);
|
|
27379
26634
|
}
|
|
27380
26635
|
levels.forEach((level) => {
|
|
27381
|
-
response[level] = (data,
|
|
27382
|
-
module.exports._logFunc(logger2, level, defaults, data,
|
|
26636
|
+
response[level] = (data, message, ...args) => {
|
|
26637
|
+
module.exports._logFunc(logger2, level, defaults, data, message, ...args);
|
|
27383
26638
|
};
|
|
27384
26639
|
});
|
|
27385
26640
|
return response;
|
|
@@ -27562,7 +26817,7 @@ var fetchExports = fetch$1.exports;
|
|
|
27562
26817
|
}
|
|
27563
26818
|
levelNames.set(level, levelName);
|
|
27564
26819
|
});
|
|
27565
|
-
let print2 = (level, entry,
|
|
26820
|
+
let print2 = (level, entry, message, ...args) => {
|
|
27566
26821
|
let prefix = "";
|
|
27567
26822
|
if (entry) {
|
|
27568
26823
|
if (entry.tnx === "server") {
|
|
@@ -27577,8 +26832,8 @@ var fetchExports = fetch$1.exports;
|
|
|
27577
26832
|
prefix = "[#" + entry.cid + "] " + prefix;
|
|
27578
26833
|
}
|
|
27579
26834
|
}
|
|
27580
|
-
|
|
27581
|
-
|
|
26835
|
+
message = util2.format(message, ...args);
|
|
26836
|
+
message.split(/\r?\n/).forEach((line) => {
|
|
27582
26837
|
console.log("[%s] %s %s", (/* @__PURE__ */ new Date()).toISOString().substr(0, 19).replace(/T/, " "), levelNames.get(level), prefix + line);
|
|
27583
26838
|
});
|
|
27584
26839
|
};
|
|
@@ -34074,8 +33329,8 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34074
33329
|
* @param {Object} message String, Buffer or a Stream
|
|
34075
33330
|
* @param {Function} callback Callback to return once sending is completed
|
|
34076
33331
|
*/
|
|
34077
|
-
send(envelope,
|
|
34078
|
-
if (!
|
|
33332
|
+
send(envelope, message, done) {
|
|
33333
|
+
if (!message) {
|
|
34079
33334
|
return done(this._formatError("Empty message", "EMESSAGE", false, "API"));
|
|
34080
33335
|
}
|
|
34081
33336
|
const isDestroyedMessage = this._isDestroyedMessage("send message");
|
|
@@ -34095,17 +33350,17 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34095
33350
|
returned = true;
|
|
34096
33351
|
done(...arguments);
|
|
34097
33352
|
};
|
|
34098
|
-
if (typeof
|
|
34099
|
-
|
|
33353
|
+
if (typeof message.on === "function") {
|
|
33354
|
+
message.on("error", (err) => callback(this._formatError(err, "ESTREAM", false, "API")));
|
|
34100
33355
|
}
|
|
34101
33356
|
let startTime = Date.now();
|
|
34102
33357
|
this._setEnvelope(envelope, (err, info) => {
|
|
34103
33358
|
if (err) {
|
|
34104
33359
|
let stream3 = new PassThrough();
|
|
34105
|
-
if (typeof
|
|
34106
|
-
|
|
33360
|
+
if (typeof message.pipe === "function") {
|
|
33361
|
+
message.pipe(stream3);
|
|
34107
33362
|
} else {
|
|
34108
|
-
stream3.write(
|
|
33363
|
+
stream3.write(message);
|
|
34109
33364
|
stream3.end();
|
|
34110
33365
|
}
|
|
34111
33366
|
return callback(err);
|
|
@@ -34121,10 +33376,10 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34121
33376
|
info.response = str;
|
|
34122
33377
|
return callback(null, info);
|
|
34123
33378
|
});
|
|
34124
|
-
if (typeof
|
|
34125
|
-
|
|
33379
|
+
if (typeof message.pipe === "function") {
|
|
33380
|
+
message.pipe(stream2);
|
|
34126
33381
|
} else {
|
|
34127
|
-
stream2.write(
|
|
33382
|
+
stream2.write(message);
|
|
34128
33383
|
stream2.end();
|
|
34129
33384
|
}
|
|
34130
33385
|
});
|
|
@@ -34237,12 +33492,12 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34237
33492
|
this.emit("error", err);
|
|
34238
33493
|
this.close();
|
|
34239
33494
|
}
|
|
34240
|
-
_formatError(
|
|
33495
|
+
_formatError(message, type, response, command) {
|
|
34241
33496
|
let err;
|
|
34242
|
-
if (/Error\]$/i.test(Object.prototype.toString.call(
|
|
34243
|
-
err =
|
|
33497
|
+
if (/Error\]$/i.test(Object.prototype.toString.call(message))) {
|
|
33498
|
+
err = message;
|
|
34244
33499
|
} else {
|
|
34245
|
-
err = new Error(
|
|
33500
|
+
err = new Error(message);
|
|
34246
33501
|
}
|
|
34247
33502
|
if (type && type !== "Error") {
|
|
34248
33503
|
err.code = type;
|
|
@@ -34885,14 +34140,14 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34885
34140
|
* @param {String} str Message from the server
|
|
34886
34141
|
*/
|
|
34887
34142
|
_actionMAIL(str, callback) {
|
|
34888
|
-
let
|
|
34143
|
+
let message, curRecipient;
|
|
34889
34144
|
if (Number(str.charAt(0)) !== 2) {
|
|
34890
34145
|
if (this._usingSmtpUtf8 && /^550 /.test(str) && /[\x80-\uFFFF]/.test(this._envelope.from)) {
|
|
34891
|
-
|
|
34146
|
+
message = "Internationalized mailbox name not allowed";
|
|
34892
34147
|
} else {
|
|
34893
|
-
|
|
34148
|
+
message = "Mail command failed";
|
|
34894
34149
|
}
|
|
34895
|
-
return callback(this._formatError(
|
|
34150
|
+
return callback(this._formatError(message, "EENVELOPE", str, "MAIL FROM"));
|
|
34896
34151
|
}
|
|
34897
34152
|
if (!this._envelope.rcptQueue.length) {
|
|
34898
34153
|
return callback(this._formatError("Can't send mail - no recipients defined", "EENVELOPE", false, "API"));
|
|
@@ -34923,15 +34178,15 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34923
34178
|
* @param {String} str Message from the server
|
|
34924
34179
|
*/
|
|
34925
34180
|
_actionRCPT(str, callback) {
|
|
34926
|
-
let
|
|
34181
|
+
let message, err, curRecipient = this._recipientQueue.shift();
|
|
34927
34182
|
if (Number(str.charAt(0)) !== 2) {
|
|
34928
34183
|
if (this._usingSmtpUtf8 && /^553 /.test(str) && /[\x80-\uFFFF]/.test(curRecipient)) {
|
|
34929
|
-
|
|
34184
|
+
message = "Internationalized mailbox name not allowed";
|
|
34930
34185
|
} else {
|
|
34931
|
-
|
|
34186
|
+
message = "Recipient command failed";
|
|
34932
34187
|
}
|
|
34933
34188
|
this._envelope.rejected.push(curRecipient);
|
|
34934
|
-
err = this._formatError(
|
|
34189
|
+
err = this._formatError(message, "EENVELOPE", str, "RCPT TO");
|
|
34935
34190
|
err.recipient = curRecipient;
|
|
34936
34191
|
this._envelope.rejectedErrors.push(err);
|
|
34937
34192
|
} else {
|
|
@@ -37647,9 +36902,9 @@ class SMTPEmailService {
|
|
|
37647
36902
|
replyTo: options2.replyTo
|
|
37648
36903
|
});
|
|
37649
36904
|
} catch (error2) {
|
|
37650
|
-
const
|
|
37651
|
-
console.error("Failed to send email:",
|
|
37652
|
-
throw new Error(`Failed to send email: ${
|
|
36905
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
36906
|
+
console.error("Failed to send email:", message);
|
|
36907
|
+
throw new Error(`Failed to send email: ${message}`);
|
|
37653
36908
|
}
|
|
37654
36909
|
}
|
|
37655
36910
|
/**
|
|
@@ -37663,8 +36918,8 @@ class SMTPEmailService {
|
|
|
37663
36918
|
await this.transporter.verify();
|
|
37664
36919
|
return true;
|
|
37665
36920
|
} catch (error2) {
|
|
37666
|
-
const
|
|
37667
|
-
console.error("SMTP connection verification failed:",
|
|
36921
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
36922
|
+
console.error("SMTP connection verification failed:", message);
|
|
37668
36923
|
return false;
|
|
37669
36924
|
}
|
|
37670
36925
|
}
|
|
@@ -37944,7 +37199,8 @@ async function _initializeRebaseBackend(config) {
|
|
|
37944
37199
|
authRepo: authConfigResult.authRepository ?? authConfigResult.userService,
|
|
37945
37200
|
emailService: authConfigResult.emailService,
|
|
37946
37201
|
emailConfig: config.auth.email,
|
|
37947
|
-
serviceKey
|
|
37202
|
+
serviceKey,
|
|
37203
|
+
hooks: config.hooks
|
|
37948
37204
|
});
|
|
37949
37205
|
config.app.route(`${basePath}/admin`, adminRoutes);
|
|
37950
37206
|
}
|
|
@@ -38002,7 +37258,7 @@ async function _initializeRebaseBackend(config) {
|
|
|
38002
37258
|
});
|
|
38003
37259
|
dataRouter.route("/", historyRoutes);
|
|
38004
37260
|
}
|
|
38005
|
-
const restGenerator = new RestApiGenerator(activeCollections, defaultDriver);
|
|
37261
|
+
const restGenerator = new RestApiGenerator(activeCollections, defaultDriver, config.hooks?.data);
|
|
38006
37262
|
dataRouter.route("/", restGenerator.generateRoutes());
|
|
38007
37263
|
config.app.route(`${basePath}/data`, dataRouter);
|
|
38008
37264
|
}
|
|
@@ -38196,10 +37452,10 @@ async function _initializeRebaseBackend(config) {
|
|
|
38196
37452
|
shutdown
|
|
38197
37453
|
};
|
|
38198
37454
|
}
|
|
38199
|
-
function devAssert(condition,
|
|
37455
|
+
function devAssert(condition, message) {
|
|
38200
37456
|
const booleanCondition = Boolean(condition);
|
|
38201
37457
|
if (!booleanCondition) {
|
|
38202
|
-
throw new Error(
|
|
37458
|
+
throw new Error(message);
|
|
38203
37459
|
}
|
|
38204
37460
|
}
|
|
38205
37461
|
function isPromise(value) {
|
|
@@ -38208,11 +37464,11 @@ function isPromise(value) {
|
|
|
38208
37464
|
function isObjectLike(value) {
|
|
38209
37465
|
return typeof value == "object" && value !== null;
|
|
38210
37466
|
}
|
|
38211
|
-
function invariant(condition,
|
|
37467
|
+
function invariant(condition, message) {
|
|
38212
37468
|
const booleanCondition = Boolean(condition);
|
|
38213
37469
|
if (!booleanCondition) {
|
|
38214
37470
|
throw new Error(
|
|
38215
|
-
|
|
37471
|
+
message != null ? message : "Unexpected invariant triggered."
|
|
38216
37472
|
);
|
|
38217
37473
|
}
|
|
38218
37474
|
}
|
|
@@ -38331,10 +37587,10 @@ class GraphQLError extends Error {
|
|
|
38331
37587
|
/**
|
|
38332
37588
|
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
38333
37589
|
*/
|
|
38334
|
-
constructor(
|
|
37590
|
+
constructor(message, ...rawArgs) {
|
|
38335
37591
|
var _this$nodes, _nodeLocations$, _ref;
|
|
38336
37592
|
const { nodes, source, positions, path: path2, originalError, extensions: extensions2 } = toNormalizedOptions(rawArgs);
|
|
38337
|
-
super(
|
|
37593
|
+
super(message);
|
|
38338
37594
|
this.name = "GraphQLError";
|
|
38339
37595
|
this.path = path2 !== null && path2 !== void 0 ? path2 : void 0;
|
|
38340
37596
|
this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
|
|
@@ -39352,14 +38608,14 @@ function formatArray(array, seenValues) {
|
|
|
39352
38608
|
return "[" + items.join(", ") + "]";
|
|
39353
38609
|
}
|
|
39354
38610
|
function getObjectTag(object) {
|
|
39355
|
-
const
|
|
39356
|
-
if (
|
|
38611
|
+
const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
|
|
38612
|
+
if (tag === "Object" && typeof object.constructor === "function") {
|
|
39357
38613
|
const name2 = object.constructor.name;
|
|
39358
38614
|
if (typeof name2 === "string" && name2 !== "") {
|
|
39359
38615
|
return name2;
|
|
39360
38616
|
}
|
|
39361
38617
|
}
|
|
39362
|
-
return
|
|
38618
|
+
return tag;
|
|
39363
38619
|
}
|
|
39364
38620
|
const isProduction = globalThis.process && // eslint-disable-next-line no-undef
|
|
39365
38621
|
process.env.NODE_ENV === "production";
|
|
@@ -40757,22 +40013,22 @@ function getTokenKindDesc(kind) {
|
|
|
40757
40013
|
const MAX_SUGGESTIONS = 5;
|
|
40758
40014
|
function didYouMean(firstArg, secondArg) {
|
|
40759
40015
|
const [subMessage, suggestionsArg] = secondArg ? [firstArg, secondArg] : [void 0, firstArg];
|
|
40760
|
-
let
|
|
40016
|
+
let message = " Did you mean ";
|
|
40761
40017
|
if (subMessage) {
|
|
40762
|
-
|
|
40018
|
+
message += subMessage + " ";
|
|
40763
40019
|
}
|
|
40764
40020
|
const suggestions = suggestionsArg.map((x) => `"${x}"`);
|
|
40765
40021
|
switch (suggestions.length) {
|
|
40766
40022
|
case 0:
|
|
40767
40023
|
return "";
|
|
40768
40024
|
case 1:
|
|
40769
|
-
return
|
|
40025
|
+
return message + suggestions[0] + "?";
|
|
40770
40026
|
case 2:
|
|
40771
|
-
return
|
|
40027
|
+
return message + suggestions[0] + " or " + suggestions[1] + "?";
|
|
40772
40028
|
}
|
|
40773
40029
|
const selected = suggestions.slice(0, MAX_SUGGESTIONS);
|
|
40774
40030
|
const lastItem = selected.pop();
|
|
40775
|
-
return
|
|
40031
|
+
return message + selected.join(", ") + ", or " + lastItem + "?";
|
|
40776
40032
|
}
|
|
40777
40033
|
function identityFunc(x) {
|
|
40778
40034
|
return x;
|
|
@@ -43416,10 +42672,10 @@ class SchemaValidationContext {
|
|
|
43416
42672
|
this._errors = [];
|
|
43417
42673
|
this.schema = schema;
|
|
43418
42674
|
}
|
|
43419
|
-
reportError(
|
|
42675
|
+
reportError(message, nodes) {
|
|
43420
42676
|
const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
|
|
43421
42677
|
this._errors.push(
|
|
43422
|
-
new GraphQLError(
|
|
42678
|
+
new GraphQLError(message, {
|
|
43423
42679
|
nodes: _nodes
|
|
43424
42680
|
})
|
|
43425
42681
|
);
|
|
@@ -47794,9 +47050,9 @@ var errorMessages = (messages, graphqlErrors) => {
|
|
|
47794
47050
|
};
|
|
47795
47051
|
}
|
|
47796
47052
|
return {
|
|
47797
|
-
errors: messages.map((
|
|
47053
|
+
errors: messages.map((message) => {
|
|
47798
47054
|
return {
|
|
47799
|
-
message
|
|
47055
|
+
message
|
|
47800
47056
|
};
|
|
47801
47057
|
})
|
|
47802
47058
|
};
|
|
@@ -49020,9 +48276,9 @@ class RebaseApiServer {
|
|
|
49020
48276
|
if (process.env.NODE_ENV === "production") {
|
|
49021
48277
|
console.warn("[RebaseApiServer] Schema Editor is disabled in production environments for security.");
|
|
49022
48278
|
} else {
|
|
48279
|
+
this.router.use(`${basePath}/schema-editor/*`, requireAuth, requireAdmin);
|
|
49023
48280
|
const schemaEditorRoutes2 = createSchemaEditorRoutes(this.config.collectionsDir);
|
|
49024
48281
|
this.router.route(`${basePath}/schema-editor`, schemaEditorRoutes2);
|
|
49025
|
-
this.router.use(`${basePath}/schema-editor/*`, requireAuth, requireAdmin);
|
|
49026
48282
|
}
|
|
49027
48283
|
}
|
|
49028
48284
|
this.router.get(`${basePath}/docs`, (c) => {
|
|
@@ -49136,8 +48392,8 @@ async function loadFunctionsFromDirectory(directory) {
|
|
|
49136
48392
|
Hint: ensure the function exports a Hono app created with the same hono version as the server.
|
|
49137
48393
|
The loader checks for .fetch() and .routes — any Hono-compatible app will work.`);
|
|
49138
48394
|
} catch (err) {
|
|
49139
|
-
const
|
|
49140
|
-
console.error(`[functions] Failed to load ${file}: ${
|
|
48395
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
48396
|
+
console.error(`[functions] Failed to load ${file}: ${message}`);
|
|
49141
48397
|
}
|
|
49142
48398
|
}
|
|
49143
48399
|
}
|
|
@@ -49209,8 +48465,8 @@ async function loadCronJobsFromDirectory(directory) {
|
|
|
49209
48465
|
});
|
|
49210
48466
|
console.log(`⏰ Loaded cron job: ${id} (${definition.schedule})`);
|
|
49211
48467
|
} catch (err) {
|
|
49212
|
-
const
|
|
49213
|
-
console.error(`[cron] Failed to load ${file}: ${
|
|
48468
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
48469
|
+
console.error(`[cron] Failed to load ${file}: ${message}`);
|
|
49214
48470
|
}
|
|
49215
48471
|
}
|
|
49216
48472
|
}
|
|
@@ -49220,46 +48476,98 @@ const cronLoader = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
49220
48476
|
__proto__: null,
|
|
49221
48477
|
loadCronJobsFromDirectory
|
|
49222
48478
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
48479
|
+
function expandCronField(field, min, max) {
|
|
48480
|
+
const results = /* @__PURE__ */ new Set();
|
|
48481
|
+
for (const segment of field.split(",")) {
|
|
48482
|
+
const trimmed = segment.trim();
|
|
48483
|
+
if (trimmed === "*") {
|
|
48484
|
+
for (let i = min; i <= max; i++) results.add(i);
|
|
48485
|
+
} else if (trimmed.includes("/")) {
|
|
48486
|
+
const [rangeStr, stepStr] = trimmed.split("/");
|
|
48487
|
+
const step = parseInt(stepStr, 10);
|
|
48488
|
+
if (isNaN(step) || step <= 0) {
|
|
48489
|
+
throw new Error(`Invalid step value "${stepStr}" in cron field "${field}"`);
|
|
48490
|
+
}
|
|
48491
|
+
let start = min;
|
|
48492
|
+
let end2 = max;
|
|
48493
|
+
if (rangeStr !== "*") {
|
|
48494
|
+
if (rangeStr.includes("-")) {
|
|
48495
|
+
const [a2, b] = rangeStr.split("-").map(Number);
|
|
48496
|
+
start = a2;
|
|
48497
|
+
end2 = b;
|
|
48498
|
+
} else {
|
|
48499
|
+
start = parseInt(rangeStr, 10);
|
|
48500
|
+
}
|
|
48501
|
+
}
|
|
48502
|
+
for (let i = start; i <= end2; i += step) results.add(i);
|
|
48503
|
+
} else if (trimmed.includes("-")) {
|
|
48504
|
+
const [a2, b] = trimmed.split("-").map(Number);
|
|
48505
|
+
for (let i = a2; i <= b; i++) results.add(i);
|
|
48506
|
+
} else {
|
|
48507
|
+
const val = parseInt(trimmed, 10);
|
|
48508
|
+
if (isNaN(val)) {
|
|
48509
|
+
throw new Error(`Invalid value "${trimmed}" in cron field "${field}"`);
|
|
48510
|
+
}
|
|
48511
|
+
results.add(val);
|
|
48512
|
+
}
|
|
48513
|
+
}
|
|
48514
|
+
return [...results].sort((a2, b) => a2 - b);
|
|
48515
|
+
}
|
|
48516
|
+
function validateCronExpression(schedule) {
|
|
48517
|
+
if (!schedule || typeof schedule !== "string") {
|
|
48518
|
+
return {
|
|
48519
|
+
valid: false,
|
|
48520
|
+
reason: "Schedule must be a non-empty string"
|
|
48521
|
+
};
|
|
48522
|
+
}
|
|
48523
|
+
const parts = schedule.trim().split(/\s+/);
|
|
48524
|
+
if (parts.length !== 5) {
|
|
48525
|
+
return {
|
|
48526
|
+
valid: false,
|
|
48527
|
+
reason: `Expected 5 fields, got ${parts.length}`
|
|
48528
|
+
};
|
|
48529
|
+
}
|
|
48530
|
+
const fieldRanges = [["minute", 0, 59], ["hour", 0, 23], ["day of month", 1, 31], ["month", 1, 12], ["day of week", 0, 6]];
|
|
48531
|
+
for (let i = 0; i < 5; i++) {
|
|
48532
|
+
const [name2, min, max] = fieldRanges[i];
|
|
48533
|
+
try {
|
|
48534
|
+
const values2 = expandCronField(parts[i], min, max);
|
|
48535
|
+
if (values2.length === 0) {
|
|
48536
|
+
return {
|
|
48537
|
+
valid: false,
|
|
48538
|
+
reason: `${name2} field "${parts[i]}" produces no values`
|
|
48539
|
+
};
|
|
48540
|
+
}
|
|
48541
|
+
for (const v of values2) {
|
|
48542
|
+
if (v < min || v > max) {
|
|
48543
|
+
return {
|
|
48544
|
+
valid: false,
|
|
48545
|
+
reason: `${name2} field value ${v} out of range [${min}–${max}]`
|
|
48546
|
+
};
|
|
48547
|
+
}
|
|
48548
|
+
}
|
|
48549
|
+
} catch (err) {
|
|
48550
|
+
return {
|
|
48551
|
+
valid: false,
|
|
48552
|
+
reason: `${name2} field: ${err instanceof Error ? err.message : String(err)}`
|
|
48553
|
+
};
|
|
48554
|
+
}
|
|
48555
|
+
}
|
|
48556
|
+
return {
|
|
48557
|
+
valid: true
|
|
48558
|
+
};
|
|
48559
|
+
}
|
|
49223
48560
|
function parseCronExpression(expression, after) {
|
|
49224
48561
|
const parts = expression.trim().split(/\s+/);
|
|
49225
48562
|
if (parts.length < 5) {
|
|
49226
48563
|
throw new Error(`Invalid cron expression: "${expression}". Expected 5 fields.`);
|
|
49227
48564
|
}
|
|
49228
48565
|
const [minField, hourField, domField, monField, dowField] = parts;
|
|
49229
|
-
const
|
|
49230
|
-
|
|
49231
|
-
|
|
49232
|
-
|
|
49233
|
-
|
|
49234
|
-
} else if (segment.includes("/")) {
|
|
49235
|
-
const [rangeStr, stepStr] = segment.split("/");
|
|
49236
|
-
const step = parseInt(stepStr, 10);
|
|
49237
|
-
let start = min;
|
|
49238
|
-
let end2 = max;
|
|
49239
|
-
if (rangeStr !== "*") {
|
|
49240
|
-
if (rangeStr.includes("-")) {
|
|
49241
|
-
const [a2, b] = rangeStr.split("-").map(Number);
|
|
49242
|
-
start = a2;
|
|
49243
|
-
end2 = b;
|
|
49244
|
-
} else {
|
|
49245
|
-
start = parseInt(rangeStr, 10);
|
|
49246
|
-
}
|
|
49247
|
-
}
|
|
49248
|
-
for (let i = start; i <= end2; i += step) results.add(i);
|
|
49249
|
-
} else if (segment.includes("-")) {
|
|
49250
|
-
const [a2, b] = segment.split("-").map(Number);
|
|
49251
|
-
for (let i = a2; i <= b; i++) results.add(i);
|
|
49252
|
-
} else {
|
|
49253
|
-
results.add(parseInt(segment, 10));
|
|
49254
|
-
}
|
|
49255
|
-
}
|
|
49256
|
-
return [...results].sort((a2, b) => a2 - b);
|
|
49257
|
-
};
|
|
49258
|
-
const minutes = expand(minField, 0, 59);
|
|
49259
|
-
const hours = expand(hourField, 0, 23);
|
|
49260
|
-
const doms = expand(domField, 1, 31);
|
|
49261
|
-
const months = expand(monField, 1, 12);
|
|
49262
|
-
const dows = expand(dowField, 0, 6);
|
|
48566
|
+
const minutes = expandCronField(minField, 0, 59);
|
|
48567
|
+
const hours = expandCronField(hourField, 0, 23);
|
|
48568
|
+
const doms = expandCronField(domField, 1, 31);
|
|
48569
|
+
const months = expandCronField(monField, 1, 12);
|
|
48570
|
+
const dows = expandCronField(dowField, 0, 6);
|
|
49263
48571
|
const candidate = new Date(after);
|
|
49264
48572
|
candidate.setSeconds(0, 0);
|
|
49265
48573
|
candidate.setMinutes(candidate.getMinutes() + 1);
|
|
@@ -49268,9 +48576,9 @@ function parseCronExpression(expression, after) {
|
|
|
49268
48576
|
const month = candidate.getMonth() + 1;
|
|
49269
48577
|
const dom = candidate.getDate();
|
|
49270
48578
|
const dow = candidate.getDay();
|
|
49271
|
-
const
|
|
49272
|
-
const
|
|
49273
|
-
if (months.includes(month) && doms.includes(dom) && dows.includes(dow) && hours.includes(
|
|
48579
|
+
const hour = candidate.getHours();
|
|
48580
|
+
const minute = candidate.getMinutes();
|
|
48581
|
+
if (months.includes(month) && doms.includes(dom) && dows.includes(dow) && hours.includes(hour) && minutes.includes(minute)) {
|
|
49274
48582
|
return candidate;
|
|
49275
48583
|
}
|
|
49276
48584
|
candidate.setMinutes(candidate.getMinutes() + 1);
|
|
@@ -49280,6 +48588,7 @@ function parseCronExpression(expression, after) {
|
|
|
49280
48588
|
return fallback;
|
|
49281
48589
|
}
|
|
49282
48590
|
const MAX_LOGS_PER_JOB = 50;
|
|
48591
|
+
const MIN_SCHEDULE_INTERVAL_MS = 5e3;
|
|
49283
48592
|
class CronScheduler {
|
|
49284
48593
|
jobs = /* @__PURE__ */ new Map();
|
|
49285
48594
|
started = false;
|
|
@@ -49301,23 +48610,39 @@ class CronScheduler {
|
|
|
49301
48610
|
}
|
|
49302
48611
|
/**
|
|
49303
48612
|
* Register a batch of loaded cron jobs.
|
|
48613
|
+
*
|
|
48614
|
+
* If the scheduler is already started, newly registered jobs are
|
|
48615
|
+
* automatically scheduled (so late-registered jobs don't sit idle).
|
|
48616
|
+
*
|
|
48617
|
+
* Validates the cron schedule on registration — invalid schedules
|
|
48618
|
+
* are rejected with a warning and the job is NOT registered.
|
|
49304
48619
|
*/
|
|
49305
48620
|
registerJobs(loadedJobs) {
|
|
49306
48621
|
for (const loaded of loadedJobs) {
|
|
48622
|
+
const validation = validateCronExpression(loaded.definition.schedule);
|
|
48623
|
+
if (!validation.valid) {
|
|
48624
|
+
console.error(`[cron] Rejecting job "${loaded.id}": invalid schedule "${loaded.definition.schedule}" — ${validation.reason}`);
|
|
48625
|
+
continue;
|
|
48626
|
+
}
|
|
49307
48627
|
const existing = this.jobs.get(loaded.id);
|
|
49308
48628
|
if (existing) {
|
|
49309
48629
|
console.warn(`[cron] Duplicate cron job id: "${loaded.id}". Overwriting.`);
|
|
49310
48630
|
this.stopJob(loaded.id);
|
|
49311
48631
|
}
|
|
48632
|
+
const enabled = loaded.definition.enabled !== false;
|
|
49312
48633
|
this.jobs.set(loaded.id, {
|
|
49313
48634
|
id: loaded.id,
|
|
49314
48635
|
definition: loaded.definition,
|
|
49315
|
-
enabled
|
|
49316
|
-
state:
|
|
48636
|
+
enabled,
|
|
48637
|
+
state: enabled ? "idle" : "disabled",
|
|
49317
48638
|
totalRuns: 0,
|
|
49318
48639
|
totalFailures: 0,
|
|
49319
|
-
logs: []
|
|
48640
|
+
logs: [],
|
|
48641
|
+
executing: false
|
|
49320
48642
|
});
|
|
48643
|
+
if (this.started && enabled) {
|
|
48644
|
+
this.scheduleNext(loaded.id);
|
|
48645
|
+
}
|
|
49321
48646
|
}
|
|
49322
48647
|
}
|
|
49323
48648
|
/**
|
|
@@ -49351,6 +48676,9 @@ class CronScheduler {
|
|
|
49351
48676
|
}
|
|
49352
48677
|
/**
|
|
49353
48678
|
* Stop the scheduler and clear all timers.
|
|
48679
|
+
*
|
|
48680
|
+
* Currently-executing handlers run to completion (they are async),
|
|
48681
|
+
* but no further scheduling occurs after stop.
|
|
49354
48682
|
*/
|
|
49355
48683
|
stop() {
|
|
49356
48684
|
this.started = false;
|
|
@@ -49409,32 +48737,81 @@ class CronScheduler {
|
|
|
49409
48737
|
}
|
|
49410
48738
|
/**
|
|
49411
48739
|
* Manually trigger a job execution immediately.
|
|
48740
|
+
*
|
|
48741
|
+
* Returns `undefined` if the job doesn't exist.
|
|
48742
|
+
* If the job is currently executing, returns the log entry with
|
|
48743
|
+
* a `skipped: true` result rather than running concurrently.
|
|
49412
48744
|
*/
|
|
49413
48745
|
async triggerJob(id) {
|
|
49414
48746
|
const job = this.jobs.get(id);
|
|
49415
48747
|
if (!job) return void 0;
|
|
48748
|
+
if (job.executing) {
|
|
48749
|
+
console.warn(`[cron] Skipping manual trigger of "${id}" — already executing`);
|
|
48750
|
+
const logEntry = {
|
|
48751
|
+
jobId: id,
|
|
48752
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48753
|
+
finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48754
|
+
durationMs: 0,
|
|
48755
|
+
success: true,
|
|
48756
|
+
result: {
|
|
48757
|
+
skipped: true,
|
|
48758
|
+
reason: "already_executing"
|
|
48759
|
+
},
|
|
48760
|
+
logs: ["Skipped: job is already running"],
|
|
48761
|
+
manual: true
|
|
48762
|
+
};
|
|
48763
|
+
job.logs.push(logEntry);
|
|
48764
|
+
if (job.logs.length > MAX_LOGS_PER_JOB) job.logs.shift();
|
|
48765
|
+
return logEntry;
|
|
48766
|
+
}
|
|
49416
48767
|
return this.executeJob(job, true);
|
|
49417
48768
|
}
|
|
49418
48769
|
// ─── Internal ────────────────────────────────────────────────────
|
|
48770
|
+
/**
|
|
48771
|
+
* Schedule the next execution for a job.
|
|
48772
|
+
*
|
|
48773
|
+
* Safety guarantees:
|
|
48774
|
+
* 1. Clears any existing timer first (prevents leaked/duplicate timers)
|
|
48775
|
+
* 2. Enforces a minimum delay to prevent tight loops from jitter
|
|
48776
|
+
* 3. Unref's the timer so it doesn't prevent process exit
|
|
48777
|
+
* 4. Re-checks enabled & started state before executing
|
|
48778
|
+
* 5. Concurrency guard prevents overlapping handler executions
|
|
48779
|
+
*/
|
|
49419
48780
|
scheduleNext(id) {
|
|
49420
48781
|
const job = this.jobs.get(id);
|
|
49421
48782
|
if (!job || !job.enabled || !this.started) return;
|
|
48783
|
+
this.stopJob(id);
|
|
49422
48784
|
try {
|
|
49423
48785
|
const now = /* @__PURE__ */ new Date();
|
|
49424
48786
|
const nextRun = parseCronExpression(job.definition.schedule, now);
|
|
49425
48787
|
job.nextRunAt = nextRun;
|
|
49426
|
-
const
|
|
49427
|
-
|
|
48788
|
+
const rawDelay = nextRun.getTime() - now.getTime();
|
|
48789
|
+
const delay = Math.max(rawDelay, MIN_SCHEDULE_INTERVAL_MS);
|
|
48790
|
+
const timer = setTimeout(async () => {
|
|
49428
48791
|
if (!job.enabled || !this.started) return;
|
|
48792
|
+
if (job.executing) {
|
|
48793
|
+
console.warn(`[cron] Skipping scheduled run of "${id}" — still executing from previous run`);
|
|
48794
|
+
this.scheduleNext(id);
|
|
48795
|
+
return;
|
|
48796
|
+
}
|
|
49429
48797
|
await this.executeJob(job, false);
|
|
49430
|
-
this.
|
|
48798
|
+
if (this.started && job.enabled) {
|
|
48799
|
+
this.scheduleNext(id);
|
|
48800
|
+
}
|
|
49431
48801
|
}, delay);
|
|
48802
|
+
if (timer && typeof timer === "object" && "unref" in timer) {
|
|
48803
|
+
timer.unref();
|
|
48804
|
+
}
|
|
48805
|
+
job.timerId = timer;
|
|
49432
48806
|
} catch (err) {
|
|
49433
48807
|
console.error(`[cron] Failed to schedule "${id}":`, err);
|
|
49434
48808
|
job.state = "error";
|
|
49435
48809
|
job.lastError = err instanceof Error ? err.message : String(err);
|
|
49436
48810
|
}
|
|
49437
48811
|
}
|
|
48812
|
+
/**
|
|
48813
|
+
* Stop a single job's timer and clear its next run state.
|
|
48814
|
+
*/
|
|
49438
48815
|
stopJob(id) {
|
|
49439
48816
|
const job = this.jobs.get(id);
|
|
49440
48817
|
if (job?.timerId) {
|
|
@@ -49443,9 +48820,19 @@ class CronScheduler {
|
|
|
49443
48820
|
job.nextRunAt = void 0;
|
|
49444
48821
|
}
|
|
49445
48822
|
}
|
|
48823
|
+
/**
|
|
48824
|
+
* Execute a job's handler with full isolation and safety.
|
|
48825
|
+
*
|
|
48826
|
+
* - Sets a concurrency flag to prevent overlapping runs
|
|
48827
|
+
* - Wraps handler in a timeout race
|
|
48828
|
+
* - Captures all logs, errors, and results
|
|
48829
|
+
* - Persists to store (non-blocking) if available
|
|
48830
|
+
* - Always restores state even on catastrophic errors
|
|
48831
|
+
*/
|
|
49446
48832
|
async executeJob(job, manual) {
|
|
49447
48833
|
const startedAt = /* @__PURE__ */ new Date();
|
|
49448
48834
|
const capturedLogs = [];
|
|
48835
|
+
job.executing = true;
|
|
49449
48836
|
const ctx = {
|
|
49450
48837
|
jobId: job.id,
|
|
49451
48838
|
scheduledAt: startedAt,
|
|
@@ -49464,14 +48851,21 @@ class CronScheduler {
|
|
|
49464
48851
|
try {
|
|
49465
48852
|
const timeout = (job.definition.timeoutSeconds ?? 300) * 1e3;
|
|
49466
48853
|
const handlerPromise = Promise.resolve(job.definition.handler(ctx));
|
|
48854
|
+
let timeoutHandle;
|
|
49467
48855
|
const timeoutPromise = new Promise((_, reject) => {
|
|
49468
|
-
setTimeout(() => reject(new Error(`Cron job "${job.id}" timed out after ${timeout}ms`)), timeout);
|
|
48856
|
+
timeoutHandle = setTimeout(() => reject(new Error(`Cron job "${job.id}" timed out after ${timeout}ms`)), timeout);
|
|
49469
48857
|
});
|
|
49470
|
-
|
|
48858
|
+
try {
|
|
48859
|
+
result = await Promise.race([handlerPromise, timeoutPromise]);
|
|
48860
|
+
} finally {
|
|
48861
|
+
clearTimeout(timeoutHandle);
|
|
48862
|
+
}
|
|
49471
48863
|
} catch (err) {
|
|
49472
48864
|
success = false;
|
|
49473
48865
|
error2 = err instanceof Error ? err.message : String(err);
|
|
49474
48866
|
job.totalFailures++;
|
|
48867
|
+
} finally {
|
|
48868
|
+
job.executing = false;
|
|
49475
48869
|
}
|
|
49476
48870
|
const finishedAt = /* @__PURE__ */ new Date();
|
|
49477
48871
|
const durationMs = finishedAt.getTime() - startedAt.getTime();
|
|
@@ -49494,8 +48888,8 @@ class CronScheduler {
|
|
|
49494
48888
|
job.logs.shift();
|
|
49495
48889
|
}
|
|
49496
48890
|
if (this.store) {
|
|
49497
|
-
this.store.insertLog(logEntry).catch((
|
|
49498
|
-
console.error(`[cron] Failed to persist log for "${job.id}":`,
|
|
48891
|
+
this.store.insertLog(logEntry).catch((persistErr) => {
|
|
48892
|
+
console.error(`[cron] Failed to persist log for "${job.id}":`, persistErr);
|
|
49499
48893
|
});
|
|
49500
48894
|
}
|
|
49501
48895
|
if (success) {
|
|
@@ -49524,7 +48918,8 @@ class CronScheduler {
|
|
|
49524
48918
|
}
|
|
49525
48919
|
const cronScheduler = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
49526
48920
|
__proto__: null,
|
|
49527
|
-
CronScheduler
|
|
48921
|
+
CronScheduler,
|
|
48922
|
+
validateCronExpression
|
|
49528
48923
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
49529
48924
|
function createCronRoutes(scheduler) {
|
|
49530
48925
|
const router = new Hono();
|
|
@@ -49927,6 +49322,7 @@ export {
|
|
|
49927
49322
|
resetConsole,
|
|
49928
49323
|
serveSPA,
|
|
49929
49324
|
strictAuthLimiter,
|
|
49325
|
+
validateCronExpression,
|
|
49930
49326
|
validatePasswordStrength,
|
|
49931
49327
|
verifyAccessToken,
|
|
49932
49328
|
verifyPassword
|