@interop/wallet-core 0.23.1 → 0.25.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 +41 -22
- package/dist/clients/index.d.ts +6 -4
- package/dist/clients/index.d.ts.map +1 -1
- package/dist/clients/index.js +5 -3
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/policy.d.ts +11 -3
- package/dist/clients/policy.d.ts.map +1 -1
- package/dist/clients/policy.js +12 -4
- package/dist/clients/policy.js.map +1 -1
- package/dist/clients/revocation.d.ts +24 -9
- package/dist/clients/revocation.d.ts.map +1 -1
- package/dist/clients/revocation.js +23 -10
- package/dist/clients/revocation.js.map +1 -1
- package/dist/clients/rosterPolicy.d.ts +23 -22
- package/dist/clients/rosterPolicy.d.ts.map +1 -1
- package/dist/clients/rosterPolicy.js +50 -31
- package/dist/clients/rosterPolicy.js.map +1 -1
- package/dist/descriptors/acquire.d.ts +4 -1
- package/dist/descriptors/acquire.d.ts.map +1 -1
- package/dist/descriptors/acquire.js +29 -1
- package/dist/descriptors/acquire.js.map +1 -1
- package/dist/descriptors/index.d.ts +9 -1
- package/dist/descriptors/index.d.ts.map +1 -1
- package/dist/descriptors/index.js +9 -1
- package/dist/descriptors/index.js.map +1 -1
- package/dist/descriptors/logSource.d.ts +33 -0
- package/dist/descriptors/logSource.d.ts.map +1 -0
- package/dist/descriptors/logSource.js +49 -0
- package/dist/descriptors/logSource.js.map +1 -0
- package/dist/enrollment/enrollment.d.ts +2 -2
- package/dist/enrollment/enrollment.d.ts.map +1 -1
- package/dist/enrollment/enrollment.js +15 -10
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/keys/index.d.ts +15 -8
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +14 -8
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/rosterLogStore.d.ts +53 -0
- package/dist/keys/rosterLogStore.d.ts.map +1 -0
- package/dist/keys/rosterLogStore.js +134 -0
- package/dist/keys/rosterLogStore.js.map +1 -0
- package/dist/keys/rosterStore.d.ts +20 -6
- package/dist/keys/rosterStore.d.ts.map +1 -1
- package/dist/keys/rosterStore.js +36 -17
- package/dist/keys/rosterStore.js.map +1 -1
- package/dist/keys/userKeyCascade.d.ts +14 -7
- package/dist/keys/userKeyCascade.d.ts.map +1 -1
- package/dist/keys/userKeyCascade.js +12 -3
- package/dist/keys/userKeyCascade.js.map +1 -1
- package/dist/keys/userKeyRoster.d.ts +50 -97
- package/dist/keys/userKeyRoster.d.ts.map +1 -1
- package/dist/keys/userKeyRoster.js +44 -145
- package/dist/keys/userKeyRoster.js.map +1 -1
- package/dist/request/appKey.d.ts +255 -0
- package/dist/request/appKey.d.ts.map +1 -0
- package/dist/request/appKey.js +492 -0
- package/dist/request/appKey.js.map +1 -0
- package/dist/request/classify.d.ts +54 -3
- package/dist/request/classify.d.ts.map +1 -1
- package/dist/request/classify.js +106 -0
- package/dist/request/classify.js.map +1 -1
- package/dist/request/composeVp.d.ts +6 -7
- package/dist/request/composeVp.d.ts.map +1 -1
- package/dist/request/composeVp.js +44 -55
- package/dist/request/composeVp.js.map +1 -1
- package/dist/request/index.d.ts +4 -0
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +4 -0
- package/dist/request/index.js.map +1 -1
- package/dist/request/processRequest.d.ts +1 -4
- package/dist/request/processRequest.d.ts.map +1 -1
- package/dist/request/processRequest.js +17 -11
- package/dist/request/processRequest.js.map +1 -1
- package/dist/request/types.d.ts +45 -2
- package/dist/request/types.d.ts.map +1 -1
- package/dist/resourceLog/append.d.ts +103 -0
- package/dist/resourceLog/append.d.ts.map +1 -0
- package/dist/resourceLog/append.js +190 -0
- package/dist/resourceLog/append.js.map +1 -0
- package/dist/resourceLog/controller.d.ts +57 -0
- package/dist/resourceLog/controller.d.ts.map +1 -0
- package/dist/resourceLog/controller.js +81 -0
- package/dist/resourceLog/controller.js.map +1 -0
- package/dist/resourceLog/entry.d.ts +68 -0
- package/dist/resourceLog/entry.d.ts.map +1 -0
- package/dist/resourceLog/entry.js +167 -0
- package/dist/resourceLog/entry.js.map +1 -0
- package/dist/resourceLog/errors.d.ts +75 -0
- package/dist/resourceLog/errors.d.ts.map +1 -0
- package/dist/resourceLog/errors.js +76 -0
- package/dist/resourceLog/errors.js.map +1 -0
- package/dist/resourceLog/index.d.ts +26 -0
- package/dist/resourceLog/index.d.ts.map +1 -0
- package/dist/resourceLog/index.js +26 -0
- package/dist/resourceLog/index.js.map +1 -0
- package/dist/resourceLog/pin.d.ts +44 -0
- package/dist/resourceLog/pin.d.ts.map +1 -0
- package/dist/resourceLog/pin.js +32 -0
- package/dist/resourceLog/pin.js.map +1 -0
- package/dist/resourceLog/seal.d.ts +86 -0
- package/dist/resourceLog/seal.d.ts.map +1 -0
- package/dist/resourceLog/seal.js +99 -0
- package/dist/resourceLog/seal.js.map +1 -0
- package/dist/resourceLog/verify.d.ts +95 -0
- package/dist/resourceLog/verify.d.ts.map +1 -0
- package/dist/resourceLog/verify.js +435 -0
- package/dist/resourceLog/verify.js.map +1 -0
- package/dist/space/collections.d.ts +14 -11
- package/dist/space/collections.d.ts.map +1 -1
- package/dist/space/collections.js +14 -11
- package/dist/space/collections.js.map +1 -1
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.d.ts.map +1 -1
- package/dist/space/index.js +2 -2
- package/dist/space/index.js.map +1 -1
- package/dist/webvh/didWeb.d.ts +4 -6
- package/dist/webvh/didWeb.d.ts.map +1 -1
- package/dist/webvh/didWeb.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +1 -2
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +1 -6
- package/dist/webvh/didWebvh.js.map +1 -1
- package/package.json +11 -4
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type ResourceLogEntry, type ResourceLogStore } from '@interop/was-client/log';
|
|
2
|
+
import type { ResourceLogController } from './controller.js';
|
|
3
|
+
import { type ResourceLogSigner } from './entry.js';
|
|
4
|
+
import type { ResourceLogPinStore } from './pin.js';
|
|
5
|
+
import { type VerifiedResourceLog } from './verify.js';
|
|
6
|
+
/**
|
|
7
|
+
* Reads and fully verifies a log through the store seam, advancing the
|
|
8
|
+
* chain-head pin. Resolves `null` when the log resource does not exist yet
|
|
9
|
+
* (the pre-genesis state). The one read entry point every consumer -- a
|
|
10
|
+
* login-time roster read, a pre-append verification, a first-contact
|
|
11
|
+
* bootstrap -- goes through, so the pin rules cannot be bypassed by reading
|
|
12
|
+
* around them.
|
|
13
|
+
*
|
|
14
|
+
* @param options {object}
|
|
15
|
+
* @param options.store {ResourceLogStore} the log's transport seam
|
|
16
|
+
* @param options.controller {ResourceLogController} the verified controller
|
|
17
|
+
* view
|
|
18
|
+
* @param options.expectedMethod {string} the format identifier expected
|
|
19
|
+
* (also confirming any `history` dispatch hint the caller followed)
|
|
20
|
+
* @param options.pinStore {ResourceLogPinStore} this client's pin for this
|
|
21
|
+
* log
|
|
22
|
+
* @returns {Promise<{ verified: VerifiedResourceLog; etag?: string } | null>}
|
|
23
|
+
*/
|
|
24
|
+
export declare function readResourceLog({ store, controller, expectedMethod, pinStore }: {
|
|
25
|
+
store: ResourceLogStore;
|
|
26
|
+
controller: ResourceLogController;
|
|
27
|
+
expectedMethod: string;
|
|
28
|
+
pinStore: ResourceLogPinStore;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
verified: VerifiedResourceLog;
|
|
31
|
+
etag?: string;
|
|
32
|
+
} | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Appends one state change: verify, build against the verified head, CAS,
|
|
35
|
+
* rebase-and-retry on conflict, confirm by read-back. `buildState` is the
|
|
36
|
+
* rebase hook -- it is called with the current verified log on every attempt
|
|
37
|
+
* and returns the full next state built on THAT head's state (or `null` to
|
|
38
|
+
* signal the change is already present, making a re-run converge instead of
|
|
39
|
+
* duplicating an entry). Refuses a log whose verified head is a terminal
|
|
40
|
+
* handover entry ({@link ResourceLogClosedError}).
|
|
41
|
+
*
|
|
42
|
+
* @param options {object}
|
|
43
|
+
* @param options.store {ResourceLogStore}
|
|
44
|
+
* @param options.controller {ResourceLogController}
|
|
45
|
+
* @param options.expectedMethod {string}
|
|
46
|
+
* @param options.pinStore {ResourceLogPinStore}
|
|
47
|
+
* @param options.signer {ResourceLogSigner}
|
|
48
|
+
* @param options.buildState {function} `(verified) => state | null` -- the
|
|
49
|
+
* full next state rebased on the verified head, or `null` when the head
|
|
50
|
+
* already carries the change
|
|
51
|
+
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
52
|
+
* @param [options.maxAttempts] {number} CAS attempts before giving up
|
|
53
|
+
* (default 3)
|
|
54
|
+
* @returns {Promise<VerifiedResourceLog>} the read-back, re-verified log
|
|
55
|
+
* (whether or not this call appended)
|
|
56
|
+
*/
|
|
57
|
+
export declare function appendResourceLog({ store, controller, expectedMethod, pinStore, signer, buildState, versionTime, maxAttempts }: {
|
|
58
|
+
store: ResourceLogStore;
|
|
59
|
+
controller: ResourceLogController;
|
|
60
|
+
expectedMethod: string;
|
|
61
|
+
pinStore: ResourceLogPinStore;
|
|
62
|
+
signer: ResourceLogSigner;
|
|
63
|
+
buildState: (verified: VerifiedResourceLog) => Promise<ResourceLogEntry['state'] | null> | ResourceLogEntry['state'] | null;
|
|
64
|
+
versionTime?: string;
|
|
65
|
+
maxAttempts?: number;
|
|
66
|
+
}): Promise<VerifiedResourceLog>;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a log with its genesis entry, guarded create-if-absent, and
|
|
69
|
+
* confirms by read-back. Losing the create race to a concurrent provisioner
|
|
70
|
+
* adopts the winner's log (the create is CAS, never clobbering): the served
|
|
71
|
+
* log is verified and pinned, and the caller reconciles its intended state
|
|
72
|
+
* through an ordinary {@link appendResourceLog}. First contact is where the
|
|
73
|
+
* pin is established, so the pin store is written either way.
|
|
74
|
+
*
|
|
75
|
+
* @param options {object}
|
|
76
|
+
* @param options.store {ResourceLogStore}
|
|
77
|
+
* @param options.controller {ResourceLogController}
|
|
78
|
+
* @param options.method {string} the format identifier to declare
|
|
79
|
+
* @param options.pinStore {ResourceLogPinStore}
|
|
80
|
+
* @param options.signer {ResourceLogSigner}
|
|
81
|
+
* @param options.state {ResourceLogEntry['state']} the full initial state
|
|
82
|
+
* @param [options.previousLog] {object} handover successors only
|
|
83
|
+
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
84
|
+
* @returns {Promise<{ verified: VerifiedResourceLog; created: boolean }>}
|
|
85
|
+
* the verified log as it now stands, and whether this call created it
|
|
86
|
+
*/
|
|
87
|
+
export declare function createResourceLog({ store, controller, method, pinStore, signer, state, previousLog, versionTime }: {
|
|
88
|
+
store: ResourceLogStore;
|
|
89
|
+
controller: ResourceLogController;
|
|
90
|
+
method: string;
|
|
91
|
+
pinStore: ResourceLogPinStore;
|
|
92
|
+
signer: ResourceLogSigner;
|
|
93
|
+
state: ResourceLogEntry['state'];
|
|
94
|
+
previousLog?: {
|
|
95
|
+
scid: string;
|
|
96
|
+
head: string;
|
|
97
|
+
};
|
|
98
|
+
versionTime?: string;
|
|
99
|
+
}): Promise<{
|
|
100
|
+
verified: VerifiedResourceLog;
|
|
101
|
+
created: boolean;
|
|
102
|
+
}>;
|
|
103
|
+
//# sourceMappingURL=append.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../../src/resourceLog/append.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAE5D,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAqB,KAAK,mBAAmB,EAAE,M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EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,MAAM,EAAE,iBAAiB,CAAA;IACzB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAChC,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAmC/D"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The append path (App Connect spec `#log-append`): read the full log and
|
|
6
|
+
* verify it (an entry is never built on an unverified head), build the new
|
|
7
|
+
* entry against the verified head anchored at the writer's current verified
|
|
8
|
+
* controller head, write compare-and-swapped on the read's validator, and on
|
|
9
|
+
* conflict re-read, re-verify, rebase, retry. A write acknowledgement is a
|
|
10
|
+
* promise, not a fact: every append is confirmed by reading the log back and
|
|
11
|
+
* re-verifying the extended history before the append -- or any ceremony step
|
|
12
|
+
* gated on it -- is treated as durable. The chain-head pin advances on every
|
|
13
|
+
* successful verification along the way, and only ever forward.
|
|
14
|
+
*/
|
|
15
|
+
import { PreconditionFailedError } from '@interop/was-client';
|
|
16
|
+
import { confirmAppend } from '@interop/was-client/log';
|
|
17
|
+
import { ResourceLogClosedError } from './errors.js';
|
|
18
|
+
import { buildResourceLogEntry, buildResourceLogGenesis } from './entry.js';
|
|
19
|
+
import { verifyResourceLog } from './verify.js';
|
|
20
|
+
/**
|
|
21
|
+
* Reads and fully verifies a log through the store seam, advancing the
|
|
22
|
+
* chain-head pin. Resolves `null` when the log resource does not exist yet
|
|
23
|
+
* (the pre-genesis state). The one read entry point every consumer -- a
|
|
24
|
+
* login-time roster read, a pre-append verification, a first-contact
|
|
25
|
+
* bootstrap -- goes through, so the pin rules cannot be bypassed by reading
|
|
26
|
+
* around them.
|
|
27
|
+
*
|
|
28
|
+
* @param options {object}
|
|
29
|
+
* @param options.store {ResourceLogStore} the log's transport seam
|
|
30
|
+
* @param options.controller {ResourceLogController} the verified controller
|
|
31
|
+
* view
|
|
32
|
+
* @param options.expectedMethod {string} the format identifier expected
|
|
33
|
+
* (also confirming any `history` dispatch hint the caller followed)
|
|
34
|
+
* @param options.pinStore {ResourceLogPinStore} this client's pin for this
|
|
35
|
+
* log
|
|
36
|
+
* @returns {Promise<{ verified: VerifiedResourceLog; etag?: string } | null>}
|
|
37
|
+
*/
|
|
38
|
+
export async function readResourceLog({ store, controller, expectedMethod, pinStore }) {
|
|
39
|
+
const current = await store.read();
|
|
40
|
+
if (current === null) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const pin = await pinStore.read();
|
|
44
|
+
const verified = await verifyResourceLog({
|
|
45
|
+
entries: current.entries,
|
|
46
|
+
controller,
|
|
47
|
+
expectedMethod,
|
|
48
|
+
pin
|
|
49
|
+
});
|
|
50
|
+
await pinStore.write(verified.pin);
|
|
51
|
+
return { verified, etag: current.etag };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Appends one state change: verify, build against the verified head, CAS,
|
|
55
|
+
* rebase-and-retry on conflict, confirm by read-back. `buildState` is the
|
|
56
|
+
* rebase hook -- it is called with the current verified log on every attempt
|
|
57
|
+
* and returns the full next state built on THAT head's state (or `null` to
|
|
58
|
+
* signal the change is already present, making a re-run converge instead of
|
|
59
|
+
* duplicating an entry). Refuses a log whose verified head is a terminal
|
|
60
|
+
* handover entry ({@link ResourceLogClosedError}).
|
|
61
|
+
*
|
|
62
|
+
* @param options {object}
|
|
63
|
+
* @param options.store {ResourceLogStore}
|
|
64
|
+
* @param options.controller {ResourceLogController}
|
|
65
|
+
* @param options.expectedMethod {string}
|
|
66
|
+
* @param options.pinStore {ResourceLogPinStore}
|
|
67
|
+
* @param options.signer {ResourceLogSigner}
|
|
68
|
+
* @param options.buildState {function} `(verified) => state | null` -- the
|
|
69
|
+
* full next state rebased on the verified head, or `null` when the head
|
|
70
|
+
* already carries the change
|
|
71
|
+
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
72
|
+
* @param [options.maxAttempts] {number} CAS attempts before giving up
|
|
73
|
+
* (default 3)
|
|
74
|
+
* @returns {Promise<VerifiedResourceLog>} the read-back, re-verified log
|
|
75
|
+
* (whether or not this call appended)
|
|
76
|
+
*/
|
|
77
|
+
export async function appendResourceLog({ store, controller, expectedMethod, pinStore, signer, buildState, versionTime, maxAttempts = 3 }) {
|
|
78
|
+
let lastConflict;
|
|
79
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
80
|
+
const current = await readResourceLog({
|
|
81
|
+
store,
|
|
82
|
+
controller,
|
|
83
|
+
expectedMethod,
|
|
84
|
+
pinStore
|
|
85
|
+
});
|
|
86
|
+
if (current === null) {
|
|
87
|
+
throw new Error('Cannot append to the resource log: the log does not exist yet ' +
|
|
88
|
+
'(create it with its genesis entry first).');
|
|
89
|
+
}
|
|
90
|
+
const { verified, etag } = current;
|
|
91
|
+
if (verified.terminal) {
|
|
92
|
+
throw new ResourceLogClosedError({ nextLog: verified.terminal });
|
|
93
|
+
}
|
|
94
|
+
if (etag === undefined) {
|
|
95
|
+
throw new Error('Cannot append to the resource log: the backend returned no ' +
|
|
96
|
+
'validator, and the profile forbids an unconditional write.');
|
|
97
|
+
}
|
|
98
|
+
const state = await buildState(verified);
|
|
99
|
+
if (state === null) {
|
|
100
|
+
// The head already carries the change -- a torn earlier run landed it,
|
|
101
|
+
// or a concurrent writer did. Converged.
|
|
102
|
+
return verified;
|
|
103
|
+
}
|
|
104
|
+
const entry = await buildResourceLogEntry({
|
|
105
|
+
head: verified.head,
|
|
106
|
+
state,
|
|
107
|
+
controller,
|
|
108
|
+
signer,
|
|
109
|
+
versionTime
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
await store.append(entry, { ifMatch: etag });
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
if (err instanceof PreconditionFailedError) {
|
|
116
|
+
// A concurrent append won the CAS: re-read, re-verify, rebase, retry.
|
|
117
|
+
lastConflict = err;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
throw err;
|
|
121
|
+
}
|
|
122
|
+
const readBack = await confirmAppend({ store, entry });
|
|
123
|
+
const confirmed = await verifyResourceLog({
|
|
124
|
+
entries: readBack.entries,
|
|
125
|
+
controller,
|
|
126
|
+
expectedMethod,
|
|
127
|
+
pin: await pinStore.read()
|
|
128
|
+
});
|
|
129
|
+
await pinStore.write(confirmed.pin);
|
|
130
|
+
return confirmed;
|
|
131
|
+
}
|
|
132
|
+
throw new Error(`Appending to the resource log lost the compare-and-swap race ` +
|
|
133
|
+
`${maxAttempts} times in a row.`, { cause: lastConflict });
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Creates a log with its genesis entry, guarded create-if-absent, and
|
|
137
|
+
* confirms by read-back. Losing the create race to a concurrent provisioner
|
|
138
|
+
* adopts the winner's log (the create is CAS, never clobbering): the served
|
|
139
|
+
* log is verified and pinned, and the caller reconciles its intended state
|
|
140
|
+
* through an ordinary {@link appendResourceLog}. First contact is where the
|
|
141
|
+
* pin is established, so the pin store is written either way.
|
|
142
|
+
*
|
|
143
|
+
* @param options {object}
|
|
144
|
+
* @param options.store {ResourceLogStore}
|
|
145
|
+
* @param options.controller {ResourceLogController}
|
|
146
|
+
* @param options.method {string} the format identifier to declare
|
|
147
|
+
* @param options.pinStore {ResourceLogPinStore}
|
|
148
|
+
* @param options.signer {ResourceLogSigner}
|
|
149
|
+
* @param options.state {ResourceLogEntry['state']} the full initial state
|
|
150
|
+
* @param [options.previousLog] {object} handover successors only
|
|
151
|
+
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
152
|
+
* @returns {Promise<{ verified: VerifiedResourceLog; created: boolean }>}
|
|
153
|
+
* the verified log as it now stands, and whether this call created it
|
|
154
|
+
*/
|
|
155
|
+
export async function createResourceLog({ store, controller, method, pinStore, signer, state, previousLog, versionTime }) {
|
|
156
|
+
const genesis = await buildResourceLogGenesis({
|
|
157
|
+
state,
|
|
158
|
+
method,
|
|
159
|
+
controller,
|
|
160
|
+
signer,
|
|
161
|
+
previousLog,
|
|
162
|
+
versionTime
|
|
163
|
+
});
|
|
164
|
+
let created = true;
|
|
165
|
+
try {
|
|
166
|
+
await store.create(genesis);
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
if (!(err instanceof PreconditionFailedError)) {
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
created = false;
|
|
173
|
+
}
|
|
174
|
+
const current = created
|
|
175
|
+
? await confirmAppend({ store, entry: genesis })
|
|
176
|
+
: await store.read();
|
|
177
|
+
if (current === null) {
|
|
178
|
+
throw new Error('The resource log create lost its guarded-create race, but no log ' +
|
|
179
|
+
'was served on re-read.');
|
|
180
|
+
}
|
|
181
|
+
const verified = await verifyResourceLog({
|
|
182
|
+
entries: current.entries,
|
|
183
|
+
controller,
|
|
184
|
+
expectedMethod: method,
|
|
185
|
+
pin: await pinStore.read()
|
|
186
|
+
});
|
|
187
|
+
await pinStore.write(verified.pin);
|
|
188
|
+
return { verified, created };
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=append.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../src/resourceLog/append.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EACL,aAAa,EAGd,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EACL,qBAAqB,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,CAAA;IACF,MAAM,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The controller-document view a resource-log verifier authorizes against:
|
|
6
|
+
* the profile's root of authority, resolved and verified by the reader
|
|
7
|
+
* independently of the host serving the log. The interface is the seam --
|
|
8
|
+
* verification consumes only the account DID, the ordered controller-log
|
|
9
|
+
* version list, and per-version `assertionMethod` membership -- and the
|
|
10
|
+
* did:webvh adapter builds it from an already-verified account log (the
|
|
11
|
+
* `verifyAccountLog` output), answering anchored-version lookups from that
|
|
12
|
+
* verified history rather than from any wire fetch. Handing the verifier a
|
|
13
|
+
* view instead of a resolver is what enforces the profile's rule that
|
|
14
|
+
* controller-document material never comes from the channel the log came
|
|
15
|
+
* from.
|
|
16
|
+
*/
|
|
17
|
+
import { type DIDLog } from '@interop/did-method-webvh';
|
|
18
|
+
/**
|
|
19
|
+
* What log verification consumes of the independently verified controller
|
|
20
|
+
* document: the DID the entry proofs must sign under, the verified controller
|
|
21
|
+
* log's `versionId` list in order (empty for an unversioned static
|
|
22
|
+
* controller, degrading every anchor rule to current-document verification),
|
|
23
|
+
* and the set of `assertionMethod` key multibases at a given version --
|
|
24
|
+
* membership there is the whole authorization rule, so `keyAgreement`-only
|
|
25
|
+
* recovery keys and `authentication`-only convenience keys are excluded
|
|
26
|
+
* structurally.
|
|
27
|
+
*/
|
|
28
|
+
export interface ResourceLogController {
|
|
29
|
+
did: string;
|
|
30
|
+
versionIds: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the `assertionMethod` public-key multibases at a controller-log
|
|
33
|
+
* version (`undefined`: the current document, the unversioned-controller
|
|
34
|
+
* degradation).
|
|
35
|
+
*
|
|
36
|
+
* @param [versionId] {string}
|
|
37
|
+
* @returns {Promise<Set<string>>}
|
|
38
|
+
*/
|
|
39
|
+
assertionKeysAt(versionId?: string): Promise<Set<string>>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Builds the controller view over an already-verified did:webvh account log
|
|
43
|
+
* (the `verifyAccountLog` output -- callers never hand this a log they have
|
|
44
|
+
* not verified against the account pointer). Anchored-version lookups
|
|
45
|
+
* re-resolve the held log at that version and are memoized: controller logs
|
|
46
|
+
* are tens of entries and anchors cluster on few versions.
|
|
47
|
+
*
|
|
48
|
+
* @param options {object}
|
|
49
|
+
* @param options.did {string} the account's did:webvh, as verified
|
|
50
|
+
* @param options.log {DIDLog} the verified account log
|
|
51
|
+
* @returns {ResourceLogController}
|
|
52
|
+
*/
|
|
53
|
+
export declare function webvhResourceLogController({ did, log }: {
|
|
54
|
+
did: string;
|
|
55
|
+
log: DIDLog;
|
|
56
|
+
}): ResourceLogController;
|
|
57
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/resourceLog/controller.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;GAYG;AACH,OAAO,EAAqB,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAG1E;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB;;;;;;;OAOG;IACH,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAC1D;AAmCD;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,GAAG,EACH,GAAG,EACJ,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,qBAAqB,CAkCxB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The controller-document view a resource-log verifier authorizes against:
|
|
6
|
+
* the profile's root of authority, resolved and verified by the reader
|
|
7
|
+
* independently of the host serving the log. The interface is the seam --
|
|
8
|
+
* verification consumes only the account DID, the ordered controller-log
|
|
9
|
+
* version list, and per-version `assertionMethod` membership -- and the
|
|
10
|
+
* did:webvh adapter builds it from an already-verified account log (the
|
|
11
|
+
* `verifyAccountLog` output), answering anchored-version lookups from that
|
|
12
|
+
* verified history rather than from any wire fetch. Handing the verifier a
|
|
13
|
+
* view instead of a resolver is what enforces the profile's rule that
|
|
14
|
+
* controller-document material never comes from the channel the log came
|
|
15
|
+
* from.
|
|
16
|
+
*/
|
|
17
|
+
import { resolveDIDFromLog } from '@interop/did-method-webvh';
|
|
18
|
+
import { ResourceLogIntegrityError } from './errors.js';
|
|
19
|
+
/**
|
|
20
|
+
* Collects a document's `assertionMethod` key multibases: embedded
|
|
21
|
+
* verification methods verbatim, string references resolved against
|
|
22
|
+
* `verificationMethod`.
|
|
23
|
+
*
|
|
24
|
+
* @param doc {AssertionDocument}
|
|
25
|
+
* @returns {Set<string>}
|
|
26
|
+
*/
|
|
27
|
+
function assertionKeysOf(doc) {
|
|
28
|
+
const byId = new Map();
|
|
29
|
+
for (const method of doc.verificationMethod ?? []) {
|
|
30
|
+
if (typeof method?.id === 'string') {
|
|
31
|
+
byId.set(method.id, method);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const keys = new Set();
|
|
35
|
+
for (const entry of doc.assertionMethod ?? []) {
|
|
36
|
+
const method = typeof entry === 'string' ? byId.get(entry) : entry;
|
|
37
|
+
if (method && typeof method.publicKeyMultibase === 'string') {
|
|
38
|
+
keys.add(method.publicKeyMultibase);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return keys;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Builds the controller view over an already-verified did:webvh account log
|
|
45
|
+
* (the `verifyAccountLog` output -- callers never hand this a log they have
|
|
46
|
+
* not verified against the account pointer). Anchored-version lookups
|
|
47
|
+
* re-resolve the held log at that version and are memoized: controller logs
|
|
48
|
+
* are tens of entries and anchors cluster on few versions.
|
|
49
|
+
*
|
|
50
|
+
* @param options {object}
|
|
51
|
+
* @param options.did {string} the account's did:webvh, as verified
|
|
52
|
+
* @param options.log {DIDLog} the verified account log
|
|
53
|
+
* @returns {ResourceLogController}
|
|
54
|
+
*/
|
|
55
|
+
export function webvhResourceLogController({ did, log }) {
|
|
56
|
+
const versionIds = log.map(entry => entry.versionId);
|
|
57
|
+
const memo = new Map();
|
|
58
|
+
async function resolveAssertionKeys(versionId) {
|
|
59
|
+
const resolved = await resolveDIDFromLog(log, versionId === undefined ? {} : { versionId });
|
|
60
|
+
if (resolved.meta.error || !resolved.doc) {
|
|
61
|
+
throw new ResourceLogIntegrityError(`The controller document did not resolve at version ` +
|
|
62
|
+
`"${versionId ?? '<head>'}" (${resolved.meta.error ?? 'no document returned'}).`);
|
|
63
|
+
}
|
|
64
|
+
return assertionKeysOf(resolved.doc);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
did,
|
|
68
|
+
versionIds,
|
|
69
|
+
assertionKeysAt(versionId) {
|
|
70
|
+
const key = versionId ?? '';
|
|
71
|
+
let pending = memo.get(key);
|
|
72
|
+
if (!pending) {
|
|
73
|
+
pending = resolveAssertionKeys(versionId);
|
|
74
|
+
memo.set(key, pending);
|
|
75
|
+
pending.catch(() => memo.delete(key));
|
|
76
|
+
}
|
|
77
|
+
return pending;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":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AkB;QAElB,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CACtC,GAAG,EACH,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAC7C,CAAA;QACD,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YACzC,MAAM,IAAI,yBAAyB,CACjC,qDAAqD;gBACnD,IAAI,SAAS,IAAI,QAAQ,MACvB,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,sBACzB,IAAI,CACP,CAAA;QACH,CAAC;QACD,OAAO,eAAe,CAAC,QAAQ,CAAC,GAAwB,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO;QACL,GAAG;QACH,UAAU;QACV,eAAe,CAAC,SAAkB;YAChC,MAAM,GAAG,GAAG,SAAS,IAAI,EAAE,CAAA;YAC3B,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAA;gBACzC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;gBACtB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;YACvC,CAAC;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ResourceLogEntry } from '@interop/was-client/log';
|
|
2
|
+
import type { ResourceLogController } from './controller.js';
|
|
3
|
+
/**
|
|
4
|
+
* The writer's signing seam: its enrolled Ed25519 signing key's multibase
|
|
5
|
+
* (the fragment of its verification method in the controller document) and a
|
|
6
|
+
* raw detached-signature hook over it. The multibase names the key in the
|
|
7
|
+
* proof's `verificationMethod`; membership under `assertionMethod` at the
|
|
8
|
+
* anchored version is what authorizes the append.
|
|
9
|
+
*/
|
|
10
|
+
export interface ResourceLogSigner {
|
|
11
|
+
keyMultibase: string;
|
|
12
|
+
sign(input: {
|
|
13
|
+
data: Uint8Array;
|
|
14
|
+
}): Promise<Uint8Array>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Builds and signs a genesis entry by the profile's two-pass SCID procedure:
|
|
18
|
+
* the preliminary entry carries the `{SCID}` placeholder as `versionId` and
|
|
19
|
+
* `parameters.scid`, its hash is the SCID, and the final entry substitutes it
|
|
20
|
+
* back in before the ordinary entry hash is computed (`versionId` input
|
|
21
|
+
* value: the SCID).
|
|
22
|
+
*
|
|
23
|
+
* @param options {object}
|
|
24
|
+
* @param options.state {ResourceLogEntry['state']} the full initial state
|
|
25
|
+
* (with its `type`)
|
|
26
|
+
* @param options.method {string} the format identifier
|
|
27
|
+
* (`WAS_RESOURCE_LOG_METHOD`)
|
|
28
|
+
* @param options.controller {ResourceLogController} the verified controller
|
|
29
|
+
* view -- the anchor source
|
|
30
|
+
* @param options.signer {ResourceLogSigner}
|
|
31
|
+
* @param [options.previousLog] {object} handover successors only: the prior
|
|
32
|
+
* log's SCID and the `versionId` of its terminal entry's predecessor
|
|
33
|
+
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
34
|
+
* @returns {Promise<ResourceLogEntry>}
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildResourceLogGenesis({ state, method, controller, signer, previousLog, versionTime }: {
|
|
37
|
+
state: ResourceLogEntry['state'];
|
|
38
|
+
method: string;
|
|
39
|
+
controller: ResourceLogController;
|
|
40
|
+
signer: ResourceLogSigner;
|
|
41
|
+
previousLog?: {
|
|
42
|
+
scid: string;
|
|
43
|
+
head: string;
|
|
44
|
+
};
|
|
45
|
+
versionTime?: string;
|
|
46
|
+
}): Promise<ResourceLogEntry>;
|
|
47
|
+
/**
|
|
48
|
+
* Builds and signs the next ordinary entry against a verified head: full
|
|
49
|
+
* state, empty `parameters`, hash chained off the head's `versionId`, proof
|
|
50
|
+
* anchored at the controller's verified head. Callers hold a verified head
|
|
51
|
+
* by construction (an entry is never built on an unverified one).
|
|
52
|
+
*
|
|
53
|
+
* @param options {object}
|
|
54
|
+
* @param options.head {ResourceLogEntry} the verified head entry
|
|
55
|
+
* @param options.state {ResourceLogEntry['state']} the full next state
|
|
56
|
+
* @param options.controller {ResourceLogController}
|
|
57
|
+
* @param options.signer {ResourceLogSigner}
|
|
58
|
+
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
59
|
+
* @returns {Promise<ResourceLogEntry>}
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildResourceLogEntry({ head, state, controller, signer, versionTime }: {
|
|
62
|
+
head: ResourceLogEntry;
|
|
63
|
+
state: ResourceLogEntry['state'];
|
|
64
|
+
controller: ResourceLogController;
|
|
65
|
+
signer: ResourceLogSigner;
|
|
66
|
+
versionTime?: string;
|
|
67
|
+
}): Promise<ResourceLogEntry>;
|
|
68
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/resourceLog/entry.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACvD;AAqFD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,KAAK,EACL,MAAM,EACN,UAAU,EACV,MAAM,EACN,WAAW,EACX,WAAW,EACZ,EAAE;IACD,KAAK,EAAE,gB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