mindoodb 0.0.49 → 0.0.51
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/browser/index.mjs +15 -0
- package/dist/core/BaseMindooDB.d.ts +6 -5
- package/dist/core/BaseMindooDB.d.ts.map +1 -1
- package/dist/core/BaseMindooDB.js +57 -4
- package/dist/core/BaseMindooDB.js.map +1 -1
- package/dist/core/BaseMindooTenant.d.ts.map +1 -1
- package/dist/core/BaseMindooTenant.js +21 -5
- package/dist/core/BaseMindooTenant.js.map +1 -1
- package/dist/core/BaseMindooTenantFactory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantFactory.js +8 -1
- package/dist/core/BaseMindooTenantFactory.js.map +1 -1
- package/dist/core/accesscontrol/types.d.ts +11 -6
- package/dist/core/accesscontrol/types.d.ts.map +1 -1
- package/dist/core/accesscontrol/types.js +13 -8
- package/dist/core/accesscontrol/types.js.map +1 -1
- package/dist/core/copy/flatten.js +1 -1
- package/dist/core/copy/flatten.js.map +1 -1
- package/dist/core/copy/types.d.ts +1 -1
- package/dist/core/databaseIdValidation.d.ts +23 -0
- package/dist/core/databaseIdValidation.d.ts.map +1 -1
- package/dist/core/databaseIdValidation.js +59 -1
- package/dist/core/databaseIdValidation.js.map +1 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +14 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/tenantSetup.d.ts +24 -0
- package/dist/core/tenantSetup.d.ts.map +1 -0
- package/dist/core/tenantSetup.js +62 -0
- package/dist/core/tenantSetup.js.map +1 -0
- package/dist/core/types.d.ts +98 -14
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +14 -9
- package/dist/core/types.js.map +1 -1
- package/dist/core/uri/joinRequestUri.d.ts +37 -0
- package/dist/core/uri/joinRequestUri.d.ts.map +1 -0
- package/dist/core/uri/joinRequestUri.js +159 -0
- package/dist/core/uri/joinRequestUri.js.map +1 -0
- package/dist/core/utils/idGeneration.d.ts +39 -20
- package/dist/core/utils/idGeneration.d.ts.map +1 -1
- package/dist/core/utils/idGeneration.js +82 -62
- package/dist/core/utils/idGeneration.js.map +1 -1
- package/dist/core/utils/index.d.ts +1 -1
- package/dist/core/utils/index.d.ts.map +1 -1
- package/dist/core/utils/index.js +4 -1
- package/dist/core/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeJoinRequestUri = encodeJoinRequestUri;
|
|
4
|
+
exports.decodeJoinRequestUri = decodeJoinRequestUri;
|
|
5
|
+
exports.normalizeJoinRequestPayload = normalizeJoinRequestPayload;
|
|
6
|
+
const MindooURI_1 = require("./MindooURI");
|
|
7
|
+
/** Transport version for the compact, PEM-stripped payload. */
|
|
8
|
+
const COMPACT_VERSION = 3;
|
|
9
|
+
const PEM_LABEL = "PUBLIC KEY";
|
|
10
|
+
const PEM_HEADER = `-----BEGIN ${PEM_LABEL}-----`;
|
|
11
|
+
const PEM_FOOTER = `-----END ${PEM_LABEL}-----`;
|
|
12
|
+
/** PEM wraps base64 at 64 characters; reproducing it exactly matters (see {@link toCompactKey}). */
|
|
13
|
+
const PEM_LINE_LENGTH = 64;
|
|
14
|
+
/**
|
|
15
|
+
* Generous ceiling for a single base64 key body. RSA-3072 SPKI is ~532
|
|
16
|
+
* characters; anything an order of magnitude beyond that is a malformed or
|
|
17
|
+
* hostile URI, not a key we could use.
|
|
18
|
+
*/
|
|
19
|
+
const MAX_KEY_BASE64_CHARS = 8192;
|
|
20
|
+
/** Guards against a username field used as a payload smuggling channel. */
|
|
21
|
+
const MAX_USERNAME_CHARS = 512;
|
|
22
|
+
/** Device labels are a short human note (§6.5), not free-form storage. */
|
|
23
|
+
const MAX_LABEL_CHARS = 256;
|
|
24
|
+
const BASE64_PATTERN = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
25
|
+
/** Rebuild the canonical PEM produced by `BaseMindooTenantFactory.uint8ArrayToPEM`. */
|
|
26
|
+
function toPem(base64) {
|
|
27
|
+
const chunks = base64.match(new RegExp(`.{1,${PEM_LINE_LENGTH}}`, "g")) ?? [];
|
|
28
|
+
return `${PEM_HEADER}\n${chunks.join("\n")}\n${PEM_FOOTER}`;
|
|
29
|
+
}
|
|
30
|
+
function toBareBase64(pem) {
|
|
31
|
+
return pem.replace(PEM_HEADER, "").replace(PEM_FOOTER, "").replace(/\s/g, "");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The bare base64 body of a PEM key, but only when re-wrapping it reproduces
|
|
35
|
+
* the input byte for byte.
|
|
36
|
+
*
|
|
37
|
+
* The directory compares public keys as exact strings when deciding whether a
|
|
38
|
+
* grant belongs to a known device (`BaseMindooTenantDirectory.registerUser`), so
|
|
39
|
+
* a request that came back from the wire differing by a single newline would
|
|
40
|
+
* register a second person instead of a second device. Rather than assume every
|
|
41
|
+
* PEM is canonically formatted, we verify the round-trip and fall back to the
|
|
42
|
+
* verbose encoding when it is not.
|
|
43
|
+
*/
|
|
44
|
+
function toCompactKey(pem) {
|
|
45
|
+
if (typeof pem !== "string") {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const bare = toBareBase64(pem);
|
|
49
|
+
if (!bare || bare.length > MAX_KEY_BASE64_CHARS || !BASE64_PATTERN.test(bare)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return toPem(bare) === pem ? bare : null;
|
|
53
|
+
}
|
|
54
|
+
function readCompactKey(value, field) {
|
|
55
|
+
if (typeof value !== "string" || !value) {
|
|
56
|
+
throw new Error(`Invalid join request: missing "${field}"`);
|
|
57
|
+
}
|
|
58
|
+
if (value.length > MAX_KEY_BASE64_CHARS || !BASE64_PATTERN.test(value)) {
|
|
59
|
+
throw new Error(`Invalid join request: "${field}" is not a base64 public key body`);
|
|
60
|
+
}
|
|
61
|
+
return toPem(value);
|
|
62
|
+
}
|
|
63
|
+
function readVerboseKey(value, field) {
|
|
64
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
65
|
+
throw new Error(`Invalid join request: missing "${field}"`);
|
|
66
|
+
}
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
function readOptionalText(value, max) {
|
|
70
|
+
if (typeof value !== "string") {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const trimmed = value.trim();
|
|
74
|
+
if (!trimmed) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
return trimmed.slice(0, max);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Encode a join request, preferring the compact `v: 3` payload.
|
|
81
|
+
*
|
|
82
|
+
* Falls back to the verbose form when either key is not canonically formatted
|
|
83
|
+
* PEM, so the exact string the directory will compare against always survives
|
|
84
|
+
* the round-trip.
|
|
85
|
+
*/
|
|
86
|
+
function encodeJoinRequestUri(request) {
|
|
87
|
+
const signing = toCompactKey(request.signingPublicKey);
|
|
88
|
+
const encryption = toCompactKey(request.encryptionPublicKey);
|
|
89
|
+
if (!signing || !encryption) {
|
|
90
|
+
return (0, MindooURI_1.encodeMindooURI)("join-request", request);
|
|
91
|
+
}
|
|
92
|
+
const payload = { v: COMPACT_VERSION, s: signing, e: encryption };
|
|
93
|
+
const username = readOptionalText(request.username, MAX_USERNAME_CHARS);
|
|
94
|
+
if (username) {
|
|
95
|
+
payload.u = username;
|
|
96
|
+
}
|
|
97
|
+
const label = readOptionalText(request.label, MAX_LABEL_CHARS);
|
|
98
|
+
if (label) {
|
|
99
|
+
payload.l = label;
|
|
100
|
+
}
|
|
101
|
+
return (0, MindooURI_1.encodeMindooURI)("join-request", payload);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Decode any supported `mdb://join-request/...` URI into a {@link JoinRequest}
|
|
105
|
+
* with PEM-armored keys, regardless of which transport version produced it.
|
|
106
|
+
*
|
|
107
|
+
* Unknown versions are rejected rather than best-effort parsed: silently
|
|
108
|
+
* dropping a field a future version added could register a device under the
|
|
109
|
+
* wrong assumptions.
|
|
110
|
+
*/
|
|
111
|
+
function decodeJoinRequestUri(uri) {
|
|
112
|
+
const decoded = (0, MindooURI_1.decodeMindooURI)(uri);
|
|
113
|
+
if (decoded.type !== "join-request") {
|
|
114
|
+
throw new Error(`Invalid URI type: expected "join-request", got "${decoded.type}"`);
|
|
115
|
+
}
|
|
116
|
+
return normalizeJoinRequestPayload(decoded.payload, decoded.version);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Normalize a decoded join-request payload of any transport version into the
|
|
120
|
+
* PEM-armored {@link JoinRequest} shape the rest of the SDK works with.
|
|
121
|
+
*/
|
|
122
|
+
function normalizeJoinRequestPayload(payload, version) {
|
|
123
|
+
if (version === COMPACT_VERSION) {
|
|
124
|
+
const username = readOptionalText(payload.u, MAX_USERNAME_CHARS);
|
|
125
|
+
const label = readOptionalText(payload.l, MAX_LABEL_CHARS);
|
|
126
|
+
const request = {
|
|
127
|
+
// The compact form is a transport detail; the semantic version is still
|
|
128
|
+
// "named" (1) vs. "the admin names it" (2), derived from the payload.
|
|
129
|
+
v: username ? 1 : 2,
|
|
130
|
+
signingPublicKey: readCompactKey(payload.s, "s"),
|
|
131
|
+
encryptionPublicKey: readCompactKey(payload.e, "e"),
|
|
132
|
+
};
|
|
133
|
+
if (username) {
|
|
134
|
+
request.username = username;
|
|
135
|
+
}
|
|
136
|
+
if (label) {
|
|
137
|
+
request.label = label;
|
|
138
|
+
}
|
|
139
|
+
return request;
|
|
140
|
+
}
|
|
141
|
+
if (version === 1 || version === 2) {
|
|
142
|
+
const username = readOptionalText(payload.username, MAX_USERNAME_CHARS);
|
|
143
|
+
const label = readOptionalText(payload.label, MAX_LABEL_CHARS);
|
|
144
|
+
const request = {
|
|
145
|
+
v: version,
|
|
146
|
+
signingPublicKey: readVerboseKey(payload.signingPublicKey, "signingPublicKey"),
|
|
147
|
+
encryptionPublicKey: readVerboseKey(payload.encryptionPublicKey, "encryptionPublicKey"),
|
|
148
|
+
};
|
|
149
|
+
if (username) {
|
|
150
|
+
request.username = username;
|
|
151
|
+
}
|
|
152
|
+
if (label) {
|
|
153
|
+
request.label = label;
|
|
154
|
+
}
|
|
155
|
+
return request;
|
|
156
|
+
}
|
|
157
|
+
throw new Error(`Unsupported join request version ${version}. Update this client to accept it.`);
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=joinRequestUri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joinRequestUri.js","sourceRoot":"","sources":["../../../src/core/uri/joinRequestUri.ts"],"names":[],"mappings":";;AA6GA,oDAoBC;AAUD,oDAMC;AAMD,kEA2CC;AAnLD,2CAA+D;AAE/D,+DAA+D;AAC/D,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,MAAM,UAAU,GAAG,cAAc,SAAS,OAAO,CAAC;AAClD,MAAM,UAAU,GAAG,YAAY,SAAS,OAAO,CAAC;AAEhD,oGAAoG;AACpG,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,0EAA0E;AAC1E,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEhD,uFAAuF;AACvF,SAAS,KAAK,CAAC,MAAc;IAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9E,OAAO,GAAG,UAAU,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;AAC9D,CAAC;AAED,SAAS,YAAY,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,CAAC,CAAC;QACxE,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAgB;YAC3B,CAAC,EAAE,OAAO;YACV,gBAAgB,EAAE,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;YAC9E,mBAAmB,EAAE,cAAc,CAAC,OAAO,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;SACxF,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC9B,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACxB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,KAAK,CACb,oCAAoC,OAAO,oCAAoC,CAChF,CAAC;AACJ,CAAC"}
|
|
@@ -7,30 +7,50 @@
|
|
|
7
7
|
* - Debugging visibility into entry relationships
|
|
8
8
|
* - Blockchain-like integrity for document entries
|
|
9
9
|
*/
|
|
10
|
+
/** MongoDB-style ObjectId length: 12 bytes → 24 lowercase hex chars. */
|
|
11
|
+
export declare const OBJECT_ID_LENGTH = 24;
|
|
10
12
|
/**
|
|
11
|
-
* Generate a
|
|
12
|
-
* fixed-length (22 char), left-zero-padded base62 string, optionally prefixed
|
|
13
|
-
* with `<prefix>_`.
|
|
13
|
+
* Generate a MongoDB-style ObjectId: 24 lowercase hex characters.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* Layout (12 bytes):
|
|
16
|
+
* - 4-byte big-endian Unix timestamp (seconds)
|
|
17
|
+
* - 5-byte process-unique random value
|
|
18
|
+
* - 3-byte big-endian incrementing counter
|
|
19
|
+
*
|
|
20
|
+
* Leading timestamp bytes make ids lexicographically sortable by creation
|
|
21
|
+
* time. The alphabet is `0-9a-f` only — safe on case-insensitive filesystems.
|
|
22
|
+
*
|
|
23
|
+
* @param timeSeconds Optional Unix timestamp in seconds (for tests). Defaults
|
|
24
|
+
* to `Math.floor(Date.now() / 1000)`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateObjectId(timeSeconds?: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* Generate a fresh, globally unique document id: a MongoDB-style ObjectId
|
|
29
|
+
* (24-char lowercase hex), optionally prefixed with `<prefix>_`.
|
|
30
|
+
*
|
|
31
|
+
* Because the ObjectId timestamp occupies the leading bytes, ids generated
|
|
32
|
+
* later sort lexicographically after earlier ones (within the same prefix).
|
|
19
33
|
*
|
|
20
34
|
* The prefix (if any) is NOT validated here; callers validate it against
|
|
21
35
|
* `DOC_ID_PREFIX_REGEX` before invoking this.
|
|
22
36
|
*
|
|
23
37
|
* @param prefix Optional short application prefix (e.g. "cls"); joined with "_".
|
|
24
|
-
* @returns e.g. "
|
|
38
|
+
* @returns e.g. "507f1f77bcf86cd799439011" or "cls_507f1f77bcf86cd799439011"
|
|
25
39
|
*/
|
|
26
40
|
export declare function generateDocId(prefix?: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Generate a fresh tenant id: MongoDB-style ObjectId (24-char lowercase hex).
|
|
43
|
+
* Same format as {@link generateDocId} without a prefix — unique, time-sortable,
|
|
44
|
+
* and case-insensitive-filesystem safe.
|
|
45
|
+
*/
|
|
46
|
+
export declare function generateTenantId(): string;
|
|
27
47
|
/**
|
|
28
48
|
* Boundary-aware document-id prefix match used by prefix-filtered listing and
|
|
29
49
|
* changefeed iteration.
|
|
30
50
|
*
|
|
31
51
|
* A `docId` matches `idPrefix` when it either equals the prefix exactly or
|
|
32
52
|
* begins with `<idPrefix>_`. Matching on the `_` boundary (rather than a raw
|
|
33
|
-
* `startsWith`) mirrors the `<prefix>_<
|
|
53
|
+
* `startsWith`) mirrors the `<prefix>_<objectId>` id scheme, so filtering by
|
|
34
54
|
* `"cls"` returns `cls_…` documents without also catching an unrelated prefix
|
|
35
55
|
* like `classroom_…`.
|
|
36
56
|
*
|
|
@@ -65,25 +85,24 @@ export declare function generateDocEntryId(docId: string, automergeHash: string,
|
|
|
65
85
|
export declare function generateDepsFingerprint(dependencyAutomergeHashes: string[], subtle: SubtleCrypto): Promise<string>;
|
|
66
86
|
/**
|
|
67
87
|
* Generate an attachment chunk ID.
|
|
68
|
-
* Format: <docId>_a_<fileUuid7>_<
|
|
88
|
+
* Format: <docId>_a_<fileUuid7>_<objectId>
|
|
69
89
|
*
|
|
70
90
|
* @param docId The document ID this attachment belongs to
|
|
71
91
|
* @param fileUuid7 The UUID7 for the whole file (same for all chunks)
|
|
72
|
-
* @param
|
|
92
|
+
* @param chunkObjectId Optional 24-char ObjectId for this chunk. If omitted, a
|
|
93
|
+
* fresh ObjectId is generated.
|
|
73
94
|
* @returns The generated chunk ID
|
|
74
95
|
*/
|
|
75
|
-
export declare function generateAttachmentChunkId(docId: string, fileUuid7: string,
|
|
96
|
+
export declare function generateAttachmentChunkId(docId: string, fileUuid7: string, chunkObjectId?: string): string;
|
|
76
97
|
/**
|
|
77
98
|
* Generate an attachment chunk id that is unique within one write operation
|
|
78
99
|
* even under case-insensitive comparison.
|
|
79
100
|
*
|
|
80
|
-
* Chunk entry ids become on-disk filenames (`entries/<id>.json`)
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* unlikely) fold-collision the id is simply regenerated. The set is expected
|
|
86
|
-
* to be scoped to a single attachment write, so there is no persistent cost.
|
|
101
|
+
* Chunk entry ids become on-disk filenames (`entries/<id>.json`). New chunk
|
|
102
|
+
* suffixes are lowercase ObjectIds, but legacy mixed-case suffixes may still
|
|
103
|
+
* appear; the caller passes a set of case-folded ids already used in the
|
|
104
|
+
* current write and on a fold-collision the id is regenerated. The set is
|
|
105
|
+
* expected to be scoped to a single attachment write.
|
|
87
106
|
*
|
|
88
107
|
* @param docId The document ID this attachment belongs to
|
|
89
108
|
* @param fileUuid7 The UUID7 for the whole file (same for all chunks)
|
|
@@ -126,7 +145,7 @@ export declare function parseDocEntryId(id: string): {
|
|
|
126
145
|
export declare function parseAttachmentChunkId(id: string): {
|
|
127
146
|
docId: string;
|
|
128
147
|
fileUuid7: string;
|
|
129
|
-
|
|
148
|
+
chunkObjectId: string;
|
|
130
149
|
} | null;
|
|
131
150
|
/**
|
|
132
151
|
* Check if an ID is a document entry ID (contains "_d_").
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idGeneration.d.ts","sourceRoot":"","sources":["../../../src/core/utils/idGeneration.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"idGeneration.d.ts","sourceRoot":"","sources":["../../../src/core/utils/idGeneration.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAgCnC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAa7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,yBAAyB,EAAE,MAAM,EAAE,EACnC,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,yBAAyB,EAAE,MAAM,EAAE,EACnC,MAAM,EAAE,YAAY,GAC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for document entries
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OBJECT_ID_LENGTH = void 0;
|
|
13
|
+
exports.generateObjectId = generateObjectId;
|
|
12
14
|
exports.generateDocId = generateDocId;
|
|
15
|
+
exports.generateTenantId = generateTenantId;
|
|
13
16
|
exports.matchesDocIdPrefix = matchesDocIdPrefix;
|
|
14
17
|
exports.generateDocEntryId = generateDocEntryId;
|
|
15
18
|
exports.generateDepsFingerprint = generateDepsFingerprint;
|
|
@@ -24,75 +27,94 @@ exports.isAttachmentChunkId = isAttachmentChunkId;
|
|
|
24
27
|
exports.extractDocIdFromEntryId = extractDocIdFromEntryId;
|
|
25
28
|
exports.computeContentHash = computeContentHash;
|
|
26
29
|
const uuid_1 = require("uuid");
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const UUID_NO_DASH_LENGTH = 32;
|
|
35
|
-
const BASE62_UUID_LENGTH = 22;
|
|
36
|
-
function trimLeft(target, length) {
|
|
37
|
-
let trim = 0;
|
|
38
|
-
while (target[trim] === "0" && target.length - trim > length) {
|
|
39
|
-
trim++;
|
|
30
|
+
/** MongoDB-style ObjectId length: 12 bytes → 24 lowercase hex chars. */
|
|
31
|
+
exports.OBJECT_ID_LENGTH = 24;
|
|
32
|
+
function randomBytes(length) {
|
|
33
|
+
const bytes = new Uint8Array(length);
|
|
34
|
+
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
35
|
+
crypto.getRandomValues(bytes);
|
|
36
|
+
return bytes;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function ensureLength(target, length) {
|
|
44
|
-
if (target.length < length) {
|
|
45
|
-
return target.padStart(length, "0");
|
|
38
|
+
for (let i = 0; i < length; i++) {
|
|
39
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
return trimLeft(target, length);
|
|
49
|
-
}
|
|
50
|
-
return target;
|
|
41
|
+
return bytes;
|
|
51
42
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
let value = BigInt(`0x${normalized}`);
|
|
58
|
-
if (value === 0n) {
|
|
59
|
-
return "0".repeat(BASE62_UUID_LENGTH);
|
|
43
|
+
function bytesToHex(bytes) {
|
|
44
|
+
let out = "";
|
|
45
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
46
|
+
out += bytes[i].toString(16).padStart(2, "0");
|
|
60
47
|
}
|
|
61
|
-
|
|
62
|
-
while (value > 0n) {
|
|
63
|
-
const digit = Number(value % 62n);
|
|
64
|
-
encoded = BASE62_ALPHABET[digit] + encoded;
|
|
65
|
-
value /= 62n;
|
|
66
|
-
}
|
|
67
|
-
return ensureLength(encoded, BASE62_UUID_LENGTH);
|
|
48
|
+
return out;
|
|
68
49
|
}
|
|
69
50
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
51
|
+
* Process-unique 5-byte machine/process id (MongoDB ObjectId layout).
|
|
52
|
+
* Regenerated once per JS realm so concurrent realms don't share the same
|
|
53
|
+
* random prefix.
|
|
54
|
+
*/
|
|
55
|
+
const OBJECT_ID_PROCESS_UNIQUE = randomBytes(5);
|
|
56
|
+
/** 3-byte counter; seeded randomly then incremented per id (wraps at 2^24). */
|
|
57
|
+
let objectIdCounter = Math.floor(Math.random() * 0xffffff);
|
|
58
|
+
/**
|
|
59
|
+
* Generate a MongoDB-style ObjectId: 24 lowercase hex characters.
|
|
60
|
+
*
|
|
61
|
+
* Layout (12 bytes):
|
|
62
|
+
* - 4-byte big-endian Unix timestamp (seconds)
|
|
63
|
+
* - 5-byte process-unique random value
|
|
64
|
+
* - 3-byte big-endian incrementing counter
|
|
73
65
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
66
|
+
* Leading timestamp bytes make ids lexicographically sortable by creation
|
|
67
|
+
* time. The alphabet is `0-9a-f` only — safe on case-insensitive filesystems.
|
|
68
|
+
*
|
|
69
|
+
* @param timeSeconds Optional Unix timestamp in seconds (for tests). Defaults
|
|
70
|
+
* to `Math.floor(Date.now() / 1000)`.
|
|
71
|
+
*/
|
|
72
|
+
function generateObjectId(timeSeconds) {
|
|
73
|
+
const seconds = timeSeconds ?? Math.floor(Date.now() / 1000);
|
|
74
|
+
const bytes = new Uint8Array(12);
|
|
75
|
+
bytes[0] = (seconds >>> 24) & 0xff;
|
|
76
|
+
bytes[1] = (seconds >>> 16) & 0xff;
|
|
77
|
+
bytes[2] = (seconds >>> 8) & 0xff;
|
|
78
|
+
bytes[3] = seconds & 0xff;
|
|
79
|
+
bytes.set(OBJECT_ID_PROCESS_UNIQUE, 4);
|
|
80
|
+
objectIdCounter = (objectIdCounter + 1) & 0xffffff;
|
|
81
|
+
bytes[9] = (objectIdCounter >>> 16) & 0xff;
|
|
82
|
+
bytes[10] = (objectIdCounter >>> 8) & 0xff;
|
|
83
|
+
bytes[11] = objectIdCounter & 0xff;
|
|
84
|
+
return bytesToHex(bytes);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generate a fresh, globally unique document id: a MongoDB-style ObjectId
|
|
88
|
+
* (24-char lowercase hex), optionally prefixed with `<prefix>_`.
|
|
89
|
+
*
|
|
90
|
+
* Because the ObjectId timestamp occupies the leading bytes, ids generated
|
|
91
|
+
* later sort lexicographically after earlier ones (within the same prefix).
|
|
78
92
|
*
|
|
79
93
|
* The prefix (if any) is NOT validated here; callers validate it against
|
|
80
94
|
* `DOC_ID_PREFIX_REGEX` before invoking this.
|
|
81
95
|
*
|
|
82
96
|
* @param prefix Optional short application prefix (e.g. "cls"); joined with "_".
|
|
83
|
-
* @returns e.g. "
|
|
97
|
+
* @returns e.g. "507f1f77bcf86cd799439011" or "cls_507f1f77bcf86cd799439011"
|
|
84
98
|
*/
|
|
85
99
|
function generateDocId(prefix) {
|
|
86
|
-
const encoded =
|
|
100
|
+
const encoded = generateObjectId();
|
|
87
101
|
return prefix ? `${prefix}_${encoded}` : encoded;
|
|
88
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Generate a fresh tenant id: MongoDB-style ObjectId (24-char lowercase hex).
|
|
105
|
+
* Same format as {@link generateDocId} without a prefix — unique, time-sortable,
|
|
106
|
+
* and case-insensitive-filesystem safe.
|
|
107
|
+
*/
|
|
108
|
+
function generateTenantId() {
|
|
109
|
+
return generateObjectId();
|
|
110
|
+
}
|
|
89
111
|
/**
|
|
90
112
|
* Boundary-aware document-id prefix match used by prefix-filtered listing and
|
|
91
113
|
* changefeed iteration.
|
|
92
114
|
*
|
|
93
115
|
* A `docId` matches `idPrefix` when it either equals the prefix exactly or
|
|
94
116
|
* begins with `<idPrefix>_`. Matching on the `_` boundary (rather than a raw
|
|
95
|
-
* `startsWith`) mirrors the `<prefix>_<
|
|
117
|
+
* `startsWith`) mirrors the `<prefix>_<objectId>` id scheme, so filtering by
|
|
96
118
|
* `"cls"` returns `cls_…` documents without also catching an unrelated prefix
|
|
97
119
|
* like `classroom_…`.
|
|
98
120
|
*
|
|
@@ -146,29 +168,27 @@ async function generateDepsFingerprint(dependencyAutomergeHashes, subtle) {
|
|
|
146
168
|
}
|
|
147
169
|
/**
|
|
148
170
|
* Generate an attachment chunk ID.
|
|
149
|
-
* Format: <docId>_a_<fileUuid7>_<
|
|
171
|
+
* Format: <docId>_a_<fileUuid7>_<objectId>
|
|
150
172
|
*
|
|
151
173
|
* @param docId The document ID this attachment belongs to
|
|
152
174
|
* @param fileUuid7 The UUID7 for the whole file (same for all chunks)
|
|
153
|
-
* @param
|
|
175
|
+
* @param chunkObjectId Optional 24-char ObjectId for this chunk. If omitted, a
|
|
176
|
+
* fresh ObjectId is generated.
|
|
154
177
|
* @returns The generated chunk ID
|
|
155
178
|
*/
|
|
156
|
-
function generateAttachmentChunkId(docId, fileUuid7,
|
|
157
|
-
const chunkId =
|
|
158
|
-
|
|
159
|
-
return `${docId}_a_${fileUuid7}_${base62Chunk}`;
|
|
179
|
+
function generateAttachmentChunkId(docId, fileUuid7, chunkObjectId) {
|
|
180
|
+
const chunkId = chunkObjectId ?? generateObjectId();
|
|
181
|
+
return `${docId}_a_${fileUuid7}_${chunkId}`;
|
|
160
182
|
}
|
|
161
183
|
/**
|
|
162
184
|
* Generate an attachment chunk id that is unique within one write operation
|
|
163
185
|
* even under case-insensitive comparison.
|
|
164
186
|
*
|
|
165
|
-
* Chunk entry ids become on-disk filenames (`entries/<id>.json`)
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* unlikely) fold-collision the id is simply regenerated. The set is expected
|
|
171
|
-
* to be scoped to a single attachment write, so there is no persistent cost.
|
|
187
|
+
* Chunk entry ids become on-disk filenames (`entries/<id>.json`). New chunk
|
|
188
|
+
* suffixes are lowercase ObjectIds, but legacy mixed-case suffixes may still
|
|
189
|
+
* appear; the caller passes a set of case-folded ids already used in the
|
|
190
|
+
* current write and on a fold-collision the id is regenerated. The set is
|
|
191
|
+
* expected to be scoped to a single attachment write.
|
|
172
192
|
*
|
|
173
193
|
* @param docId The document ID this attachment belongs to
|
|
174
194
|
* @param fileUuid7 The UUID7 for the whole file (same for all chunks)
|
|
@@ -229,14 +249,14 @@ function parseDocEntryId(id) {
|
|
|
229
249
|
* @returns The parsed components, or null if the ID doesn't match the expected format
|
|
230
250
|
*/
|
|
231
251
|
function parseAttachmentChunkId(id) {
|
|
232
|
-
// Match: <docId>_a_<fileUuid7>_<
|
|
252
|
+
// Match: <docId>_a_<fileUuid7>_<chunkObjectId> (legacy suffixes also parse)
|
|
233
253
|
const match = id.match(/^(.+)_a_([^_]+)_(.+)$/);
|
|
234
254
|
if (!match)
|
|
235
255
|
return null;
|
|
236
256
|
return {
|
|
237
257
|
docId: match[1],
|
|
238
258
|
fileUuid7: match[2],
|
|
239
|
-
|
|
259
|
+
chunkObjectId: match[3],
|
|
240
260
|
};
|
|
241
261
|
}
|
|
242
262
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idGeneration.js","sourceRoot":"","sources":["../../../src/core/utils/idGeneration.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG
|
|
1
|
+
{"version":3,"file":"idGeneration.js","sourceRoot":"","sources":["../../../src/core/utils/idGeneration.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAmDH,4CAaC;AAeD,sCAGC;AAOD,4CAEC;AAiBD,gDAGC;AAeD,gDAQC;AAUD,0DAgBC;AAYD,8DAOC;AAkBD,0EAaC;AAQD,8CAEC;AAQD,gDAEC;AAQD,0CAcC;AAQD,wDAaC;AAQD,oCAEC;AAQD,kDAEC;AAQD,0DASC;AAUD,gDAUC;AAxUD,+BAAoC;AAEpC,wEAAwE;AAC3D,QAAA,gBAAgB,GAAG,EAAE,CAAC;AAEnC,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAClF,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,KAAiB;IACnC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,G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AAC,CAAC;QAC1C,OAAO,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;IAC/B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,kBAAkB,CACtC,IAAgB,EAChB,MAAoB;IAEpB,sEAAsE;IACtE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAgB,CAAC;IACpG,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;SAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACzC,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core utility functions for MindooDB.
|
|
3
3
|
*/
|
|
4
|
-
export { generateDocId, matchesDocIdPrefix, generateDocEntryId, generateDepsFingerprint, generateAttachmentChunkId, generateUniqueAttachmentChunkId, generateFileUuid7, generateChunkUuid7, parseDocEntryId, parseAttachmentChunkId, isDocEntryId, isAttachmentChunkId, extractDocIdFromEntryId, computeContentHash, } from './idGeneration';
|
|
4
|
+
export { generateObjectId, OBJECT_ID_LENGTH, generateDocId, generateTenantId, matchesDocIdPrefix, generateDocEntryId, generateDepsFingerprint, generateAttachmentChunkId, generateUniqueAttachmentChunkId, generateFileUuid7, generateChunkUuid7, parseDocEntryId, parseAttachmentChunkId, isDocEntryId, isAttachmentChunkId, extractDocIdFromEntryId, computeContentHash, } from './idGeneration';
|
|
5
5
|
export { semanticNow, setSemanticTimeSourceForTesting, createQuantizedTimeSource, } from './timeSource';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,+BAA+B,EAC/B,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,+BAA+B,EAC/B,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,cAAc,CAAC"}
|
package/dist/core/utils/index.js
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* Core utility functions for MindooDB.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createQuantizedTimeSource = exports.setSemanticTimeSourceForTesting = exports.semanticNow = exports.computeContentHash = exports.extractDocIdFromEntryId = exports.isAttachmentChunkId = exports.isDocEntryId = exports.parseAttachmentChunkId = exports.parseDocEntryId = exports.generateChunkUuid7 = exports.generateFileUuid7 = exports.generateUniqueAttachmentChunkId = exports.generateAttachmentChunkId = exports.generateDepsFingerprint = exports.generateDocEntryId = exports.matchesDocIdPrefix = exports.generateDocId = void 0;
|
|
6
|
+
exports.createQuantizedTimeSource = exports.setSemanticTimeSourceForTesting = exports.semanticNow = exports.computeContentHash = exports.extractDocIdFromEntryId = exports.isAttachmentChunkId = exports.isDocEntryId = exports.parseAttachmentChunkId = exports.parseDocEntryId = exports.generateChunkUuid7 = exports.generateFileUuid7 = exports.generateUniqueAttachmentChunkId = exports.generateAttachmentChunkId = exports.generateDepsFingerprint = exports.generateDocEntryId = exports.matchesDocIdPrefix = exports.generateTenantId = exports.generateDocId = exports.OBJECT_ID_LENGTH = exports.generateObjectId = void 0;
|
|
7
7
|
var idGeneration_1 = require("./idGeneration");
|
|
8
|
+
Object.defineProperty(exports, "generateObjectId", { enumerable: true, get: function () { return idGeneration_1.generateObjectId; } });
|
|
9
|
+
Object.defineProperty(exports, "OBJECT_ID_LENGTH", { enumerable: true, get: function () { return idGeneration_1.OBJECT_ID_LENGTH; } });
|
|
8
10
|
Object.defineProperty(exports, "generateDocId", { enumerable: true, get: function () { return idGeneration_1.generateDocId; } });
|
|
11
|
+
Object.defineProperty(exports, "generateTenantId", { enumerable: true, get: function () { return idGeneration_1.generateTenantId; } });
|
|
9
12
|
Object.defineProperty(exports, "matchesDocIdPrefix", { enumerable: true, get: function () { return idGeneration_1.matchesDocIdPrefix; } });
|
|
10
13
|
Object.defineProperty(exports, "generateDocEntryId", { enumerable: true, get: function () { return idGeneration_1.generateDocEntryId; } });
|
|
11
14
|
Object.defineProperty(exports, "generateDepsFingerprint", { enumerable: true, get: function () { return idGeneration_1.generateDepsFingerprint; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,+CAkBwB;AAjBtB,gHAAA,gBAAgB,OAAA;AAChB,gHAAA,gBAAgB,OAAA;AAChB,6GAAA,aAAa,OAAA;AACb,gHAAA,gBAAgB,OAAA;AAChB,kHAAA,kBAAkB,OAAA;AAClB,kHAAA,kBAAkB,OAAA;AAClB,uHAAA,uBAAuB,OAAA;AACvB,yHAAA,yBAAyB,OAAA;AACzB,+HAAA,+BAA+B,OAAA;AAC/B,iHAAA,iBAAiB,OAAA;AACjB,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AACf,sHAAA,sBAAsB,OAAA;AACtB,4GAAA,YAAY,OAAA;AACZ,mHAAA,mBAAmB,OAAA;AACnB,uHAAA,uBAAuB,OAAA;AACvB,kHAAA,kBAAkB,OAAA;AAGpB,2CAIsB;AAHpB,yGAAA,WAAW,OAAA;AACX,6HAAA,+BAA+B,OAAA;AAC/B,uHAAA,yBAAyB,OAAA"}
|