@rebasepro/server-core 0.0.1-canary.6e26b67 → 0.0.1-canary.892f711
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 +872 -1610
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +871 -1609
- 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/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 +71 -87
- package/dist/types/src/types/slots.d.ts +20 -10
- package/dist/types/src/types/translations.d.ts +4 -0
- package/package.json +7 -8
- 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/init.ts +13 -3
- package/src/storage/LocalStorageController.ts +37 -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/history_diff.log +0 -385
- package/scratch.ts +0 -9
- package/test-ast.ts +0 -28
- package/test_output.txt +0 -1133
package/dist/index.es.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Hono } from "hono";
|
|
|
7
7
|
import require$$0$2 from "buffer";
|
|
8
8
|
import require$$0$3 from "stream";
|
|
9
9
|
import require$$5, { promisify } from "util";
|
|
10
|
-
import require$$0$4, { randomBytes, createHash, timingSafeEqual as timingSafeEqual$1, scrypt
|
|
10
|
+
import require$$0$4, { randomBytes, createHash, timingSafeEqual as timingSafeEqual$1, scrypt } from "crypto";
|
|
11
11
|
import { bodyLimit } from "hono/body-limit";
|
|
12
12
|
import { csrf } from "hono/csrf";
|
|
13
13
|
import require$$0$a from "child_process";
|
|
@@ -1020,13 +1020,14 @@ var object_hash = { exports: {} };
|
|
|
1020
1020
|
}, { buffer: 3, lYpoI2: 11 }] }, {}, [1])(1);
|
|
1021
1021
|
});
|
|
1022
1022
|
})(object_hash);
|
|
1023
|
-
const
|
|
1023
|
+
const tokenizeRegex = /[A-Z]{2,}(?=[A-Z][a-z]|\b)|[A-Z]?[a-z]+|[0-9]+(?:[a-z](?![a-z]))?|[A-Z]/g;
|
|
1024
|
+
const snakeCaseRegex = tokenizeRegex;
|
|
1024
1025
|
const toSnakeCase = (str) => {
|
|
1025
1026
|
const regExpMatchArray = str.match(snakeCaseRegex);
|
|
1026
1027
|
if (!regExpMatchArray) return "";
|
|
1027
1028
|
return regExpMatchArray.map((x) => x.toLowerCase()).join("_");
|
|
1028
1029
|
};
|
|
1029
|
-
function isObject$
|
|
1030
|
+
function isObject$a(item) {
|
|
1030
1031
|
return !!item && typeof item === "object" && !Array.isArray(item);
|
|
1031
1032
|
}
|
|
1032
1033
|
function isPlainObject$3(obj) {
|
|
@@ -1037,13 +1038,13 @@ function isPlainObject$3(obj) {
|
|
|
1037
1038
|
return proto === Object.prototype;
|
|
1038
1039
|
}
|
|
1039
1040
|
function mergeDeep(target, source, ignoreUndefined = false) {
|
|
1040
|
-
if (!isObject$
|
|
1041
|
+
if (!isObject$a(target)) {
|
|
1041
1042
|
return target;
|
|
1042
1043
|
}
|
|
1043
1044
|
const output = {
|
|
1044
1045
|
...target
|
|
1045
1046
|
};
|
|
1046
|
-
if (!isObject$
|
|
1047
|
+
if (!isObject$a(source)) {
|
|
1047
1048
|
return output;
|
|
1048
1049
|
}
|
|
1049
1050
|
for (const key in source) {
|
|
@@ -1084,7 +1085,7 @@ function mergeDeep(target, source, ignoreUndefined = false) {
|
|
|
1084
1085
|
} else {
|
|
1085
1086
|
output[key] = sourceValue;
|
|
1086
1087
|
}
|
|
1087
|
-
} else if (isObject$
|
|
1088
|
+
} else if (isObject$a(sourceValue)) {
|
|
1088
1089
|
output[key] = sourceValue;
|
|
1089
1090
|
} else {
|
|
1090
1091
|
output[key] = sourceValue;
|
|
@@ -1721,8 +1722,8 @@ var logic = { exports: {} };
|
|
|
1721
1722
|
return jsonLogic;
|
|
1722
1723
|
});
|
|
1723
1724
|
})(logic);
|
|
1724
|
-
|
|
1725
|
-
|
|
1725
|
+
const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
1726
|
+
const { hasOwnProperty: hasOwnProperty$d } = Object.prototype;
|
|
1726
1727
|
function combineComparators(comparatorA, comparatorB) {
|
|
1727
1728
|
return function isEqual(a2, b, state) {
|
|
1728
1729
|
return comparatorA(a2, b, state) && comparatorB(a2, b, state);
|
|
@@ -1733,38 +1734,45 @@ function createIsCircular(areItemsEqual) {
|
|
|
1733
1734
|
if (!a2 || !b || typeof a2 !== "object" || typeof b !== "object") {
|
|
1734
1735
|
return areItemsEqual(a2, b, state);
|
|
1735
1736
|
}
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1737
|
+
const { cache } = state;
|
|
1738
|
+
const cachedA = cache.get(a2);
|
|
1739
|
+
const cachedB = cache.get(b);
|
|
1739
1740
|
if (cachedA && cachedB) {
|
|
1740
1741
|
return cachedA === b && cachedB === a2;
|
|
1741
1742
|
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1743
|
+
cache.set(a2, b);
|
|
1744
|
+
cache.set(b, a2);
|
|
1745
|
+
const result = areItemsEqual(a2, b, state);
|
|
1746
|
+
cache.delete(a2);
|
|
1747
|
+
cache.delete(b);
|
|
1747
1748
|
return result;
|
|
1748
1749
|
};
|
|
1749
1750
|
}
|
|
1750
|
-
function getShortTag(value) {
|
|
1751
|
-
return value != null ? value[Symbol.toStringTag] : void 0;
|
|
1752
|
-
}
|
|
1753
1751
|
function getStrictProperties(object) {
|
|
1754
1752
|
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
|
|
1755
1753
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1754
|
+
const hasOwn$1 = (
|
|
1755
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1756
|
+
Object.hasOwn || ((object, property) => hasOwnProperty$d.call(object, property))
|
|
1757
|
+
);
|
|
1758
|
+
const PREACT_VNODE = "__v";
|
|
1759
|
+
const PREACT_OWNER = "__o";
|
|
1760
|
+
const REACT_OWNER = "_owner";
|
|
1761
|
+
const { getOwnPropertyDescriptor, keys: keys$5 } = Object;
|
|
1762
|
+
const sameValueEqual = (
|
|
1763
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1764
|
+
Object.is || function sameValueEqual2(a2, b) {
|
|
1765
|
+
return a2 === b ? a2 !== 0 || 1 / a2 === 1 / b : a2 !== a2 && b !== b;
|
|
1766
|
+
}
|
|
1767
|
+
);
|
|
1768
|
+
function strictEqual(a2, b) {
|
|
1769
|
+
return a2 === b;
|
|
1770
|
+
}
|
|
1771
|
+
function areArrayBuffersEqual(a2, b) {
|
|
1772
|
+
return a2.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a2), new Uint8Array(b));
|
|
1761
1773
|
}
|
|
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
1774
|
function areArraysEqual(a2, b, state) {
|
|
1767
|
-
|
|
1775
|
+
let index = a2.length;
|
|
1768
1776
|
if (b.length !== index) {
|
|
1769
1777
|
return false;
|
|
1770
1778
|
}
|
|
@@ -1775,35 +1783,35 @@ function areArraysEqual(a2, b, state) {
|
|
|
1775
1783
|
}
|
|
1776
1784
|
return true;
|
|
1777
1785
|
}
|
|
1786
|
+
function areDataViewsEqual(a2, b) {
|
|
1787
|
+
return a2.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a2.buffer, a2.byteOffset, a2.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength));
|
|
1788
|
+
}
|
|
1778
1789
|
function areDatesEqual(a2, b) {
|
|
1779
|
-
return
|
|
1790
|
+
return sameValueEqual(a2.getTime(), b.getTime());
|
|
1780
1791
|
}
|
|
1781
1792
|
function areErrorsEqual(a2, b) {
|
|
1782
1793
|
return a2.name === b.name && a2.message === b.message && a2.cause === b.cause && a2.stack === b.stack;
|
|
1783
1794
|
}
|
|
1784
|
-
function areFunctionsEqual(a2, b) {
|
|
1785
|
-
return a2 === b;
|
|
1786
|
-
}
|
|
1787
1795
|
function areMapsEqual(a2, b, state) {
|
|
1788
|
-
|
|
1796
|
+
const size = a2.size;
|
|
1789
1797
|
if (size !== b.size) {
|
|
1790
1798
|
return false;
|
|
1791
1799
|
}
|
|
1792
1800
|
if (!size) {
|
|
1793
1801
|
return true;
|
|
1794
1802
|
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1803
|
+
const matchedIndices = new Array(size);
|
|
1804
|
+
const aIterable = a2.entries();
|
|
1805
|
+
let aResult;
|
|
1806
|
+
let bResult;
|
|
1807
|
+
let index = 0;
|
|
1800
1808
|
while (aResult = aIterable.next()) {
|
|
1801
1809
|
if (aResult.done) {
|
|
1802
1810
|
break;
|
|
1803
1811
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1812
|
+
const bIterable = b.entries();
|
|
1813
|
+
let hasMatch = false;
|
|
1814
|
+
let matchIndex = 0;
|
|
1807
1815
|
while (bResult = bIterable.next()) {
|
|
1808
1816
|
if (bResult.done) {
|
|
1809
1817
|
break;
|
|
@@ -1812,8 +1820,8 @@ function areMapsEqual(a2, b, state) {
|
|
|
1812
1820
|
matchIndex++;
|
|
1813
1821
|
continue;
|
|
1814
1822
|
}
|
|
1815
|
-
|
|
1816
|
-
|
|
1823
|
+
const aEntry = aResult.value;
|
|
1824
|
+
const bEntry = bResult.value;
|
|
1817
1825
|
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
1826
|
hasMatch = matchedIndices[matchIndex] = true;
|
|
1819
1827
|
break;
|
|
@@ -1827,10 +1835,9 @@ function areMapsEqual(a2, b, state) {
|
|
|
1827
1835
|
}
|
|
1828
1836
|
return true;
|
|
1829
1837
|
}
|
|
1830
|
-
var areNumbersEqual = sameValueZeroEqual;
|
|
1831
1838
|
function areObjectsEqual(a2, b, state) {
|
|
1832
|
-
|
|
1833
|
-
|
|
1839
|
+
const properties = keys$5(a2);
|
|
1840
|
+
let index = properties.length;
|
|
1834
1841
|
if (keys$5(b).length !== index) {
|
|
1835
1842
|
return false;
|
|
1836
1843
|
}
|
|
@@ -1842,14 +1849,14 @@ function areObjectsEqual(a2, b, state) {
|
|
|
1842
1849
|
return true;
|
|
1843
1850
|
}
|
|
1844
1851
|
function areObjectsEqualStrict(a2, b, state) {
|
|
1845
|
-
|
|
1846
|
-
|
|
1852
|
+
const properties = getStrictProperties(a2);
|
|
1853
|
+
let index = properties.length;
|
|
1847
1854
|
if (getStrictProperties(b).length !== index) {
|
|
1848
1855
|
return false;
|
|
1849
1856
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1857
|
+
let property;
|
|
1858
|
+
let descriptorA;
|
|
1859
|
+
let descriptorB;
|
|
1853
1860
|
while (index-- > 0) {
|
|
1854
1861
|
property = properties[index];
|
|
1855
1862
|
if (!isPropertyEqual(a2, b, state, property)) {
|
|
@@ -1864,30 +1871,30 @@ function areObjectsEqualStrict(a2, b, state) {
|
|
|
1864
1871
|
return true;
|
|
1865
1872
|
}
|
|
1866
1873
|
function arePrimitiveWrappersEqual(a2, b) {
|
|
1867
|
-
return
|
|
1874
|
+
return sameValueEqual(a2.valueOf(), b.valueOf());
|
|
1868
1875
|
}
|
|
1869
1876
|
function areRegExpsEqual(a2, b) {
|
|
1870
1877
|
return a2.source === b.source && a2.flags === b.flags;
|
|
1871
1878
|
}
|
|
1872
1879
|
function areSetsEqual(a2, b, state) {
|
|
1873
|
-
|
|
1880
|
+
const size = a2.size;
|
|
1874
1881
|
if (size !== b.size) {
|
|
1875
1882
|
return false;
|
|
1876
1883
|
}
|
|
1877
1884
|
if (!size) {
|
|
1878
1885
|
return true;
|
|
1879
1886
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1887
|
+
const matchedIndices = new Array(size);
|
|
1888
|
+
const aIterable = a2.values();
|
|
1889
|
+
let aResult;
|
|
1890
|
+
let bResult;
|
|
1884
1891
|
while (aResult = aIterable.next()) {
|
|
1885
1892
|
if (aResult.done) {
|
|
1886
1893
|
break;
|
|
1887
1894
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1895
|
+
const bIterable = b.values();
|
|
1896
|
+
let hasMatch = false;
|
|
1897
|
+
let matchIndex = 0;
|
|
1891
1898
|
while (bResult = bIterable.next()) {
|
|
1892
1899
|
if (bResult.done) {
|
|
1893
1900
|
break;
|
|
@@ -1905,8 +1912,8 @@ function areSetsEqual(a2, b, state) {
|
|
|
1905
1912
|
return true;
|
|
1906
1913
|
}
|
|
1907
1914
|
function areTypedArraysEqual(a2, b) {
|
|
1908
|
-
|
|
1909
|
-
if (b.
|
|
1915
|
+
let index = a2.byteLength;
|
|
1916
|
+
if (b.byteLength !== index || a2.byteOffset !== b.byteOffset) {
|
|
1910
1917
|
return false;
|
|
1911
1918
|
}
|
|
1912
1919
|
while (index-- > 0) {
|
|
@@ -1925,23 +1932,10 @@ function isPropertyEqual(a2, b, state, property) {
|
|
|
1925
1932
|
}
|
|
1926
1933
|
return hasOwn$1(b, property) && state.equals(a2[property], b[property], property, property, a2, b, state);
|
|
1927
1934
|
}
|
|
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;
|
|
1935
|
+
const toString$2 = Object.prototype.toString;
|
|
1936
|
+
function createEqualityComparator(config) {
|
|
1937
|
+
const supportedComparatorMap = createSupportedComparatorMap(config);
|
|
1938
|
+
const { areArraysEqual: areArraysEqual2, areDatesEqual: areDatesEqual2, areFunctionsEqual, areMapsEqual: areMapsEqual2, areNumbersEqual, areObjectsEqual: areObjectsEqual2, areRegExpsEqual: areRegExpsEqual2, areSetsEqual: areSetsEqual2, getUnsupportedCustomComparator } = config;
|
|
1945
1939
|
return function comparator2(a2, b, state) {
|
|
1946
1940
|
if (a2 === b) {
|
|
1947
1941
|
return true;
|
|
@@ -1949,32 +1943,29 @@ function createEqualityComparator(_a2) {
|
|
|
1949
1943
|
if (a2 == null || b == null) {
|
|
1950
1944
|
return false;
|
|
1951
1945
|
}
|
|
1952
|
-
|
|
1946
|
+
const type = typeof a2;
|
|
1953
1947
|
if (type !== typeof b) {
|
|
1954
1948
|
return false;
|
|
1955
1949
|
}
|
|
1956
1950
|
if (type !== "object") {
|
|
1957
|
-
if (type === "number") {
|
|
1958
|
-
return
|
|
1951
|
+
if (type === "number" || type === "bigint") {
|
|
1952
|
+
return areNumbersEqual(a2, b, state);
|
|
1959
1953
|
}
|
|
1960
1954
|
if (type === "function") {
|
|
1961
|
-
return
|
|
1955
|
+
return areFunctionsEqual(a2, b, state);
|
|
1962
1956
|
}
|
|
1963
1957
|
return false;
|
|
1964
1958
|
}
|
|
1965
|
-
|
|
1959
|
+
const constructor = a2.constructor;
|
|
1966
1960
|
if (constructor !== b.constructor) {
|
|
1967
1961
|
return false;
|
|
1968
1962
|
}
|
|
1969
1963
|
if (constructor === Object) {
|
|
1970
1964
|
return areObjectsEqual2(a2, b, state);
|
|
1971
1965
|
}
|
|
1972
|
-
if (
|
|
1966
|
+
if (constructor === Array) {
|
|
1973
1967
|
return areArraysEqual2(a2, b, state);
|
|
1974
1968
|
}
|
|
1975
|
-
if (isTypedArray$2 != null && isTypedArray$2(a2)) {
|
|
1976
|
-
return areTypedArraysEqual2(a2, b, state);
|
|
1977
|
-
}
|
|
1978
1969
|
if (constructor === Date) {
|
|
1979
1970
|
return areDatesEqual2(a2, b, state);
|
|
1980
1971
|
}
|
|
@@ -1987,79 +1978,55 @@ function createEqualityComparator(_a2) {
|
|
|
1987
1978
|
if (constructor === Set) {
|
|
1988
1979
|
return areSetsEqual2(a2, b, state);
|
|
1989
1980
|
}
|
|
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);
|
|
1981
|
+
if (constructor === Promise) {
|
|
1982
|
+
return false;
|
|
2011
1983
|
}
|
|
2012
|
-
if (
|
|
2013
|
-
return
|
|
1984
|
+
if (Array.isArray(a2)) {
|
|
1985
|
+
return areArraysEqual2(a2, b, state);
|
|
2014
1986
|
}
|
|
2015
|
-
|
|
2016
|
-
|
|
1987
|
+
const tag = toString$2.call(a2);
|
|
1988
|
+
const supportedComparator = supportedComparatorMap[tag];
|
|
1989
|
+
if (supportedComparator) {
|
|
1990
|
+
return supportedComparator(a2, b, state);
|
|
2017
1991
|
}
|
|
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
|
-
}
|
|
1992
|
+
const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a2, b, state, tag);
|
|
1993
|
+
if (unsupportedCustomComparator) {
|
|
1994
|
+
return unsupportedCustomComparator(a2, b, state);
|
|
2029
1995
|
}
|
|
2030
1996
|
return false;
|
|
2031
1997
|
};
|
|
2032
1998
|
}
|
|
2033
|
-
function createEqualityComparatorConfig(
|
|
2034
|
-
|
|
2035
|
-
|
|
1999
|
+
function createEqualityComparatorConfig({ circular, createCustomConfig, strict }) {
|
|
2000
|
+
let config = {
|
|
2001
|
+
areArrayBuffersEqual,
|
|
2036
2002
|
areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
|
|
2003
|
+
areDataViewsEqual,
|
|
2037
2004
|
areDatesEqual,
|
|
2038
2005
|
areErrorsEqual,
|
|
2039
|
-
areFunctionsEqual,
|
|
2006
|
+
areFunctionsEqual: strictEqual,
|
|
2040
2007
|
areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
|
|
2041
|
-
areNumbersEqual,
|
|
2008
|
+
areNumbersEqual: sameValueEqual,
|
|
2042
2009
|
areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
|
|
2043
2010
|
arePrimitiveWrappersEqual,
|
|
2044
2011
|
areRegExpsEqual,
|
|
2045
2012
|
areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
|
|
2046
|
-
areTypedArraysEqual: strict ? areObjectsEqualStrict : areTypedArraysEqual,
|
|
2013
|
+
areTypedArraysEqual: strict ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict) : areTypedArraysEqual,
|
|
2047
2014
|
areUrlsEqual,
|
|
2048
|
-
|
|
2015
|
+
getUnsupportedCustomComparator: void 0
|
|
2049
2016
|
};
|
|
2050
2017
|
if (createCustomConfig) {
|
|
2051
|
-
config = assign
|
|
2018
|
+
config = Object.assign({}, config, createCustomConfig(config));
|
|
2052
2019
|
}
|
|
2053
2020
|
if (circular) {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
config = assign
|
|
2059
|
-
areArraysEqual:
|
|
2060
|
-
areMapsEqual:
|
|
2061
|
-
areObjectsEqual:
|
|
2062
|
-
areSetsEqual:
|
|
2021
|
+
const areArraysEqual2 = createIsCircular(config.areArraysEqual);
|
|
2022
|
+
const areMapsEqual2 = createIsCircular(config.areMapsEqual);
|
|
2023
|
+
const areObjectsEqual2 = createIsCircular(config.areObjectsEqual);
|
|
2024
|
+
const areSetsEqual2 = createIsCircular(config.areSetsEqual);
|
|
2025
|
+
config = Object.assign({}, config, {
|
|
2026
|
+
areArraysEqual: areArraysEqual2,
|
|
2027
|
+
areMapsEqual: areMapsEqual2,
|
|
2028
|
+
areObjectsEqual: areObjectsEqual2,
|
|
2029
|
+
areSetsEqual: areSetsEqual2
|
|
2063
2030
|
});
|
|
2064
2031
|
}
|
|
2065
2032
|
return config;
|
|
@@ -2069,13 +2036,12 @@ function createInternalEqualityComparator(compare2) {
|
|
|
2069
2036
|
return compare2(a2, b, state);
|
|
2070
2037
|
};
|
|
2071
2038
|
}
|
|
2072
|
-
function createIsEqual(
|
|
2073
|
-
var circular = _a2.circular, comparator2 = _a2.comparator, createState = _a2.createState, equals = _a2.equals, strict = _a2.strict;
|
|
2039
|
+
function createIsEqual({ circular, comparator: comparator2, createState, equals, strict }) {
|
|
2074
2040
|
if (createState) {
|
|
2075
2041
|
return function isEqual(a2, b) {
|
|
2076
|
-
|
|
2042
|
+
const { cache = circular ? /* @__PURE__ */ new WeakMap() : void 0, meta } = createState();
|
|
2077
2043
|
return comparator2(a2, b, {
|
|
2078
|
-
cache
|
|
2044
|
+
cache,
|
|
2079
2045
|
equals,
|
|
2080
2046
|
meta,
|
|
2081
2047
|
strict
|
|
@@ -2092,7 +2058,7 @@ function createIsEqual(_a2) {
|
|
|
2092
2058
|
});
|
|
2093
2059
|
};
|
|
2094
2060
|
}
|
|
2095
|
-
|
|
2061
|
+
const state = {
|
|
2096
2062
|
cache: void 0,
|
|
2097
2063
|
equals,
|
|
2098
2064
|
meta: void 0,
|
|
@@ -2102,7 +2068,50 @@ function createIsEqual(_a2) {
|
|
|
2102
2068
|
return comparator2(a2, b, state);
|
|
2103
2069
|
};
|
|
2104
2070
|
}
|
|
2105
|
-
|
|
2071
|
+
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 }) {
|
|
2072
|
+
return {
|
|
2073
|
+
"[object Arguments]": areObjectsEqual2,
|
|
2074
|
+
"[object Array]": areArraysEqual2,
|
|
2075
|
+
"[object ArrayBuffer]": areArrayBuffersEqual2,
|
|
2076
|
+
"[object AsyncGeneratorFunction]": areFunctionsEqual,
|
|
2077
|
+
"[object BigInt]": areNumbersEqual,
|
|
2078
|
+
"[object BigInt64Array]": areTypedArraysEqual2,
|
|
2079
|
+
"[object BigUint64Array]": areTypedArraysEqual2,
|
|
2080
|
+
"[object Boolean]": arePrimitiveWrappersEqual2,
|
|
2081
|
+
"[object DataView]": areDataViewsEqual2,
|
|
2082
|
+
"[object Date]": areDatesEqual2,
|
|
2083
|
+
// If an error tag, it should be tested explicitly. Like RegExp, the properties are not
|
|
2084
|
+
// enumerable, and therefore will give false positives if tested like a standard object.
|
|
2085
|
+
"[object Error]": areErrorsEqual2,
|
|
2086
|
+
"[object Float16Array]": areTypedArraysEqual2,
|
|
2087
|
+
"[object Float32Array]": areTypedArraysEqual2,
|
|
2088
|
+
"[object Float64Array]": areTypedArraysEqual2,
|
|
2089
|
+
"[object Function]": areFunctionsEqual,
|
|
2090
|
+
"[object GeneratorFunction]": areFunctionsEqual,
|
|
2091
|
+
"[object Int8Array]": areTypedArraysEqual2,
|
|
2092
|
+
"[object Int16Array]": areTypedArraysEqual2,
|
|
2093
|
+
"[object Int32Array]": areTypedArraysEqual2,
|
|
2094
|
+
"[object Map]": areMapsEqual2,
|
|
2095
|
+
"[object Number]": arePrimitiveWrappersEqual2,
|
|
2096
|
+
"[object Object]": (a2, b, state) => (
|
|
2097
|
+
// The exception for value comparison is custom `Promise`-like class instances. These should
|
|
2098
|
+
// be treated the same as standard `Promise` objects, which means strict equality, and if
|
|
2099
|
+
// it reaches this point then that strict equality comparison has already failed.
|
|
2100
|
+
typeof a2.then !== "function" && typeof b.then !== "function" && areObjectsEqual2(a2, b, state)
|
|
2101
|
+
),
|
|
2102
|
+
// For RegExp, the properties are not enumerable, and therefore will give false positives if
|
|
2103
|
+
// tested like a standard object.
|
|
2104
|
+
"[object RegExp]": areRegExpsEqual2,
|
|
2105
|
+
"[object Set]": areSetsEqual2,
|
|
2106
|
+
"[object String]": arePrimitiveWrappersEqual2,
|
|
2107
|
+
"[object URL]": areUrlsEqual2,
|
|
2108
|
+
"[object Uint8Array]": areTypedArraysEqual2,
|
|
2109
|
+
"[object Uint8ClampedArray]": areTypedArraysEqual2,
|
|
2110
|
+
"[object Uint16Array]": areTypedArraysEqual2,
|
|
2111
|
+
"[object Uint32Array]": areTypedArraysEqual2
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
const deepEqual = createCustomEqual();
|
|
2106
2115
|
createCustomEqual({ strict: true });
|
|
2107
2116
|
createCustomEqual({ circular: true });
|
|
2108
2117
|
createCustomEqual({
|
|
@@ -2110,37 +2119,26 @@ createCustomEqual({
|
|
|
2110
2119
|
strict: true
|
|
2111
2120
|
});
|
|
2112
2121
|
createCustomEqual({
|
|
2113
|
-
createInternalComparator:
|
|
2114
|
-
return sameValueZeroEqual;
|
|
2115
|
-
}
|
|
2122
|
+
createInternalComparator: () => sameValueEqual
|
|
2116
2123
|
});
|
|
2117
2124
|
createCustomEqual({
|
|
2118
2125
|
strict: true,
|
|
2119
|
-
createInternalComparator:
|
|
2120
|
-
return sameValueZeroEqual;
|
|
2121
|
-
}
|
|
2126
|
+
createInternalComparator: () => sameValueEqual
|
|
2122
2127
|
});
|
|
2123
2128
|
createCustomEqual({
|
|
2124
2129
|
circular: true,
|
|
2125
|
-
createInternalComparator:
|
|
2126
|
-
return sameValueZeroEqual;
|
|
2127
|
-
}
|
|
2130
|
+
createInternalComparator: () => sameValueEqual
|
|
2128
2131
|
});
|
|
2129
2132
|
createCustomEqual({
|
|
2130
2133
|
circular: true,
|
|
2131
|
-
createInternalComparator:
|
|
2132
|
-
return sameValueZeroEqual;
|
|
2133
|
-
},
|
|
2134
|
+
createInternalComparator: () => sameValueEqual,
|
|
2134
2135
|
strict: true
|
|
2135
2136
|
});
|
|
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);
|
|
2137
|
+
function createCustomEqual(options2 = {}) {
|
|
2138
|
+
const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false } = options2;
|
|
2139
|
+
const config = createEqualityComparatorConfig(options2);
|
|
2140
|
+
const comparator2 = createEqualityComparator(config);
|
|
2141
|
+
const equals = createCustomInternalComparator ? createCustomInternalComparator(comparator2) : createInternalEqualityComparator(comparator2);
|
|
2144
2142
|
return createIsEqual({ circular, comparator: comparator2, createState, equals, strict });
|
|
2145
2143
|
}
|
|
2146
2144
|
function listCacheClear$1() {
|
|
@@ -2254,7 +2252,7 @@ var hasOwnProperty$c = objectProto$j.hasOwnProperty;
|
|
|
2254
2252
|
var nativeObjectToString$1 = objectProto$j.toString;
|
|
2255
2253
|
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
2256
2254
|
function getRawTag$1(value) {
|
|
2257
|
-
var isOwn = hasOwnProperty$c.call(value, symToStringTag$1),
|
|
2255
|
+
var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
2258
2256
|
try {
|
|
2259
2257
|
value[symToStringTag$1] = void 0;
|
|
2260
2258
|
var unmasked = true;
|
|
@@ -2263,7 +2261,7 @@ function getRawTag$1(value) {
|
|
|
2263
2261
|
var result = nativeObjectToString$1.call(value);
|
|
2264
2262
|
if (unmasked) {
|
|
2265
2263
|
if (isOwn) {
|
|
2266
|
-
value[symToStringTag$1] =
|
|
2264
|
+
value[symToStringTag$1] = tag;
|
|
2267
2265
|
} else {
|
|
2268
2266
|
delete value[symToStringTag$1];
|
|
2269
2267
|
}
|
|
@@ -2287,19 +2285,19 @@ function baseGetTag$4(value) {
|
|
|
2287
2285
|
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString$7(value);
|
|
2288
2286
|
}
|
|
2289
2287
|
var _baseGetTag = baseGetTag$4;
|
|
2290
|
-
function isObject$
|
|
2288
|
+
function isObject$9(value) {
|
|
2291
2289
|
var type = typeof value;
|
|
2292
2290
|
return value != null && (type == "object" || type == "function");
|
|
2293
2291
|
}
|
|
2294
|
-
var isObject_1 = isObject$
|
|
2295
|
-
var baseGetTag$3 = _baseGetTag, isObject$
|
|
2292
|
+
var isObject_1 = isObject$9;
|
|
2293
|
+
var baseGetTag$3 = _baseGetTag, isObject$8 = isObject_1;
|
|
2296
2294
|
var asyncTag = "[object AsyncFunction]", funcTag$3 = "[object Function]", genTag$2 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
2297
2295
|
function isFunction$3(value) {
|
|
2298
|
-
if (!isObject$
|
|
2296
|
+
if (!isObject$8(value)) {
|
|
2299
2297
|
return false;
|
|
2300
2298
|
}
|
|
2301
|
-
var
|
|
2302
|
-
return
|
|
2299
|
+
var tag = baseGetTag$3(value);
|
|
2300
|
+
return tag == funcTag$3 || tag == genTag$2 || tag == asyncTag || tag == proxyTag;
|
|
2303
2301
|
}
|
|
2304
2302
|
var isFunction_1 = isFunction$3;
|
|
2305
2303
|
var root$6 = _root;
|
|
@@ -2330,7 +2328,7 @@ function toSource$2(func) {
|
|
|
2330
2328
|
return "";
|
|
2331
2329
|
}
|
|
2332
2330
|
var _toSource = toSource$2;
|
|
2333
|
-
var isFunction$2 = isFunction_1, isMasked = _isMasked, isObject$
|
|
2331
|
+
var isFunction$2 = isFunction_1, isMasked = _isMasked, isObject$7 = isObject_1, toSource$1 = _toSource;
|
|
2334
2332
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
2335
2333
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
2336
2334
|
var funcProto$1 = Function.prototype, objectProto$h = Object.prototype;
|
|
@@ -2340,7 +2338,7 @@ var reIsNative = RegExp(
|
|
|
2340
2338
|
"^" + funcToString$1.call(hasOwnProperty$b).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
2341
2339
|
);
|
|
2342
2340
|
function baseIsNative$1(value) {
|
|
2343
|
-
if (!isObject$
|
|
2341
|
+
if (!isObject$7(value) || isMasked(value)) {
|
|
2344
2342
|
return false;
|
|
2345
2343
|
}
|
|
2346
2344
|
var pattern = isFunction$2(value) ? reIsNative : reIsHostCtor;
|
|
@@ -2582,24 +2580,24 @@ function baseTimes$2(n, iteratee) {
|
|
|
2582
2580
|
return result;
|
|
2583
2581
|
}
|
|
2584
2582
|
var _baseTimes = baseTimes$2;
|
|
2585
|
-
function isObjectLike$
|
|
2583
|
+
function isObjectLike$d(value) {
|
|
2586
2584
|
return value != null && typeof value == "object";
|
|
2587
2585
|
}
|
|
2588
|
-
var isObjectLike_1 = isObjectLike$
|
|
2589
|
-
var baseGetTag$2 = _baseGetTag, isObjectLike$
|
|
2586
|
+
var isObjectLike_1 = isObjectLike$d;
|
|
2587
|
+
var baseGetTag$2 = _baseGetTag, isObjectLike$c = isObjectLike_1;
|
|
2590
2588
|
var argsTag$3 = "[object Arguments]";
|
|
2591
2589
|
function baseIsArguments$1(value) {
|
|
2592
|
-
return isObjectLike$
|
|
2590
|
+
return isObjectLike$c(value) && baseGetTag$2(value) == argsTag$3;
|
|
2593
2591
|
}
|
|
2594
2592
|
var _baseIsArguments = baseIsArguments$1;
|
|
2595
|
-
var baseIsArguments = _baseIsArguments, isObjectLike$
|
|
2593
|
+
var baseIsArguments = _baseIsArguments, isObjectLike$b = isObjectLike_1;
|
|
2596
2594
|
var objectProto$d = Object.prototype;
|
|
2597
2595
|
var hasOwnProperty$7 = objectProto$d.hasOwnProperty;
|
|
2598
2596
|
var propertyIsEnumerable$2 = objectProto$d.propertyIsEnumerable;
|
|
2599
2597
|
var isArguments$2 = baseIsArguments(/* @__PURE__ */ function() {
|
|
2600
2598
|
return arguments;
|
|
2601
2599
|
}()) ? baseIsArguments : function(value) {
|
|
2602
|
-
return isObjectLike$
|
|
2600
|
+
return isObjectLike$b(value) && hasOwnProperty$7.call(value, "callee") && !propertyIsEnumerable$2.call(value, "callee");
|
|
2603
2601
|
};
|
|
2604
2602
|
var isArguments_1 = isArguments$2;
|
|
2605
2603
|
var isArray$6 = Array.isArray;
|
|
@@ -2634,14 +2632,14 @@ function isLength$3(value) {
|
|
|
2634
2632
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$3;
|
|
2635
2633
|
}
|
|
2636
2634
|
var isLength_1 = isLength$3;
|
|
2637
|
-
var baseGetTag$1 = _baseGetTag, isLength$2 = isLength_1, isObjectLike$
|
|
2635
|
+
var baseGetTag$1 = _baseGetTag, isLength$2 = isLength_1, isObjectLike$a = isObjectLike_1;
|
|
2638
2636
|
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
2637
|
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
2638
|
var typedArrayTags = {};
|
|
2641
2639
|
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
2640
|
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
2641
|
function baseIsTypedArray$1(value) {
|
|
2644
|
-
return isObjectLike$
|
|
2642
|
+
return isObjectLike$a(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$1(value)];
|
|
2645
2643
|
}
|
|
2646
2644
|
var _baseIsTypedArray = baseIsTypedArray$1;
|
|
2647
2645
|
function baseUnary$3(func) {
|
|
@@ -2748,11 +2746,11 @@ function nativeKeysIn$1(object) {
|
|
|
2748
2746
|
return result;
|
|
2749
2747
|
}
|
|
2750
2748
|
var _nativeKeysIn = nativeKeysIn$1;
|
|
2751
|
-
var isObject$
|
|
2749
|
+
var isObject$6 = isObject_1, isPrototype$2 = _isPrototype, nativeKeysIn = _nativeKeysIn;
|
|
2752
2750
|
var objectProto$9 = Object.prototype;
|
|
2753
2751
|
var hasOwnProperty$4 = objectProto$9.hasOwnProperty;
|
|
2754
2752
|
function baseKeysIn$1(object) {
|
|
2755
|
-
if (!isObject$
|
|
2753
|
+
if (!isObject$6(object)) {
|
|
2756
2754
|
return nativeKeysIn(object);
|
|
2757
2755
|
}
|
|
2758
2756
|
var isProto = isPrototype$2(object), result = [];
|
|
@@ -2966,9 +2964,9 @@ var _cloneTypedArray = cloneTypedArray$1;
|
|
|
2966
2964
|
var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
|
|
2967
2965
|
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
2966
|
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,
|
|
2967
|
+
function initCloneByTag$1(object, tag, isDeep) {
|
|
2970
2968
|
var Ctor = object.constructor;
|
|
2971
|
-
switch (
|
|
2969
|
+
switch (tag) {
|
|
2972
2970
|
case arrayBufferTag$1:
|
|
2973
2971
|
return cloneArrayBuffer(object);
|
|
2974
2972
|
case boolTag$2:
|
|
@@ -3000,13 +2998,13 @@ function initCloneByTag$1(object, tag2, isDeep) {
|
|
|
3000
2998
|
}
|
|
3001
2999
|
}
|
|
3002
3000
|
var _initCloneByTag = initCloneByTag$1;
|
|
3003
|
-
var isObject$
|
|
3001
|
+
var isObject$5 = isObject_1;
|
|
3004
3002
|
var objectCreate = Object.create;
|
|
3005
3003
|
var baseCreate$1 = /* @__PURE__ */ function() {
|
|
3006
3004
|
function object() {
|
|
3007
3005
|
}
|
|
3008
3006
|
return function(proto) {
|
|
3009
|
-
if (!isObject$
|
|
3007
|
+
if (!isObject$5(proto)) {
|
|
3010
3008
|
return {};
|
|
3011
3009
|
}
|
|
3012
3010
|
if (objectCreate) {
|
|
@@ -3024,27 +3022,27 @@ function initCloneObject$1(object) {
|
|
|
3024
3022
|
return typeof object.constructor == "function" && !isPrototype$1(object) ? baseCreate(getPrototype$1(object)) : {};
|
|
3025
3023
|
}
|
|
3026
3024
|
var _initCloneObject = initCloneObject$1;
|
|
3027
|
-
var getTag$2 = _getTag, isObjectLike$
|
|
3025
|
+
var getTag$2 = _getTag, isObjectLike$9 = isObjectLike_1;
|
|
3028
3026
|
var mapTag$1 = "[object Map]";
|
|
3029
3027
|
function baseIsMap$1(value) {
|
|
3030
|
-
return isObjectLike$
|
|
3028
|
+
return isObjectLike$9(value) && getTag$2(value) == mapTag$1;
|
|
3031
3029
|
}
|
|
3032
3030
|
var _baseIsMap = baseIsMap$1;
|
|
3033
3031
|
var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtilExports;
|
|
3034
3032
|
var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
|
|
3035
3033
|
var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
|
|
3036
3034
|
var isMap_1 = isMap$1;
|
|
3037
|
-
var getTag$1 = _getTag, isObjectLike$
|
|
3035
|
+
var getTag$1 = _getTag, isObjectLike$8 = isObjectLike_1;
|
|
3038
3036
|
var setTag$1 = "[object Set]";
|
|
3039
3037
|
function baseIsSet$1(value) {
|
|
3040
|
-
return isObjectLike$
|
|
3038
|
+
return isObjectLike$8(value) && getTag$1(value) == setTag$1;
|
|
3041
3039
|
}
|
|
3042
3040
|
var _baseIsSet = baseIsSet$1;
|
|
3043
3041
|
var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
|
|
3044
3042
|
var nodeIsSet = nodeUtil && nodeUtil.isSet;
|
|
3045
3043
|
var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
|
|
3046
3044
|
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$
|
|
3045
|
+
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
3046
|
var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
|
|
3049
3047
|
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
3048
|
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 +3057,7 @@ function baseClone$1(value, bitmask, customizer, key, object, stack) {
|
|
|
3059
3057
|
if (result !== void 0) {
|
|
3060
3058
|
return result;
|
|
3061
3059
|
}
|
|
3062
|
-
if (!isObject$
|
|
3060
|
+
if (!isObject$4(value)) {
|
|
3063
3061
|
return value;
|
|
3064
3062
|
}
|
|
3065
3063
|
var isArr = isArray$3(value);
|
|
@@ -3069,20 +3067,20 @@ function baseClone$1(value, bitmask, customizer, key, object, stack) {
|
|
|
3069
3067
|
return copyArray(value, result);
|
|
3070
3068
|
}
|
|
3071
3069
|
} else {
|
|
3072
|
-
var
|
|
3070
|
+
var tag = getTag(value), isFunc = tag == funcTag$1 || tag == genTag$1;
|
|
3073
3071
|
if (isBuffer(value)) {
|
|
3074
3072
|
return cloneBuffer(value, isDeep);
|
|
3075
3073
|
}
|
|
3076
|
-
if (
|
|
3074
|
+
if (tag == objectTag$1 || tag == argsTag$1 || isFunc && !object) {
|
|
3077
3075
|
result = isFlat || isFunc ? {} : initCloneObject(value);
|
|
3078
3076
|
if (!isDeep) {
|
|
3079
3077
|
return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
|
|
3080
3078
|
}
|
|
3081
3079
|
} else {
|
|
3082
|
-
if (!cloneableTags[
|
|
3080
|
+
if (!cloneableTags[tag]) {
|
|
3083
3081
|
return object ? value : {};
|
|
3084
3082
|
}
|
|
3085
|
-
result = initCloneByTag(value,
|
|
3083
|
+
result = initCloneByTag(value, tag, isDeep);
|
|
3086
3084
|
}
|
|
3087
3085
|
}
|
|
3088
3086
|
stack || (stack = new Stack());
|
|
@@ -3390,7 +3388,10 @@ class CollectionRegistry {
|
|
|
3390
3388
|
if (!relation) {
|
|
3391
3389
|
throw new Error(`Relation '${relationKey}' not found in collection '${currentCollection.slug}'`);
|
|
3392
3390
|
}
|
|
3393
|
-
|
|
3391
|
+
const target = relation.target();
|
|
3392
|
+
const targetRelationKey = relation.relationName || target.slug;
|
|
3393
|
+
const targetSlug = relation.overrides?.slug ?? targetRelationKey;
|
|
3394
|
+
currentCollection = this.get(targetSlug) || this.normalizeCollection(target);
|
|
3394
3395
|
if (i + 1 < pathSegments.length) ;
|
|
3395
3396
|
}
|
|
3396
3397
|
return currentCollection;
|
|
@@ -3439,7 +3440,7 @@ class CollectionRegistry {
|
|
|
3439
3440
|
if (!subcollection) {
|
|
3440
3441
|
throw new Error(`Subcollection '${subcollectionSlug}' not found in ${currentCollection.slug}`);
|
|
3441
3442
|
}
|
|
3442
|
-
currentCollection = subcollection;
|
|
3443
|
+
currentCollection = this.get(subcollection.slug) || this.normalizeCollection(subcollection);
|
|
3443
3444
|
collections.push(currentCollection);
|
|
3444
3445
|
}
|
|
3445
3446
|
}
|
|
@@ -3482,8 +3483,8 @@ async function loadCollectionsFromDirectory(directory) {
|
|
|
3482
3483
|
console.warn(`[loadCollectionsFromDirectory] File ${file} does not have a default export. Skipping.`);
|
|
3483
3484
|
}
|
|
3484
3485
|
} catch (err) {
|
|
3485
|
-
const
|
|
3486
|
-
console.error(`[loadCollectionsFromDirectory] Failed to load collection from ${file}: ${
|
|
3486
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3487
|
+
console.error(`[loadCollectionsFromDirectory] Failed to load collection from ${file}: ${message}`);
|
|
3487
3488
|
}
|
|
3488
3489
|
}
|
|
3489
3490
|
}
|
|
@@ -3566,34 +3567,34 @@ class ApiError extends Error {
|
|
|
3566
3567
|
statusCode;
|
|
3567
3568
|
code;
|
|
3568
3569
|
details;
|
|
3569
|
-
constructor(statusCode, code2,
|
|
3570
|
-
super(
|
|
3570
|
+
constructor(statusCode, code2, message, details) {
|
|
3571
|
+
super(message);
|
|
3571
3572
|
this.name = "ApiError";
|
|
3572
3573
|
this.statusCode = statusCode;
|
|
3573
3574
|
this.code = code2;
|
|
3574
3575
|
this.details = details;
|
|
3575
3576
|
}
|
|
3576
3577
|
// ── Factory methods ──────────────────────────────────────────────
|
|
3577
|
-
static badRequest(
|
|
3578
|
-
return new ApiError(400, code2,
|
|
3578
|
+
static badRequest(message, code2 = "BAD_REQUEST", details) {
|
|
3579
|
+
return new ApiError(400, code2, message, details);
|
|
3579
3580
|
}
|
|
3580
|
-
static unauthorized(
|
|
3581
|
-
return new ApiError(401, code2,
|
|
3581
|
+
static unauthorized(message, code2 = "UNAUTHORIZED") {
|
|
3582
|
+
return new ApiError(401, code2, message);
|
|
3582
3583
|
}
|
|
3583
|
-
static forbidden(
|
|
3584
|
-
return new ApiError(403, code2,
|
|
3584
|
+
static forbidden(message, code2 = "FORBIDDEN") {
|
|
3585
|
+
return new ApiError(403, code2, message);
|
|
3585
3586
|
}
|
|
3586
|
-
static notFound(
|
|
3587
|
-
return new ApiError(404, code2,
|
|
3587
|
+
static notFound(message, code2 = "NOT_FOUND") {
|
|
3588
|
+
return new ApiError(404, code2, message);
|
|
3588
3589
|
}
|
|
3589
|
-
static conflict(
|
|
3590
|
-
return new ApiError(409, code2,
|
|
3590
|
+
static conflict(message, code2 = "CONFLICT") {
|
|
3591
|
+
return new ApiError(409, code2, message);
|
|
3591
3592
|
}
|
|
3592
|
-
static internal(
|
|
3593
|
-
return new ApiError(500, code2,
|
|
3593
|
+
static internal(message, code2 = "INTERNAL_ERROR") {
|
|
3594
|
+
return new ApiError(500, code2, message);
|
|
3594
3595
|
}
|
|
3595
|
-
static serviceUnavailable(
|
|
3596
|
-
return new ApiError(503, code2,
|
|
3596
|
+
static serviceUnavailable(message, code2 = "SERVICE_UNAVAILABLE") {
|
|
3597
|
+
return new ApiError(503, code2, message);
|
|
3597
3598
|
}
|
|
3598
3599
|
}
|
|
3599
3600
|
const errorHandler = (err, c) => {
|
|
@@ -3721,8 +3722,8 @@ function parseQueryOptions(query) {
|
|
|
3721
3722
|
}
|
|
3722
3723
|
Object.assign(options2.where, parsedWhere);
|
|
3723
3724
|
} catch (e) {
|
|
3724
|
-
const
|
|
3725
|
-
const err = new Error(`Invalid 'where' filter: ${
|
|
3725
|
+
const message = e instanceof Error ? e.message : "malformed JSON";
|
|
3726
|
+
const err = new Error(`Invalid 'where' filter: ${message}`);
|
|
3726
3727
|
err.code = "BAD_REQUEST";
|
|
3727
3728
|
err.statusCode = 400;
|
|
3728
3729
|
throw err;
|
|
@@ -3806,11 +3807,24 @@ class RestApiGenerator {
|
|
|
3806
3807
|
collections;
|
|
3807
3808
|
router;
|
|
3808
3809
|
driver;
|
|
3809
|
-
|
|
3810
|
+
dataHooks;
|
|
3811
|
+
constructor(collections, driver, dataHooks) {
|
|
3810
3812
|
this.collections = collections;
|
|
3811
3813
|
this.driver = driver;
|
|
3814
|
+
this.dataHooks = dataHooks;
|
|
3812
3815
|
this.router = new Hono();
|
|
3813
3816
|
}
|
|
3817
|
+
/** Build a BackendHookContext from a Hono context */
|
|
3818
|
+
buildHookContext(c, method) {
|
|
3819
|
+
const user = c.get("user");
|
|
3820
|
+
return {
|
|
3821
|
+
requestUser: user ? {
|
|
3822
|
+
userId: user.userId,
|
|
3823
|
+
roles: user.roles ?? []
|
|
3824
|
+
} : void 0,
|
|
3825
|
+
method
|
|
3826
|
+
};
|
|
3827
|
+
}
|
|
3814
3828
|
/**
|
|
3815
3829
|
* Generate REST routes using existing DataDriver
|
|
3816
3830
|
*/
|
|
@@ -3822,16 +3836,10 @@ class RestApiGenerator {
|
|
|
3822
3836
|
return this.router;
|
|
3823
3837
|
}
|
|
3824
3838
|
/**
|
|
3825
|
-
* Get the
|
|
3839
|
+
* Get the typed RestFetchService from a driver if it exposes one (for include support).
|
|
3826
3840
|
*/
|
|
3827
3841
|
getFetchService(driver) {
|
|
3828
|
-
|
|
3829
|
-
const es = driver.entityService;
|
|
3830
|
-
if (typeof es.getFetchService === "function") {
|
|
3831
|
-
return es.getFetchService();
|
|
3832
|
-
}
|
|
3833
|
-
}
|
|
3834
|
-
return null;
|
|
3842
|
+
return driver.restFetchService;
|
|
3835
3843
|
}
|
|
3836
3844
|
/**
|
|
3837
3845
|
* Create REST routes for a collection using existing Rebase patterns
|
|
@@ -3839,15 +3847,26 @@ class RestApiGenerator {
|
|
|
3839
3847
|
createCollectionRoutes(collection) {
|
|
3840
3848
|
const basePath = `/${collection.slug}`;
|
|
3841
3849
|
const resolvedCollection = collection;
|
|
3850
|
+
this.router.get(`${basePath}/count`, async (c) => {
|
|
3851
|
+
const queryDict = c.req.query();
|
|
3852
|
+
const queryOptions = parseQueryOptions(queryDict);
|
|
3853
|
+
const searchString = queryDict.searchString;
|
|
3854
|
+
const driver = c.get("driver") || this.driver;
|
|
3855
|
+
const total = await this.countRawEntities(driver, resolvedCollection, queryOptions, searchString);
|
|
3856
|
+
return c.json({
|
|
3857
|
+
count: total
|
|
3858
|
+
});
|
|
3859
|
+
});
|
|
3842
3860
|
this.router.get(basePath, async (c) => {
|
|
3843
3861
|
const queryDict = c.req.query();
|
|
3844
3862
|
const queryOptions = parseQueryOptions(queryDict);
|
|
3845
3863
|
const searchString = queryDict.searchString;
|
|
3846
3864
|
const driver = c.get("driver") || this.driver;
|
|
3847
3865
|
const fetchService = this.getFetchService(driver);
|
|
3866
|
+
const hookCtx = this.buildHookContext(c, "GET");
|
|
3848
3867
|
if (fetchService) {
|
|
3849
3868
|
const collectionPath = collection.slug;
|
|
3850
|
-
|
|
3869
|
+
let entities2 = await fetchService.fetchCollectionForRest(collectionPath, {
|
|
3851
3870
|
filter: queryOptions.where,
|
|
3852
3871
|
limit: queryOptions.limit,
|
|
3853
3872
|
offset: queryOptions.offset,
|
|
@@ -3855,6 +3874,7 @@ class RestApiGenerator {
|
|
|
3855
3874
|
order: queryOptions.orderBy?.[0]?.direction === "desc" ? "desc" : "asc",
|
|
3856
3875
|
searchString
|
|
3857
3876
|
}, queryOptions.include);
|
|
3877
|
+
entities2 = await this.applyAfterReadBatch(collection.slug, entities2, hookCtx);
|
|
3858
3878
|
const total2 = await this.countRawEntities(driver, resolvedCollection, queryOptions, searchString);
|
|
3859
3879
|
return c.json({
|
|
3860
3880
|
data: entities2,
|
|
@@ -3866,7 +3886,8 @@ class RestApiGenerator {
|
|
|
3866
3886
|
}
|
|
3867
3887
|
});
|
|
3868
3888
|
}
|
|
3869
|
-
|
|
3889
|
+
let entities = await this.fetchRawCollection(driver, resolvedCollection, queryOptions, searchString);
|
|
3890
|
+
entities = await this.applyAfterReadBatch(collection.slug, entities, hookCtx);
|
|
3870
3891
|
const total = await this.countRawEntities(driver, resolvedCollection, queryOptions, searchString);
|
|
3871
3892
|
return c.json({
|
|
3872
3893
|
data: entities,
|
|
@@ -3884,15 +3905,24 @@ class RestApiGenerator {
|
|
|
3884
3905
|
const queryOptions = parseQueryOptions(queryDict);
|
|
3885
3906
|
const driver = c.get("driver") || this.driver;
|
|
3886
3907
|
const fetchService = this.getFetchService(driver);
|
|
3908
|
+
const hookCtx = this.buildHookContext(c, "GET");
|
|
3887
3909
|
if (fetchService) {
|
|
3888
3910
|
const collectionPath = collection.slug;
|
|
3889
|
-
|
|
3911
|
+
let entity2 = await fetchService.fetchEntityForRest(collectionPath, String(id), queryOptions.include);
|
|
3912
|
+
if (!entity2) {
|
|
3913
|
+
throw ApiError.notFound("Entity not found");
|
|
3914
|
+
}
|
|
3915
|
+
entity2 = await this.applyAfterRead(collection.slug, entity2, hookCtx);
|
|
3890
3916
|
if (!entity2) {
|
|
3891
3917
|
throw ApiError.notFound("Entity not found");
|
|
3892
3918
|
}
|
|
3893
3919
|
return c.json(entity2);
|
|
3894
3920
|
}
|
|
3895
|
-
|
|
3921
|
+
let entity = await this.fetchRawEntity(driver, resolvedCollection, String(id));
|
|
3922
|
+
if (!entity) {
|
|
3923
|
+
throw ApiError.notFound("Entity not found");
|
|
3924
|
+
}
|
|
3925
|
+
entity = await this.applyAfterRead(collection.slug, entity, hookCtx);
|
|
3896
3926
|
if (!entity) {
|
|
3897
3927
|
throw ApiError.notFound("Entity not found");
|
|
3898
3928
|
}
|
|
@@ -3902,14 +3932,24 @@ class RestApiGenerator {
|
|
|
3902
3932
|
try {
|
|
3903
3933
|
const driver = c.get("driver") || this.driver;
|
|
3904
3934
|
const path2 = collection.slug;
|
|
3905
|
-
const
|
|
3935
|
+
const hookCtx = this.buildHookContext(c, "POST");
|
|
3936
|
+
let body = await c.req.json().catch(() => ({}));
|
|
3937
|
+
if (this.dataHooks?.beforeSave) {
|
|
3938
|
+
body = await this.dataHooks.beforeSave(path2, body, void 0, hookCtx);
|
|
3939
|
+
}
|
|
3906
3940
|
const entity = await driver.saveEntity({
|
|
3907
3941
|
path: path2,
|
|
3908
3942
|
values: body,
|
|
3909
3943
|
collection: resolvedCollection,
|
|
3910
3944
|
status: "new"
|
|
3911
3945
|
});
|
|
3912
|
-
|
|
3946
|
+
const response = this.formatResponse(entity);
|
|
3947
|
+
if (this.dataHooks?.afterSave) {
|
|
3948
|
+
Promise.resolve(this.dataHooks.afterSave(path2, response, hookCtx)).catch((err) => {
|
|
3949
|
+
console.error("[BackendHooks] data.afterSave error:", err instanceof Error ? err.message : err);
|
|
3950
|
+
});
|
|
3951
|
+
}
|
|
3952
|
+
return c.json(response, 201);
|
|
3913
3953
|
} catch (error2) {
|
|
3914
3954
|
const err = error2;
|
|
3915
3955
|
err.code = err.code || "BAD_REQUEST";
|
|
@@ -3920,6 +3960,7 @@ class RestApiGenerator {
|
|
|
3920
3960
|
try {
|
|
3921
3961
|
const id = c.req.param("id");
|
|
3922
3962
|
const driver = c.get("driver") || this.driver;
|
|
3963
|
+
const hookCtx = this.buildHookContext(c, "PUT");
|
|
3923
3964
|
const existingEntity = await driver.fetchEntity({
|
|
3924
3965
|
path: collection.slug,
|
|
3925
3966
|
entityId: String(id),
|
|
@@ -3928,7 +3969,10 @@ class RestApiGenerator {
|
|
|
3928
3969
|
if (!existingEntity) {
|
|
3929
3970
|
throw ApiError.notFound("Entity not found");
|
|
3930
3971
|
}
|
|
3931
|
-
|
|
3972
|
+
let body = await c.req.json().catch(() => ({}));
|
|
3973
|
+
if (this.dataHooks?.beforeSave) {
|
|
3974
|
+
body = await this.dataHooks.beforeSave(collection.slug, body, String(id), hookCtx);
|
|
3975
|
+
}
|
|
3932
3976
|
const entity = await driver.saveEntity({
|
|
3933
3977
|
path: collection.slug,
|
|
3934
3978
|
entityId: String(id),
|
|
@@ -3936,7 +3980,13 @@ class RestApiGenerator {
|
|
|
3936
3980
|
collection: resolvedCollection,
|
|
3937
3981
|
status: "existing"
|
|
3938
3982
|
});
|
|
3939
|
-
|
|
3983
|
+
const response = this.formatResponse(entity);
|
|
3984
|
+
if (this.dataHooks?.afterSave) {
|
|
3985
|
+
Promise.resolve(this.dataHooks.afterSave(collection.slug, response, hookCtx)).catch((err) => {
|
|
3986
|
+
console.error("[BackendHooks] data.afterSave error:", err instanceof Error ? err.message : err);
|
|
3987
|
+
});
|
|
3988
|
+
}
|
|
3989
|
+
return c.json(response);
|
|
3940
3990
|
} catch (error2) {
|
|
3941
3991
|
const err = error2;
|
|
3942
3992
|
err.code = err.code || "BAD_REQUEST";
|
|
@@ -3946,6 +3996,7 @@ class RestApiGenerator {
|
|
|
3946
3996
|
this.router.delete(`${basePath}/:id`, async (c) => {
|
|
3947
3997
|
const id = c.req.param("id");
|
|
3948
3998
|
const driver = c.get("driver") || this.driver;
|
|
3999
|
+
const hookCtx = this.buildHookContext(c, "DELETE");
|
|
3949
4000
|
const existingEntity = await driver.fetchEntity({
|
|
3950
4001
|
path: collection.slug,
|
|
3951
4002
|
entityId: String(id),
|
|
@@ -3954,10 +4005,18 @@ class RestApiGenerator {
|
|
|
3954
4005
|
if (!existingEntity) {
|
|
3955
4006
|
throw ApiError.notFound("Entity not found");
|
|
3956
4007
|
}
|
|
4008
|
+
if (this.dataHooks?.beforeDelete) {
|
|
4009
|
+
await this.dataHooks.beforeDelete(collection.slug, String(id), hookCtx);
|
|
4010
|
+
}
|
|
3957
4011
|
await driver.deleteEntity({
|
|
3958
4012
|
entity: existingEntity,
|
|
3959
4013
|
collection: resolvedCollection
|
|
3960
4014
|
});
|
|
4015
|
+
if (this.dataHooks?.afterDelete) {
|
|
4016
|
+
Promise.resolve(this.dataHooks.afterDelete(collection.slug, String(id), hookCtx)).catch((err) => {
|
|
4017
|
+
console.error("[BackendHooks] data.afterDelete error:", err instanceof Error ? err.message : err);
|
|
4018
|
+
});
|
|
4019
|
+
}
|
|
3961
4020
|
return new Response(null, {
|
|
3962
4021
|
status: 204
|
|
3963
4022
|
});
|
|
@@ -4006,7 +4065,18 @@ class RestApiGenerator {
|
|
|
4006
4065
|
const parsed = parseSubPath(rawPath);
|
|
4007
4066
|
if (!parsed) return next();
|
|
4008
4067
|
const driver = c.get("driver") || this.driver;
|
|
4009
|
-
if (parsed.entityId) {
|
|
4068
|
+
if (parsed.entityId === "count") {
|
|
4069
|
+
const queryDict = c.req.query();
|
|
4070
|
+
const queryOptions = parseQueryOptions(queryDict);
|
|
4071
|
+
const total = driver.countEntities ? await driver.countEntities({
|
|
4072
|
+
path: parsed.collectionPath,
|
|
4073
|
+
filter: queryOptions.where,
|
|
4074
|
+
searchString: queryDict.searchString
|
|
4075
|
+
}) : 0;
|
|
4076
|
+
return c.json({
|
|
4077
|
+
count: total
|
|
4078
|
+
});
|
|
4079
|
+
} else if (parsed.entityId) {
|
|
4010
4080
|
const entity = await driver.fetchEntity({
|
|
4011
4081
|
path: parsed.collectionPath,
|
|
4012
4082
|
entityId: parsed.entityId
|
|
@@ -4164,6 +4234,22 @@ class RestApiGenerator {
|
|
|
4164
4234
|
});
|
|
4165
4235
|
return entity ? this.flattenEntity(entity) : null;
|
|
4166
4236
|
}
|
|
4237
|
+
/**
|
|
4238
|
+
* Apply data.afterRead hook to a single entity.
|
|
4239
|
+
* Returns the transformed entity, or null to filter it out.
|
|
4240
|
+
*/
|
|
4241
|
+
async applyAfterRead(slug, entity, ctx) {
|
|
4242
|
+
if (!this.dataHooks?.afterRead) return entity;
|
|
4243
|
+
return this.dataHooks.afterRead(slug, entity, ctx);
|
|
4244
|
+
}
|
|
4245
|
+
/**
|
|
4246
|
+
* Apply data.afterRead hook to an array of entities, filtering out nulls.
|
|
4247
|
+
*/
|
|
4248
|
+
async applyAfterReadBatch(slug, entities, ctx) {
|
|
4249
|
+
if (!this.dataHooks?.afterRead) return entities;
|
|
4250
|
+
const results = await Promise.all(entities.map((e) => this.applyAfterRead(slug, e, ctx)));
|
|
4251
|
+
return results.filter((e) => e !== null);
|
|
4252
|
+
}
|
|
4167
4253
|
}
|
|
4168
4254
|
var jws$5 = {};
|
|
4169
4255
|
var safeBuffer = { exports: {} };
|
|
@@ -4745,11 +4831,11 @@ var Stream$1 = require$$0$3;
|
|
|
4745
4831
|
var toString2 = tostring;
|
|
4746
4832
|
var util$4 = require$$5;
|
|
4747
4833
|
var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
|
|
4748
|
-
function isObject$
|
|
4834
|
+
function isObject$3(thing) {
|
|
4749
4835
|
return Object.prototype.toString.call(thing) === "[object Object]";
|
|
4750
4836
|
}
|
|
4751
4837
|
function safeJsonParse(thing) {
|
|
4752
|
-
if (isObject$
|
|
4838
|
+
if (isObject$3(thing))
|
|
4753
4839
|
return thing;
|
|
4754
4840
|
try {
|
|
4755
4841
|
return JSON.parse(thing);
|
|
@@ -4875,7 +4961,7 @@ jws$5.createVerify = function createVerify(opts) {
|
|
|
4875
4961
|
return new VerifyStream(opts);
|
|
4876
4962
|
};
|
|
4877
4963
|
var jws$4 = jws$5;
|
|
4878
|
-
var decode$
|
|
4964
|
+
var decode$2 = function(jwt2, options2) {
|
|
4879
4965
|
options2 = options2 || {};
|
|
4880
4966
|
var decoded = jws$4.decode(jwt2, options2);
|
|
4881
4967
|
if (!decoded) {
|
|
@@ -4900,21 +4986,21 @@ var decode$3 = function(jwt2, options2) {
|
|
|
4900
4986
|
}
|
|
4901
4987
|
return payload;
|
|
4902
4988
|
};
|
|
4903
|
-
var JsonWebTokenError$3 = function(
|
|
4904
|
-
Error.call(this,
|
|
4989
|
+
var JsonWebTokenError$3 = function(message, error2) {
|
|
4990
|
+
Error.call(this, message);
|
|
4905
4991
|
if (Error.captureStackTrace) {
|
|
4906
4992
|
Error.captureStackTrace(this, this.constructor);
|
|
4907
4993
|
}
|
|
4908
4994
|
this.name = "JsonWebTokenError";
|
|
4909
|
-
this.message =
|
|
4995
|
+
this.message = message;
|
|
4910
4996
|
if (error2) this.inner = error2;
|
|
4911
4997
|
};
|
|
4912
4998
|
JsonWebTokenError$3.prototype = Object.create(Error.prototype);
|
|
4913
4999
|
JsonWebTokenError$3.prototype.constructor = JsonWebTokenError$3;
|
|
4914
5000
|
var JsonWebTokenError_1 = JsonWebTokenError$3;
|
|
4915
5001
|
var JsonWebTokenError$2 = JsonWebTokenError_1;
|
|
4916
|
-
var NotBeforeError$1 = function(
|
|
4917
|
-
JsonWebTokenError$2.call(this,
|
|
5002
|
+
var NotBeforeError$1 = function(message, date) {
|
|
5003
|
+
JsonWebTokenError$2.call(this, message);
|
|
4918
5004
|
this.name = "NotBeforeError";
|
|
4919
5005
|
this.date = date;
|
|
4920
5006
|
};
|
|
@@ -4922,8 +5008,8 @@ NotBeforeError$1.prototype = Object.create(JsonWebTokenError$2.prototype);
|
|
|
4922
5008
|
NotBeforeError$1.prototype.constructor = NotBeforeError$1;
|
|
4923
5009
|
var NotBeforeError_1 = NotBeforeError$1;
|
|
4924
5010
|
var JsonWebTokenError$1 = JsonWebTokenError_1;
|
|
4925
|
-
var TokenExpiredError$1 = function(
|
|
4926
|
-
JsonWebTokenError$1.call(this,
|
|
5011
|
+
var TokenExpiredError$1 = function(message, expiredAt) {
|
|
5012
|
+
JsonWebTokenError$1.call(this, message);
|
|
4927
5013
|
this.name = "TokenExpiredError";
|
|
4928
5014
|
this.expiredAt = expiredAt;
|
|
4929
5015
|
};
|
|
@@ -5788,7 +5874,7 @@ function requireRange() {
|
|
|
5788
5874
|
parseRange(range2) {
|
|
5789
5875
|
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
5790
5876
|
const memoKey = memoOpts + ":" + range2;
|
|
5791
|
-
const cached =
|
|
5877
|
+
const cached = cache.get(memoKey);
|
|
5792
5878
|
if (cached) {
|
|
5793
5879
|
return cached;
|
|
5794
5880
|
}
|
|
@@ -5822,7 +5908,7 @@ function requireRange() {
|
|
|
5822
5908
|
rangeMap.delete("");
|
|
5823
5909
|
}
|
|
5824
5910
|
const result = [...rangeMap.values()];
|
|
5825
|
-
|
|
5911
|
+
cache.set(memoKey, result);
|
|
5826
5912
|
return result;
|
|
5827
5913
|
}
|
|
5828
5914
|
intersects(range2, options2) {
|
|
@@ -5861,7 +5947,7 @@ function requireRange() {
|
|
|
5861
5947
|
}
|
|
5862
5948
|
range = Range2;
|
|
5863
5949
|
const LRU = lrucache;
|
|
5864
|
-
const
|
|
5950
|
+
const cache = new LRU();
|
|
5865
5951
|
const parseOptions2 = parseOptions_1;
|
|
5866
5952
|
const Comparator2 = requireComparator();
|
|
5867
5953
|
const debug2 = debug_1;
|
|
@@ -6738,7 +6824,7 @@ var psSupported = semver.satisfies(process.version, "^6.12.0 || >=8.0.0");
|
|
|
6738
6824
|
const JsonWebTokenError = JsonWebTokenError_1;
|
|
6739
6825
|
const NotBeforeError = NotBeforeError_1;
|
|
6740
6826
|
const TokenExpiredError = TokenExpiredError_1;
|
|
6741
|
-
const decode$
|
|
6827
|
+
const decode$1 = decode$2;
|
|
6742
6828
|
const timespan$1 = timespan$2;
|
|
6743
6829
|
const validateAsymmetricKey$1 = validateAsymmetricKey$2;
|
|
6744
6830
|
const PS_SUPPORTED$1 = psSupported;
|
|
@@ -6792,7 +6878,7 @@ var verify2 = function(jwtString, secretOrPublicKey, options2, callback) {
|
|
|
6792
6878
|
}
|
|
6793
6879
|
let decodedToken;
|
|
6794
6880
|
try {
|
|
6795
|
-
decodedToken = decode$
|
|
6881
|
+
decodedToken = decode$1(jwtString, { complete: true });
|
|
6796
6882
|
} catch (err) {
|
|
6797
6883
|
return done(err);
|
|
6798
6884
|
}
|
|
@@ -7052,27 +7138,27 @@ function isArrayLike(value) {
|
|
|
7052
7138
|
return value != null && isLength(value.length) && !isFunction(value);
|
|
7053
7139
|
}
|
|
7054
7140
|
function isArrayLikeObject(value) {
|
|
7055
|
-
return isObjectLike$
|
|
7141
|
+
return isObjectLike$7(value) && isArrayLike(value);
|
|
7056
7142
|
}
|
|
7057
7143
|
function isFunction(value) {
|
|
7058
|
-
var
|
|
7059
|
-
return
|
|
7144
|
+
var tag = isObject$2(value) ? objectToString$6.call(value) : "";
|
|
7145
|
+
return tag == funcTag || tag == genTag;
|
|
7060
7146
|
}
|
|
7061
7147
|
function isLength(value) {
|
|
7062
7148
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
7063
7149
|
}
|
|
7064
|
-
function isObject$
|
|
7150
|
+
function isObject$2(value) {
|
|
7065
7151
|
var type = typeof value;
|
|
7066
7152
|
return !!value && (type == "object" || type == "function");
|
|
7067
7153
|
}
|
|
7068
|
-
function isObjectLike$
|
|
7154
|
+
function isObjectLike$7(value) {
|
|
7069
7155
|
return !!value && typeof value == "object";
|
|
7070
7156
|
}
|
|
7071
7157
|
function isString$2(value) {
|
|
7072
|
-
return typeof value == "string" || !isArray$2(value) && isObjectLike$
|
|
7158
|
+
return typeof value == "string" || !isArray$2(value) && isObjectLike$7(value) && objectToString$6.call(value) == stringTag$1;
|
|
7073
7159
|
}
|
|
7074
7160
|
function isSymbol$2(value) {
|
|
7075
|
-
return typeof value == "symbol" || isObjectLike$
|
|
7161
|
+
return typeof value == "symbol" || isObjectLike$7(value) && objectToString$6.call(value) == symbolTag$2;
|
|
7076
7162
|
}
|
|
7077
7163
|
function toFinite$2(value) {
|
|
7078
7164
|
if (!value) {
|
|
@@ -7096,9 +7182,9 @@ function toNumber$2(value) {
|
|
|
7096
7182
|
if (isSymbol$2(value)) {
|
|
7097
7183
|
return NAN$2;
|
|
7098
7184
|
}
|
|
7099
|
-
if (isObject$
|
|
7185
|
+
if (isObject$2(value)) {
|
|
7100
7186
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
7101
|
-
value = isObject$
|
|
7187
|
+
value = isObject$2(other) ? other + "" : other;
|
|
7102
7188
|
}
|
|
7103
7189
|
if (typeof value != "string") {
|
|
7104
7190
|
return value === 0 ? value : +value;
|
|
@@ -7118,9 +7204,9 @@ var boolTag = "[object Boolean]";
|
|
|
7118
7204
|
var objectProto$5 = Object.prototype;
|
|
7119
7205
|
var objectToString$5 = objectProto$5.toString;
|
|
7120
7206
|
function isBoolean$1(value) {
|
|
7121
|
-
return value === true || value === false || isObjectLike$
|
|
7207
|
+
return value === true || value === false || isObjectLike$6(value) && objectToString$5.call(value) == boolTag;
|
|
7122
7208
|
}
|
|
7123
|
-
function isObjectLike$
|
|
7209
|
+
function isObjectLike$6(value) {
|
|
7124
7210
|
return !!value && typeof value == "object";
|
|
7125
7211
|
}
|
|
7126
7212
|
var lodash_isboolean = isBoolean$1;
|
|
@@ -7136,15 +7222,15 @@ var objectToString$4 = objectProto$4.toString;
|
|
|
7136
7222
|
function isInteger$1(value) {
|
|
7137
7223
|
return typeof value == "number" && value == toInteger$1(value);
|
|
7138
7224
|
}
|
|
7139
|
-
function isObject$
|
|
7225
|
+
function isObject$1(value) {
|
|
7140
7226
|
var type = typeof value;
|
|
7141
7227
|
return !!value && (type == "object" || type == "function");
|
|
7142
7228
|
}
|
|
7143
|
-
function isObjectLike$
|
|
7229
|
+
function isObjectLike$5(value) {
|
|
7144
7230
|
return !!value && typeof value == "object";
|
|
7145
7231
|
}
|
|
7146
7232
|
function isSymbol$1(value) {
|
|
7147
|
-
return typeof value == "symbol" || isObjectLike$
|
|
7233
|
+
return typeof value == "symbol" || isObjectLike$5(value) && objectToString$4.call(value) == symbolTag$1;
|
|
7148
7234
|
}
|
|
7149
7235
|
function toFinite$1(value) {
|
|
7150
7236
|
if (!value) {
|
|
@@ -7168,9 +7254,9 @@ function toNumber$1(value) {
|
|
|
7168
7254
|
if (isSymbol$1(value)) {
|
|
7169
7255
|
return NAN$1;
|
|
7170
7256
|
}
|
|
7171
|
-
if (isObject$
|
|
7257
|
+
if (isObject$1(value)) {
|
|
7172
7258
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
7173
|
-
value = isObject$
|
|
7259
|
+
value = isObject$1(other) ? other + "" : other;
|
|
7174
7260
|
}
|
|
7175
7261
|
if (typeof value != "string") {
|
|
7176
7262
|
return value === 0 ? value : +value;
|
|
@@ -7183,11 +7269,11 @@ var lodash_isinteger = isInteger$1;
|
|
|
7183
7269
|
var numberTag = "[object Number]";
|
|
7184
7270
|
var objectProto$3 = Object.prototype;
|
|
7185
7271
|
var objectToString$3 = objectProto$3.toString;
|
|
7186
|
-
function isObjectLike$
|
|
7272
|
+
function isObjectLike$4(value) {
|
|
7187
7273
|
return !!value && typeof value == "object";
|
|
7188
7274
|
}
|
|
7189
7275
|
function isNumber$1(value) {
|
|
7190
|
-
return typeof value == "number" || isObjectLike$
|
|
7276
|
+
return typeof value == "number" || isObjectLike$4(value) && objectToString$3.call(value) == numberTag;
|
|
7191
7277
|
}
|
|
7192
7278
|
var lodash_isnumber = isNumber$1;
|
|
7193
7279
|
var objectTag = "[object Object]";
|
|
@@ -7212,11 +7298,11 @@ var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
|
|
7212
7298
|
var objectCtorString = funcToString.call(Object);
|
|
7213
7299
|
var objectToString$2 = objectProto$2.toString;
|
|
7214
7300
|
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
7215
|
-
function isObjectLike$
|
|
7301
|
+
function isObjectLike$3(value) {
|
|
7216
7302
|
return !!value && typeof value == "object";
|
|
7217
7303
|
}
|
|
7218
7304
|
function isPlainObject$2(value) {
|
|
7219
|
-
if (!isObjectLike$
|
|
7305
|
+
if (!isObjectLike$3(value) || objectToString$2.call(value) != objectTag || isHostObject(value)) {
|
|
7220
7306
|
return false;
|
|
7221
7307
|
}
|
|
7222
7308
|
var proto = getPrototype(value);
|
|
@@ -7231,11 +7317,11 @@ var stringTag = "[object String]";
|
|
|
7231
7317
|
var objectProto$1 = Object.prototype;
|
|
7232
7318
|
var objectToString$1 = objectProto$1.toString;
|
|
7233
7319
|
var isArray$1 = Array.isArray;
|
|
7234
|
-
function isObjectLike$
|
|
7320
|
+
function isObjectLike$2(value) {
|
|
7235
7321
|
return !!value && typeof value == "object";
|
|
7236
7322
|
}
|
|
7237
7323
|
function isString$1(value) {
|
|
7238
|
-
return typeof value == "string" || !isArray$1(value) && isObjectLike$
|
|
7324
|
+
return typeof value == "string" || !isArray$1(value) && isObjectLike$2(value) && objectToString$1.call(value) == stringTag;
|
|
7239
7325
|
}
|
|
7240
7326
|
var lodash_isstring = isString$1;
|
|
7241
7327
|
var FUNC_ERROR_TEXT = "Expected a function";
|
|
@@ -7267,15 +7353,15 @@ function before(n, func) {
|
|
|
7267
7353
|
function once$1(func) {
|
|
7268
7354
|
return before(2, func);
|
|
7269
7355
|
}
|
|
7270
|
-
function isObject
|
|
7356
|
+
function isObject(value) {
|
|
7271
7357
|
var type = typeof value;
|
|
7272
7358
|
return !!value && (type == "object" || type == "function");
|
|
7273
7359
|
}
|
|
7274
|
-
function isObjectLike$
|
|
7360
|
+
function isObjectLike$1(value) {
|
|
7275
7361
|
return !!value && typeof value == "object";
|
|
7276
7362
|
}
|
|
7277
7363
|
function isSymbol(value) {
|
|
7278
|
-
return typeof value == "symbol" || isObjectLike$
|
|
7364
|
+
return typeof value == "symbol" || isObjectLike$1(value) && objectToString.call(value) == symbolTag;
|
|
7279
7365
|
}
|
|
7280
7366
|
function toFinite(value) {
|
|
7281
7367
|
if (!value) {
|
|
@@ -7299,9 +7385,9 @@ function toNumber(value) {
|
|
|
7299
7385
|
if (isSymbol(value)) {
|
|
7300
7386
|
return NAN;
|
|
7301
7387
|
}
|
|
7302
|
-
if (isObject
|
|
7388
|
+
if (isObject(value)) {
|
|
7303
7389
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
7304
|
-
value = isObject
|
|
7390
|
+
value = isObject(other) ? other + "" : other;
|
|
7305
7391
|
}
|
|
7306
7392
|
if (typeof value != "string") {
|
|
7307
7393
|
return value === 0 ? value : +value;
|
|
@@ -7392,7 +7478,7 @@ const options_for_objects = [
|
|
|
7392
7478
|
"subject",
|
|
7393
7479
|
"jwtid"
|
|
7394
7480
|
];
|
|
7395
|
-
var sign$
|
|
7481
|
+
var sign$3 = function(payload, secretOrPrivateKey, options2, callback) {
|
|
7396
7482
|
if (typeof options2 === "function") {
|
|
7397
7483
|
callback = options2;
|
|
7398
7484
|
options2 = {};
|
|
@@ -7531,9 +7617,9 @@ var sign$4 = function(payload, secretOrPrivateKey, options2, callback) {
|
|
|
7531
7617
|
}
|
|
7532
7618
|
};
|
|
7533
7619
|
var jsonwebtoken = {
|
|
7534
|
-
decode: decode$
|
|
7620
|
+
decode: decode$2,
|
|
7535
7621
|
verify: verify2,
|
|
7536
|
-
sign: sign$
|
|
7622
|
+
sign: sign$3,
|
|
7537
7623
|
JsonWebTokenError: JsonWebTokenError_1,
|
|
7538
7624
|
NotBeforeError: NotBeforeError_1,
|
|
7539
7625
|
TokenExpiredError: TokenExpiredError_1
|
|
@@ -7984,7 +8070,7 @@ function formatData(data) {
|
|
|
7984
8070
|
}
|
|
7985
8071
|
function createLogger(defaultFields = {}) {
|
|
7986
8072
|
const minLevel = getMinLevel();
|
|
7987
|
-
function emit(level,
|
|
8073
|
+
function emit(level, message, data) {
|
|
7988
8074
|
if (LOG_PRIORITY[level] < LOG_PRIORITY[minLevel]) return;
|
|
7989
8075
|
const merged = {
|
|
7990
8076
|
...defaultFields,
|
|
@@ -7993,7 +8079,7 @@ function createLogger(defaultFields = {}) {
|
|
|
7993
8079
|
if (isProduction$1()) {
|
|
7994
8080
|
const entry = {
|
|
7995
8081
|
severity: GCP_SEVERITY[level],
|
|
7996
|
-
message
|
|
8082
|
+
message,
|
|
7997
8083
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7998
8084
|
...merged
|
|
7999
8085
|
};
|
|
@@ -8006,7 +8092,7 @@ function createLogger(defaultFields = {}) {
|
|
|
8006
8092
|
} else {
|
|
8007
8093
|
const prefix = level === "error" ? "❌" : level === "warn" ? "⚠️" : level === "info" ? "ℹ️" : "🐛";
|
|
8008
8094
|
const extra = Object.keys(merged).length > 0 ? ` ${JSON.stringify(merged)}` : "";
|
|
8009
|
-
const out = `${prefix} [${level.toUpperCase()}] ${
|
|
8095
|
+
const out = `${prefix} [${level.toUpperCase()}] ${message}${extra}`;
|
|
8010
8096
|
if (level === "error") {
|
|
8011
8097
|
console.error(out);
|
|
8012
8098
|
} else if (level === "warn") {
|
|
@@ -8367,9 +8453,9 @@ util$3.pkg = require$$0$1;
|
|
|
8367
8453
|
}
|
|
8368
8454
|
return Function.prototype[Symbol.hasInstance].call(GaxiosError, instance);
|
|
8369
8455
|
}
|
|
8370
|
-
constructor(
|
|
8456
|
+
constructor(message, config, response, error2) {
|
|
8371
8457
|
var _b2;
|
|
8372
|
-
super(
|
|
8458
|
+
super(message);
|
|
8373
8459
|
this.config = config;
|
|
8374
8460
|
this.response = response;
|
|
8375
8461
|
this.error = error2;
|
|
@@ -14265,8 +14351,8 @@ const readFile$2 = fs$3.readFile ? (0, util_1$5.promisify)(fs$3.readFile) : asyn
|
|
|
14265
14351
|
const GOOGLE_TOKEN_URL = "https://www.googleapis.com/oauth2/v4/token";
|
|
14266
14352
|
const GOOGLE_REVOKE_TOKEN_URL = "https://accounts.google.com/o/oauth2/revoke?token=";
|
|
14267
14353
|
class ErrorWithCode extends Error {
|
|
14268
|
-
constructor(
|
|
14269
|
-
super(
|
|
14354
|
+
constructor(message, code2) {
|
|
14355
|
+
super(message);
|
|
14270
14356
|
this.code = code2;
|
|
14271
14357
|
}
|
|
14272
14358
|
}
|
|
@@ -15122,13 +15208,13 @@ class Impersonated extends oauth2client_1.OAuth2Client {
|
|
|
15122
15208
|
if (!(error2 instanceof Error))
|
|
15123
15209
|
throw error2;
|
|
15124
15210
|
let status = 0;
|
|
15125
|
-
let
|
|
15211
|
+
let message = "";
|
|
15126
15212
|
if (error2 instanceof gaxios_1$2.GaxiosError) {
|
|
15127
15213
|
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
|
-
|
|
15214
|
+
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
15215
|
}
|
|
15130
|
-
if (status &&
|
|
15131
|
-
error2.message = `${status}: unable to impersonate: ${
|
|
15216
|
+
if (status && message) {
|
|
15217
|
+
error2.message = `${status}: unable to impersonate: ${message}`;
|
|
15132
15218
|
throw error2;
|
|
15133
15219
|
} else {
|
|
15134
15220
|
error2.message = `unable to impersonate: ${error2}`;
|
|
@@ -15290,14 +15376,14 @@ function getErrorFromOAuthErrorResponse(resp, err) {
|
|
|
15290
15376
|
const errorCode = resp.error;
|
|
15291
15377
|
const errorDescription = resp.error_description;
|
|
15292
15378
|
const errorUri = resp.error_uri;
|
|
15293
|
-
let
|
|
15379
|
+
let message = `Error code ${errorCode}`;
|
|
15294
15380
|
if (typeof errorDescription !== "undefined") {
|
|
15295
|
-
|
|
15381
|
+
message += `: ${errorDescription}`;
|
|
15296
15382
|
}
|
|
15297
15383
|
if (typeof errorUri !== "undefined") {
|
|
15298
|
-
|
|
15384
|
+
message += ` - ${errorUri}`;
|
|
15299
15385
|
}
|
|
15300
|
-
const newError = new Error(
|
|
15386
|
+
const newError = new Error(message);
|
|
15301
15387
|
if (err) {
|
|
15302
15388
|
const keys2 = Object.keys(err);
|
|
15303
15389
|
if (err.stack) {
|
|
@@ -16025,14 +16111,14 @@ class AwsRequestSigner {
|
|
|
16025
16111
|
}
|
|
16026
16112
|
}
|
|
16027
16113
|
awsrequestsigner.AwsRequestSigner = AwsRequestSigner;
|
|
16028
|
-
async function sign$
|
|
16114
|
+
async function sign$2(crypto2, key, msg) {
|
|
16029
16115
|
return await crypto2.signWithHmacSha256(key, msg);
|
|
16030
16116
|
}
|
|
16031
16117
|
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$
|
|
16118
|
+
const kDate = await sign$2(crypto2, `AWS4${key}`, dateStamp);
|
|
16119
|
+
const kRegion = await sign$2(crypto2, kDate, region);
|
|
16120
|
+
const kService = await sign$2(crypto2, kRegion, serviceName);
|
|
16121
|
+
const kSigning = await sign$2(crypto2, kService, "aws4_request");
|
|
16036
16122
|
return kSigning;
|
|
16037
16123
|
}
|
|
16038
16124
|
async function generateAuthenticationHeaderMap(options2) {
|
|
@@ -16078,7 +16164,7 @@ ${amzDate}
|
|
|
16078
16164
|
${credentialScope}
|
|
16079
16165
|
` + await options2.crypto.sha256DigestHex(canonicalRequest);
|
|
16080
16166
|
const signingKey = await getSigningKey(options2.crypto, options2.securityCredentials.secretAccessKey, dateStamp, options2.region, serviceName);
|
|
16081
|
-
const signature = await sign$
|
|
16167
|
+
const signature = await sign$2(options2.crypto, signingKey, stringToSign);
|
|
16082
16168
|
const authorizationHeader = `${AWS_ALGORITHM} Credential=${options2.securityCredentials.accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${(0, crypto_1.fromArrayBufferToHex)(signature)}`;
|
|
16083
16169
|
return {
|
|
16084
16170
|
// Do not return x-amz-date if date is available.
|
|
@@ -16409,8 +16495,8 @@ class ExecutableResponse {
|
|
|
16409
16495
|
}
|
|
16410
16496
|
executableResponse.ExecutableResponse = ExecutableResponse;
|
|
16411
16497
|
class ExecutableResponseError extends Error {
|
|
16412
|
-
constructor(
|
|
16413
|
-
super(
|
|
16498
|
+
constructor(message) {
|
|
16499
|
+
super(message);
|
|
16414
16500
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
16415
16501
|
}
|
|
16416
16502
|
}
|
|
@@ -16573,8 +16659,8 @@ function requirePluggableAuthClient() {
|
|
|
16573
16659
|
const executable_response_1 = executableResponse;
|
|
16574
16660
|
const pluggable_auth_handler_1 = requirePluggableAuthHandler();
|
|
16575
16661
|
class ExecutableError extends Error {
|
|
16576
|
-
constructor(
|
|
16577
|
-
super(`The executable failed with exit code: ${code2} and error message: ${
|
|
16662
|
+
constructor(message, code2) {
|
|
16663
|
+
super(`The executable failed with exit code: ${code2} and error message: ${message}.`);
|
|
16578
16664
|
this.code = code2;
|
|
16579
16665
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
16580
16666
|
}
|
|
@@ -18222,104 +18308,104 @@ ZodError.create = (issues) => {
|
|
|
18222
18308
|
return error2;
|
|
18223
18309
|
};
|
|
18224
18310
|
const errorMap = (issue, _ctx) => {
|
|
18225
|
-
let
|
|
18311
|
+
let message;
|
|
18226
18312
|
switch (issue.code) {
|
|
18227
18313
|
case ZodIssueCode.invalid_type:
|
|
18228
18314
|
if (issue.received === ZodParsedType.undefined) {
|
|
18229
|
-
|
|
18315
|
+
message = "Required";
|
|
18230
18316
|
} else {
|
|
18231
|
-
|
|
18317
|
+
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
18232
18318
|
}
|
|
18233
18319
|
break;
|
|
18234
18320
|
case ZodIssueCode.invalid_literal:
|
|
18235
|
-
|
|
18321
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util$1.jsonStringifyReplacer)}`;
|
|
18236
18322
|
break;
|
|
18237
18323
|
case ZodIssueCode.unrecognized_keys:
|
|
18238
|
-
|
|
18324
|
+
message = `Unrecognized key(s) in object: ${util$1.joinValues(issue.keys, ", ")}`;
|
|
18239
18325
|
break;
|
|
18240
18326
|
case ZodIssueCode.invalid_union:
|
|
18241
|
-
|
|
18327
|
+
message = `Invalid input`;
|
|
18242
18328
|
break;
|
|
18243
18329
|
case ZodIssueCode.invalid_union_discriminator:
|
|
18244
|
-
|
|
18330
|
+
message = `Invalid discriminator value. Expected ${util$1.joinValues(issue.options)}`;
|
|
18245
18331
|
break;
|
|
18246
18332
|
case ZodIssueCode.invalid_enum_value:
|
|
18247
|
-
|
|
18333
|
+
message = `Invalid enum value. Expected ${util$1.joinValues(issue.options)}, received '${issue.received}'`;
|
|
18248
18334
|
break;
|
|
18249
18335
|
case ZodIssueCode.invalid_arguments:
|
|
18250
|
-
|
|
18336
|
+
message = `Invalid function arguments`;
|
|
18251
18337
|
break;
|
|
18252
18338
|
case ZodIssueCode.invalid_return_type:
|
|
18253
|
-
|
|
18339
|
+
message = `Invalid function return type`;
|
|
18254
18340
|
break;
|
|
18255
18341
|
case ZodIssueCode.invalid_date:
|
|
18256
|
-
|
|
18342
|
+
message = `Invalid date`;
|
|
18257
18343
|
break;
|
|
18258
18344
|
case ZodIssueCode.invalid_string:
|
|
18259
18345
|
if (typeof issue.validation === "object") {
|
|
18260
18346
|
if ("includes" in issue.validation) {
|
|
18261
|
-
|
|
18347
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
18262
18348
|
if (typeof issue.validation.position === "number") {
|
|
18263
|
-
|
|
18349
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
18264
18350
|
}
|
|
18265
18351
|
} else if ("startsWith" in issue.validation) {
|
|
18266
|
-
|
|
18352
|
+
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
18267
18353
|
} else if ("endsWith" in issue.validation) {
|
|
18268
|
-
|
|
18354
|
+
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
18269
18355
|
} else {
|
|
18270
18356
|
util$1.assertNever(issue.validation);
|
|
18271
18357
|
}
|
|
18272
18358
|
} else if (issue.validation !== "regex") {
|
|
18273
|
-
|
|
18359
|
+
message = `Invalid ${issue.validation}`;
|
|
18274
18360
|
} else {
|
|
18275
|
-
|
|
18361
|
+
message = "Invalid";
|
|
18276
18362
|
}
|
|
18277
18363
|
break;
|
|
18278
18364
|
case ZodIssueCode.too_small:
|
|
18279
18365
|
if (issue.type === "array")
|
|
18280
|
-
|
|
18366
|
+
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
18281
18367
|
else if (issue.type === "string")
|
|
18282
|
-
|
|
18368
|
+
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
18283
18369
|
else if (issue.type === "number")
|
|
18284
|
-
|
|
18370
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
18285
18371
|
else if (issue.type === "bigint")
|
|
18286
|
-
|
|
18372
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
18287
18373
|
else if (issue.type === "date")
|
|
18288
|
-
|
|
18374
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
18289
18375
|
else
|
|
18290
|
-
|
|
18376
|
+
message = "Invalid input";
|
|
18291
18377
|
break;
|
|
18292
18378
|
case ZodIssueCode.too_big:
|
|
18293
18379
|
if (issue.type === "array")
|
|
18294
|
-
|
|
18380
|
+
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
18295
18381
|
else if (issue.type === "string")
|
|
18296
|
-
|
|
18382
|
+
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
18297
18383
|
else if (issue.type === "number")
|
|
18298
|
-
|
|
18384
|
+
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
18299
18385
|
else if (issue.type === "bigint")
|
|
18300
|
-
|
|
18386
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
18301
18387
|
else if (issue.type === "date")
|
|
18302
|
-
|
|
18388
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
18303
18389
|
else
|
|
18304
|
-
|
|
18390
|
+
message = "Invalid input";
|
|
18305
18391
|
break;
|
|
18306
18392
|
case ZodIssueCode.custom:
|
|
18307
|
-
|
|
18393
|
+
message = `Invalid input`;
|
|
18308
18394
|
break;
|
|
18309
18395
|
case ZodIssueCode.invalid_intersection_types:
|
|
18310
|
-
|
|
18396
|
+
message = `Intersection results could not be merged`;
|
|
18311
18397
|
break;
|
|
18312
18398
|
case ZodIssueCode.not_multiple_of:
|
|
18313
|
-
|
|
18399
|
+
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
18314
18400
|
break;
|
|
18315
18401
|
case ZodIssueCode.not_finite:
|
|
18316
|
-
|
|
18402
|
+
message = "Number must be finite";
|
|
18317
18403
|
break;
|
|
18318
18404
|
default:
|
|
18319
|
-
|
|
18405
|
+
message = _ctx.defaultError;
|
|
18320
18406
|
util$1.assertNever(issue);
|
|
18321
18407
|
}
|
|
18322
|
-
return { message
|
|
18408
|
+
return { message };
|
|
18323
18409
|
};
|
|
18324
18410
|
let overrideErrorMap = errorMap;
|
|
18325
18411
|
function getErrorMap() {
|
|
@@ -18434,8 +18520,8 @@ const isValid = (x) => x.status === "valid";
|
|
|
18434
18520
|
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
18435
18521
|
var errorUtil;
|
|
18436
18522
|
(function(errorUtil2) {
|
|
18437
|
-
errorUtil2.errToObj = (
|
|
18438
|
-
errorUtil2.toString = (
|
|
18523
|
+
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
18524
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
18439
18525
|
})(errorUtil || (errorUtil = {}));
|
|
18440
18526
|
class ParseInputLazyPath {
|
|
18441
18527
|
constructor(parent, value, path2, key) {
|
|
@@ -18485,16 +18571,16 @@ function processCreateParams(params) {
|
|
|
18485
18571
|
if (errorMap2)
|
|
18486
18572
|
return { errorMap: errorMap2, description: description2 };
|
|
18487
18573
|
const customMap = (iss, ctx) => {
|
|
18488
|
-
const { message
|
|
18574
|
+
const { message } = params;
|
|
18489
18575
|
if (iss.code === "invalid_enum_value") {
|
|
18490
|
-
return { message:
|
|
18576
|
+
return { message: message ?? ctx.defaultError };
|
|
18491
18577
|
}
|
|
18492
18578
|
if (typeof ctx.data === "undefined") {
|
|
18493
|
-
return { message:
|
|
18579
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
18494
18580
|
}
|
|
18495
18581
|
if (iss.code !== "invalid_type")
|
|
18496
18582
|
return { message: ctx.defaultError };
|
|
18497
|
-
return { message:
|
|
18583
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
18498
18584
|
};
|
|
18499
18585
|
return { errorMap: customMap, description: description2 };
|
|
18500
18586
|
}
|
|
@@ -18620,14 +18706,14 @@ class ZodType {
|
|
|
18620
18706
|
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
18621
18707
|
return handleResult(ctx, result);
|
|
18622
18708
|
}
|
|
18623
|
-
refine(check,
|
|
18709
|
+
refine(check, message) {
|
|
18624
18710
|
const getIssueProperties = (val) => {
|
|
18625
|
-
if (typeof
|
|
18626
|
-
return { message
|
|
18627
|
-
} else if (typeof
|
|
18628
|
-
return
|
|
18711
|
+
if (typeof message === "string" || typeof message === "undefined") {
|
|
18712
|
+
return { message };
|
|
18713
|
+
} else if (typeof message === "function") {
|
|
18714
|
+
return message(val);
|
|
18629
18715
|
} else {
|
|
18630
|
-
return
|
|
18716
|
+
return message;
|
|
18631
18717
|
}
|
|
18632
18718
|
};
|
|
18633
18719
|
return this._refinement((val, ctx) => {
|
|
@@ -19163,11 +19249,11 @@ class ZodString extends ZodType {
|
|
|
19163
19249
|
}
|
|
19164
19250
|
return { status: status.value, value: input.data };
|
|
19165
19251
|
}
|
|
19166
|
-
_regex(regex2, validation,
|
|
19252
|
+
_regex(regex2, validation, message) {
|
|
19167
19253
|
return this.refinement((data) => regex2.test(data), {
|
|
19168
19254
|
validation,
|
|
19169
19255
|
code: ZodIssueCode.invalid_string,
|
|
19170
|
-
...errorUtil.errToObj(
|
|
19256
|
+
...errorUtil.errToObj(message)
|
|
19171
19257
|
});
|
|
19172
19258
|
}
|
|
19173
19259
|
_addCheck(check) {
|
|
@@ -19176,37 +19262,37 @@ class ZodString extends ZodType {
|
|
|
19176
19262
|
checks: [...this._def.checks, check]
|
|
19177
19263
|
});
|
|
19178
19264
|
}
|
|
19179
|
-
email(
|
|
19180
|
-
return this._addCheck({ kind: "email", ...errorUtil.errToObj(
|
|
19265
|
+
email(message) {
|
|
19266
|
+
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
|
|
19181
19267
|
}
|
|
19182
|
-
url(
|
|
19183
|
-
return this._addCheck({ kind: "url", ...errorUtil.errToObj(
|
|
19268
|
+
url(message) {
|
|
19269
|
+
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
19184
19270
|
}
|
|
19185
|
-
emoji(
|
|
19186
|
-
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(
|
|
19271
|
+
emoji(message) {
|
|
19272
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
19187
19273
|
}
|
|
19188
|
-
uuid(
|
|
19189
|
-
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(
|
|
19274
|
+
uuid(message) {
|
|
19275
|
+
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
19190
19276
|
}
|
|
19191
|
-
nanoid(
|
|
19192
|
-
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(
|
|
19277
|
+
nanoid(message) {
|
|
19278
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
19193
19279
|
}
|
|
19194
|
-
cuid(
|
|
19195
|
-
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(
|
|
19280
|
+
cuid(message) {
|
|
19281
|
+
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
19196
19282
|
}
|
|
19197
|
-
cuid2(
|
|
19198
|
-
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(
|
|
19283
|
+
cuid2(message) {
|
|
19284
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
19199
19285
|
}
|
|
19200
|
-
ulid(
|
|
19201
|
-
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(
|
|
19286
|
+
ulid(message) {
|
|
19287
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
19202
19288
|
}
|
|
19203
|
-
base64(
|
|
19204
|
-
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(
|
|
19289
|
+
base64(message) {
|
|
19290
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
19205
19291
|
}
|
|
19206
|
-
base64url(
|
|
19292
|
+
base64url(message) {
|
|
19207
19293
|
return this._addCheck({
|
|
19208
19294
|
kind: "base64url",
|
|
19209
|
-
...errorUtil.errToObj(
|
|
19295
|
+
...errorUtil.errToObj(message)
|
|
19210
19296
|
});
|
|
19211
19297
|
}
|
|
19212
19298
|
jwt(options2) {
|
|
@@ -19236,8 +19322,8 @@ class ZodString extends ZodType {
|
|
|
19236
19322
|
...errorUtil.errToObj(options2?.message)
|
|
19237
19323
|
});
|
|
19238
19324
|
}
|
|
19239
|
-
date(
|
|
19240
|
-
return this._addCheck({ kind: "date", message
|
|
19325
|
+
date(message) {
|
|
19326
|
+
return this._addCheck({ kind: "date", message });
|
|
19241
19327
|
}
|
|
19242
19328
|
time(options2) {
|
|
19243
19329
|
if (typeof options2 === "string") {
|
|
@@ -19253,14 +19339,14 @@ class ZodString extends ZodType {
|
|
|
19253
19339
|
...errorUtil.errToObj(options2?.message)
|
|
19254
19340
|
});
|
|
19255
19341
|
}
|
|
19256
|
-
duration(
|
|
19257
|
-
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(
|
|
19342
|
+
duration(message) {
|
|
19343
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
19258
19344
|
}
|
|
19259
|
-
regex(regex2,
|
|
19345
|
+
regex(regex2, message) {
|
|
19260
19346
|
return this._addCheck({
|
|
19261
19347
|
kind: "regex",
|
|
19262
19348
|
regex: regex2,
|
|
19263
|
-
...errorUtil.errToObj(
|
|
19349
|
+
...errorUtil.errToObj(message)
|
|
19264
19350
|
});
|
|
19265
19351
|
}
|
|
19266
19352
|
includes(value, options2) {
|
|
@@ -19271,46 +19357,46 @@ class ZodString extends ZodType {
|
|
|
19271
19357
|
...errorUtil.errToObj(options2?.message)
|
|
19272
19358
|
});
|
|
19273
19359
|
}
|
|
19274
|
-
startsWith(value,
|
|
19360
|
+
startsWith(value, message) {
|
|
19275
19361
|
return this._addCheck({
|
|
19276
19362
|
kind: "startsWith",
|
|
19277
19363
|
value,
|
|
19278
|
-
...errorUtil.errToObj(
|
|
19364
|
+
...errorUtil.errToObj(message)
|
|
19279
19365
|
});
|
|
19280
19366
|
}
|
|
19281
|
-
endsWith(value,
|
|
19367
|
+
endsWith(value, message) {
|
|
19282
19368
|
return this._addCheck({
|
|
19283
19369
|
kind: "endsWith",
|
|
19284
19370
|
value,
|
|
19285
|
-
...errorUtil.errToObj(
|
|
19371
|
+
...errorUtil.errToObj(message)
|
|
19286
19372
|
});
|
|
19287
19373
|
}
|
|
19288
|
-
min(minLength,
|
|
19374
|
+
min(minLength, message) {
|
|
19289
19375
|
return this._addCheck({
|
|
19290
19376
|
kind: "min",
|
|
19291
19377
|
value: minLength,
|
|
19292
|
-
...errorUtil.errToObj(
|
|
19378
|
+
...errorUtil.errToObj(message)
|
|
19293
19379
|
});
|
|
19294
19380
|
}
|
|
19295
|
-
max(maxLength,
|
|
19381
|
+
max(maxLength, message) {
|
|
19296
19382
|
return this._addCheck({
|
|
19297
19383
|
kind: "max",
|
|
19298
19384
|
value: maxLength,
|
|
19299
|
-
...errorUtil.errToObj(
|
|
19385
|
+
...errorUtil.errToObj(message)
|
|
19300
19386
|
});
|
|
19301
19387
|
}
|
|
19302
|
-
length(len,
|
|
19388
|
+
length(len, message) {
|
|
19303
19389
|
return this._addCheck({
|
|
19304
19390
|
kind: "length",
|
|
19305
19391
|
value: len,
|
|
19306
|
-
...errorUtil.errToObj(
|
|
19392
|
+
...errorUtil.errToObj(message)
|
|
19307
19393
|
});
|
|
19308
19394
|
}
|
|
19309
19395
|
/**
|
|
19310
19396
|
* Equivalent to `.min(1)`
|
|
19311
19397
|
*/
|
|
19312
|
-
nonempty(
|
|
19313
|
-
return this.min(1, errorUtil.errToObj(
|
|
19398
|
+
nonempty(message) {
|
|
19399
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
19314
19400
|
}
|
|
19315
19401
|
trim() {
|
|
19316
19402
|
return new ZodString({
|
|
@@ -19503,19 +19589,19 @@ class ZodNumber extends ZodType {
|
|
|
19503
19589
|
}
|
|
19504
19590
|
return { status: status.value, value: input.data };
|
|
19505
19591
|
}
|
|
19506
|
-
gte(value,
|
|
19507
|
-
return this.setLimit("min", value, true, errorUtil.toString(
|
|
19592
|
+
gte(value, message) {
|
|
19593
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
19508
19594
|
}
|
|
19509
|
-
gt(value,
|
|
19510
|
-
return this.setLimit("min", value, false, errorUtil.toString(
|
|
19595
|
+
gt(value, message) {
|
|
19596
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
19511
19597
|
}
|
|
19512
|
-
lte(value,
|
|
19513
|
-
return this.setLimit("max", value, true, errorUtil.toString(
|
|
19598
|
+
lte(value, message) {
|
|
19599
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
19514
19600
|
}
|
|
19515
|
-
lt(value,
|
|
19516
|
-
return this.setLimit("max", value, false, errorUtil.toString(
|
|
19601
|
+
lt(value, message) {
|
|
19602
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
19517
19603
|
}
|
|
19518
|
-
setLimit(kind, value, inclusive,
|
|
19604
|
+
setLimit(kind, value, inclusive, message) {
|
|
19519
19605
|
return new ZodNumber({
|
|
19520
19606
|
...this._def,
|
|
19521
19607
|
checks: [
|
|
@@ -19524,7 +19610,7 @@ class ZodNumber extends ZodType {
|
|
|
19524
19610
|
kind,
|
|
19525
19611
|
value,
|
|
19526
19612
|
inclusive,
|
|
19527
|
-
message: errorUtil.toString(
|
|
19613
|
+
message: errorUtil.toString(message)
|
|
19528
19614
|
}
|
|
19529
19615
|
]
|
|
19530
19616
|
});
|
|
@@ -19535,68 +19621,68 @@ class ZodNumber extends ZodType {
|
|
|
19535
19621
|
checks: [...this._def.checks, check]
|
|
19536
19622
|
});
|
|
19537
19623
|
}
|
|
19538
|
-
int(
|
|
19624
|
+
int(message) {
|
|
19539
19625
|
return this._addCheck({
|
|
19540
19626
|
kind: "int",
|
|
19541
|
-
message: errorUtil.toString(
|
|
19627
|
+
message: errorUtil.toString(message)
|
|
19542
19628
|
});
|
|
19543
19629
|
}
|
|
19544
|
-
positive(
|
|
19630
|
+
positive(message) {
|
|
19545
19631
|
return this._addCheck({
|
|
19546
19632
|
kind: "min",
|
|
19547
19633
|
value: 0,
|
|
19548
19634
|
inclusive: false,
|
|
19549
|
-
message: errorUtil.toString(
|
|
19635
|
+
message: errorUtil.toString(message)
|
|
19550
19636
|
});
|
|
19551
19637
|
}
|
|
19552
|
-
negative(
|
|
19638
|
+
negative(message) {
|
|
19553
19639
|
return this._addCheck({
|
|
19554
19640
|
kind: "max",
|
|
19555
19641
|
value: 0,
|
|
19556
19642
|
inclusive: false,
|
|
19557
|
-
message: errorUtil.toString(
|
|
19643
|
+
message: errorUtil.toString(message)
|
|
19558
19644
|
});
|
|
19559
19645
|
}
|
|
19560
|
-
nonpositive(
|
|
19646
|
+
nonpositive(message) {
|
|
19561
19647
|
return this._addCheck({
|
|
19562
19648
|
kind: "max",
|
|
19563
19649
|
value: 0,
|
|
19564
19650
|
inclusive: true,
|
|
19565
|
-
message: errorUtil.toString(
|
|
19651
|
+
message: errorUtil.toString(message)
|
|
19566
19652
|
});
|
|
19567
19653
|
}
|
|
19568
|
-
nonnegative(
|
|
19654
|
+
nonnegative(message) {
|
|
19569
19655
|
return this._addCheck({
|
|
19570
19656
|
kind: "min",
|
|
19571
19657
|
value: 0,
|
|
19572
19658
|
inclusive: true,
|
|
19573
|
-
message: errorUtil.toString(
|
|
19659
|
+
message: errorUtil.toString(message)
|
|
19574
19660
|
});
|
|
19575
19661
|
}
|
|
19576
|
-
multipleOf(value,
|
|
19662
|
+
multipleOf(value, message) {
|
|
19577
19663
|
return this._addCheck({
|
|
19578
19664
|
kind: "multipleOf",
|
|
19579
19665
|
value,
|
|
19580
|
-
message: errorUtil.toString(
|
|
19666
|
+
message: errorUtil.toString(message)
|
|
19581
19667
|
});
|
|
19582
19668
|
}
|
|
19583
|
-
finite(
|
|
19669
|
+
finite(message) {
|
|
19584
19670
|
return this._addCheck({
|
|
19585
19671
|
kind: "finite",
|
|
19586
|
-
message: errorUtil.toString(
|
|
19672
|
+
message: errorUtil.toString(message)
|
|
19587
19673
|
});
|
|
19588
19674
|
}
|
|
19589
|
-
safe(
|
|
19675
|
+
safe(message) {
|
|
19590
19676
|
return this._addCheck({
|
|
19591
19677
|
kind: "min",
|
|
19592
19678
|
inclusive: true,
|
|
19593
19679
|
value: Number.MIN_SAFE_INTEGER,
|
|
19594
|
-
message: errorUtil.toString(
|
|
19680
|
+
message: errorUtil.toString(message)
|
|
19595
19681
|
})._addCheck({
|
|
19596
19682
|
kind: "max",
|
|
19597
19683
|
inclusive: true,
|
|
19598
19684
|
value: Number.MAX_SAFE_INTEGER,
|
|
19599
|
-
message: errorUtil.toString(
|
|
19685
|
+
message: errorUtil.toString(message)
|
|
19600
19686
|
});
|
|
19601
19687
|
}
|
|
19602
19688
|
get minValue() {
|
|
@@ -19719,19 +19805,19 @@ class ZodBigInt extends ZodType {
|
|
|
19719
19805
|
});
|
|
19720
19806
|
return INVALID;
|
|
19721
19807
|
}
|
|
19722
|
-
gte(value,
|
|
19723
|
-
return this.setLimit("min", value, true, errorUtil.toString(
|
|
19808
|
+
gte(value, message) {
|
|
19809
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
19724
19810
|
}
|
|
19725
|
-
gt(value,
|
|
19726
|
-
return this.setLimit("min", value, false, errorUtil.toString(
|
|
19811
|
+
gt(value, message) {
|
|
19812
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
19727
19813
|
}
|
|
19728
|
-
lte(value,
|
|
19729
|
-
return this.setLimit("max", value, true, errorUtil.toString(
|
|
19814
|
+
lte(value, message) {
|
|
19815
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
19730
19816
|
}
|
|
19731
|
-
lt(value,
|
|
19732
|
-
return this.setLimit("max", value, false, errorUtil.toString(
|
|
19817
|
+
lt(value, message) {
|
|
19818
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
19733
19819
|
}
|
|
19734
|
-
setLimit(kind, value, inclusive,
|
|
19820
|
+
setLimit(kind, value, inclusive, message) {
|
|
19735
19821
|
return new ZodBigInt({
|
|
19736
19822
|
...this._def,
|
|
19737
19823
|
checks: [
|
|
@@ -19740,7 +19826,7 @@ class ZodBigInt extends ZodType {
|
|
|
19740
19826
|
kind,
|
|
19741
19827
|
value,
|
|
19742
19828
|
inclusive,
|
|
19743
|
-
message: errorUtil.toString(
|
|
19829
|
+
message: errorUtil.toString(message)
|
|
19744
19830
|
}
|
|
19745
19831
|
]
|
|
19746
19832
|
});
|
|
@@ -19751,43 +19837,43 @@ class ZodBigInt extends ZodType {
|
|
|
19751
19837
|
checks: [...this._def.checks, check]
|
|
19752
19838
|
});
|
|
19753
19839
|
}
|
|
19754
|
-
positive(
|
|
19840
|
+
positive(message) {
|
|
19755
19841
|
return this._addCheck({
|
|
19756
19842
|
kind: "min",
|
|
19757
19843
|
value: BigInt(0),
|
|
19758
19844
|
inclusive: false,
|
|
19759
|
-
message: errorUtil.toString(
|
|
19845
|
+
message: errorUtil.toString(message)
|
|
19760
19846
|
});
|
|
19761
19847
|
}
|
|
19762
|
-
negative(
|
|
19848
|
+
negative(message) {
|
|
19763
19849
|
return this._addCheck({
|
|
19764
19850
|
kind: "max",
|
|
19765
19851
|
value: BigInt(0),
|
|
19766
19852
|
inclusive: false,
|
|
19767
|
-
message: errorUtil.toString(
|
|
19853
|
+
message: errorUtil.toString(message)
|
|
19768
19854
|
});
|
|
19769
19855
|
}
|
|
19770
|
-
nonpositive(
|
|
19856
|
+
nonpositive(message) {
|
|
19771
19857
|
return this._addCheck({
|
|
19772
19858
|
kind: "max",
|
|
19773
19859
|
value: BigInt(0),
|
|
19774
19860
|
inclusive: true,
|
|
19775
|
-
message: errorUtil.toString(
|
|
19861
|
+
message: errorUtil.toString(message)
|
|
19776
19862
|
});
|
|
19777
19863
|
}
|
|
19778
|
-
nonnegative(
|
|
19864
|
+
nonnegative(message) {
|
|
19779
19865
|
return this._addCheck({
|
|
19780
19866
|
kind: "min",
|
|
19781
19867
|
value: BigInt(0),
|
|
19782
19868
|
inclusive: true,
|
|
19783
|
-
message: errorUtil.toString(
|
|
19869
|
+
message: errorUtil.toString(message)
|
|
19784
19870
|
});
|
|
19785
19871
|
}
|
|
19786
|
-
multipleOf(value,
|
|
19872
|
+
multipleOf(value, message) {
|
|
19787
19873
|
return this._addCheck({
|
|
19788
19874
|
kind: "multipleOf",
|
|
19789
19875
|
value,
|
|
19790
|
-
message: errorUtil.toString(
|
|
19876
|
+
message: errorUtil.toString(message)
|
|
19791
19877
|
});
|
|
19792
19878
|
}
|
|
19793
19879
|
get minValue() {
|
|
@@ -19910,18 +19996,18 @@ class ZodDate extends ZodType {
|
|
|
19910
19996
|
checks: [...this._def.checks, check]
|
|
19911
19997
|
});
|
|
19912
19998
|
}
|
|
19913
|
-
min(minDate,
|
|
19999
|
+
min(minDate, message) {
|
|
19914
20000
|
return this._addCheck({
|
|
19915
20001
|
kind: "min",
|
|
19916
20002
|
value: minDate.getTime(),
|
|
19917
|
-
message: errorUtil.toString(
|
|
20003
|
+
message: errorUtil.toString(message)
|
|
19918
20004
|
});
|
|
19919
20005
|
}
|
|
19920
|
-
max(maxDate,
|
|
20006
|
+
max(maxDate, message) {
|
|
19921
20007
|
return this._addCheck({
|
|
19922
20008
|
kind: "max",
|
|
19923
20009
|
value: maxDate.getTime(),
|
|
19924
|
-
message: errorUtil.toString(
|
|
20010
|
+
message: errorUtil.toString(message)
|
|
19925
20011
|
});
|
|
19926
20012
|
}
|
|
19927
20013
|
get minDate() {
|
|
@@ -20153,26 +20239,26 @@ class ZodArray extends ZodType {
|
|
|
20153
20239
|
get element() {
|
|
20154
20240
|
return this._def.type;
|
|
20155
20241
|
}
|
|
20156
|
-
min(minLength,
|
|
20242
|
+
min(minLength, message) {
|
|
20157
20243
|
return new ZodArray({
|
|
20158
20244
|
...this._def,
|
|
20159
|
-
minLength: { value: minLength, message: errorUtil.toString(
|
|
20245
|
+
minLength: { value: minLength, message: errorUtil.toString(message) }
|
|
20160
20246
|
});
|
|
20161
20247
|
}
|
|
20162
|
-
max(maxLength,
|
|
20248
|
+
max(maxLength, message) {
|
|
20163
20249
|
return new ZodArray({
|
|
20164
20250
|
...this._def,
|
|
20165
|
-
maxLength: { value: maxLength, message: errorUtil.toString(
|
|
20251
|
+
maxLength: { value: maxLength, message: errorUtil.toString(message) }
|
|
20166
20252
|
});
|
|
20167
20253
|
}
|
|
20168
|
-
length(len,
|
|
20254
|
+
length(len, message) {
|
|
20169
20255
|
return new ZodArray({
|
|
20170
20256
|
...this._def,
|
|
20171
|
-
exactLength: { value: len, message: errorUtil.toString(
|
|
20257
|
+
exactLength: { value: len, message: errorUtil.toString(message) }
|
|
20172
20258
|
});
|
|
20173
20259
|
}
|
|
20174
|
-
nonempty(
|
|
20175
|
-
return this.min(1,
|
|
20260
|
+
nonempty(message) {
|
|
20261
|
+
return this.min(1, message);
|
|
20176
20262
|
}
|
|
20177
20263
|
}
|
|
20178
20264
|
ZodArray.create = (schema, params) => {
|
|
@@ -20315,17 +20401,17 @@ class ZodObject extends ZodType {
|
|
|
20315
20401
|
get shape() {
|
|
20316
20402
|
return this._def.shape();
|
|
20317
20403
|
}
|
|
20318
|
-
strict(
|
|
20404
|
+
strict(message) {
|
|
20319
20405
|
errorUtil.errToObj;
|
|
20320
20406
|
return new ZodObject({
|
|
20321
20407
|
...this._def,
|
|
20322
20408
|
unknownKeys: "strict",
|
|
20323
|
-
...
|
|
20409
|
+
...message !== void 0 ? {
|
|
20324
20410
|
errorMap: (issue, ctx) => {
|
|
20325
20411
|
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
20326
20412
|
if (issue.code === "unrecognized_keys")
|
|
20327
20413
|
return {
|
|
20328
|
-
message: errorUtil.errToObj(
|
|
20414
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
|
20329
20415
|
};
|
|
20330
20416
|
return {
|
|
20331
20417
|
message: defaultError
|
|
@@ -20921,23 +21007,23 @@ class ZodSet extends ZodType {
|
|
|
20921
21007
|
return finalizeSet(elements);
|
|
20922
21008
|
}
|
|
20923
21009
|
}
|
|
20924
|
-
min(minSize,
|
|
21010
|
+
min(minSize, message) {
|
|
20925
21011
|
return new ZodSet({
|
|
20926
21012
|
...this._def,
|
|
20927
|
-
minSize: { value: minSize, message: errorUtil.toString(
|
|
21013
|
+
minSize: { value: minSize, message: errorUtil.toString(message) }
|
|
20928
21014
|
});
|
|
20929
21015
|
}
|
|
20930
|
-
max(maxSize,
|
|
21016
|
+
max(maxSize, message) {
|
|
20931
21017
|
return new ZodSet({
|
|
20932
21018
|
...this._def,
|
|
20933
|
-
maxSize: { value: maxSize, message: errorUtil.toString(
|
|
21019
|
+
maxSize: { value: maxSize, message: errorUtil.toString(message) }
|
|
20934
21020
|
});
|
|
20935
21021
|
}
|
|
20936
|
-
size(size,
|
|
20937
|
-
return this.min(size,
|
|
21022
|
+
size(size, message) {
|
|
21023
|
+
return this.min(size, message).max(size, message);
|
|
20938
21024
|
}
|
|
20939
|
-
nonempty(
|
|
20940
|
-
return this.min(1,
|
|
21025
|
+
nonempty(message) {
|
|
21026
|
+
return this.min(1, message);
|
|
20941
21027
|
}
|
|
20942
21028
|
}
|
|
20943
21029
|
ZodSet.create = (valueType, params) => {
|
|
@@ -21552,26 +21638,53 @@ function createGoogleProvider(clientId) {
|
|
|
21552
21638
|
return {
|
|
21553
21639
|
id: "google",
|
|
21554
21640
|
schema: objectType({
|
|
21555
|
-
idToken: stringType().min(1,
|
|
21641
|
+
idToken: stringType().min(1).optional(),
|
|
21642
|
+
accessToken: stringType().min(1).optional()
|
|
21643
|
+
}).refine((data) => data.idToken || data.accessToken, {
|
|
21644
|
+
message: "Either idToken or accessToken is required"
|
|
21556
21645
|
}),
|
|
21557
21646
|
verify: async (payload) => {
|
|
21558
21647
|
try {
|
|
21559
|
-
|
|
21560
|
-
|
|
21561
|
-
|
|
21562
|
-
|
|
21563
|
-
|
|
21564
|
-
|
|
21565
|
-
|
|
21648
|
+
if (payload.idToken) {
|
|
21649
|
+
const ticket = await googleClient.verifyIdToken({
|
|
21650
|
+
idToken: payload.idToken,
|
|
21651
|
+
audience: clientId
|
|
21652
|
+
});
|
|
21653
|
+
const content = ticket.getPayload();
|
|
21654
|
+
if (!content) {
|
|
21655
|
+
return null;
|
|
21656
|
+
}
|
|
21657
|
+
return {
|
|
21658
|
+
providerId: content.sub,
|
|
21659
|
+
email: content.email || "",
|
|
21660
|
+
displayName: content.name || null,
|
|
21661
|
+
photoUrl: content.picture || null
|
|
21662
|
+
};
|
|
21566
21663
|
}
|
|
21567
|
-
|
|
21568
|
-
|
|
21569
|
-
|
|
21570
|
-
|
|
21571
|
-
|
|
21572
|
-
|
|
21664
|
+
if (payload.accessToken) {
|
|
21665
|
+
const res = await fetch("https://www.googleapis.com/oauth2/v3/userinfo", {
|
|
21666
|
+
headers: {
|
|
21667
|
+
Authorization: `Bearer ${payload.accessToken}`
|
|
21668
|
+
}
|
|
21669
|
+
});
|
|
21670
|
+
if (!res.ok) {
|
|
21671
|
+
console.error("Google userinfo request failed:", res.status);
|
|
21672
|
+
return null;
|
|
21673
|
+
}
|
|
21674
|
+
const info = await res.json();
|
|
21675
|
+
if (!info.sub || !info.email) {
|
|
21676
|
+
return null;
|
|
21677
|
+
}
|
|
21678
|
+
return {
|
|
21679
|
+
providerId: info.sub,
|
|
21680
|
+
email: info.email,
|
|
21681
|
+
displayName: info.name || null,
|
|
21682
|
+
photoUrl: info.picture || null
|
|
21683
|
+
};
|
|
21684
|
+
}
|
|
21685
|
+
return null;
|
|
21573
21686
|
} catch (error2) {
|
|
21574
|
-
console.error("Failed to verify Google
|
|
21687
|
+
console.error("Failed to verify Google token:", error2);
|
|
21575
21688
|
return null;
|
|
21576
21689
|
}
|
|
21577
21690
|
}
|
|
@@ -21764,1002 +21877,16 @@ function createMicrosoftProvider(config) {
|
|
|
21764
21877
|
}
|
|
21765
21878
|
};
|
|
21766
21879
|
}
|
|
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
21880
|
function createAppleProvider(config) {
|
|
22753
21881
|
async function generateClientSecret() {
|
|
22754
|
-
|
|
22755
|
-
|
|
22756
|
-
|
|
21882
|
+
return jwt.sign({}, config.privateKey, {
|
|
21883
|
+
algorithm: "ES256",
|
|
21884
|
+
keyid: config.keyId,
|
|
21885
|
+
issuer: config.teamId,
|
|
21886
|
+
expiresIn: "180d",
|
|
21887
|
+
audience: "https://appleid.apple.com",
|
|
21888
|
+
subject: config.clientId
|
|
22757
21889
|
});
|
|
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
21890
|
}
|
|
22764
21891
|
return {
|
|
22765
21892
|
id: "apple",
|
|
@@ -23567,7 +22694,7 @@ function createRateLimiter(options2 = {}) {
|
|
|
23567
22694
|
windowMs = 15 * 60 * 1e3,
|
|
23568
22695
|
limit = 100,
|
|
23569
22696
|
keyGenerator = defaultKeyGenerator,
|
|
23570
|
-
message
|
|
22697
|
+
message = "Too many requests, please try again later."
|
|
23571
22698
|
} = options2;
|
|
23572
22699
|
const store = /* @__PURE__ */ new Map();
|
|
23573
22700
|
const cleanupInterval = setInterval(() => {
|
|
@@ -23602,7 +22729,7 @@ function createRateLimiter(options2 = {}) {
|
|
|
23602
22729
|
c.header("X-RateLimit-Reset", String(Math.ceil((now + retryAfterMs) / 1e3)));
|
|
23603
22730
|
return c.json({
|
|
23604
22731
|
error: {
|
|
23605
|
-
message
|
|
22732
|
+
message,
|
|
23606
22733
|
code: "RATE_LIMITED"
|
|
23607
22734
|
}
|
|
23608
22735
|
}, 429);
|
|
@@ -23614,7 +22741,12 @@ function createRateLimiter(options2 = {}) {
|
|
|
23614
22741
|
};
|
|
23615
22742
|
}
|
|
23616
22743
|
function defaultKeyGenerator(c) {
|
|
23617
|
-
|
|
22744
|
+
const forwardedFor = c.req.header("x-forwarded-for");
|
|
22745
|
+
if (forwardedFor) {
|
|
22746
|
+
const ips = forwardedFor.split(",");
|
|
22747
|
+
return ips[ips.length - 1].trim();
|
|
22748
|
+
}
|
|
22749
|
+
return c.req.header("x-real-ip") || "unknown";
|
|
23618
22750
|
}
|
|
23619
22751
|
const defaultAuthLimiter = createRateLimiter({
|
|
23620
22752
|
windowMs: 15 * 60 * 1e3,
|
|
@@ -24182,8 +23314,45 @@ function createAdminRoutes(config) {
|
|
|
24182
23314
|
const authRepo = config.authRepo;
|
|
24183
23315
|
const {
|
|
24184
23316
|
emailService,
|
|
24185
|
-
emailConfig
|
|
23317
|
+
emailConfig,
|
|
23318
|
+
hooks
|
|
24186
23319
|
} = config;
|
|
23320
|
+
function buildHookContext(c, method) {
|
|
23321
|
+
const user = c.get("user");
|
|
23322
|
+
return {
|
|
23323
|
+
requestUser: user ? {
|
|
23324
|
+
userId: user.userId,
|
|
23325
|
+
roles: user.roles ?? []
|
|
23326
|
+
} : void 0,
|
|
23327
|
+
method
|
|
23328
|
+
};
|
|
23329
|
+
}
|
|
23330
|
+
async function applyUserAfterRead(user, ctx) {
|
|
23331
|
+
if (!hooks?.users?.afterRead) return user;
|
|
23332
|
+
return hooks.users.afterRead(user, ctx);
|
|
23333
|
+
}
|
|
23334
|
+
async function applyUserAfterReadBatch(users, ctx) {
|
|
23335
|
+
if (!hooks?.users?.afterRead) return users;
|
|
23336
|
+
const results = await Promise.all(users.map((u) => applyUserAfterRead(u, ctx)));
|
|
23337
|
+
return results.filter((u) => u !== null);
|
|
23338
|
+
}
|
|
23339
|
+
async function applyRoleAfterReadBatch(roles, ctx) {
|
|
23340
|
+
if (!hooks?.roles?.afterRead) return roles;
|
|
23341
|
+
const results = await Promise.all(roles.map((r) => hooks.roles.afterRead(r, ctx)));
|
|
23342
|
+
return results.filter((r) => r !== null);
|
|
23343
|
+
}
|
|
23344
|
+
function toAdminUser(u, roles) {
|
|
23345
|
+
return {
|
|
23346
|
+
uid: u.id,
|
|
23347
|
+
email: u.email,
|
|
23348
|
+
displayName: u.displayName ?? null,
|
|
23349
|
+
photoURL: u.photoUrl ?? null,
|
|
23350
|
+
provider: "custom",
|
|
23351
|
+
roles,
|
|
23352
|
+
createdAt: u.createdAt instanceof Date ? u.createdAt.toISOString() : u.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
23353
|
+
updatedAt: u.updatedAt instanceof Date ? u.updatedAt.toISOString() : u.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
23354
|
+
};
|
|
23355
|
+
}
|
|
24187
23356
|
router.onError(errorHandler);
|
|
24188
23357
|
router.use("/*", createRequireAuth({
|
|
24189
23358
|
serviceKey: config.serviceKey
|
|
@@ -24234,6 +23403,7 @@ function createAdminRoutes(config) {
|
|
|
24234
23403
|
const search = c.req.query("search");
|
|
24235
23404
|
const orderBy = c.req.query("orderBy");
|
|
24236
23405
|
const orderDir = c.req.query("orderDir");
|
|
23406
|
+
const hookCtx = buildHookContext(c, "GET");
|
|
24237
23407
|
if (limitParam !== void 0 || search) {
|
|
24238
23408
|
const limit = limitParam ? parseInt(limitParam, 10) : 25;
|
|
24239
23409
|
const offset = offsetParam ? parseInt(offsetParam, 10) : 0;
|
|
@@ -24245,18 +23415,11 @@ function createAdminRoutes(config) {
|
|
|
24245
23415
|
orderDir: orderDir || void 0,
|
|
24246
23416
|
roleId: c.req.query("role") || void 0
|
|
24247
23417
|
});
|
|
24248
|
-
|
|
23418
|
+
let usersWithRoles2 = await Promise.all(result.users.map(async (u) => {
|
|
24249
23419
|
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
|
-
};
|
|
23420
|
+
return toAdminUser(u, roles);
|
|
24259
23421
|
}));
|
|
23422
|
+
usersWithRoles2 = await applyUserAfterReadBatch(usersWithRoles2, hookCtx);
|
|
24260
23423
|
return c.json({
|
|
24261
23424
|
users: usersWithRoles2,
|
|
24262
23425
|
total: result.total,
|
|
@@ -24265,18 +23428,11 @@ function createAdminRoutes(config) {
|
|
|
24265
23428
|
});
|
|
24266
23429
|
}
|
|
24267
23430
|
const users = await authRepo.listUsers();
|
|
24268
|
-
|
|
23431
|
+
let usersWithRoles = await Promise.all(users.map(async (u) => {
|
|
24269
23432
|
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
|
-
};
|
|
23433
|
+
return toAdminUser(u, roles);
|
|
24279
23434
|
}));
|
|
23435
|
+
usersWithRoles = await applyUserAfterReadBatch(usersWithRoles, hookCtx);
|
|
24280
23436
|
return c.json({
|
|
24281
23437
|
users: usersWithRoles
|
|
24282
23438
|
});
|
|
@@ -24287,21 +23443,19 @@ function createAdminRoutes(config) {
|
|
|
24287
23443
|
if (!result) {
|
|
24288
23444
|
throw ApiError.notFound("User not found");
|
|
24289
23445
|
}
|
|
23446
|
+
const hookCtx = buildHookContext(c, "GET");
|
|
23447
|
+
let adminUser = toAdminUser(result.user, result.roles.map((r) => r.id));
|
|
23448
|
+
adminUser = await applyUserAfterRead(adminUser, hookCtx);
|
|
23449
|
+
if (!adminUser) {
|
|
23450
|
+
throw ApiError.notFound("User not found");
|
|
23451
|
+
}
|
|
24290
23452
|
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
|
-
}
|
|
23453
|
+
user: adminUser
|
|
24300
23454
|
});
|
|
24301
23455
|
});
|
|
24302
23456
|
router.post("/users", requireAdmin, async (c) => {
|
|
24303
23457
|
const body = await c.req.json();
|
|
24304
|
-
|
|
23458
|
+
let {
|
|
24305
23459
|
email,
|
|
24306
23460
|
displayName,
|
|
24307
23461
|
password,
|
|
@@ -24310,6 +23464,17 @@ function createAdminRoutes(config) {
|
|
|
24310
23464
|
if (!email) {
|
|
24311
23465
|
throw ApiError.badRequest("Email is required", "INVALID_INPUT");
|
|
24312
23466
|
}
|
|
23467
|
+
const hookCtx = buildHookContext(c, "POST");
|
|
23468
|
+
if (hooks?.users?.beforeSave) {
|
|
23469
|
+
const hooked = await hooks.users.beforeSave({
|
|
23470
|
+
email,
|
|
23471
|
+
displayName,
|
|
23472
|
+
roles
|
|
23473
|
+
}, hookCtx);
|
|
23474
|
+
email = hooked.email ?? email;
|
|
23475
|
+
displayName = hooked.displayName ?? displayName;
|
|
23476
|
+
roles = hooked.roles ?? roles;
|
|
23477
|
+
}
|
|
24313
23478
|
const existing = await authRepo.getUserByEmail(email);
|
|
24314
23479
|
if (existing) {
|
|
24315
23480
|
throw ApiError.conflict("Email already exists", "EMAIL_EXISTS");
|
|
@@ -24365,13 +23530,14 @@ function createAdminRoutes(config) {
|
|
|
24365
23530
|
} else if (!password) {
|
|
24366
23531
|
temporaryPassword = clearPassword;
|
|
24367
23532
|
}
|
|
23533
|
+
const createdAdminUser = toAdminUser(user, userRoles);
|
|
23534
|
+
if (hooks?.users?.afterSave) {
|
|
23535
|
+
Promise.resolve(hooks.users.afterSave(createdAdminUser, hookCtx)).catch((err) => {
|
|
23536
|
+
console.error("[BackendHooks] users.afterSave error:", err instanceof Error ? err.message : err);
|
|
23537
|
+
});
|
|
23538
|
+
}
|
|
24368
23539
|
return c.json({
|
|
24369
|
-
user:
|
|
24370
|
-
uid: user.id,
|
|
24371
|
-
email: user.email,
|
|
24372
|
-
displayName: user.displayName,
|
|
24373
|
-
roles: userRoles
|
|
24374
|
-
},
|
|
23540
|
+
user: createdAdminUser,
|
|
24375
23541
|
invitationSent,
|
|
24376
23542
|
...temporaryPassword ? {
|
|
24377
23543
|
temporaryPassword
|
|
@@ -24441,7 +23607,7 @@ function createAdminRoutes(config) {
|
|
|
24441
23607
|
router.put("/users/:userId", requireAdmin, async (c) => {
|
|
24442
23608
|
const userId = c.req.param("userId");
|
|
24443
23609
|
const body = await c.req.json();
|
|
24444
|
-
|
|
23610
|
+
let {
|
|
24445
23611
|
email,
|
|
24446
23612
|
displayName,
|
|
24447
23613
|
password,
|
|
@@ -24451,6 +23617,17 @@ function createAdminRoutes(config) {
|
|
|
24451
23617
|
if (!existing) {
|
|
24452
23618
|
throw ApiError.notFound("User not found");
|
|
24453
23619
|
}
|
|
23620
|
+
const hookCtx = buildHookContext(c, "PUT");
|
|
23621
|
+
if (hooks?.users?.beforeSave) {
|
|
23622
|
+
const hooked = await hooks.users.beforeSave({
|
|
23623
|
+
email,
|
|
23624
|
+
displayName,
|
|
23625
|
+
roles
|
|
23626
|
+
}, hookCtx);
|
|
23627
|
+
email = hooked.email ?? email;
|
|
23628
|
+
displayName = hooked.displayName ?? displayName;
|
|
23629
|
+
roles = hooked.roles ?? roles;
|
|
23630
|
+
}
|
|
24454
23631
|
const updates = {};
|
|
24455
23632
|
if (email !== void 0) updates.email = email.toLowerCase();
|
|
24456
23633
|
if (displayName !== void 0) updates.displayName = displayName;
|
|
@@ -24468,13 +23645,14 @@ function createAdminRoutes(config) {
|
|
|
24468
23645
|
await authRepo.setUserRoles(userId, roles);
|
|
24469
23646
|
}
|
|
24470
23647
|
const result = await authRepo.getUserWithRoles(userId);
|
|
23648
|
+
const updatedAdminUser = toAdminUser(result.user, result.roles.map((r) => r.id));
|
|
23649
|
+
if (hooks?.users?.afterSave) {
|
|
23650
|
+
Promise.resolve(hooks.users.afterSave(updatedAdminUser, hookCtx)).catch((err) => {
|
|
23651
|
+
console.error("[BackendHooks] users.afterSave error:", err instanceof Error ? err.message : err);
|
|
23652
|
+
});
|
|
23653
|
+
}
|
|
24471
23654
|
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
|
-
}
|
|
23655
|
+
user: updatedAdminUser
|
|
24478
23656
|
});
|
|
24479
23657
|
});
|
|
24480
23658
|
router.delete("/users/:userId", requireAdmin, async (c) => {
|
|
@@ -24488,21 +23666,33 @@ function createAdminRoutes(config) {
|
|
|
24488
23666
|
if (!existing) {
|
|
24489
23667
|
throw ApiError.notFound("User not found");
|
|
24490
23668
|
}
|
|
23669
|
+
const hookCtx = buildHookContext(c, "DELETE");
|
|
23670
|
+
if (hooks?.users?.beforeDelete) {
|
|
23671
|
+
await hooks.users.beforeDelete(userId, hookCtx);
|
|
23672
|
+
}
|
|
24491
23673
|
await authRepo.deleteUser(userId);
|
|
23674
|
+
if (hooks?.users?.afterDelete) {
|
|
23675
|
+
Promise.resolve(hooks.users.afterDelete(userId, hookCtx)).catch((err) => {
|
|
23676
|
+
console.error("[BackendHooks] users.afterDelete error:", err instanceof Error ? err.message : err);
|
|
23677
|
+
});
|
|
23678
|
+
}
|
|
24492
23679
|
return c.json({
|
|
24493
23680
|
success: true
|
|
24494
23681
|
});
|
|
24495
23682
|
});
|
|
24496
23683
|
router.get("/roles", requireAdmin, async (c) => {
|
|
24497
23684
|
const roles = await authRepo.listRoles();
|
|
23685
|
+
const hookCtx = buildHookContext(c, "GET");
|
|
23686
|
+
let adminRoles = roles.map((r) => ({
|
|
23687
|
+
id: r.id,
|
|
23688
|
+
name: r.name,
|
|
23689
|
+
isAdmin: r.isAdmin,
|
|
23690
|
+
defaultPermissions: r.defaultPermissions,
|
|
23691
|
+
config: r.config
|
|
23692
|
+
}));
|
|
23693
|
+
adminRoles = await applyRoleAfterReadBatch(adminRoles, hookCtx);
|
|
24498
23694
|
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
|
-
}))
|
|
23695
|
+
roles: adminRoles
|
|
24506
23696
|
});
|
|
24507
23697
|
});
|
|
24508
23698
|
router.get("/roles/:roleId", requireAdmin, async (c) => {
|
|
@@ -24630,10 +23820,10 @@ class LocalStorageController {
|
|
|
24630
23820
|
* Includes a path traversal guard to prevent escaping the base directory.
|
|
24631
23821
|
*/
|
|
24632
23822
|
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
|
|
23823
|
+
const bucketPath = bucket ? path$3.join(this.basePath, bucket) : this.basePath;
|
|
23824
|
+
const resolved = path$3.resolve(path$3.join(bucketPath, storagePath));
|
|
23825
|
+
if (!resolved.startsWith(bucketPath + path$3.sep) && resolved !== bucketPath) {
|
|
23826
|
+
throw new Error("Path traversal detected: resolved storage path is outside the bucket directory.");
|
|
24637
23827
|
}
|
|
24638
23828
|
return resolved;
|
|
24639
23829
|
}
|
|
@@ -24780,17 +23970,34 @@ class LocalStorageController {
|
|
|
24780
23970
|
}
|
|
24781
23971
|
}
|
|
24782
23972
|
resolvedPath = normalizeStoragePath(resolvedPath);
|
|
23973
|
+
if (!resolvedPath) {
|
|
23974
|
+
return;
|
|
23975
|
+
}
|
|
24783
23976
|
const fullPath = this.getFullPath(resolvedPath, resolvedBucket);
|
|
24784
23977
|
try {
|
|
24785
|
-
await
|
|
24786
|
-
|
|
24787
|
-
|
|
24788
|
-
|
|
23978
|
+
await access(fullPath, fs$4.constants.F_OK);
|
|
23979
|
+
} catch {
|
|
23980
|
+
return;
|
|
23981
|
+
}
|
|
23982
|
+
try {
|
|
23983
|
+
const stats = await stat(fullPath);
|
|
23984
|
+
if (stats.isDirectory()) {
|
|
23985
|
+
await fs$4.promises.rmdir(fullPath);
|
|
23986
|
+
} else {
|
|
23987
|
+
await unlink(fullPath);
|
|
23988
|
+
try {
|
|
23989
|
+
await unlink(`${fullPath}.metadata.json`);
|
|
23990
|
+
} catch {
|
|
23991
|
+
}
|
|
24789
23992
|
}
|
|
24790
23993
|
} catch (error2) {
|
|
24791
|
-
if (error2 instanceof Error
|
|
24792
|
-
|
|
23994
|
+
if (error2 instanceof Error) {
|
|
23995
|
+
const code2 = error2.code;
|
|
23996
|
+
if (code2 === "ENOENT" || code2 === "ENOTEMPTY") {
|
|
23997
|
+
return;
|
|
23998
|
+
}
|
|
24793
23999
|
}
|
|
24000
|
+
throw error2;
|
|
24794
24001
|
}
|
|
24795
24002
|
}
|
|
24796
24003
|
async listObjects(prefix, options2) {
|
|
@@ -24897,7 +24104,8 @@ class S3StorageController {
|
|
|
24897
24104
|
* Get the bucket name - either from parameter or config
|
|
24898
24105
|
*/
|
|
24899
24106
|
getBucket(bucket) {
|
|
24900
|
-
|
|
24107
|
+
if (!bucket || bucket === "default") return this.config.bucket;
|
|
24108
|
+
return bucket;
|
|
24901
24109
|
}
|
|
24902
24110
|
async putObject({
|
|
24903
24111
|
file,
|
|
@@ -25185,11 +24393,18 @@ function createStorageRoutes(config) {
|
|
|
25185
24393
|
const fileContent = fs$4.readFileSync(absolutePath);
|
|
25186
24394
|
return c.body(new Uint8Array(fileContent));
|
|
25187
24395
|
}
|
|
25188
|
-
const
|
|
25189
|
-
|
|
24396
|
+
const {
|
|
24397
|
+
bucket: parsedBucket,
|
|
24398
|
+
resolvedPath: parsedPath
|
|
24399
|
+
} = parseBucketAndPath(filePath);
|
|
24400
|
+
const fileObject = await controller.getObject(parsedPath, parsedBucket);
|
|
24401
|
+
if (!fileObject) {
|
|
25190
24402
|
throw ApiError.notFound("File not found");
|
|
25191
24403
|
}
|
|
25192
|
-
|
|
24404
|
+
c.header("Content-Type", fileObject.type || "application/octet-stream");
|
|
24405
|
+
c.header("Cache-Control", "public, max-age=3600, immutable");
|
|
24406
|
+
const buf = await fileObject.arrayBuffer();
|
|
24407
|
+
return c.body(new Uint8Array(buf));
|
|
25193
24408
|
});
|
|
25194
24409
|
router.get("/metadata/*", readAuthMiddleware, async (c) => {
|
|
25195
24410
|
const rawPath = extractWildcardPath(c);
|
|
@@ -25239,7 +24454,7 @@ function createStorageRoutes(config) {
|
|
|
25239
24454
|
const maxResults = c.req.query("maxResults");
|
|
25240
24455
|
const pageToken = c.req.query("pageToken");
|
|
25241
24456
|
const result = await controller.listObjects(storagePrefix, {
|
|
25242
|
-
bucket,
|
|
24457
|
+
bucket: bucket ?? (controller.getType() === "local" ? "default" : void 0),
|
|
25243
24458
|
maxResults: maxResults ? parseInt(maxResults, 10) : void 0,
|
|
25244
24459
|
pageToken
|
|
25245
24460
|
});
|
|
@@ -25248,6 +24463,40 @@ function createStorageRoutes(config) {
|
|
|
25248
24463
|
data: result
|
|
25249
24464
|
});
|
|
25250
24465
|
});
|
|
24466
|
+
router.post("/folder", writeAuthMiddleware, async (c) => {
|
|
24467
|
+
const body = await c.req.json();
|
|
24468
|
+
const folderPath = body.path;
|
|
24469
|
+
if (!folderPath || typeof folderPath !== "string") {
|
|
24470
|
+
throw ApiError.badRequest("Folder path is required");
|
|
24471
|
+
}
|
|
24472
|
+
const {
|
|
24473
|
+
bucket,
|
|
24474
|
+
resolvedPath
|
|
24475
|
+
} = parseBucketAndPath(folderPath);
|
|
24476
|
+
if (!resolvedPath || resolvedPath.trim() === "") {
|
|
24477
|
+
throw ApiError.badRequest("Invalid folder path");
|
|
24478
|
+
}
|
|
24479
|
+
if (controller.getType() === "local") {
|
|
24480
|
+
const localController = controller;
|
|
24481
|
+
const absolutePath = localController.getAbsolutePath(resolvedPath, bucket);
|
|
24482
|
+
fs$4.mkdirSync(absolutePath, {
|
|
24483
|
+
recursive: true
|
|
24484
|
+
});
|
|
24485
|
+
} else {
|
|
24486
|
+
const key = resolvedPath.endsWith("/") ? resolvedPath : resolvedPath + "/";
|
|
24487
|
+
const emptyFile = new File([], key, {
|
|
24488
|
+
type: "application/x-directory"
|
|
24489
|
+
});
|
|
24490
|
+
await controller.putObject({
|
|
24491
|
+
file: emptyFile,
|
|
24492
|
+
key
|
|
24493
|
+
});
|
|
24494
|
+
}
|
|
24495
|
+
return c.json({
|
|
24496
|
+
success: true,
|
|
24497
|
+
message: "Folder created"
|
|
24498
|
+
}, 201);
|
|
24499
|
+
});
|
|
25251
24500
|
return router;
|
|
25252
24501
|
}
|
|
25253
24502
|
const DEFAULT_STORAGE_ID = "(default)";
|
|
@@ -25371,8 +24620,8 @@ class RebaseApiError extends Error {
|
|
|
25371
24620
|
status;
|
|
25372
24621
|
code;
|
|
25373
24622
|
details;
|
|
25374
|
-
constructor(status,
|
|
25375
|
-
super(
|
|
24623
|
+
constructor(status, message, code2, details) {
|
|
24624
|
+
super(message);
|
|
25376
24625
|
this.name = "RebaseApiError";
|
|
25377
24626
|
this.status = status;
|
|
25378
24627
|
this.code = code2;
|
|
@@ -26343,6 +25592,18 @@ function createCollectionClient(transport, slug, ws) {
|
|
|
26343
25592
|
method: "DELETE"
|
|
26344
25593
|
});
|
|
26345
25594
|
},
|
|
25595
|
+
async count(params) {
|
|
25596
|
+
const countParams = {
|
|
25597
|
+
...params,
|
|
25598
|
+
limit: void 0,
|
|
25599
|
+
offset: void 0
|
|
25600
|
+
};
|
|
25601
|
+
const qs = buildQueryString(countParams);
|
|
25602
|
+
const raw = await transport.request(basePath + "/count" + qs, {
|
|
25603
|
+
method: "GET"
|
|
25604
|
+
});
|
|
25605
|
+
return raw.count ?? 0;
|
|
25606
|
+
},
|
|
26346
25607
|
// Fluent builder instantiation
|
|
26347
25608
|
where(column, operator, value) {
|
|
26348
25609
|
return new QueryBuilder(client).where(column, operator, value);
|
|
@@ -27349,7 +26610,7 @@ var fetchExports = fetch$1.exports;
|
|
|
27349
26610
|
});
|
|
27350
26611
|
return options2;
|
|
27351
26612
|
};
|
|
27352
|
-
module.exports._logFunc = (logger2, level, defaults, data,
|
|
26613
|
+
module.exports._logFunc = (logger2, level, defaults, data, message, ...args) => {
|
|
27353
26614
|
let entry = {};
|
|
27354
26615
|
Object.keys(defaults || {}).forEach((key) => {
|
|
27355
26616
|
if (key !== "level") {
|
|
@@ -27361,7 +26622,7 @@ var fetchExports = fetch$1.exports;
|
|
|
27361
26622
|
entry[key] = data[key];
|
|
27362
26623
|
}
|
|
27363
26624
|
});
|
|
27364
|
-
logger2[level](entry,
|
|
26625
|
+
logger2[level](entry, message, ...args);
|
|
27365
26626
|
};
|
|
27366
26627
|
module.exports.getLogger = (options2, defaults) => {
|
|
27367
26628
|
options2 = options2 || {};
|
|
@@ -27378,8 +26639,8 @@ var fetchExports = fetch$1.exports;
|
|
|
27378
26639
|
logger2 = createDefaultLogger(levels);
|
|
27379
26640
|
}
|
|
27380
26641
|
levels.forEach((level) => {
|
|
27381
|
-
response[level] = (data,
|
|
27382
|
-
module.exports._logFunc(logger2, level, defaults, data,
|
|
26642
|
+
response[level] = (data, message, ...args) => {
|
|
26643
|
+
module.exports._logFunc(logger2, level, defaults, data, message, ...args);
|
|
27383
26644
|
};
|
|
27384
26645
|
});
|
|
27385
26646
|
return response;
|
|
@@ -27562,7 +26823,7 @@ var fetchExports = fetch$1.exports;
|
|
|
27562
26823
|
}
|
|
27563
26824
|
levelNames.set(level, levelName);
|
|
27564
26825
|
});
|
|
27565
|
-
let print2 = (level, entry,
|
|
26826
|
+
let print2 = (level, entry, message, ...args) => {
|
|
27566
26827
|
let prefix = "";
|
|
27567
26828
|
if (entry) {
|
|
27568
26829
|
if (entry.tnx === "server") {
|
|
@@ -27577,8 +26838,8 @@ var fetchExports = fetch$1.exports;
|
|
|
27577
26838
|
prefix = "[#" + entry.cid + "] " + prefix;
|
|
27578
26839
|
}
|
|
27579
26840
|
}
|
|
27580
|
-
|
|
27581
|
-
|
|
26841
|
+
message = util2.format(message, ...args);
|
|
26842
|
+
message.split(/\r?\n/).forEach((line) => {
|
|
27582
26843
|
console.log("[%s] %s %s", (/* @__PURE__ */ new Date()).toISOString().substr(0, 19).replace(/T/, " "), levelNames.get(level), prefix + line);
|
|
27583
26844
|
});
|
|
27584
26845
|
};
|
|
@@ -34074,8 +33335,8 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34074
33335
|
* @param {Object} message String, Buffer or a Stream
|
|
34075
33336
|
* @param {Function} callback Callback to return once sending is completed
|
|
34076
33337
|
*/
|
|
34077
|
-
send(envelope,
|
|
34078
|
-
if (!
|
|
33338
|
+
send(envelope, message, done) {
|
|
33339
|
+
if (!message) {
|
|
34079
33340
|
return done(this._formatError("Empty message", "EMESSAGE", false, "API"));
|
|
34080
33341
|
}
|
|
34081
33342
|
const isDestroyedMessage = this._isDestroyedMessage("send message");
|
|
@@ -34095,17 +33356,17 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34095
33356
|
returned = true;
|
|
34096
33357
|
done(...arguments);
|
|
34097
33358
|
};
|
|
34098
|
-
if (typeof
|
|
34099
|
-
|
|
33359
|
+
if (typeof message.on === "function") {
|
|
33360
|
+
message.on("error", (err) => callback(this._formatError(err, "ESTREAM", false, "API")));
|
|
34100
33361
|
}
|
|
34101
33362
|
let startTime = Date.now();
|
|
34102
33363
|
this._setEnvelope(envelope, (err, info) => {
|
|
34103
33364
|
if (err) {
|
|
34104
33365
|
let stream3 = new PassThrough();
|
|
34105
|
-
if (typeof
|
|
34106
|
-
|
|
33366
|
+
if (typeof message.pipe === "function") {
|
|
33367
|
+
message.pipe(stream3);
|
|
34107
33368
|
} else {
|
|
34108
|
-
stream3.write(
|
|
33369
|
+
stream3.write(message);
|
|
34109
33370
|
stream3.end();
|
|
34110
33371
|
}
|
|
34111
33372
|
return callback(err);
|
|
@@ -34121,10 +33382,10 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34121
33382
|
info.response = str;
|
|
34122
33383
|
return callback(null, info);
|
|
34123
33384
|
});
|
|
34124
|
-
if (typeof
|
|
34125
|
-
|
|
33385
|
+
if (typeof message.pipe === "function") {
|
|
33386
|
+
message.pipe(stream2);
|
|
34126
33387
|
} else {
|
|
34127
|
-
stream2.write(
|
|
33388
|
+
stream2.write(message);
|
|
34128
33389
|
stream2.end();
|
|
34129
33390
|
}
|
|
34130
33391
|
});
|
|
@@ -34237,12 +33498,12 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34237
33498
|
this.emit("error", err);
|
|
34238
33499
|
this.close();
|
|
34239
33500
|
}
|
|
34240
|
-
_formatError(
|
|
33501
|
+
_formatError(message, type, response, command) {
|
|
34241
33502
|
let err;
|
|
34242
|
-
if (/Error\]$/i.test(Object.prototype.toString.call(
|
|
34243
|
-
err =
|
|
33503
|
+
if (/Error\]$/i.test(Object.prototype.toString.call(message))) {
|
|
33504
|
+
err = message;
|
|
34244
33505
|
} else {
|
|
34245
|
-
err = new Error(
|
|
33506
|
+
err = new Error(message);
|
|
34246
33507
|
}
|
|
34247
33508
|
if (type && type !== "Error") {
|
|
34248
33509
|
err.code = type;
|
|
@@ -34885,14 +34146,14 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34885
34146
|
* @param {String} str Message from the server
|
|
34886
34147
|
*/
|
|
34887
34148
|
_actionMAIL(str, callback) {
|
|
34888
|
-
let
|
|
34149
|
+
let message, curRecipient;
|
|
34889
34150
|
if (Number(str.charAt(0)) !== 2) {
|
|
34890
34151
|
if (this._usingSmtpUtf8 && /^550 /.test(str) && /[\x80-\uFFFF]/.test(this._envelope.from)) {
|
|
34891
|
-
|
|
34152
|
+
message = "Internationalized mailbox name not allowed";
|
|
34892
34153
|
} else {
|
|
34893
|
-
|
|
34154
|
+
message = "Mail command failed";
|
|
34894
34155
|
}
|
|
34895
|
-
return callback(this._formatError(
|
|
34156
|
+
return callback(this._formatError(message, "EENVELOPE", str, "MAIL FROM"));
|
|
34896
34157
|
}
|
|
34897
34158
|
if (!this._envelope.rcptQueue.length) {
|
|
34898
34159
|
return callback(this._formatError("Can't send mail - no recipients defined", "EENVELOPE", false, "API"));
|
|
@@ -34923,15 +34184,15 @@ let SMTPConnection$3 = class SMTPConnection extends EventEmitter$4 {
|
|
|
34923
34184
|
* @param {String} str Message from the server
|
|
34924
34185
|
*/
|
|
34925
34186
|
_actionRCPT(str, callback) {
|
|
34926
|
-
let
|
|
34187
|
+
let message, err, curRecipient = this._recipientQueue.shift();
|
|
34927
34188
|
if (Number(str.charAt(0)) !== 2) {
|
|
34928
34189
|
if (this._usingSmtpUtf8 && /^553 /.test(str) && /[\x80-\uFFFF]/.test(curRecipient)) {
|
|
34929
|
-
|
|
34190
|
+
message = "Internationalized mailbox name not allowed";
|
|
34930
34191
|
} else {
|
|
34931
|
-
|
|
34192
|
+
message = "Recipient command failed";
|
|
34932
34193
|
}
|
|
34933
34194
|
this._envelope.rejected.push(curRecipient);
|
|
34934
|
-
err = this._formatError(
|
|
34195
|
+
err = this._formatError(message, "EENVELOPE", str, "RCPT TO");
|
|
34935
34196
|
err.recipient = curRecipient;
|
|
34936
34197
|
this._envelope.rejectedErrors.push(err);
|
|
34937
34198
|
} else {
|
|
@@ -37647,9 +36908,9 @@ class SMTPEmailService {
|
|
|
37647
36908
|
replyTo: options2.replyTo
|
|
37648
36909
|
});
|
|
37649
36910
|
} catch (error2) {
|
|
37650
|
-
const
|
|
37651
|
-
console.error("Failed to send email:",
|
|
37652
|
-
throw new Error(`Failed to send email: ${
|
|
36911
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
36912
|
+
console.error("Failed to send email:", message);
|
|
36913
|
+
throw new Error(`Failed to send email: ${message}`);
|
|
37653
36914
|
}
|
|
37654
36915
|
}
|
|
37655
36916
|
/**
|
|
@@ -37663,8 +36924,8 @@ class SMTPEmailService {
|
|
|
37663
36924
|
await this.transporter.verify();
|
|
37664
36925
|
return true;
|
|
37665
36926
|
} catch (error2) {
|
|
37666
|
-
const
|
|
37667
|
-
console.error("SMTP connection verification failed:",
|
|
36927
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
36928
|
+
console.error("SMTP connection verification failed:", message);
|
|
37668
36929
|
return false;
|
|
37669
36930
|
}
|
|
37670
36931
|
}
|
|
@@ -37944,7 +37205,8 @@ async function _initializeRebaseBackend(config) {
|
|
|
37944
37205
|
authRepo: authConfigResult.authRepository ?? authConfigResult.userService,
|
|
37945
37206
|
emailService: authConfigResult.emailService,
|
|
37946
37207
|
emailConfig: config.auth.email,
|
|
37947
|
-
serviceKey
|
|
37208
|
+
serviceKey,
|
|
37209
|
+
hooks: config.hooks
|
|
37948
37210
|
});
|
|
37949
37211
|
config.app.route(`${basePath}/admin`, adminRoutes);
|
|
37950
37212
|
}
|
|
@@ -38002,7 +37264,7 @@ async function _initializeRebaseBackend(config) {
|
|
|
38002
37264
|
});
|
|
38003
37265
|
dataRouter.route("/", historyRoutes);
|
|
38004
37266
|
}
|
|
38005
|
-
const restGenerator = new RestApiGenerator(activeCollections, defaultDriver);
|
|
37267
|
+
const restGenerator = new RestApiGenerator(activeCollections, defaultDriver, config.hooks?.data);
|
|
38006
37268
|
dataRouter.route("/", restGenerator.generateRoutes());
|
|
38007
37269
|
config.app.route(`${basePath}/data`, dataRouter);
|
|
38008
37270
|
}
|
|
@@ -38196,10 +37458,10 @@ async function _initializeRebaseBackend(config) {
|
|
|
38196
37458
|
shutdown
|
|
38197
37459
|
};
|
|
38198
37460
|
}
|
|
38199
|
-
function devAssert(condition,
|
|
37461
|
+
function devAssert(condition, message) {
|
|
38200
37462
|
const booleanCondition = Boolean(condition);
|
|
38201
37463
|
if (!booleanCondition) {
|
|
38202
|
-
throw new Error(
|
|
37464
|
+
throw new Error(message);
|
|
38203
37465
|
}
|
|
38204
37466
|
}
|
|
38205
37467
|
function isPromise(value) {
|
|
@@ -38208,11 +37470,11 @@ function isPromise(value) {
|
|
|
38208
37470
|
function isObjectLike(value) {
|
|
38209
37471
|
return typeof value == "object" && value !== null;
|
|
38210
37472
|
}
|
|
38211
|
-
function invariant(condition,
|
|
37473
|
+
function invariant(condition, message) {
|
|
38212
37474
|
const booleanCondition = Boolean(condition);
|
|
38213
37475
|
if (!booleanCondition) {
|
|
38214
37476
|
throw new Error(
|
|
38215
|
-
|
|
37477
|
+
message != null ? message : "Unexpected invariant triggered."
|
|
38216
37478
|
);
|
|
38217
37479
|
}
|
|
38218
37480
|
}
|
|
@@ -38331,10 +37593,10 @@ class GraphQLError extends Error {
|
|
|
38331
37593
|
/**
|
|
38332
37594
|
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
38333
37595
|
*/
|
|
38334
|
-
constructor(
|
|
37596
|
+
constructor(message, ...rawArgs) {
|
|
38335
37597
|
var _this$nodes, _nodeLocations$, _ref;
|
|
38336
37598
|
const { nodes, source, positions, path: path2, originalError, extensions: extensions2 } = toNormalizedOptions(rawArgs);
|
|
38337
|
-
super(
|
|
37599
|
+
super(message);
|
|
38338
37600
|
this.name = "GraphQLError";
|
|
38339
37601
|
this.path = path2 !== null && path2 !== void 0 ? path2 : void 0;
|
|
38340
37602
|
this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
|
|
@@ -39352,14 +38614,14 @@ function formatArray(array, seenValues) {
|
|
|
39352
38614
|
return "[" + items.join(", ") + "]";
|
|
39353
38615
|
}
|
|
39354
38616
|
function getObjectTag(object) {
|
|
39355
|
-
const
|
|
39356
|
-
if (
|
|
38617
|
+
const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
|
|
38618
|
+
if (tag === "Object" && typeof object.constructor === "function") {
|
|
39357
38619
|
const name2 = object.constructor.name;
|
|
39358
38620
|
if (typeof name2 === "string" && name2 !== "") {
|
|
39359
38621
|
return name2;
|
|
39360
38622
|
}
|
|
39361
38623
|
}
|
|
39362
|
-
return
|
|
38624
|
+
return tag;
|
|
39363
38625
|
}
|
|
39364
38626
|
const isProduction = globalThis.process && // eslint-disable-next-line no-undef
|
|
39365
38627
|
process.env.NODE_ENV === "production";
|
|
@@ -40757,22 +40019,22 @@ function getTokenKindDesc(kind) {
|
|
|
40757
40019
|
const MAX_SUGGESTIONS = 5;
|
|
40758
40020
|
function didYouMean(firstArg, secondArg) {
|
|
40759
40021
|
const [subMessage, suggestionsArg] = secondArg ? [firstArg, secondArg] : [void 0, firstArg];
|
|
40760
|
-
let
|
|
40022
|
+
let message = " Did you mean ";
|
|
40761
40023
|
if (subMessage) {
|
|
40762
|
-
|
|
40024
|
+
message += subMessage + " ";
|
|
40763
40025
|
}
|
|
40764
40026
|
const suggestions = suggestionsArg.map((x) => `"${x}"`);
|
|
40765
40027
|
switch (suggestions.length) {
|
|
40766
40028
|
case 0:
|
|
40767
40029
|
return "";
|
|
40768
40030
|
case 1:
|
|
40769
|
-
return
|
|
40031
|
+
return message + suggestions[0] + "?";
|
|
40770
40032
|
case 2:
|
|
40771
|
-
return
|
|
40033
|
+
return message + suggestions[0] + " or " + suggestions[1] + "?";
|
|
40772
40034
|
}
|
|
40773
40035
|
const selected = suggestions.slice(0, MAX_SUGGESTIONS);
|
|
40774
40036
|
const lastItem = selected.pop();
|
|
40775
|
-
return
|
|
40037
|
+
return message + selected.join(", ") + ", or " + lastItem + "?";
|
|
40776
40038
|
}
|
|
40777
40039
|
function identityFunc(x) {
|
|
40778
40040
|
return x;
|
|
@@ -43416,10 +42678,10 @@ class SchemaValidationContext {
|
|
|
43416
42678
|
this._errors = [];
|
|
43417
42679
|
this.schema = schema;
|
|
43418
42680
|
}
|
|
43419
|
-
reportError(
|
|
42681
|
+
reportError(message, nodes) {
|
|
43420
42682
|
const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
|
|
43421
42683
|
this._errors.push(
|
|
43422
|
-
new GraphQLError(
|
|
42684
|
+
new GraphQLError(message, {
|
|
43423
42685
|
nodes: _nodes
|
|
43424
42686
|
})
|
|
43425
42687
|
);
|
|
@@ -47794,9 +47056,9 @@ var errorMessages = (messages, graphqlErrors) => {
|
|
|
47794
47056
|
};
|
|
47795
47057
|
}
|
|
47796
47058
|
return {
|
|
47797
|
-
errors: messages.map((
|
|
47059
|
+
errors: messages.map((message) => {
|
|
47798
47060
|
return {
|
|
47799
|
-
message
|
|
47061
|
+
message
|
|
47800
47062
|
};
|
|
47801
47063
|
})
|
|
47802
47064
|
};
|
|
@@ -49020,9 +48282,9 @@ class RebaseApiServer {
|
|
|
49020
48282
|
if (process.env.NODE_ENV === "production") {
|
|
49021
48283
|
console.warn("[RebaseApiServer] Schema Editor is disabled in production environments for security.");
|
|
49022
48284
|
} else {
|
|
48285
|
+
this.router.use(`${basePath}/schema-editor/*`, requireAuth, requireAdmin);
|
|
49023
48286
|
const schemaEditorRoutes2 = createSchemaEditorRoutes(this.config.collectionsDir);
|
|
49024
48287
|
this.router.route(`${basePath}/schema-editor`, schemaEditorRoutes2);
|
|
49025
|
-
this.router.use(`${basePath}/schema-editor/*`, requireAuth, requireAdmin);
|
|
49026
48288
|
}
|
|
49027
48289
|
}
|
|
49028
48290
|
this.router.get(`${basePath}/docs`, (c) => {
|
|
@@ -49136,8 +48398,8 @@ async function loadFunctionsFromDirectory(directory) {
|
|
|
49136
48398
|
Hint: ensure the function exports a Hono app created with the same hono version as the server.
|
|
49137
48399
|
The loader checks for .fetch() and .routes — any Hono-compatible app will work.`);
|
|
49138
48400
|
} catch (err) {
|
|
49139
|
-
const
|
|
49140
|
-
console.error(`[functions] Failed to load ${file}: ${
|
|
48401
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
48402
|
+
console.error(`[functions] Failed to load ${file}: ${message}`);
|
|
49141
48403
|
}
|
|
49142
48404
|
}
|
|
49143
48405
|
}
|
|
@@ -49209,8 +48471,8 @@ async function loadCronJobsFromDirectory(directory) {
|
|
|
49209
48471
|
});
|
|
49210
48472
|
console.log(`⏰ Loaded cron job: ${id} (${definition.schedule})`);
|
|
49211
48473
|
} catch (err) {
|
|
49212
|
-
const
|
|
49213
|
-
console.error(`[cron] Failed to load ${file}: ${
|
|
48474
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
48475
|
+
console.error(`[cron] Failed to load ${file}: ${message}`);
|
|
49214
48476
|
}
|
|
49215
48477
|
}
|
|
49216
48478
|
}
|
|
@@ -49320,9 +48582,9 @@ function parseCronExpression(expression, after) {
|
|
|
49320
48582
|
const month = candidate.getMonth() + 1;
|
|
49321
48583
|
const dom = candidate.getDate();
|
|
49322
48584
|
const dow = candidate.getDay();
|
|
49323
|
-
const
|
|
49324
|
-
const
|
|
49325
|
-
if (months.includes(month) && doms.includes(dom) && dows.includes(dow) && hours.includes(
|
|
48585
|
+
const hour = candidate.getHours();
|
|
48586
|
+
const minute = candidate.getMinutes();
|
|
48587
|
+
if (months.includes(month) && doms.includes(dom) && dows.includes(dow) && hours.includes(hour) && minutes.includes(minute)) {
|
|
49326
48588
|
return candidate;
|
|
49327
48589
|
}
|
|
49328
48590
|
candidate.setMinutes(candidate.getMinutes() + 1);
|