@interop/was-client 0.30.0 → 0.32.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 +25 -0
- package/dist/codec.d.ts +1 -1
- package/dist/edv/descriptorStore.d.ts +13 -9
- package/dist/edv/descriptorStore.d.ts.map +1 -1
- package/dist/edv/descriptorStore.js +5 -3
- package/dist/edv/descriptorStore.js.map +1 -1
- package/dist/edv/epochKeys.d.ts.map +1 -1
- package/dist/edv/epochKeys.js +10 -46
- package/dist/edv/epochKeys.js.map +1 -1
- package/dist/edv/index.d.ts +0 -2
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +0 -1
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/recipients.d.ts +5 -24
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +18 -90
- package/dist/edv/recipients.js.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/conditional.d.ts +3 -3
- package/dist/internal/conditional.d.ts.map +1 -1
- package/dist/internal/conditional.js +4 -4
- package/dist/internal/conditional.js.map +1 -1
- package/dist/log/index.d.ts +24 -0
- package/dist/log/index.d.ts.map +1 -0
- package/dist/log/index.js +22 -0
- package/dist/log/index.js.map +1 -0
- package/dist/log/jsonl.d.ts +49 -0
- package/dist/log/jsonl.d.ts.map +1 -0
- package/dist/log/jsonl.js +60 -0
- package/dist/log/jsonl.js.map +1 -0
- package/dist/log/logStore.d.ts +95 -0
- package/dist/log/logStore.d.ts.map +1 -0
- package/dist/log/logStore.js +123 -0
- package/dist/log/logStore.js.map +1 -0
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +1 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/port.d.ts +2 -2
- package/dist/sync/port.d.ts.map +1 -1
- package/dist/sync/port.js +2 -2
- package/dist/sync/port.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -2
- package/dist/edv/epochMac.d.ts +0 -56
- package/dist/edv/epochMac.d.ts.map +0 -1
- package/dist/edv/epochMac.js +0 -148
- package/dist/edv/epochMac.js.map +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ValidationError } from '../errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a resource-log body into its entries, strictly: the text must be one
|
|
4
|
+
* JSON object per line, with an optional single trailing newline. Any empty
|
|
5
|
+
* line, non-JSON line, or line holding a non-object JSON value (an array, a
|
|
6
|
+
* string, a number, `null`) fails the whole parse. An empty body fails too --
|
|
7
|
+
* a log has at least its genesis entry (an absent resource is the store
|
|
8
|
+
* seam's `null`, not an empty body).
|
|
9
|
+
*
|
|
10
|
+
* @param text {string} the log resource's body
|
|
11
|
+
* @returns {ResourceLogEntry[]} the parsed entries, first line first
|
|
12
|
+
*/
|
|
13
|
+
export function parseResourceLog(text) {
|
|
14
|
+
const body = text.endsWith('\n') ? text.slice(0, -1) : text;
|
|
15
|
+
if (body === '') {
|
|
16
|
+
throw new ValidationError('Cannot parse resource log: the body is empty (a log carries at least ' +
|
|
17
|
+
'its genesis entry).');
|
|
18
|
+
}
|
|
19
|
+
return body.split('\n').map((line, index) => {
|
|
20
|
+
let parsed;
|
|
21
|
+
try {
|
|
22
|
+
parsed = JSON.parse(line);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
throw new ValidationError(`Cannot parse resource log: line ${index + 1} is not valid JSON.`, { cause: err });
|
|
26
|
+
}
|
|
27
|
+
if (parsed === null ||
|
|
28
|
+
typeof parsed !== 'object' ||
|
|
29
|
+
Array.isArray(parsed)) {
|
|
30
|
+
throw new ValidationError(`Cannot parse resource log: line ${index + 1} is not a JSON object.`);
|
|
31
|
+
}
|
|
32
|
+
return parsed;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Serializes one log entry as its single JSON Lines line, without the line
|
|
37
|
+
* separator. `JSON.stringify` escapes any newline inside string values, so the
|
|
38
|
+
* result never contains an embedded U+000A.
|
|
39
|
+
*
|
|
40
|
+
* @param entry {ResourceLogEntry}
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
export function serializeResourceLogEntry(entry) {
|
|
44
|
+
return JSON.stringify(entry);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Serializes a full resource log as JSON Lines: one entry per line, in order,
|
|
48
|
+
* with a terminating newline. Refuses an empty log (a log carries at least
|
|
49
|
+
* its genesis entry).
|
|
50
|
+
*
|
|
51
|
+
* @param entries {ResourceLogEntry[]}
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
export function serializeResourceLog(entries) {
|
|
55
|
+
if (entries.length === 0) {
|
|
56
|
+
throw new ValidationError('Cannot serialize resource log: a log carries at least its genesis entry.');
|
|
57
|
+
}
|
|
58
|
+
return entries.map(serializeResourceLogEntry).join('\n') + '\n';
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=jsonl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../src/log/jsonl.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC3D,IAAI,IAAI,KAAK,EAAE,EAAE,CAA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/**
|
|
4
|
+
* The content type a resource log is stored under (JSON Lines, not JSON --
|
|
5
|
+
* load-bearing: a JSON content type would have the request layer parse and
|
|
6
|
+
* re-serialize the body, losing the line framing).
|
|
7
|
+
*/
|
|
8
|
+
export declare const LOG_CONTENT_TYPE = "text/jsonl";
|
|
9
|
+
/**
|
|
10
|
+
* Where a resource log lives: a read-with-validator, a compare-and-swap
|
|
11
|
+
* append, and a guarded genesis create. Implementations host the log anywhere
|
|
12
|
+
* a versioned text resource can live; the shipped adapter is
|
|
13
|
+
* {@link resourceLogStore}.
|
|
14
|
+
*/
|
|
15
|
+
export interface ResourceLogStore {
|
|
16
|
+
/**
|
|
17
|
+
* Reads the full log together with the opaque `etag` validator the next
|
|
18
|
+
* {@link append} must be compare-and-swapped against. Resolves `null` when
|
|
19
|
+
* the log resource does not exist yet (the pre-genesis state -- see
|
|
20
|
+
* {@link create}); throws on a body that does not parse as strict JSON
|
|
21
|
+
* Lines. `etag` is absent against a backend that does not version resources
|
|
22
|
+
* -- a caller MUST NOT append without one (the profile forbids falling back
|
|
23
|
+
* to an unconditional write).
|
|
24
|
+
*
|
|
25
|
+
* @returns {Promise<{ entries: ResourceLogEntry[]; etag?: string } | null>}
|
|
26
|
+
*/
|
|
27
|
+
read(): Promise<{
|
|
28
|
+
entries: ResourceLogEntry[];
|
|
29
|
+
etag?: string;
|
|
30
|
+
} | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Appends one entry to the log read by the most recent {@link read} on this
|
|
33
|
+
* store instance, compare-and-swapped against `ifMatch` (the validator that
|
|
34
|
+
* read returned); a stale validator throws `PreconditionFailedError` (412),
|
|
35
|
+
* and the caller re-reads, re-verifies, rebases the entry on the new head,
|
|
36
|
+
* and retries. The prior entries' bytes are carried forward verbatim from
|
|
37
|
+
* the read, with the new entry's line appended -- an append never
|
|
38
|
+
* re-serializes history.
|
|
39
|
+
*
|
|
40
|
+
* @param entry {ResourceLogEntry} the entry extending the log
|
|
41
|
+
* @param options {object}
|
|
42
|
+
* @param options.ifMatch {string} the validator from the prior read
|
|
43
|
+
* @returns {Promise<void>}
|
|
44
|
+
*/
|
|
45
|
+
append(entry: ResourceLogEntry, options: {
|
|
46
|
+
ifMatch: string;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates the log with its genesis entry where {@link read} resolved `null`,
|
|
50
|
+
* guarded create-if-absent (`If-None-Match: *`); throws
|
|
51
|
+
* `PreconditionFailedError` (412) when a concurrent writer created the log
|
|
52
|
+
* first.
|
|
53
|
+
*
|
|
54
|
+
* @param entry {ResourceLogEntry} the genesis entry
|
|
55
|
+
* @returns {Promise<void>}
|
|
56
|
+
*/
|
|
57
|
+
create(entry: ResourceLogEntry): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The WAS Resource adapter: the log is the resource's entire body, stored as
|
|
61
|
+
* `text/jsonl`. Host the resource in a plaintext collection -- on an encrypted
|
|
62
|
+
* collection the EDV codec computes the write preconditions itself, so this
|
|
63
|
+
* store's `ifMatch` / create guard would not be honored.
|
|
64
|
+
*
|
|
65
|
+
* @param options {object}
|
|
66
|
+
* @param options.resource {Resource}
|
|
67
|
+
* @returns {ResourceLogStore}
|
|
68
|
+
*/
|
|
69
|
+
export declare function resourceLogStore({ resource }: {
|
|
70
|
+
resource: Resource;
|
|
71
|
+
}): ResourceLogStore;
|
|
72
|
+
/**
|
|
73
|
+
* The profile's "acknowledgement is a promise" rule, mechanically: after an
|
|
74
|
+
* acked {@link ResourceLogStore.append} (or `create`), reads the log back and
|
|
75
|
+
* checks the served history actually contains the written entry at its
|
|
76
|
+
* ordinal, throwing {@link LogNotConfirmedError} when it does not (the log is
|
|
77
|
+
* missing, shorter than the entry's ordinal, or holds a different entry
|
|
78
|
+
* there). Returns the read-back log so the caller can run full chain
|
|
79
|
+
* verification over exactly what was confirmed -- containment here is a
|
|
80
|
+
* byte-level check (JCS equality), not a verification.
|
|
81
|
+
*
|
|
82
|
+
* @param options {object}
|
|
83
|
+
* @param options.store {ResourceLogStore}
|
|
84
|
+
* @param options.entry {ResourceLogEntry} the entry the append wrote
|
|
85
|
+
* @returns {Promise<{ entries: ResourceLogEntry[]; etag?: string }>} the
|
|
86
|
+
* read-back log containing the entry
|
|
87
|
+
*/
|
|
88
|
+
export declare function confirmAppend({ store, entry }: {
|
|
89
|
+
store: ResourceLogStore;
|
|
90
|
+
entry: ResourceLogEntry;
|
|
91
|
+
}): Promise<{
|
|
92
|
+
entries: ResourceLogEntry[];
|
|
93
|
+
etag?: string;
|
|
94
|
+
}>;
|
|
95
|
+
//# sourceMappingURL=logStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAS9C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAEtE;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5E;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAA;CACnB,GAAG,gBAAgB,CAoDnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,KAAK,EACN,EAAE;IACD,KAAK,EAAE,gBAAgB,CAAA;IACvB,KAAK,EAAE,gBAAgB,CAAA;CACxB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuB1D"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The log-store seam: where a resource log lives and how it is extended --
|
|
6
|
+
* read-with-etag of the full log, compare-and-swap append conditioned on that
|
|
7
|
+
* etag, and the guarded create of a genesis entry. The seam is transport only,
|
|
8
|
+
* the log-side sibling of the descriptor-store seam (`edv/descriptorStore.ts`):
|
|
9
|
+
* chain verification (SCID, entry hashes, proofs, authorization, the chain-head
|
|
10
|
+
* pin) lives in the consuming verifier, which reads through this seam, verifies
|
|
11
|
+
* the parsed entries, builds the next entry against the verified head, and
|
|
12
|
+
* appends through it.
|
|
13
|
+
*
|
|
14
|
+
* Both the append and the create ride the backend's `conditional-writes`
|
|
15
|
+
* feature -- the profile requires it (without the precondition, concurrent
|
|
16
|
+
* appends silently overwrite one another instead of failing into the caller's
|
|
17
|
+
* rebase-and-retry loop). `confirmAppend` is the profile's "acknowledgement is
|
|
18
|
+
* a promise" rule: after an acked append, read the log back and check the
|
|
19
|
+
* entry is actually in the served history before treating the append -- or any
|
|
20
|
+
* ceremony step gated on it -- as durable.
|
|
21
|
+
*/
|
|
22
|
+
import { canonicalize } from 'json-canonicalize';
|
|
23
|
+
import { LogNotConfirmedError, ValidationError } from '../errors.js';
|
|
24
|
+
import { ENCODER } from '../internal/content.js';
|
|
25
|
+
import { parseResourceLog, serializeResourceLog, serializeResourceLogEntry } from './jsonl.js';
|
|
26
|
+
/**
|
|
27
|
+
* The content type a resource log is stored under (JSON Lines, not JSON --
|
|
28
|
+
* load-bearing: a JSON content type would have the request layer parse and
|
|
29
|
+
* re-serialize the body, losing the line framing).
|
|
30
|
+
*/
|
|
31
|
+
export const LOG_CONTENT_TYPE = 'text/jsonl';
|
|
32
|
+
/**
|
|
33
|
+
* The WAS Resource adapter: the log is the resource's entire body, stored as
|
|
34
|
+
* `text/jsonl`. Host the resource in a plaintext collection -- on an encrypted
|
|
35
|
+
* collection the EDV codec computes the write preconditions itself, so this
|
|
36
|
+
* store's `ifMatch` / create guard would not be honored.
|
|
37
|
+
*
|
|
38
|
+
* @param options {object}
|
|
39
|
+
* @param options.resource {Resource}
|
|
40
|
+
* @returns {ResourceLogStore}
|
|
41
|
+
*/
|
|
42
|
+
export function resourceLogStore({ resource }) {
|
|
43
|
+
// The raw body observed by the most recent read; an append extends these
|
|
44
|
+
// bytes verbatim instead of re-serializing the parsed entries. Safe to carry
|
|
45
|
+
// even if stale: the append is pinned to the same read's ETag, so a
|
|
46
|
+
// concurrent append fails the CAS instead.
|
|
47
|
+
let lastReadBody;
|
|
48
|
+
return {
|
|
49
|
+
async read() {
|
|
50
|
+
const current = await resource.getWithEtag();
|
|
51
|
+
if (current === null) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const body = current.data instanceof Blob
|
|
55
|
+
? await current.data.text()
|
|
56
|
+
: typeof current.data === 'string'
|
|
57
|
+
? current.data
|
|
58
|
+
: undefined;
|
|
59
|
+
if (body === undefined) {
|
|
60
|
+
throw new ValidationError(`Cannot read resource log: the resource "${resource.id}" does not ` +
|
|
61
|
+
'hold a text body (is it stored as JSON instead of JSON Lines?).');
|
|
62
|
+
}
|
|
63
|
+
const entries = parseResourceLog(body);
|
|
64
|
+
lastReadBody = body;
|
|
65
|
+
return { entries, etag: current.etag };
|
|
66
|
+
},
|
|
67
|
+
async append(entry, { ifMatch }) {
|
|
68
|
+
if (lastReadBody === undefined) {
|
|
69
|
+
throw new ValidationError('Cannot append to resource log: append must follow a read on the ' +
|
|
70
|
+
'same store instance.');
|
|
71
|
+
}
|
|
72
|
+
const separator = lastReadBody.endsWith('\n') ? '' : '\n';
|
|
73
|
+
const extended = lastReadBody + separator + serializeResourceLogEntry(entry) + '\n';
|
|
74
|
+
await resource.put(ENCODER.encode(extended), {
|
|
75
|
+
contentType: LOG_CONTENT_TYPE,
|
|
76
|
+
ifMatch
|
|
77
|
+
});
|
|
78
|
+
lastReadBody = extended;
|
|
79
|
+
},
|
|
80
|
+
async create(entry) {
|
|
81
|
+
await resource.put(ENCODER.encode(serializeResourceLog([entry])), {
|
|
82
|
+
contentType: LOG_CONTENT_TYPE,
|
|
83
|
+
ifNoneMatch: true
|
|
84
|
+
});
|
|
85
|
+
lastReadBody = serializeResourceLog([entry]);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The profile's "acknowledgement is a promise" rule, mechanically: after an
|
|
91
|
+
* acked {@link ResourceLogStore.append} (or `create`), reads the log back and
|
|
92
|
+
* checks the served history actually contains the written entry at its
|
|
93
|
+
* ordinal, throwing {@link LogNotConfirmedError} when it does not (the log is
|
|
94
|
+
* missing, shorter than the entry's ordinal, or holds a different entry
|
|
95
|
+
* there). Returns the read-back log so the caller can run full chain
|
|
96
|
+
* verification over exactly what was confirmed -- containment here is a
|
|
97
|
+
* byte-level check (JCS equality), not a verification.
|
|
98
|
+
*
|
|
99
|
+
* @param options {object}
|
|
100
|
+
* @param options.store {ResourceLogStore}
|
|
101
|
+
* @param options.entry {ResourceLogEntry} the entry the append wrote
|
|
102
|
+
* @returns {Promise<{ entries: ResourceLogEntry[]; etag?: string }>} the
|
|
103
|
+
* read-back log containing the entry
|
|
104
|
+
*/
|
|
105
|
+
export async function confirmAppend({ store, entry }) {
|
|
106
|
+
const ordinal = Number.parseInt(entry.versionId, 10);
|
|
107
|
+
if (!Number.isInteger(ordinal) || ordinal < 1) {
|
|
108
|
+
throw new ValidationError(`Cannot confirm append: the entry's versionId "${entry.versionId}" ` +
|
|
109
|
+
'does not start with a 1-based ordinal.');
|
|
110
|
+
}
|
|
111
|
+
const current = await store.read();
|
|
112
|
+
if (current === null) {
|
|
113
|
+
throw new LogNotConfirmedError('Resource-log append not confirmed: the log resource is missing on ' +
|
|
114
|
+
'read-back.');
|
|
115
|
+
}
|
|
116
|
+
const served = current.entries[ordinal - 1];
|
|
117
|
+
if (served === undefined || canonicalize(served) !== canonicalize(entry)) {
|
|
118
|
+
throw new LogNotConfirmedError(`Resource-log append not confirmed: the served log does not contain ` +
|
|
119
|
+
`the appended entry at ordinal ${ordinal}.`);
|
|
120
|
+
}
|
|
121
|
+
return current;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=logStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logStore.js","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAA;AAkD5C;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EAGT;IACC,yEAAyE;IACzE,6EAA6E;IAC7E,oEAAoE;IACpE,2CAA2C;IAC3C,IAAI,YAAgC,CAAA;IACpC,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAA;YAC5C,IA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crypto-free sync consumer can
|
|
22
22
|
* `instanceof`-match it without importing the `/edv` entry that throws it.
|
|
23
23
|
*/
|
|
24
|
-
export { createWasSyncPort,
|
|
24
|
+
export { createWasSyncPort, KEY_EPOCH_HEADER, formatEtag, parseEtag, errorStatus } from './port.js';
|
|
25
25
|
export { contentCid, cidFrom, deriveSpaceId } from './cid.js';
|
|
26
26
|
export { isEncryptedEnvelope } from './envelope.js';
|
|
27
27
|
export { createPlaintextDocCipher } from './plaintextCipher.js';
|
package/dist/sync/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,WAAW,EACZ,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA;AAErB,YAAY,EACV,IAAI,EACJ,cAAc,EACd,OAAO,EACP,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACV,MAAM,YAAY,CAAA"}
|
package/dist/sync/index.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* signal (`UnknownEpochError`), so a crypto-free sync consumer can
|
|
22
22
|
* `instanceof`-match it without importing the `/edv` entry that throws it.
|
|
23
23
|
*/
|
|
24
|
-
export { createWasSyncPort,
|
|
24
|
+
export { createWasSyncPort, KEY_EPOCH_HEADER, formatEtag, parseEtag, errorStatus } from './port.js';
|
|
25
25
|
export { contentCid, cidFrom, deriveSpaceId } from './cid.js';
|
|
26
26
|
export { isEncryptedEnvelope } from './envelope.js';
|
|
27
27
|
export { createPlaintextDocCipher } from './plaintextCipher.js';
|
package/dist/sync/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,WAAW,EACZ,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA"}
|
package/dist/sync/port.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* sent none), so a caller can record acked revisions immediately.
|
|
27
27
|
*/
|
|
28
28
|
import type { WasClient } from '../WasClient.js';
|
|
29
|
-
import {
|
|
29
|
+
import { KEY_EPOCH_HEADER } from '../internal/conditional.js';
|
|
30
30
|
import { httpStatus } from '../errors.js';
|
|
31
31
|
import type { WasSyncPort } from './types.js';
|
|
32
32
|
/**
|
|
@@ -35,7 +35,7 @@ import type { WasSyncPort } from './types.js';
|
|
|
35
35
|
* assembly it drives (`internal/conditional.ts`) and re-exported here as part
|
|
36
36
|
* of the sync subpath's public surface.
|
|
37
37
|
*/
|
|
38
|
-
export {
|
|
38
|
+
export { KEY_EPOCH_HEADER };
|
|
39
39
|
/**
|
|
40
40
|
* Extracts an HTTP status from a raw ky/ezcap error. `was.request()` rejects on
|
|
41
41
|
* any non-2xx with `err.status` set; this reads it defensively from either the
|
package/dist/sync/port.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/sync/port.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/sync/port.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EACL,gBAAgB,EAGjB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EACL,UAAU,EAGX,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAA;AAEhE;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAW3B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,mBAAa,CAAA;AA4BrC;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAMjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,GAAG,EACH,OAAO,EACP,YAAY,EACb,EAAE;IACD,GAAG,EAAE,SAAS,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;CACrB,GAAG,WAAW,CAgJd"}
|
package/dist/sync/port.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KEY_EPOCH_HEADER, readEtag, writeHeaders } from '../internal/conditional.js';
|
|
2
2
|
import { resourceMeta, resourcePath } from '../internal/paths.js';
|
|
3
3
|
import { httpStatus, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
4
4
|
/**
|
|
@@ -7,7 +7,7 @@ import { httpStatus, WasSyncConflictError, WasSyncNotFoundError } from '../error
|
|
|
7
7
|
* assembly it drives (`internal/conditional.ts`) and re-exported here as part
|
|
8
8
|
* of the sync subpath's public surface.
|
|
9
9
|
*/
|
|
10
|
-
export {
|
|
10
|
+
export { KEY_EPOCH_HEADER };
|
|
11
11
|
/**
|
|
12
12
|
* The placeholder `updatedAt` for a 412-conflict re-read whose resource has no
|
|
13
13
|
* `/meta` document yet (its server-managed timestamp is unknown). An epoch-zero
|
package/dist/sync/port.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.js","sourceRoot":"","sources":["../../src/sync/port.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"port.js","sourceRoot":"","sources":["../../src/sync/port.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACb,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,oBAAoB,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CAAC;gBACb,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC;oBAClC,MAAM,IAAI,CAAC,GAAG,CAAA;gBAChB,CAAC;gBACD,OAAO,MAAM,CAAA;YACf,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAOlB,CAAA;YACb,IAAI,QAAQ,EAAE,SAAS,EAAE,CAAC;gBACxB,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;YACvC,CAAC;YACD,IAAI,QAAQ,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;gBACtC,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;YACvC,CAAC;YACD,IAAI,QAAQ,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;gBAClC,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAA;YAC/B,CAAC;YACD,IAAI,QAAQ,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC;gBACnC,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;YACjC,CAAC;YACD,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAA;YAC9D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;YAClC,CAAC;YAED,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type { IZcap, IDelegatedZcap, IRootZcap, ISigner };
|
|
|
22
22
|
* `ResourceListing`) and the collections-in-a-space listing is `CollectionsList`
|
|
23
23
|
* (formerly `CollectionListing`).
|
|
24
24
|
*/
|
|
25
|
-
export type { Action, ActionInput, SpaceDescription, CollectionDescription, CollectionEncryption, CollectionEncryptionEpoch,
|
|
25
|
+
export type { Action, ActionInput, SpaceDescription, CollectionDescription, CollectionEncryption, CollectionEncryptionEpoch, CollectionEncryptionRecipient, PolicyDocument, LinkSet, LinkSetEntry, CollectionSummary, CollectionsList, SpaceSummary, SpaceListing, ResourceSummary, CollectionResourcesList, ResourceMetadata, ResourceMetadataCustom, ImportStats, BackendReference, BackendDescriptor, BackendRegistration, BackendConnectionInput, BackendConnectionPublic, StorageLimit, CollectionUsage, BackendUsage, SpaceQuotaReport } from '@interop/storage-core';
|
|
26
26
|
import type { BackendReference, CollectionEncryption } from '@interop/storage-core';
|
|
27
27
|
/**
|
|
28
28
|
* The client-writable fields of a Collection Description -- the shape shared
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACd,SAAS,EACV,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;AAEzD;;;;;GAKG;AACH,YAAY,EACV,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACd,SAAS,EACV,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,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,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,kBAAkB,GAC5B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,WAAW,CAAA;AAElD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAA;CAChC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,IAAI,GAAG,UAAU,CAAA;IACxB,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interop/was-client",
|
|
3
3
|
"description": "A developer-friendly client for Wallet Attached Storage (WAS) servers.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.32.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|
|
@@ -36,6 +36,12 @@
|
|
|
36
36
|
"import": "./dist/edv/index.js",
|
|
37
37
|
"default": "./dist/edv/index.js"
|
|
38
38
|
},
|
|
39
|
+
"./log": {
|
|
40
|
+
"types": "./dist/log/index.d.ts",
|
|
41
|
+
"react-native": "./dist/log/index.js",
|
|
42
|
+
"import": "./dist/log/index.js",
|
|
43
|
+
"default": "./dist/log/index.js"
|
|
44
|
+
},
|
|
39
45
|
"./sync": {
|
|
40
46
|
"types": "./dist/sync/index.d.ts",
|
|
41
47
|
"react-native": "./dist/sync/index.js",
|
|
@@ -54,7 +60,7 @@
|
|
|
54
60
|
"@interop/ezcap": "^7.4.1",
|
|
55
61
|
"@interop/http-client": "^1.0.5",
|
|
56
62
|
"@interop/minimal-cipher": "^7.8.1",
|
|
57
|
-
"@interop/storage-core": "^0.
|
|
63
|
+
"@interop/storage-core": "^0.4.0",
|
|
58
64
|
"@interop/x25519-key-agreement-key": "^5.2.1",
|
|
59
65
|
"@noble/hashes": "^2.3.0",
|
|
60
66
|
"@scure/base": "^2.3.0",
|
package/dist/edv/epochMac.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { CollectionEncryption, CollectionEncryptionEpochsMac, CollectionEncryptionEpochsSig } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* A caller-supplied signer for the `epochsSig` member: given the canonical
|
|
4
|
-
* signature payload bytes ({@link epochsSigPayload} over the descriptor being
|
|
5
|
-
* written), it returns the full signature member to stamp. The signing key --
|
|
6
|
-
* and the root of trust the reader resolves its `kid` against -- are entirely
|
|
7
|
-
* the caller's; this module only defines the payload and where the result
|
|
8
|
-
* lands.
|
|
9
|
-
*/
|
|
10
|
-
export type EpochsSigner = (options: {
|
|
11
|
-
payload: Uint8Array;
|
|
12
|
-
}) => Promise<CollectionEncryptionEpochsSig>;
|
|
13
|
-
/**
|
|
14
|
-
* Builds the payload bytes an `epochsSig` signs: `UTF8(
|
|
15
|
-
* "was-epoch-config-sig/v1." + epochsConfigJson(descriptor))` -- the same
|
|
16
|
-
* epoch configuration the MAC covers, under its own domain-separation prefix.
|
|
17
|
-
* Exported so a signing caller and a verifying reader construct
|
|
18
|
-
* byte-identical input from the descriptor alone.
|
|
19
|
-
*
|
|
20
|
-
* @param descriptor {CollectionEncryption} the descriptor whose epoch
|
|
21
|
-
* configuration is being signed or verified
|
|
22
|
-
* @returns {Uint8Array}
|
|
23
|
-
*/
|
|
24
|
-
export declare function epochsSigPayload(descriptor: CollectionEncryption): Uint8Array;
|
|
25
|
-
/**
|
|
26
|
-
* Computes the `epochsMac` field for a descriptor under the current epoch's
|
|
27
|
-
* secret. Compute this over the exact descriptor state being written (member
|
|
28
|
-
* fields already stamped), since a compare-and-swap retry re-reads the
|
|
29
|
-
* descriptor.
|
|
30
|
-
*
|
|
31
|
-
* @param options {object}
|
|
32
|
-
* @param options.descriptor {CollectionEncryption} the descriptor being written
|
|
33
|
-
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
34
|
-
* @returns {Promise<CollectionEncryptionEpochsMac>}
|
|
35
|
-
*/
|
|
36
|
-
export declare function computeEpochsMac({ descriptor, epochSecret }: {
|
|
37
|
-
descriptor: CollectionEncryption;
|
|
38
|
-
epochSecret: Uint8Array;
|
|
39
|
-
}): Promise<CollectionEncryptionEpochsMac>;
|
|
40
|
-
/**
|
|
41
|
-
* Verifies a descriptor's `epochsMac` against a recomputation from the current
|
|
42
|
-
* epoch's secret. Returns `false` on any mismatch (or a malformed `mac`); the
|
|
43
|
-
* caller decides the error semantics. The MAC construction's own version/alg
|
|
44
|
-
* (`v` / `alg`) is validated by the caller before this is called.
|
|
45
|
-
*
|
|
46
|
-
* @param options {object}
|
|
47
|
-
* @param options.descriptor {CollectionEncryption} the descriptor to verify (its
|
|
48
|
-
* `epochsMac.mac` is the tag under test)
|
|
49
|
-
* @param options.epochSecret {Uint8Array} the 32-byte current epoch secret
|
|
50
|
-
* @returns {Promise<boolean>}
|
|
51
|
-
*/
|
|
52
|
-
export declare function verifyEpochsMac({ descriptor, epochSecret }: {
|
|
53
|
-
descriptor: CollectionEncryption;
|
|
54
|
-
epochSecret: Uint8Array;
|
|
55
|
-
}): Promise<boolean>;
|
|
56
|
-
//# sourceMappingURL=epochMac.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"epochMac.d.ts","sourceRoot":"","sources":["../../src/edv/epochMac.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,oBAAoB,EACpB,6BAA6B,EAC7B,6BAA6B,EAC9B,MAAM,aAAa,CAAA;AAmBpB;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE;IACnC,OAAO,EAAE,UAAU,CAAA;CACpB,KAAK,OAAO,CAAC,6BAA6B,CAAC,CAAA;AAuE5C;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,oBAAoB,GAAG,UAAU,CAE7E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,UAAU,EACV,WAAW,EACZ,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,WAAW,EAAE,UAAU,CAAA;CACxB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAYzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EACpC,UAAU,EACV,WAAW,EACZ,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,WAAW,EAAE,UAAU,CAAA;CACxB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBnB"}
|