@noy-db/core 0.1.0 → 0.2.0
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/README.md +56 -0
- package/dist/index.cjs +1 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -20
- package/dist/index.js.map +1 -1
- package/package.json +26 -9
package/dist/index.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
// src/env-check.ts
|
|
2
|
-
function checkEnvironment() {
|
|
3
|
-
if (typeof process !== "undefined" && process.versions?.node) {
|
|
4
|
-
const major = parseInt(process.versions.node.split(".")[0], 10);
|
|
5
|
-
if (major < 18) {
|
|
6
|
-
throw new Error(
|
|
7
|
-
`@noy-db/core requires Node.js 18 or later (found ${process.versions.node}). Node.js 18+ is required for the Web Crypto API (crypto.subtle).`
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
if (typeof globalThis.crypto?.subtle === "undefined") {
|
|
12
|
-
throw new Error(
|
|
13
|
-
"@noy-db/core requires the Web Crypto API (crypto.subtle). Ensure you are running Node.js 18+ or a modern browser (Chrome 63+, Firefox 57+, Safari 13+)."
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
checkEnvironment();
|
|
18
|
-
|
|
19
1
|
// src/types.ts
|
|
20
2
|
var NOYDB_FORMAT_VERSION = 1;
|
|
21
3
|
var NOYDB_KEYRING_VERSION = 1;
|
|
@@ -355,7 +337,6 @@ async function rotateKeys(adapter, compartment, callerKeyring, collections) {
|
|
|
355
337
|
const userEnvelope = await adapter.get(compartment, "_keyring", userId);
|
|
356
338
|
if (!userEnvelope) continue;
|
|
357
339
|
const userKeyringFile = JSON.parse(userEnvelope._data);
|
|
358
|
-
const userKek = null;
|
|
359
340
|
const updatedDeks = { ...userKeyringFile.deks };
|
|
360
341
|
for (const collName of collections) {
|
|
361
342
|
delete updatedDeks[collName];
|
|
@@ -487,7 +468,7 @@ async function saveHistory(adapter, compartment, collection, recordId, envelope)
|
|
|
487
468
|
async function getHistory(adapter, compartment, collection, recordId, options) {
|
|
488
469
|
const allIds = await adapter.list(compartment, HISTORY_COLLECTION);
|
|
489
470
|
const matchingIds = allIds.filter((id) => matchesPrefix(id, collection, recordId)).sort().reverse();
|
|
490
|
-
|
|
471
|
+
const entries = [];
|
|
491
472
|
for (const id of matchingIds) {
|
|
492
473
|
const envelope = await adapter.get(compartment, HISTORY_COLLECTION, id);
|
|
493
474
|
if (!envelope) continue;
|