@rocicorp/zero 1.12.0-canary.12 → 1.12.0-canary.13
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/out/replicache/src/btree/diff.d.ts.map +1 -1
- package/out/replicache/src/btree/diff.js +1 -2
- package/out/replicache/src/btree/diff.js.map +1 -1
- package/out/replicache/src/btree/read.d.ts +31 -1
- package/out/replicache/src/btree/read.d.ts.map +1 -1
- package/out/replicache/src/btree/read.js +74 -19
- package/out/replicache/src/btree/read.js.map +1 -1
- package/out/replicache/src/btree/splice.d.ts.map +1 -1
- package/out/replicache/src/btree/splice.js +2 -1
- package/out/replicache/src/btree/splice.js.map +1 -1
- package/out/replicache/src/btree/write.d.ts.map +1 -1
- package/out/replicache/src/btree/write.js +2 -1
- package/out/replicache/src/btree/write.js.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.d.ts +1 -0
- package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.js +13 -5
- package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
- package/out/replicache/src/scan-iterator.js +1 -1
- package/out/replicache/src/sync/request-id.js +2 -2
- package/out/replicache/src/sync/request-id.js.map +1 -1
- package/out/shared/src/bigint-json.d.ts.map +1 -1
- package/out/shared/src/bigint-json.js +1 -0
- package/out/shared/src/bigint-json.js.map +1 -1
- package/out/shared/src/btree-set.d.ts +21 -0
- package/out/shared/src/btree-set.d.ts.map +1 -1
- package/out/shared/src/btree-set.js +54 -0
- package/out/shared/src/btree-set.js.map +1 -1
- package/out/shared/src/headers.js +20 -0
- package/out/shared/src/headers.js.map +1 -0
- package/out/shared/src/natural-runs.d.ts +191 -0
- package/out/shared/src/natural-runs.d.ts.map +1 -0
- package/out/shared/src/natural-runs.js +337 -0
- package/out/shared/src/natural-runs.js.map +1 -0
- package/out/shared/src/random-uint64.d.ts.map +1 -1
- package/out/shared/src/random-uint64.js +2 -2
- package/out/shared/src/random-uint64.js.map +1 -1
- package/out/shared/src/random-values.d.ts +19 -1
- package/out/shared/src/random-values.d.ts.map +1 -1
- package/out/shared/src/random-values.js +38 -4
- package/out/shared/src/random-values.js.map +1 -1
- package/out/shared/src/tuple-map.d.ts +22 -0
- package/out/shared/src/tuple-map.d.ts.map +1 -0
- package/out/shared/src/tuple-map.js +48 -0
- package/out/shared/src/tuple-map.js.map +1 -0
- package/out/zero/package.js +1 -1
- package/out/zero/package.js.map +1 -1
- package/out/zero-cache/src/auth/auth.d.ts.map +1 -1
- package/out/zero-cache/src/auth/auth.js +5 -0
- package/out/zero-cache/src/auth/auth.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +21 -0
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +47 -9
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/custom-queries/transform-query.js +2 -2
- package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.d.ts.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.js +3 -2
- package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
- package/out/zero-cache/src/db/pg-type-parser.js +55 -2
- package/out/zero-cache/src/db/pg-type-parser.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +5 -2
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.js +6 -29
- package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
- package/out/zero-cache/src/server/main.js +5 -0
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/replicator.js +3 -2
- package/out/zero-cache/src/server/replicator.js.map +1 -1
- package/out/zero-cache/src/server/syncer.js +5 -4
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/server/worker-dispatcher.d.ts.map +1 -1
- package/out/zero-cache/src/server/worker-dispatcher.js +2 -1
- package/out/zero-cache/src/server/worker-dispatcher.js.map +1 -1
- package/out/zero-cache/src/services/admin-auth.d.ts +22 -0
- package/out/zero-cache/src/services/admin-auth.d.ts.map +1 -0
- package/out/zero-cache/src/services/admin-auth.js +42 -0
- package/out/zero-cache/src/services/admin-auth.js.map +1 -0
- package/out/zero-cache/src/services/auth-attempt-counter.d.ts +33 -0
- package/out/zero-cache/src/services/auth-attempt-counter.d.ts.map +1 -0
- package/out/zero-cache/src/services/auth-attempt-counter.js +61 -0
- package/out/zero-cache/src/services/auth-attempt-counter.js.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/backfill-stream.js +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js +110 -13
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +13 -7
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +38 -5
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +10 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +4 -0
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +10 -3
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +23 -2
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +2 -2
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer.js +10 -3
- package/out/zero-cache/src/services/change-streamer/change-streamer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
- package/out/zero-cache/src/services/heapz.d.ts.map +1 -1
- package/out/zero-cache/src/services/heapz.js +4 -5
- package/out/zero-cache/src/services/heapz.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/error.d.ts +5 -0
- package/out/zero-cache/src/services/mutagen/error.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/error.js +7 -1
- package/out/zero-cache/src/services/mutagen/error.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/plannerz.d.ts.map +1 -1
- package/out/zero-cache/src/services/plannerz.js +3 -7
- package/out/zero-cache/src/services/plannerz.js.map +1 -1
- package/out/zero-cache/src/services/profz.d.ts.map +1 -1
- package/out/zero-cache/src/services/profz.js +4 -13
- package/out/zero-cache/src/services/profz.js.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.js +29 -2
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js +3 -3
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/statz.d.ts.map +1 -1
- package/out/zero-cache/src/services/statz.js +2 -7
- package/out/zero-cache/src/services/statz.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js +22 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.js +40 -2
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js +54 -17
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +11 -0
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/inspect-auth-limiter.js +107 -0
- package/out/zero-cache/src/services/view-syncer/inspect-auth-limiter.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js +11 -6
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +2 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js +16 -14
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/cvr.js +4 -1
- package/out/zero-cache/src/services/view-syncer/schema/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/init.js +3 -0
- package/out/zero-cache/src/services/view-syncer/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +89 -51
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/client-group-log-id.d.ts +9 -0
- package/out/zero-cache/src/types/client-group-log-id.d.ts.map +1 -0
- package/out/zero-cache/src/types/client-group-log-id.js +16 -0
- package/out/zero-cache/src/types/client-group-log-id.js.map +1 -0
- package/out/zero-cache/src/types/lite.d.ts.map +1 -1
- package/out/zero-cache/src/types/lite.js +1 -0
- package/out/zero-cache/src/types/lite.js.map +1 -1
- package/out/zero-cache/src/types/pg.d.ts +13 -2
- package/out/zero-cache/src/types/pg.d.ts.map +1 -1
- package/out/zero-cache/src/types/pg.js +2 -2
- package/out/zero-cache/src/types/pg.js.map +1 -1
- package/out/zero-cache/src/types/poke-chunk.d.ts +25 -4
- package/out/zero-cache/src/types/poke-chunk.d.ts.map +1 -1
- package/out/zero-cache/src/types/poke-chunk.js +46 -5
- package/out/zero-cache/src/types/poke-chunk.js.map +1 -1
- package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connection.js +10 -3
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/rehome.d.ts +10 -0
- package/out/zero-cache/src/workers/rehome.d.ts.map +1 -1
- package/out/zero-cache/src/workers/rehome.js +4 -2
- package/out/zero-cache/src/workers/rehome.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js +3 -2
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.js +15 -15
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/inspector/inspector.d.ts +4 -0
- package/out/zero-client/src/client/inspector/inspector.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/inspector.js +4 -0
- package/out/zero-client/src/client/inspector/inspector.js.map +1 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.d.ts +10 -2
- package/out/zero-client/src/client/inspector/lazy-inspector.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.js +38 -31
- package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
- package/out/zero-client/src/client/inspector/query.d.ts +2 -2
- package/out/zero-client/src/client/inspector/query.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/query.js +4 -4
- package/out/zero-client/src/client/inspector/query.js.map +1 -1
- package/out/zero-client/src/client/ivm-branch.d.ts +3 -0
- package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
- package/out/zero-client/src/client/ivm-branch.js +10 -5
- package/out/zero-client/src/client/ivm-branch.js.map +1 -1
- package/out/zero-client/src/client/reconnect-backoff.d.ts +31 -0
- package/out/zero-client/src/client/reconnect-backoff.d.ts.map +1 -0
- package/out/zero-client/src/client/reconnect-backoff.js +44 -0
- package/out/zero-client/src/client/reconnect-backoff.js.map +1 -0
- package/out/zero-client/src/client/version.js +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +7 -0
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-client/src/util/nanoid.js +2 -2
- package/out/zero-client/src/util/nanoid.js.map +1 -1
- package/out/zero-protocol/src/up.d.ts +42 -42
- package/out/zero-server/src/process-mutations.d.ts +10 -0
- package/out/zero-server/src/process-mutations.d.ts.map +1 -1
- package/out/zero-server/src/process-mutations.js +39 -6
- package/out/zero-server/src/process-mutations.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +89 -6
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/planner/planner-connection.d.ts.map +1 -1
- package/out/zql/src/planner/planner-connection.js +37 -3
- package/out/zql/src/planner/planner-connection.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
//#region ../shared/src/random-values.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var warnedAboutFallback = false;
|
|
3
|
+
/**
|
|
4
|
+
* Fills `array` with random values. Uses `crypto.getRandomValues` when the
|
|
5
|
+
* runtime provides it, then the native `ExpoCrypto` module when running in an
|
|
6
|
+
* Expo app, and falls back to `Math.random` otherwise, logging a warning the
|
|
7
|
+
* first time the fallback is used.
|
|
8
|
+
*
|
|
9
|
+
* React Native's Hermes engine has no WebCrypto. Expo installs its native
|
|
10
|
+
* modules on `globalThis.expo.modules`, and `ExpoCrypto` is there in Expo Go
|
|
11
|
+
* and in any app that has `expo-crypto` installed, even if the app never
|
|
12
|
+
* imports it. Other React Native apps should import a polyfill such as
|
|
13
|
+
* `react-native-get-random-values` before creating IDs.
|
|
14
|
+
*
|
|
15
|
+
* The globals are looked up on every call rather than at module load: some
|
|
16
|
+
* runtimes (e.g. Cloudflare Workers) only allow generating random values
|
|
17
|
+
* while handling a request.
|
|
18
|
+
*/
|
|
19
|
+
function getRandomValues(array) {
|
|
20
|
+
const { crypto } = globalThis;
|
|
21
|
+
if (typeof crypto?.getRandomValues === "function") return crypto.getRandomValues(array);
|
|
22
|
+
if (getRandomValuesFromExpo(array)) return array;
|
|
23
|
+
if (!warnedAboutFallback) {
|
|
24
|
+
warnedAboutFallback = true;
|
|
25
|
+
console.warn("crypto.getRandomValues is not available; falling back to Math.random for IDs. On React Native, install expo-crypto or import react-native-get-random-values.");
|
|
26
|
+
}
|
|
27
|
+
const max = 2 ** (array.BYTES_PER_ELEMENT * 8);
|
|
28
|
+
for (let i = 0; i < array.length; i++) array[i] = Math.floor(Math.random() * max);
|
|
5
29
|
return array;
|
|
6
30
|
}
|
|
31
|
+
function getRandomValuesFromExpo(array) {
|
|
32
|
+
try {
|
|
33
|
+
const expoCrypto = globalThis.expo?.modules?.ExpoCrypto;
|
|
34
|
+
if (typeof expoCrypto?.getRandomValues === "function") {
|
|
35
|
+
expoCrypto.getRandomValues(array);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
} catch {}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
7
41
|
function randomCharacters(length) {
|
|
8
42
|
let result = "";
|
|
9
43
|
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
@@ -16,6 +50,6 @@ function randomCharacters(length) {
|
|
|
16
50
|
return result;
|
|
17
51
|
}
|
|
18
52
|
//#endregion
|
|
19
|
-
export {
|
|
53
|
+
export { getRandomValues, randomCharacters };
|
|
20
54
|
|
|
21
55
|
//# sourceMappingURL=random-values.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random-values.js","names":[],"sources":["../../../../shared/src/random-values.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"random-values.js","names":[],"sources":["../../../../shared/src/random-values.ts"],"sourcesContent":["let warnedAboutFallback = false;\n\ntype RandomArray = Uint8Array<ArrayBuffer> | Uint32Array<ArrayBuffer>;\n\ntype ExpoGlobal = {\n expo?:\n | {\n modules?:\n | {\n ExpoCrypto?:\n | {getRandomValues?: ((array: RandomArray) => void) | undefined}\n | undefined;\n }\n | undefined;\n }\n | undefined;\n};\n\n/**\n * Fills `array` with random values. Uses `crypto.getRandomValues` when the\n * runtime provides it, then the native `ExpoCrypto` module when running in an\n * Expo app, and falls back to `Math.random` otherwise, logging a warning the\n * first time the fallback is used.\n *\n * React Native's Hermes engine has no WebCrypto. Expo installs its native\n * modules on `globalThis.expo.modules`, and `ExpoCrypto` is there in Expo Go\n * and in any app that has `expo-crypto` installed, even if the app never\n * imports it. Other React Native apps should import a polyfill such as\n * `react-native-get-random-values` before creating IDs.\n *\n * The globals are looked up on every call rather than at module load: some\n * runtimes (e.g. Cloudflare Workers) only allow generating random values\n * while handling a request.\n */\nexport function getRandomValues<T extends RandomArray>(array: T): T {\n const {crypto} = globalThis;\n if (typeof crypto?.getRandomValues === 'function') {\n return crypto.getRandomValues(array);\n }\n\n if (getRandomValuesFromExpo(array)) {\n return array;\n }\n\n if (!warnedAboutFallback) {\n warnedAboutFallback = true;\n // oxlint-disable-next-line no-console\n console.warn(\n 'crypto.getRandomValues is not available; falling back to Math.random for IDs. ' +\n 'On React Native, install expo-crypto or import react-native-get-random-values.',\n );\n }\n const max = 2 ** (array.BYTES_PER_ELEMENT * 8);\n for (let i = 0; i < array.length; i++) {\n array[i] = Math.floor(Math.random() * max);\n }\n return array;\n}\n\nfunction getRandomValuesFromExpo(array: RandomArray): boolean {\n try {\n const expoCrypto = (globalThis as ExpoGlobal).expo?.modules?.ExpoCrypto;\n if (typeof expoCrypto?.getRandomValues === 'function') {\n expoCrypto.getRandomValues(array);\n return true;\n }\n } catch {\n // Loading a native module can throw (Expo's own lookup guards against\n // this too). Use the fallback.\n }\n return false;\n}\n\nexport function randomCharacters(length: number) {\n let result = '';\n const characters =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charactersLength = characters.length;\n let counter = 0;\n while (counter < length) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n counter += 1;\n }\n return result;\n}\n"],"mappings":";AAAA,IAAI,sBAAsB;;;;;;;;;;;;;;;;;AAkC1B,SAAgB,gBAAuC,OAAa;CAClE,MAAM,EAAC,WAAU;CACjB,IAAI,OAAO,QAAQ,oBAAoB,YACrC,OAAO,OAAO,gBAAgB,KAAK;CAGrC,IAAI,wBAAwB,KAAK,GAC/B,OAAO;CAGT,IAAI,CAAC,qBAAqB;EACxB,sBAAsB;EAEtB,QAAQ,KACN,8JAEF;CACF;CACA,MAAM,MAAM,MAAM,MAAM,oBAAoB;CAC5C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,MAAM,KAAK,KAAK,MAAM,KAAK,OAAO,IAAI,GAAG;CAE3C,OAAO;AACT;AAEA,SAAS,wBAAwB,OAA6B;CAC5D,IAAI;EACF,MAAM,aAAc,WAA0B,MAAM,SAAS;EAC7D,IAAI,OAAO,YAAY,oBAAoB,YAAY;GACrD,WAAW,gBAAgB,KAAK;GAChC,OAAO;EACT;CACF,QAAQ,CAGR;CACA,OAAO;AACT;AAEA,SAAgB,iBAAiB,QAAgB;CAC/C,IAAI,SAAS;CACb,MAAM,aACJ;CACF,MAAM,mBAAmB;CACzB,IAAI,UAAU;CACd,OAAO,UAAU,QAAQ;EACvB,UAAU,WAAW,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,gBAAgB,CAAC;EACxE,WAAW;CACb;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A map whose keys are tuples. Two keys are the same if they have the same
|
|
3
|
+
* length and their elements are the same, as a {@link Map} compares keys. No
|
|
4
|
+
* key is serialized, so the elements can be objects, compared by identity.
|
|
5
|
+
*
|
|
6
|
+
* Keys of different lengths can be mixed: a key and a prefix of it are
|
|
7
|
+
* different keys.
|
|
8
|
+
*
|
|
9
|
+
* The values cannot be `undefined`, which is how a missing entry is told
|
|
10
|
+
* apart.
|
|
11
|
+
*/
|
|
12
|
+
export declare class TupleMap<K extends readonly unknown[], V extends {} | null> {
|
|
13
|
+
#private;
|
|
14
|
+
get(key: K): V | undefined;
|
|
15
|
+
set(key: K, value: V): this;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the value for {@link key}. If there is none, calls
|
|
18
|
+
* {@link compute} with the key, inserts the result and returns it.
|
|
19
|
+
*/
|
|
20
|
+
getOrInsertComputed(key: K, compute: (key: K) => V): V;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=tuple-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple-map.d.ts","sourceRoot":"","sources":["../../../../shared/src/tuple-map.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,EAAE,GAAG,IAAI;;IAGrE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CASzB;IAED,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAG1B;IAED;;;OAGG;IACH,mBAAmB,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAOrD;CASF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getOrInsertComputed } from "./map.js";
|
|
2
|
+
//#region ../shared/src/tuple-map.ts
|
|
3
|
+
var newNode = () => [void 0, /* @__PURE__ */ new Map()];
|
|
4
|
+
/**
|
|
5
|
+
* A map whose keys are tuples. Two keys are the same if they have the same
|
|
6
|
+
* length and their elements are the same, as a {@link Map} compares keys. No
|
|
7
|
+
* key is serialized, so the elements can be objects, compared by identity.
|
|
8
|
+
*
|
|
9
|
+
* Keys of different lengths can be mixed: a key and a prefix of it are
|
|
10
|
+
* different keys.
|
|
11
|
+
*
|
|
12
|
+
* The values cannot be `undefined`, which is how a missing entry is told
|
|
13
|
+
* apart.
|
|
14
|
+
*/
|
|
15
|
+
var TupleMap = class {
|
|
16
|
+
#root = newNode();
|
|
17
|
+
get(key) {
|
|
18
|
+
let node = this.#root;
|
|
19
|
+
for (const element of key) {
|
|
20
|
+
node = node[1].get(element);
|
|
21
|
+
if (node === void 0) return;
|
|
22
|
+
}
|
|
23
|
+
return node[0];
|
|
24
|
+
}
|
|
25
|
+
set(key, value) {
|
|
26
|
+
this.#node(key)[0] = value;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the value for {@link key}. If there is none, calls
|
|
31
|
+
* {@link compute} with the key, inserts the result and returns it.
|
|
32
|
+
*/
|
|
33
|
+
getOrInsertComputed(key, compute) {
|
|
34
|
+
const node = this.#node(key);
|
|
35
|
+
let value = node[0];
|
|
36
|
+
if (value === void 0) value = node[0] = compute(key);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
#node(key) {
|
|
40
|
+
let node = this.#root;
|
|
41
|
+
for (const element of key) node = getOrInsertComputed(node[1], element, newNode);
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { TupleMap };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=tuple-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple-map.js","names":[],"sources":["../../../../shared/src/tuple-map.ts"],"sourcesContent":["import {getOrInsertComputed} from './map.ts';\n\n/** The value for the key that ends at this node, and the longer keys. */\ntype Node<V> = [value: V | undefined, children: Map<unknown, Node<V>>];\n\nconst newNode = <V>(): Node<V> => [undefined, new Map()];\n\n/**\n * A map whose keys are tuples. Two keys are the same if they have the same\n * length and their elements are the same, as a {@link Map} compares keys. No\n * key is serialized, so the elements can be objects, compared by identity.\n *\n * Keys of different lengths can be mixed: a key and a prefix of it are\n * different keys.\n *\n * The values cannot be `undefined`, which is how a missing entry is told\n * apart.\n */\nexport class TupleMap<K extends readonly unknown[], V extends {} | null> {\n readonly #root: Node<V> = newNode();\n\n get(key: K): V | undefined {\n let node: Node<V> | undefined = this.#root;\n for (const element of key) {\n node = node[1].get(element);\n if (node === undefined) {\n return undefined;\n }\n }\n return node[0];\n }\n\n set(key: K, value: V): this {\n this.#node(key)[0] = value;\n return this;\n }\n\n /**\n * Returns the value for {@link key}. If there is none, calls\n * {@link compute} with the key, inserts the result and returns it.\n */\n getOrInsertComputed(key: K, compute: (key: K) => V): V {\n const node = this.#node(key);\n let value = node[0];\n if (value === undefined) {\n value = node[0] = compute(key);\n }\n return value;\n }\n\n #node(key: K): Node<V> {\n let node = this.#root;\n for (const element of key) {\n node = getOrInsertComputed(node[1], element, newNode<V>);\n }\n return node;\n }\n}\n"],"mappings":";;AAKA,IAAM,gBAA4B,CAAC,KAAA,mBAAW,IAAI,IAAI,CAAC;;;;;;;;;;;;AAavD,IAAa,WAAb,MAAyE;CACvE,QAA0B,QAAQ;CAElC,IAAI,KAAuB;EACzB,IAAI,OAA4B,KAAK;EACrC,KAAK,MAAM,WAAW,KAAK;GACzB,OAAO,KAAK,EAAE,CAAC,IAAI,OAAO;GAC1B,IAAI,SAAS,KAAA,GACX;EAEJ;EACA,OAAO,KAAK;CACd;CAEA,IAAI,KAAQ,OAAgB;EAC1B,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK;EACrB,OAAO;CACT;;;;;CAMA,oBAAoB,KAAQ,SAA2B;EACrD,MAAM,OAAO,KAAK,MAAM,GAAG;EAC3B,IAAI,QAAQ,KAAK;EACjB,IAAI,UAAU,KAAA,GACZ,QAAQ,KAAK,KAAK,QAAQ,GAAG;EAE/B,OAAO;CACT;CAEA,MAAM,KAAiB;EACrB,IAAI,OAAO,KAAK;EAChB,KAAK,MAAM,WAAW,KACpB,OAAO,oBAAoB,KAAK,IAAI,SAAS,OAAU;EAEzD,OAAO;CACT;AACF"}
|
package/out/zero/package.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region package.json
|
|
2
2
|
var name = "@rocicorp/zero";
|
|
3
|
-
var version = "1.12.0-canary.
|
|
3
|
+
var version = "1.12.0-canary.13";
|
|
4
4
|
var description = "Zero is a web framework for serverless web development.";
|
|
5
5
|
var homepage = "https://zero.rocicorp.dev";
|
|
6
6
|
var bugs = { "url": "https://bugs.rocicorp.dev" };
|
package/out/zero/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@rocicorp/zero\",\n \"version\": \"1.12.0-canary.
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@rocicorp/zero\",\n \"version\": \"1.12.0-canary.13\",\n \"description\": \"Zero is a web framework for serverless web development.\",\n \"homepage\": \"https://zero.rocicorp.dev\",\n \"bugs\": {\n \"url\": \"https://bugs.rocicorp.dev\"\n },\n \"license\": \"Apache-2.0\",\n \"author\": \"Rocicorp, Inc.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/rocicorp/mono.git\",\n \"directory\": \"packages/zero\"\n },\n \"bin\": {\n \"ast-to-zql\": \"./out/zero/src/ast-to-zql.js\",\n \"transform-query\": \"./out/zero/src/transform-query.js\",\n \"zero-build-schema\": \"./out/zero/src/build-schema.js\",\n \"zero-cache\": \"./out/zero/src/cli.js\",\n \"zero-cache-dev\": \"./out/zero/src/zero-cache-dev.js\",\n \"zero-deploy-permissions\": \"./out/zero/src/deploy-permissions.js\",\n \"zero-out\": \"./out/zero/src/zero-out.js\"\n },\n \"files\": [\n \"out\",\n \"!*.tsbuildinfo\"\n ],\n \"type\": \"module\",\n \"main\": \"out/zero/src/zero.js\",\n \"module\": \"out/zero/src/zero.js\",\n \"types\": \"out/zero/src/zero.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./out/zero/src/zero.d.ts\",\n \"default\": \"./out/zero/src/zero.js\"\n },\n \"./analyze\": {\n \"types\": \"./out/zero/src/analyze.d.ts\",\n \"default\": \"./out/zero/src/analyze.js\"\n },\n \"./bindings\": {\n \"types\": \"./out/zero/src/bindings.d.ts\",\n \"default\": \"./out/zero/src/bindings.js\"\n },\n \"./change-protocol/v0\": {\n \"types\": \"./out/zero/src/change-protocol/v0.d.ts\",\n \"default\": \"./out/zero/src/change-protocol/v0.js\"\n },\n \"./expo-sqlite\": {\n \"types\": \"./out/zero/src/expo-sqlite.d.ts\",\n \"default\": \"./out/zero/src/expo-sqlite.js\"\n },\n \"./op-sqlite\": {\n \"types\": \"./out/zero/src/op-sqlite.d.ts\",\n \"default\": \"./out/zero/src/op-sqlite.js\"\n },\n \"./pg\": {\n \"types\": \"./out/zero/src/pg.d.ts\",\n \"default\": \"./out/zero/src/pg.js\"\n },\n \"./react\": {\n \"types\": \"./out/zero/src/react.d.ts\",\n \"default\": \"./out/zero/src/react.js\"\n },\n \"./react-native\": {\n \"types\": \"./out/zero/src/react-native.d.ts\",\n \"default\": \"./out/zero/src/react-native.js\"\n },\n \"./server\": {\n \"types\": \"./out/zero/src/server.d.ts\",\n \"default\": \"./out/zero/src/server.js\"\n },\n \"./server/adapters/drizzle\": {\n \"types\": \"./out/zero/src/adapters/drizzle.d.ts\",\n \"default\": \"./out/zero/src/adapters/drizzle.js\"\n },\n \"./server/adapters/kysely\": {\n \"types\": \"./out/zero/src/adapters/kysely.d.ts\",\n \"default\": \"./out/zero/src/adapters/kysely.js\"\n },\n \"./server/adapters/prisma\": {\n \"types\": \"./out/zero/src/adapters/prisma.d.ts\",\n \"default\": \"./out/zero/src/adapters/prisma.js\"\n },\n \"./server/adapters/pg\": {\n \"types\": \"./out/zero/src/adapters/pg.d.ts\",\n \"default\": \"./out/zero/src/adapters/pg.js\"\n },\n \"./server/adapters/postgresjs\": {\n \"types\": \"./out/zero/src/adapters/postgresjs.d.ts\",\n \"default\": \"./out/zero/src/adapters/postgresjs.js\"\n },\n \"./solid\": {\n \"types\": \"./out/zero/src/solid.d.ts\",\n \"default\": \"./out/zero/src/solid.js\"\n },\n \"./sqlite\": {\n \"types\": \"./out/zero/src/sqlite.d.ts\",\n \"default\": \"./out/zero/src/sqlite.js\"\n },\n \"./zqlite\": {\n \"types\": \"./out/zero/src/zqlite.d.ts\",\n \"default\": \"./out/zero/src/zqlite.js\"\n }\n },\n \"scripts\": {\n \"build\": \"node --experimental-strip-types --no-warnings tool/build.ts\",\n \"build:watch\": \"node --experimental-strip-types --no-warnings tool/build.ts --watch\",\n \"check-types\": \"tsc -p tsconfig.client.json && tsc -p tsconfig.server.json\",\n \"check-types:client:watch\": \"tsc -p tsconfig.client.json --watch\",\n \"check-types:server:watch\": \"tsc -p tsconfig.server.json --watch\",\n \"format\": \"oxfmt .\",\n \"check-format\": \"oxfmt --check .\",\n \"lint\": \"oxlint --quiet --config ../../oxlint.config.ts src/\",\n \"docs\": \"node --experimental-strip-types --no-warnings tool/generate-docs.ts\",\n \"docs:server\": \"node --watch --experimental-strip-types --no-warnings tool/generate-docs.ts --server\",\n \"fmt\": \"oxfmt .\",\n \"check-fmt\": \"oxfmt --check .\"\n },\n \"dependencies\": {\n \"@badrap/valita\": \"0.5.5\",\n \"@databases/escape-identifier\": \"^1.0.3\",\n \"@databases/sql\": \"^3.3.0\",\n \"@dotenvx/dotenvx\": \"^1.66.0\",\n \"@drdgvhbh/postgres-error-codes\": \"^0.0.6\",\n \"@fastify/cors\": \"^10.1.0\",\n \"@fastify/websocket\": \"^11.2.0\",\n \"@google-cloud/precise-date\": \"^4.0.0\",\n \"@opentelemetry/api\": \"1.9.1\",\n \"@opentelemetry/api-logs\": \"0.223.0\",\n \"@opentelemetry/auto-instrumentations-node\": \"0.81.2\",\n \"@opentelemetry/exporter-metrics-otlp-http\": \"0.223.0\",\n \"@opentelemetry/resources\": \"2.12.0\",\n \"@opentelemetry/sdk-metrics\": \"2.12.0\",\n \"@opentelemetry/sdk-node\": \"0.223.0\",\n \"@opentelemetry/sdk-trace-node\": \"2.12.0\",\n \"@opentelemetry/semantic-conventions\": \"1.43.0\",\n \"@postgresql-typed/oids\": \"^0.2.0\",\n \"@rocicorp/lock\": \"^2.0.1\",\n \"@rocicorp/logger\": \"^6.1.0\",\n \"@rocicorp/zero-sqlite3\": \"^1.1.7\",\n \"@standard-schema/spec\": \"^1.1.0\",\n \"@types/basic-auth\": \"^1.1.8\",\n \"@types/ws\": \"^8.18.1\",\n \"basic-auth\": \"^2.0.1\",\n \"chalk-template\": \"^1.1.2\",\n \"chokidar\": \"^4.0.3\",\n \"cloudevents\": \"^10.0.0\",\n \"command-line-args\": \"^6.0.2\",\n \"command-line-usage\": \"^7.0.4\",\n \"compare-utf8\": \"^0.2.3\",\n \"defu\": \"^6.1.7\",\n \"eventemitter3\": \"^5.0.4\",\n \"fastify\": \"^5.12.7\",\n \"is-in-subnet\": \"^4.0.1\",\n \"jose\": \"^5.10.0\",\n \"json-custom-numbers\": \"^3.1.1\",\n \"kasi\": \"^1.1.2\",\n \"nanoid\": \"^5.1.16\",\n \"oxc-parser\": \"^0.129.0\",\n \"oxfmt\": \"^0.74.0\",\n \"parse-prometheus-text-format\": \"^1.1.1\",\n \"pg-format\": \"npm:pg-format-fix@^1.0.5\",\n \"postgres\": \"3.4.7\",\n \"semver\": \"^7.8.0\",\n \"url-pattern\": \"^1.0.3\",\n \"urlpattern-polyfill\": \"^10.1.0\",\n \"ws\": \"^8.22.0\"\n },\n \"devDependencies\": {\n \"@op-engineering/op-sqlite\": \"^18.2.5\",\n \"analyze-query\": \"workspace:*\",\n \"ast-to-zql\": \"workspace:*\",\n \"expo\": \"^58.0.14\",\n \"expo-sqlite\": \"^58.0.13\",\n \"react-native\": \"^0.88.0\",\n \"replicache\": \"workspace:*\",\n \"shared\": \"workspace:*\",\n \"syncpack\": \"^14.3.1\",\n \"typedoc\": \"^0.28.19\",\n \"typescript\": \"~7.0.2\",\n \"vite\": \"^8.3.4\",\n \"vitest\": \"^5.0.5\",\n \"zero-cache\": \"workspace:*\",\n \"zero-client\": \"workspace:*\",\n \"zero-pg\": \"workspace:*\",\n \"zero-react\": \"workspace:*\",\n \"zero-server\": \"workspace:*\",\n \"zero-solid\": \"workspace:*\",\n \"zqlite\": \"workspace:*\"\n },\n \"engines\": {\n \"node\": \">=22\"\n },\n \"packageManager\": \"pnpm@11.11.0\"\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/auth/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAIrC,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oCAAoC,CAAC;AAElE,yCAAyC;AACzC,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG,CAC9B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,KACvC,OAAO,CAAC,OAAO,CAAC,CAAC;AAMtB,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,EAAE,CAAC,EAAE,IAAI,GAAG,SAAS,WAQlE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,EAAE,EAAE,UAAU,EACd,YAAY,EAAE,IAAI,GAAG,SAAS,EAC9B,MAAM,EAAE,MA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B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,iBAAiB,EAAE,iBAAiB,GAAG,SAAS,GAC/C,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CA8E3B;AAED,gEAAgE;AAChE,wBAAgB,SAAS,CACvB,EAAE,EAAE,UAAU,EACd,aAAa,EAAE,IAAI,GAAG,SAAS,EAC/B,QAAQ,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI,oBAgFlC;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,SAAS,GAAG,SAAS,CAgCxE"}
|
|
@@ -25,6 +25,11 @@ async function resolveAuth(lc, previousAuth, userID, wireAuth, validateLegacyJWT
|
|
|
25
25
|
origin: ZeroCache
|
|
26
26
|
});
|
|
27
27
|
if (!hasProvidedAuth) {
|
|
28
|
+
if (validateLegacyJWT !== void 0 && userID !== null) throw new ProtocolError({
|
|
29
|
+
kind: Unauthorized,
|
|
30
|
+
message: "No token provided. A connection with a userID requires a token when JWT verification is configured.",
|
|
31
|
+
origin: ZeroCache
|
|
32
|
+
});
|
|
28
33
|
lc.debug?.(`Cleared auth`);
|
|
29
34
|
return;
|
|
30
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":["ErrorKind.Unauthorized","ErrorOrigin.ZeroCache","ErrorKind.AuthInvalidated"],"sources":["../../../../../zero-cache/src/auth/auth.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {JWTPayload} from 'jose';\nimport {ErrorKind} from '../../../zero-protocol/src/error-kind.ts';\nimport {ErrorOrigin} from '../../../zero-protocol/src/error-origin.ts';\nimport {ErrorReason} from '../../../zero-protocol/src/error-reason.ts';\nimport {\n isProtocolError,\n ProtocolError,\n type ErrorBody,\n} from '../../../zero-protocol/src/error.ts';\nimport type {PushError} from '../../../zero-protocol/src/push.ts';\n\n/** @deprecated JWT auth is deprecated */\nexport type JWTAuth = {\n readonly type: 'jwt';\n readonly raw: string;\n readonly decoded: JWTPayload;\n};\n\nexport type OpaqueAuth = {\n readonly type: 'opaque';\n readonly raw: string;\n};\n\nexport type Auth = OpaqueAuth | JWTAuth;\n\nexport type ValidateLegacyJWT = (\n token: string,\n ctx: {readonly userID: string | undefined},\n) => Promise<JWTAuth>;\n\nfunction isProvidedAuth(wireAuth: string | undefined): wireAuth is string {\n return wireAuth !== undefined && wireAuth !== '';\n}\n\nexport function authEquals(a: Auth | undefined, b: Auth | undefined) {\n if (a === b) {\n return true;\n }\n if (!a || !b) {\n return false;\n }\n return a.type === b.type && a.raw === b.raw;\n}\n\n/**\n * Resolves one auth snapshot transition without binding it to a client group.\n */\nexport async function resolveAuth(\n lc: LogContext,\n previousAuth: Auth | undefined,\n userID: string | null,\n wireAuth: string | undefined,\n validateLegacyJWT: ValidateLegacyJWT | undefined,\n): Promise<Auth | undefined> {\n try {\n const hasProvidedAuth = isProvidedAuth(wireAuth);\n\n if (previousAuth) {\n lc.debug?.(`Attempting to update auth from previous value`);\n } else {\n lc.debug?.(`Attempting to initialize auth`);\n }\n\n if (!hasProvidedAuth && previousAuth) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'No token provided. An unauthenticated client cannot connect to an authenticated client group.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (!hasProvidedAuth) {\n lc.debug?.(`Cleared auth`);\n return undefined;\n }\n\n if (userID === null) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message: 'Authenticated connections require a userID.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (validateLegacyJWT !== undefined) {\n const verifiedToken = await validateLegacyJWT(wireAuth, {userID});\n const nextAuth = pickToken(lc, previousAuth, verifiedToken);\n lc.debug?.(`Updated auth with JWT`);\n return nextAuth;\n }\n\n if (previousAuth?.type === 'jwt') {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'Token type cannot change from JWT to opaque. Connections are pinned to a single token type.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (previousAuth?.type === 'opaque' && previousAuth.raw === wireAuth) {\n lc.debug?.(`Opaque auth unchanged, reusing previous snapshot`);\n return previousAuth;\n }\n\n lc.debug?.(`Updated auth with opaque token`);\n return {\n type: 'opaque',\n raw: wireAuth,\n };\n } catch (e) {\n if (isProtocolError(e)) {\n throw e;\n }\n throw new ProtocolError({\n kind: ErrorKind.AuthInvalidated,\n message: `Failed to decode auth token: ${String(e)}`,\n origin: ErrorOrigin.ZeroCache,\n });\n }\n}\n\n/** @deprecated used only in old JWT validation/rotation auth */\nexport function pickToken(\n lc: LogContext,\n previousToken: Auth | undefined,\n newToken: Auth | undefined | null,\n) {\n if (newToken === null) {\n return undefined;\n }\n\n if (\n previousToken?.type &&\n newToken?.type &&\n previousToken?.type !== newToken?.type\n ) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'Token type cannot change. Client groups are pinned to a single token type.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (previousToken === undefined) {\n lc.debug?.(`No previous token, using new token`);\n return newToken;\n }\n\n if (newToken?.type === 'opaque') {\n return newToken;\n }\n\n if (previousToken.type === 'opaque') {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'Token type cannot change from opaque to JWT. Client groups are pinned to a single token type.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (newToken) {\n if (previousToken.decoded.sub !== newToken.decoded.sub) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'The user id in the new token does not match the previous token. Client groups are pinned to a single user.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (previousToken.decoded.iat === undefined) {\n lc.debug?.(`No issued at time for the existing token, using new token`);\n // No issued at time for the existing token? We take the most recently received token.\n return newToken;\n }\n\n if (newToken.decoded.iat === undefined) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'The new token does not have an issued at time but the prior token does. Tokens for a client group must either all have issued at times or all not have issued at times',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n // The new token is newer, so we take it.\n if (previousToken.decoded.iat < newToken.decoded.iat) {\n lc.debug?.(`New token is newer, using it`);\n return newToken;\n }\n\n // if the new token is older or the same, we keep the existing token.\n lc.debug?.(`New token is older or the same, using existing token`);\n return previousToken;\n }\n\n // previousToken !== undefined but newToken is undefined\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'No token provided. An unauthenticated client cannot connect to an authenticated client group.',\n origin: ErrorOrigin.ZeroCache,\n });\n}\n\nexport function isAuthErrorBody(ex: unknown): ex is ErrorBody | PushError {\n if (typeof ex !== 'object' || ex === null) {\n return false;\n }\n\n if ('error' in ex) {\n return (\n ex.error === 'http' &&\n 'status' in ex &&\n (ex.status === 401 || ex.status === 403)\n );\n }\n\n if (!('kind' in ex)) {\n return false;\n }\n\n if (\n ex.kind === ErrorKind.AuthInvalidated ||\n ex.kind === ErrorKind.Unauthorized\n ) {\n return true;\n }\n\n return (\n (ex.kind === ErrorKind.PushFailed ||\n ex.kind === ErrorKind.TransformFailed) &&\n 'reason' in ex &&\n ex.reason === ErrorReason.HTTP &&\n 'status' in ex &&\n (ex.status === 401 || ex.status === 403)\n );\n}\n"],"mappings":";;;;;AA+BA,SAAS,eAAe,UAAkD;CACxE,OAAO,aAAa,KAAA,KAAa,aAAa;AAChD;AAEA,SAAgB,WAAW,GAAqB,GAAqB;CACnE,IAAI,MAAM,GACR,OAAO;CAET,IAAI,CAAC,KAAK,CAAC,GACT,OAAO;CAET,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE;AAC1C;;;;AAKA,eAAsB,YACpB,IACA,cACA,QACA,UACA,mBAC2B;CAC3B,IAAI;EACF,MAAM,kBAAkB,eAAe,QAAQ;EAE/C,IAAI,cACF,GAAG,QAAQ,+CAA+C;OAE1D,GAAG,QAAQ,+BAA+B;EAG5C,IAAI,CAAC,mBAAmB,cACtB,MAAM,IAAI,cAAc;GACtB,MAAMA;GACN,SACE;GACF,QAAQC;EACV,CAAC;EAGH,IAAI,CAAC,iBAAiB;
|
|
1
|
+
{"version":3,"file":"auth.js","names":["ErrorKind.Unauthorized","ErrorOrigin.ZeroCache","ErrorKind.AuthInvalidated"],"sources":["../../../../../zero-cache/src/auth/auth.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {JWTPayload} from 'jose';\nimport {ErrorKind} from '../../../zero-protocol/src/error-kind.ts';\nimport {ErrorOrigin} from '../../../zero-protocol/src/error-origin.ts';\nimport {ErrorReason} from '../../../zero-protocol/src/error-reason.ts';\nimport {\n isProtocolError,\n ProtocolError,\n type ErrorBody,\n} from '../../../zero-protocol/src/error.ts';\nimport type {PushError} from '../../../zero-protocol/src/push.ts';\n\n/** @deprecated JWT auth is deprecated */\nexport type JWTAuth = {\n readonly type: 'jwt';\n readonly raw: string;\n readonly decoded: JWTPayload;\n};\n\nexport type OpaqueAuth = {\n readonly type: 'opaque';\n readonly raw: string;\n};\n\nexport type Auth = OpaqueAuth | JWTAuth;\n\nexport type ValidateLegacyJWT = (\n token: string,\n ctx: {readonly userID: string | undefined},\n) => Promise<JWTAuth>;\n\nfunction isProvidedAuth(wireAuth: string | undefined): wireAuth is string {\n return wireAuth !== undefined && wireAuth !== '';\n}\n\nexport function authEquals(a: Auth | undefined, b: Auth | undefined) {\n if (a === b) {\n return true;\n }\n if (!a || !b) {\n return false;\n }\n return a.type === b.type && a.raw === b.raw;\n}\n\n/**\n * Resolves one auth snapshot transition without binding it to a client group.\n */\nexport async function resolveAuth(\n lc: LogContext,\n previousAuth: Auth | undefined,\n userID: string | null,\n wireAuth: string | undefined,\n validateLegacyJWT: ValidateLegacyJWT | undefined,\n): Promise<Auth | undefined> {\n try {\n const hasProvidedAuth = isProvidedAuth(wireAuth);\n\n if (previousAuth) {\n lc.debug?.(`Attempting to update auth from previous value`);\n } else {\n lc.debug?.(`Attempting to initialize auth`);\n }\n\n if (!hasProvidedAuth && previousAuth) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'No token provided. An unauthenticated client cannot connect to an authenticated client group.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (!hasProvidedAuth) {\n // With JWT verification configured, the token is the only thing that\n // ties a connection to its userID. A logged-out connection omits both.\n if (validateLegacyJWT !== undefined && userID !== null) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'No token provided. A connection with a userID requires a token when JWT verification is configured.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n lc.debug?.(`Cleared auth`);\n return undefined;\n }\n\n if (userID === null) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message: 'Authenticated connections require a userID.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (validateLegacyJWT !== undefined) {\n const verifiedToken = await validateLegacyJWT(wireAuth, {userID});\n const nextAuth = pickToken(lc, previousAuth, verifiedToken);\n lc.debug?.(`Updated auth with JWT`);\n return nextAuth;\n }\n\n if (previousAuth?.type === 'jwt') {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'Token type cannot change from JWT to opaque. Connections are pinned to a single token type.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (previousAuth?.type === 'opaque' && previousAuth.raw === wireAuth) {\n lc.debug?.(`Opaque auth unchanged, reusing previous snapshot`);\n return previousAuth;\n }\n\n lc.debug?.(`Updated auth with opaque token`);\n return {\n type: 'opaque',\n raw: wireAuth,\n };\n } catch (e) {\n if (isProtocolError(e)) {\n throw e;\n }\n throw new ProtocolError({\n kind: ErrorKind.AuthInvalidated,\n message: `Failed to decode auth token: ${String(e)}`,\n origin: ErrorOrigin.ZeroCache,\n });\n }\n}\n\n/** @deprecated used only in old JWT validation/rotation auth */\nexport function pickToken(\n lc: LogContext,\n previousToken: Auth | undefined,\n newToken: Auth | undefined | null,\n) {\n if (newToken === null) {\n return undefined;\n }\n\n if (\n previousToken?.type &&\n newToken?.type &&\n previousToken?.type !== newToken?.type\n ) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'Token type cannot change. Client groups are pinned to a single token type.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (previousToken === undefined) {\n lc.debug?.(`No previous token, using new token`);\n return newToken;\n }\n\n if (newToken?.type === 'opaque') {\n return newToken;\n }\n\n if (previousToken.type === 'opaque') {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'Token type cannot change from opaque to JWT. Client groups are pinned to a single token type.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (newToken) {\n if (previousToken.decoded.sub !== newToken.decoded.sub) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'The user id in the new token does not match the previous token. Client groups are pinned to a single user.',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n if (previousToken.decoded.iat === undefined) {\n lc.debug?.(`No issued at time for the existing token, using new token`);\n // No issued at time for the existing token? We take the most recently received token.\n return newToken;\n }\n\n if (newToken.decoded.iat === undefined) {\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'The new token does not have an issued at time but the prior token does. Tokens for a client group must either all have issued at times or all not have issued at times',\n origin: ErrorOrigin.ZeroCache,\n });\n }\n\n // The new token is newer, so we take it.\n if (previousToken.decoded.iat < newToken.decoded.iat) {\n lc.debug?.(`New token is newer, using it`);\n return newToken;\n }\n\n // if the new token is older or the same, we keep the existing token.\n lc.debug?.(`New token is older or the same, using existing token`);\n return previousToken;\n }\n\n // previousToken !== undefined but newToken is undefined\n throw new ProtocolError({\n kind: ErrorKind.Unauthorized,\n message:\n 'No token provided. An unauthenticated client cannot connect to an authenticated client group.',\n origin: ErrorOrigin.ZeroCache,\n });\n}\n\nexport function isAuthErrorBody(ex: unknown): ex is ErrorBody | PushError {\n if (typeof ex !== 'object' || ex === null) {\n return false;\n }\n\n if ('error' in ex) {\n return (\n ex.error === 'http' &&\n 'status' in ex &&\n (ex.status === 401 || ex.status === 403)\n );\n }\n\n if (!('kind' in ex)) {\n return false;\n }\n\n if (\n ex.kind === ErrorKind.AuthInvalidated ||\n ex.kind === ErrorKind.Unauthorized\n ) {\n return true;\n }\n\n return (\n (ex.kind === ErrorKind.PushFailed ||\n ex.kind === ErrorKind.TransformFailed) &&\n 'reason' in ex &&\n ex.reason === ErrorReason.HTTP &&\n 'status' in ex &&\n (ex.status === 401 || ex.status === 403)\n );\n}\n"],"mappings":";;;;;AA+BA,SAAS,eAAe,UAAkD;CACxE,OAAO,aAAa,KAAA,KAAa,aAAa;AAChD;AAEA,SAAgB,WAAW,GAAqB,GAAqB;CACnE,IAAI,MAAM,GACR,OAAO;CAET,IAAI,CAAC,KAAK,CAAC,GACT,OAAO;CAET,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE;AAC1C;;;;AAKA,eAAsB,YACpB,IACA,cACA,QACA,UACA,mBAC2B;CAC3B,IAAI;EACF,MAAM,kBAAkB,eAAe,QAAQ;EAE/C,IAAI,cACF,GAAG,QAAQ,+CAA+C;OAE1D,GAAG,QAAQ,+BAA+B;EAG5C,IAAI,CAAC,mBAAmB,cACtB,MAAM,IAAI,cAAc;GACtB,MAAMA;GACN,SACE;GACF,QAAQC;EACV,CAAC;EAGH,IAAI,CAAC,iBAAiB;GAGpB,IAAI,sBAAsB,KAAA,KAAa,WAAW,MAChD,MAAM,IAAI,cAAc;IACtB,MAAMD;IACN,SACE;IACF,QAAQC;GACV,CAAC;GAEH,GAAG,QAAQ,cAAc;GACzB;EACF;EAEA,IAAI,WAAW,MACb,MAAM,IAAI,cAAc;GACtB,MAAMD;GACN,SAAS;GACT,QAAQC;EACV,CAAC;EAGH,IAAI,sBAAsB,KAAA,GAAW;GAEnC,MAAM,WAAW,UAAU,IAAI,cAAc,MADjB,kBAAkB,UAAU,EAAC,OAAM,CAAC,CACN;GAC1D,GAAG,QAAQ,uBAAuB;GAClC,OAAO;EACT;EAEA,IAAI,cAAc,SAAS,OACzB,MAA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CACT;CAGA,MAAM,IAAI,cAAc;EACtB,MAAMD;EACN,SACE;EACF,QAAQC;CACV,CAAC;AACH;AAEA,SAAgB,gBAAgB,IAA0C;CACxE,IAAI,OAAO,OAAO,YAAY,OAAO,MACnC,OAAO;CAGT,IAAI,WAAW,IACb,OACE,GAAG,UAAU,UACb,YAAY,OACX,GAAG,WAAW,OAAO,GAAG,WAAW;CAIxC,IAAI,EAAE,UAAU,KACd,OAAO;CAGT,IACE,GAAG,SAAS,qBACZ,GAAG,SAAS,gBAEZ,OAAO;CAGT,QACG,GAAG,SAAS,gBACX,GAAG,SAAS,sBACd,YAAY,MACZ,GAAG,WAAW,UACd,YAAY,OACX,GAAG,WAAW,OAAO,GAAG,WAAW;AAExC"}
|
|
@@ -73,6 +73,10 @@ declare const authOptions: {
|
|
|
73
73
|
type: v.Type<number>;
|
|
74
74
|
desc: string[];
|
|
75
75
|
};
|
|
76
|
+
requireServerUserID: {
|
|
77
|
+
type: v.Type<boolean>;
|
|
78
|
+
desc: string[];
|
|
79
|
+
};
|
|
76
80
|
};
|
|
77
81
|
export type AuthConfig = Config<typeof authOptions>;
|
|
78
82
|
/** @deprecated used only by legacy JWT verification helpers */
|
|
@@ -468,6 +472,10 @@ export declare const zeroOptions: {
|
|
|
468
472
|
type: v.Type<number>;
|
|
469
473
|
desc: string[];
|
|
470
474
|
};
|
|
475
|
+
requireServerUserID: {
|
|
476
|
+
type: v.Type<boolean>;
|
|
477
|
+
desc: string[];
|
|
478
|
+
};
|
|
471
479
|
};
|
|
472
480
|
port: {
|
|
473
481
|
type: v.Type<number>;
|
|
@@ -504,6 +512,10 @@ export declare const zeroOptions: {
|
|
|
504
512
|
type: v.Optional<string>;
|
|
505
513
|
desc: string[];
|
|
506
514
|
};
|
|
515
|
+
secret: {
|
|
516
|
+
type: v.Optional<string>;
|
|
517
|
+
desc: string[];
|
|
518
|
+
};
|
|
507
519
|
/** @deprecated */
|
|
508
520
|
mode: {
|
|
509
521
|
type: v.Type<"dedicated" | "discover">;
|
|
@@ -640,6 +652,10 @@ export declare const zeroOptions: {
|
|
|
640
652
|
type: v.Optional<string>;
|
|
641
653
|
desc: string[];
|
|
642
654
|
};
|
|
655
|
+
enableHeapz: {
|
|
656
|
+
type: v.Type<boolean>;
|
|
657
|
+
desc: string[];
|
|
658
|
+
};
|
|
643
659
|
websocketCompression: {
|
|
644
660
|
type: v.Type<boolean>;
|
|
645
661
|
desc: string[];
|
|
@@ -861,5 +877,10 @@ export declare function isAdminPasswordValid(lc: LogContext, config: Pick<Normal
|
|
|
861
877
|
* documents as withheld.
|
|
862
878
|
*/
|
|
863
879
|
export declare function getOperatorAccess(lc: LogContext, config: Pick<NormalizedZeroConfig, 'adminPassword' | 'operatorPassword'>, password: string | undefined): AdminAccess | undefined;
|
|
880
|
+
/**
|
|
881
|
+
* Compares `password` with `expected` in constant time. Returns `false` when
|
|
882
|
+
* no `expected` password is configured.
|
|
883
|
+
*/
|
|
884
|
+
export declare function passwordMatches(password: string | undefined, expected: string | undefined): boolean;
|
|
864
885
|
export declare function resetWarnOnceState(): void;
|
|
865
886
|
//# sourceMappingURL=zero-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zero-config.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AAUnD,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAC,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAEhE,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAK3C,eAAO,MAAM,UAAU;IACrB,EAAE;QACA,IAAI;QAIJ,IAAI;;IAuBN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AC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,OAAO,CAST;AAgBD,wBAAgB,kBAAkB,SAEjC"}
|
|
@@ -7,7 +7,7 @@ import { singleProcessMode } from "../types/processes.js";
|
|
|
7
7
|
import { ALLOWED_APP_ID_CHARACTERS, INVALID_APP_ID_MESSAGE } from "../types/shards.js";
|
|
8
8
|
import { DEFAULT_PREFERRED_PREFIXES } from "./network.js";
|
|
9
9
|
import { assertNormalized, isDevelopmentMode } from "./normalize.js";
|
|
10
|
-
import { timingSafeEqual } from "node:crypto";
|
|
10
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
11
11
|
//#region ../zero-cache/src/config/zero-config.ts
|
|
12
12
|
/**
|
|
13
13
|
* These types represent the _compiled_ config whereas `define-config` types represent the _source_ config.
|
|
@@ -140,6 +140,16 @@ var authOptions = {
|
|
|
140
140
|
retransformIntervalSeconds: {
|
|
141
141
|
type: valita_exports.number().optional(() => 300),
|
|
142
142
|
desc: [`The interval in seconds between periodic shared /query retransform work for a client group.`, `If unset, periodic shared retransform is disabled.`]
|
|
143
|
+
},
|
|
144
|
+
requireServerUserID: {
|
|
145
|
+
type: valita_exports.boolean().optional(() => false),
|
|
146
|
+
desc: [
|
|
147
|
+
`Refuse a connection that claims a userID when the API server's answer to`,
|
|
148
|
+
`/query or /mutate does not include a userID, unless a legacy JWT verified`,
|
|
149
|
+
`it. Without this, zero-cache trusts the userID the client claims and logs`,
|
|
150
|
+
`a warning. Turn it on once your API server returns the userID ({bold null}`,
|
|
151
|
+
`for logged-out callers).`
|
|
152
|
+
]
|
|
143
153
|
}
|
|
144
154
|
};
|
|
145
155
|
var makeDeprecationMessage = (flag) => `Use {bold ${flagToEnv(ZERO_ENV_VAR_PREFIX, flag)}} (or {bold --${flag}}) instead.`;
|
|
@@ -765,6 +775,23 @@ var zeroOptions = {
|
|
|
765
775
|
`on port 4849.`
|
|
766
776
|
]
|
|
767
777
|
},
|
|
778
|
+
secret: {
|
|
779
|
+
type: valita_exports.string().optional(),
|
|
780
|
+
desc: [
|
|
781
|
+
`A shared secret that authenticates {bold view-syncers} to the {bold change-streamer}.`,
|
|
782
|
+
`View-syncers present it when connecting to the {bold replication-manager}, which`,
|
|
783
|
+
`refuses replication connections that do not present it. Set it to the same value`,
|
|
784
|
+
`on the replication-manager and on every view-syncer.`,
|
|
785
|
+
``,
|
|
786
|
+
`In a single-node configuration zero-cache generates a secret for its own workers,`,
|
|
787
|
+
`so no value is needed. In a multi-node configuration it should always be set: while`,
|
|
788
|
+
`it is unset, the replication-manager accepts replication connections from anything`,
|
|
789
|
+
`that can reach its {bold change-streamer-port}, and logs a warning on startup.`,
|
|
790
|
+
``,
|
|
791
|
+
`For a rolling upgrade, set the secret on the view-syncers before setting it on the`,
|
|
792
|
+
`replication-manager, as a replication-manager without a secret accepts both.`
|
|
793
|
+
]
|
|
794
|
+
},
|
|
768
795
|
/** @deprecated */
|
|
769
796
|
mode: {
|
|
770
797
|
type: literalUnion("dedicated", "discover").optional(() => "dedicated"),
|
|
@@ -1093,6 +1120,16 @@ var zeroOptions = {
|
|
|
1093
1120
|
`If it is the same as the {bold admin-password}, it grants admin access.`
|
|
1094
1121
|
]
|
|
1095
1122
|
},
|
|
1123
|
+
enableHeapz: {
|
|
1124
|
+
type: valita_exports.boolean().optional(() => true),
|
|
1125
|
+
desc: [
|
|
1126
|
+
`Serves heap snapshots of the zero-cache process at {bold /heapz} to the`,
|
|
1127
|
+
`{bold admin-password}. A heap snapshot contains everything the process`,
|
|
1128
|
+
`holds in memory, including the auth tokens, cookies and API keys of`,
|
|
1129
|
+
`connected clients. Set this to {bold false} to turn the endpoint off`,
|
|
1130
|
+
`while keeping the other diagnostic endpoints and the inspector.`
|
|
1131
|
+
]
|
|
1132
|
+
},
|
|
1096
1133
|
websocketCompression: {
|
|
1097
1134
|
type: valita_exports.boolean().optional(() => false),
|
|
1098
1135
|
desc: [
|
|
@@ -1594,15 +1631,16 @@ function getAccess(lc, { adminPassword }, operatorPassword, password) {
|
|
|
1594
1631
|
}
|
|
1595
1632
|
lc.warn?.(operatorPassword ? "Invalid admin or operator password" : "Invalid admin password");
|
|
1596
1633
|
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Compares `password` with `expected` in constant time. Returns `false` when
|
|
1636
|
+
* no `expected` password is configured.
|
|
1637
|
+
*/
|
|
1597
1638
|
function passwordMatches(password, expected) {
|
|
1598
1639
|
if (!expected) return false;
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
return false;
|
|
1604
|
-
}
|
|
1605
|
-
return timingSafeEqual(passwordBuffer, expectedBuffer);
|
|
1640
|
+
return timingSafeEqual(sha256(password ?? ""), sha256(expected));
|
|
1641
|
+
}
|
|
1642
|
+
function sha256(value) {
|
|
1643
|
+
return createHash("sha256").update(value).digest();
|
|
1606
1644
|
}
|
|
1607
1645
|
var hasWarned = false;
|
|
1608
1646
|
function warnOnce(lc, msg) {
|
|
@@ -1612,6 +1650,6 @@ function warnOnce(lc, msg) {
|
|
|
1612
1650
|
}
|
|
1613
1651
|
}
|
|
1614
1652
|
//#endregion
|
|
1615
|
-
export { ZERO_ENV_VAR_PREFIX, appOptions, getLogConfig, getNormalizedZeroConfig, getOperatorAccess, getServerVersion, getZeroConfig, isAdminPasswordValid, shardOptions, zeroOptions };
|
|
1653
|
+
export { ZERO_ENV_VAR_PREFIX, appOptions, getLogConfig, getNormalizedZeroConfig, getOperatorAccess, getServerVersion, getZeroConfig, isAdminPasswordValid, passwordMatches, shardOptions, zeroOptions };
|
|
1616
1654
|
|
|
1617
1655
|
//# sourceMappingURL=zero-config.js.map
|