@interop/wallet-core 0.94.0 → 0.96.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 +21 -20
- package/dist/clientAnnex/mend.js +4 -1
- package/dist/clientAnnex/mend.js.map +1 -1
- package/dist/clients/index.d.ts +3 -2
- package/dist/clients/index.d.ts.map +1 -1
- package/dist/clients/index.js +3 -2
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/listing.d.ts +19 -12
- package/dist/clients/listing.d.ts.map +1 -1
- package/dist/clients/listing.js +69 -22
- package/dist/clients/listing.js.map +1 -1
- package/dist/connections/didKey.d.ts +25 -0
- package/dist/connections/didKey.d.ts.map +1 -0
- package/dist/connections/didKey.js +49 -0
- package/dist/connections/didKey.js.map +1 -0
- package/dist/connections/entry.d.ts +226 -0
- package/dist/connections/entry.d.ts.map +1 -0
- package/dist/connections/entry.js +287 -0
- package/dist/connections/entry.js.map +1 -0
- package/dist/connections/errors.d.ts +33 -0
- package/dist/connections/errors.d.ts.map +1 -0
- package/dist/connections/errors.js +36 -0
- package/dist/connections/errors.js.map +1 -0
- package/dist/connections/grants.d.ts +94 -0
- package/dist/connections/grants.d.ts.map +1 -0
- package/dist/connections/grants.js +120 -0
- package/dist/connections/grants.js.map +1 -0
- package/dist/connections/index.d.ts +47 -0
- package/dist/connections/index.d.ts.map +1 -0
- package/dist/connections/index.js +40 -0
- package/dist/connections/index.js.map +1 -0
- package/dist/connections/read.d.ts +82 -0
- package/dist/connections/read.d.ts.map +1 -0
- package/dist/connections/read.js +100 -0
- package/dist/connections/read.js.map +1 -0
- package/dist/connections/resourceId.d.ts +36 -0
- package/dist/connections/resourceId.d.ts.map +1 -0
- package/dist/connections/resourceId.js +49 -0
- package/dist/connections/resourceId.js.map +1 -0
- package/dist/connections/store.d.ts +103 -0
- package/dist/connections/store.d.ts.map +1 -0
- package/dist/connections/store.js +67 -0
- package/dist/connections/store.js.map +1 -0
- package/dist/connections/upsert.d.ts +220 -0
- package/dist/connections/upsert.d.ts.map +1 -0
- package/dist/connections/upsert.js +478 -0
- package/dist/connections/upsert.js.map +1 -0
- package/dist/connections/writers.d.ts +217 -0
- package/dist/connections/writers.d.ts.map +1 -0
- package/dist/connections/writers.js +485 -0
- package/dist/connections/writers.js.map +1 -0
- package/dist/enrollment/onboardingResponse.d.ts +3 -3
- package/dist/enrollment/onboardingResponse.d.ts.map +1 -1
- package/dist/enrollment/onboardingResponse.js +17 -13
- package/dist/enrollment/onboardingResponse.js.map +1 -1
- package/dist/keys/index.d.ts +0 -7
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +0 -6
- package/dist/keys/index.js.map +1 -1
- package/dist/labelText.d.ts +30 -3
- package/dist/labelText.d.ts.map +1 -1
- package/dist/labelText.js +35 -3
- package/dist/labelText.js.map +1 -1
- package/dist/menders/ids.d.ts +1 -1
- package/dist/menders/ids.d.ts.map +1 -1
- package/dist/menders/ids.js +7 -2
- package/dist/menders/ids.js.map +1 -1
- package/dist/space/collections.d.ts +15 -25
- package/dist/space/collections.d.ts.map +1 -1
- package/dist/space/collections.js +19 -29
- package/dist/space/collections.js.map +1 -1
- package/dist/space/index.d.ts +4 -3
- package/dist/space/index.d.ts.map +1 -1
- package/dist/space/index.js +4 -3
- package/dist/space/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/keys/clientLabels.d.ts +0 -85
- package/dist/keys/clientLabels.d.ts.map +0 -1
- package/dist/keys/clientLabels.js +0 -96
- package/dist/keys/clientLabels.js.map +0 -1
- package/dist/keys/wasLabelsStore.d.ts +0 -33
- package/dist/keys/wasLabelsStore.d.ts.map +0 -1
- package/dist/keys/wasLabelsStore.js +0 -35
- package/dist/keys/wasLabelsStore.js.map +0 -1
- package/dist/writers/entry.d.ts +0 -95
- package/dist/writers/entry.d.ts.map +0 -1
- package/dist/writers/entry.js +0 -90
- package/dist/writers/entry.js.map +0 -1
- package/dist/writers/index.d.ts +0 -17
- package/dist/writers/index.d.ts.map +0 -1
- package/dist/writers/index.js +0 -14
- package/dist/writers/index.js.map +0 -1
- package/dist/writers/roster.d.ts +0 -152
- package/dist/writers/roster.d.ts.map +0 -1
- package/dist/writers/roster.js +0 -365
- package/dist/writers/roster.js.map +0 -1
- package/dist/writers/store.d.ts +0 -71
- package/dist/writers/store.d.ts.map +0 -1
- package/dist/writers/store.js +0 -55
- package/dist/writers/store.js.map +0 -1
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entry version this build reads for writing and writes.
|
|
3
|
+
*/
|
|
4
|
+
export declare const CONNECTION_ENTRY_VERSION = 1;
|
|
5
|
+
/**
|
|
6
|
+
* The `kind` vocabulary: what the party says it is. An entry carrying any
|
|
7
|
+
* other value reads as an unclassified party.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CONNECTION_KINDS: readonly ["app", "agent", "wallet-client", "contact"];
|
|
10
|
+
/**
|
|
11
|
+
* One value of {@link CONNECTION_KINDS}.
|
|
12
|
+
*/
|
|
13
|
+
export type ConnectionKind = (typeof CONNECTION_KINDS)[number];
|
|
14
|
+
/**
|
|
15
|
+
* The `grantKind` vocabulary: `'share'` marks a grant the
|
|
16
|
+
* shared-wallet-collection flow wrote, and `'grant'` is every other delegated
|
|
17
|
+
* capability. A reader treats any other stored value as a plain grant.
|
|
18
|
+
*/
|
|
19
|
+
export declare const GRANT_KINDS: readonly ["grant", "share"];
|
|
20
|
+
/**
|
|
21
|
+
* One value of {@link GRANT_KINDS}.
|
|
22
|
+
*/
|
|
23
|
+
export type GrantKind = (typeof GRANT_KINDS)[number];
|
|
24
|
+
/**
|
|
25
|
+
* The delegated capability a grant wrapper stores verbatim. Only the members
|
|
26
|
+
* the directory's readers take are typed. The rest of the document (its
|
|
27
|
+
* proof and chain) rides along untouched, since revocation POSTs it as it
|
|
28
|
+
* stands.
|
|
29
|
+
*/
|
|
30
|
+
export type ConnectionZcap = {
|
|
31
|
+
id: string;
|
|
32
|
+
controller: string;
|
|
33
|
+
invocationTarget: string;
|
|
34
|
+
allowedAction?: string | string[];
|
|
35
|
+
expires?: string;
|
|
36
|
+
[member: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* One member of an entry's `grants`: the capability, the kind of grant it
|
|
40
|
+
* is, and when the consent that wrote it ran. `grantKind` is kept as stored,
|
|
41
|
+
* so a value from a later build survives; {@link grantKindOf} reads it.
|
|
42
|
+
*/
|
|
43
|
+
export type ConnectionGrantRecord = {
|
|
44
|
+
zcap: ConnectionZcap;
|
|
45
|
+
grantKind: string;
|
|
46
|
+
/**
|
|
47
|
+
* ISO 8601 UTC time of the consent that wrote the grant.
|
|
48
|
+
*/
|
|
49
|
+
grantedAt: string;
|
|
50
|
+
[member: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* One member of an entry's `writers`: a `writerId` the party has written
|
|
54
|
+
* under, with the platform label it registered with and its liveness state.
|
|
55
|
+
*/
|
|
56
|
+
export type ConnectionWriter = {
|
|
57
|
+
writerId: string;
|
|
58
|
+
label: string;
|
|
59
|
+
/**
|
|
60
|
+
* ISO 8601 UTC time of the writer's latest liveness touch.
|
|
61
|
+
*/
|
|
62
|
+
lastSeen: string;
|
|
63
|
+
/**
|
|
64
|
+
* `false` once a sweep found `lastSeen` past the inactivity window. The
|
|
65
|
+
* writer's next touch sets it back to `true`.
|
|
66
|
+
*/
|
|
67
|
+
active: boolean;
|
|
68
|
+
[member: string]: unknown;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* A directory entry as the codec reads it: the members this build knows.
|
|
72
|
+
* `version` is any positive integer the body carried; only
|
|
73
|
+
* {@link CONNECTION_ENTRY_VERSION} is writable here
|
|
74
|
+
* ({@link isWritableConnectionEntry}). `kind` is kept as stored;
|
|
75
|
+
* {@link connectionKindOf} reads it. `name` is the normalized form of the
|
|
76
|
+
* stored member.
|
|
77
|
+
*/
|
|
78
|
+
export type ConnectionEntry = {
|
|
79
|
+
version: number;
|
|
80
|
+
kind: string;
|
|
81
|
+
/**
|
|
82
|
+
* The party's DID. Absent only on a keyless writer entry, which then
|
|
83
|
+
* carries exactly one member in `writers`.
|
|
84
|
+
*/
|
|
85
|
+
id?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The party's latest self-declared name.
|
|
88
|
+
*/
|
|
89
|
+
name?: string;
|
|
90
|
+
/**
|
|
91
|
+
* The user's own name for the party.
|
|
92
|
+
*/
|
|
93
|
+
label?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The attested Web origin, for an App Connect app.
|
|
96
|
+
*/
|
|
97
|
+
origin?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The canonical app URL, for an App Connect app.
|
|
100
|
+
*/
|
|
101
|
+
url?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The app-key Resource id in the app-key collection, present only while
|
|
104
|
+
* the wallet holds the key it minted.
|
|
105
|
+
*/
|
|
106
|
+
appKey?: string;
|
|
107
|
+
firstSeen: string;
|
|
108
|
+
lastSeen: string;
|
|
109
|
+
/**
|
|
110
|
+
* ISO 8601 UTC time the relationship ended. Present once retired.
|
|
111
|
+
*/
|
|
112
|
+
retired?: string;
|
|
113
|
+
grants: ConnectionGrantRecord[];
|
|
114
|
+
writers: ConnectionWriter[];
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* The writer policy every wallet that sweeps must share, or two sweepers
|
|
118
|
+
* disagree about which writer members are inactive or over the cap.
|
|
119
|
+
*/
|
|
120
|
+
export interface ConnectionWriterPolicy {
|
|
121
|
+
/**
|
|
122
|
+
* How long a writer member may go untouched before a sweep marks it
|
|
123
|
+
* inactive.
|
|
124
|
+
*/
|
|
125
|
+
inactiveAfterMs: number;
|
|
126
|
+
/**
|
|
127
|
+
* The most writer members one entry holds. A sweep, or a registration
|
|
128
|
+
* making room, drops the oldest-`lastSeen` members beyond it.
|
|
129
|
+
*/
|
|
130
|
+
maxWriters: number;
|
|
131
|
+
/**
|
|
132
|
+
* The least time between two liveness touches of the same writer member.
|
|
133
|
+
*/
|
|
134
|
+
touchIntervalMs: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The writer policy: inactive after 90 days, at most 8 writers per entry,
|
|
138
|
+
* touched at most once a day.
|
|
139
|
+
*/
|
|
140
|
+
export declare const CONNECTION_WRITER_POLICY: ConnectionWriterPolicy;
|
|
141
|
+
/**
|
|
142
|
+
* Resolves a partial policy override against the defaults. A test may
|
|
143
|
+
* override; every replica sweeping one account must use the same values.
|
|
144
|
+
*
|
|
145
|
+
* @param [policy] {Partial<ConnectionWriterPolicy>}
|
|
146
|
+
* @returns {ConnectionWriterPolicy}
|
|
147
|
+
*/
|
|
148
|
+
export declare function connectionWriterPolicy(policy?: Partial<ConnectionWriterPolicy>): ConnectionWriterPolicy;
|
|
149
|
+
/**
|
|
150
|
+
* An entry's `kind` as one of {@link CONNECTION_KINDS}, or `undefined` for an
|
|
151
|
+
* unclassified party.
|
|
152
|
+
*
|
|
153
|
+
* @param entry {ConnectionEntry}
|
|
154
|
+
* @returns {ConnectionKind | undefined}
|
|
155
|
+
*/
|
|
156
|
+
export declare function connectionKindOf(entry: ConnectionEntry): ConnectionKind | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* A grant's `grantKind` as one of {@link GRANT_KINDS}: `'share'` only when
|
|
159
|
+
* stored so, and `'grant'` for every other value.
|
|
160
|
+
*
|
|
161
|
+
* @param grant {ConnectionGrantRecord}
|
|
162
|
+
* @returns {GrantKind}
|
|
163
|
+
*/
|
|
164
|
+
export declare function grantKindOf(grant: ConnectionGrantRecord): GrantKind;
|
|
165
|
+
/**
|
|
166
|
+
* A fresh entry's body as this build creates it: this build's `version`, the
|
|
167
|
+
* party's `kind` and DID, both timestamps at `now`, and no grants or writers.
|
|
168
|
+
* Every create spreads its own members over this, so the entry shape has one
|
|
169
|
+
* write site beside the codec.
|
|
170
|
+
*
|
|
171
|
+
* @param options {object}
|
|
172
|
+
* @param options.kind {ConnectionKind}
|
|
173
|
+
* @param options.did {string}
|
|
174
|
+
* @param options.now {Date}
|
|
175
|
+
* @returns {Record<string, unknown>}
|
|
176
|
+
*/
|
|
177
|
+
export declare function newConnectionEntry({ kind, did, now }: {
|
|
178
|
+
kind: ConnectionKind;
|
|
179
|
+
did: string;
|
|
180
|
+
now: Date;
|
|
181
|
+
}): Record<string, unknown>;
|
|
182
|
+
/**
|
|
183
|
+
* Whether this build may write over the entry: its `version` is this
|
|
184
|
+
* build's. A body from a newer build is read for display only.
|
|
185
|
+
*
|
|
186
|
+
* @param entry {ConnectionEntry}
|
|
187
|
+
* @returns {boolean}
|
|
188
|
+
*/
|
|
189
|
+
export declare function isWritableConnectionEntry(entry: ConnectionEntry): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Whether a value is a plain JSON object (not null, not an array).
|
|
192
|
+
*
|
|
193
|
+
* @param value {unknown}
|
|
194
|
+
* @returns {boolean}
|
|
195
|
+
*/
|
|
196
|
+
export declare function isJsonObject(value: unknown): value is Record<string, unknown>;
|
|
197
|
+
/**
|
|
198
|
+
* Reads a stored capability's known members, or `undefined` when one of them
|
|
199
|
+
* has the wrong shape. The capability itself is returned verbatim.
|
|
200
|
+
*
|
|
201
|
+
* @param value {unknown}
|
|
202
|
+
* @returns {ConnectionZcap | undefined}
|
|
203
|
+
*/
|
|
204
|
+
export declare function parseConnectionZcap(value: unknown): ConnectionZcap | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Reads a stored body as a directory entry, or `undefined` when it is not
|
|
207
|
+
* one. A body fails when any member this build knows has the wrong shape:
|
|
208
|
+
* a `version` that is not a positive integer, an empty `kind`, an `id` that
|
|
209
|
+
* is not a DID, a `name`, `label`, or writer `label` outside the display-name
|
|
210
|
+
* rule (1 to 64 code points once the control and bidi characters are stripped
|
|
211
|
+
* and the result trimmed), a timestamp `Date.parse` cannot read, a malformed
|
|
212
|
+
* grant wrapper or writer member, or no `id` beside anything but exactly one
|
|
213
|
+
* writer. Every display string a view renders is held to that one rule.
|
|
214
|
+
* Unknown members are ignored. A body with a `version` above this build's
|
|
215
|
+
* that passes every check is returned for display;
|
|
216
|
+
* {@link isWritableConnectionEntry} says it cannot be written.
|
|
217
|
+
*
|
|
218
|
+
* Where the body sits is not checked here. A reader also checks that the
|
|
219
|
+
* body sits at the resource id its own `id` (or its one writer) derives to
|
|
220
|
+
* (`read.ts`).
|
|
221
|
+
*
|
|
222
|
+
* @param body {unknown}
|
|
223
|
+
* @returns {ConnectionEntry | undefined}
|
|
224
|
+
*/
|
|
225
|
+
export declare function parseConnectionEntry(body: unknown): ConnectionEntry | undefined;
|
|
226
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/connections/entry.ts"],"names":[],"mappings":"AAuBA;;GAEG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAA;AAEzC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,uDAKnB,CAAA;AAEV;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9D;;;;GAIG;AACH,eAAO,MAAM,WAAW,6BAA8B,CAAA;AAEtD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;CAC1B,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,cAAc,CAAA;IACpB,SAAS,E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sB,CACpC,MAAM,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACvC,sBAAsB,CAExB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,eAAe,GACrB,cAAc,GAAG,SAAS,CAI5B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CAEnE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,GAAG,EACH,GAAG,EACJ,EAAE;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,IAAI,CAAA;CACV,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAW1B;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE7E;AAsBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,cAAc,GAAG,SAAS,CAqB5B;AAkDD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,GACZ,eAAe,GAAG,SAAS,CA2E7B"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The `connections` directory entry: its version-1 members, the `kind` and
|
|
6
|
+
* `grantKind` vocabularies, the writer policy every sweeper shares, and the
|
|
7
|
+
* codec every reader runs.
|
|
8
|
+
*
|
|
9
|
+
* The codec reads leniently. It checks the shape of every member this build
|
|
10
|
+
* knows, and a body that fails that check is unparseable and skipped by
|
|
11
|
+
* every listing. It ignores members it does not know, at the top level and
|
|
12
|
+
* on a grant wrapper. A well-formed body whose `version` is above this
|
|
13
|
+
* build's is still read, for display, from the members this build knows. The
|
|
14
|
+
* writers in `upsert.ts` and `writers.ts` work on the stored body itself, so
|
|
15
|
+
* every member they do not own, known or not, is written back verbatim, and
|
|
16
|
+
* they refuse a body this build cannot write.
|
|
17
|
+
*
|
|
18
|
+
* Nothing here authenticates a body. An EDV envelope does not authenticate
|
|
19
|
+
* its writer, so the storage host can plant one. The grant checks in
|
|
20
|
+
* `grants.ts` bound what a planted grant can steer.
|
|
21
|
+
*/
|
|
22
|
+
import { normalizeDisplayName } from '../labelText.js';
|
|
23
|
+
/**
|
|
24
|
+
* The entry version this build reads for writing and writes.
|
|
25
|
+
*/
|
|
26
|
+
export const CONNECTION_ENTRY_VERSION = 1;
|
|
27
|
+
/**
|
|
28
|
+
* The `kind` vocabulary: what the party says it is. An entry carrying any
|
|
29
|
+
* other value reads as an unclassified party.
|
|
30
|
+
*/
|
|
31
|
+
export const CONNECTION_KINDS = [
|
|
32
|
+
'app',
|
|
33
|
+
'agent',
|
|
34
|
+
'wallet-client',
|
|
35
|
+
'contact'
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* The `grantKind` vocabulary: `'share'` marks a grant the
|
|
39
|
+
* shared-wallet-collection flow wrote, and `'grant'` is every other delegated
|
|
40
|
+
* capability. A reader treats any other stored value as a plain grant.
|
|
41
|
+
*/
|
|
42
|
+
export const GRANT_KINDS = ['grant', 'share'];
|
|
43
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
44
|
+
/**
|
|
45
|
+
* The writer policy: inactive after 90 days, at most 8 writers per entry,
|
|
46
|
+
* touched at most once a day.
|
|
47
|
+
*/
|
|
48
|
+
export const CONNECTION_WRITER_POLICY = {
|
|
49
|
+
inactiveAfterMs: 90 * DAY_MS,
|
|
50
|
+
maxWriters: 8,
|
|
51
|
+
touchIntervalMs: DAY_MS
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Resolves a partial policy override against the defaults. A test may
|
|
55
|
+
* override; every replica sweeping one account must use the same values.
|
|
56
|
+
*
|
|
57
|
+
* @param [policy] {Partial<ConnectionWriterPolicy>}
|
|
58
|
+
* @returns {ConnectionWriterPolicy}
|
|
59
|
+
*/
|
|
60
|
+
export function connectionWriterPolicy(policy) {
|
|
61
|
+
return { ...CONNECTION_WRITER_POLICY, ...policy };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* An entry's `kind` as one of {@link CONNECTION_KINDS}, or `undefined` for an
|
|
65
|
+
* unclassified party.
|
|
66
|
+
*
|
|
67
|
+
* @param entry {ConnectionEntry}
|
|
68
|
+
* @returns {ConnectionKind | undefined}
|
|
69
|
+
*/
|
|
70
|
+
export function connectionKindOf(entry) {
|
|
71
|
+
return CONNECTION_KINDS.includes(entry.kind)
|
|
72
|
+
? entry.kind
|
|
73
|
+
: undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A grant's `grantKind` as one of {@link GRANT_KINDS}: `'share'` only when
|
|
77
|
+
* stored so, and `'grant'` for every other value.
|
|
78
|
+
*
|
|
79
|
+
* @param grant {ConnectionGrantRecord}
|
|
80
|
+
* @returns {GrantKind}
|
|
81
|
+
*/
|
|
82
|
+
export function grantKindOf(grant) {
|
|
83
|
+
return grant.grantKind === 'share' ? 'share' : 'grant';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A fresh entry's body as this build creates it: this build's `version`, the
|
|
87
|
+
* party's `kind` and DID, both timestamps at `now`, and no grants or writers.
|
|
88
|
+
* Every create spreads its own members over this, so the entry shape has one
|
|
89
|
+
* write site beside the codec.
|
|
90
|
+
*
|
|
91
|
+
* @param options {object}
|
|
92
|
+
* @param options.kind {ConnectionKind}
|
|
93
|
+
* @param options.did {string}
|
|
94
|
+
* @param options.now {Date}
|
|
95
|
+
* @returns {Record<string, unknown>}
|
|
96
|
+
*/
|
|
97
|
+
export function newConnectionEntry({ kind, did, now }) {
|
|
98
|
+
const stamp = now.toISOString();
|
|
99
|
+
return {
|
|
100
|
+
version: CONNECTION_ENTRY_VERSION,
|
|
101
|
+
kind,
|
|
102
|
+
id: did,
|
|
103
|
+
firstSeen: stamp,
|
|
104
|
+
lastSeen: stamp,
|
|
105
|
+
grants: [],
|
|
106
|
+
writers: []
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Whether this build may write over the entry: its `version` is this
|
|
111
|
+
* build's. A body from a newer build is read for display only.
|
|
112
|
+
*
|
|
113
|
+
* @param entry {ConnectionEntry}
|
|
114
|
+
* @returns {boolean}
|
|
115
|
+
*/
|
|
116
|
+
export function isWritableConnectionEntry(entry) {
|
|
117
|
+
return entry.version === CONNECTION_ENTRY_VERSION;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Whether a value is a plain JSON object (not null, not an array).
|
|
121
|
+
*
|
|
122
|
+
* @param value {unknown}
|
|
123
|
+
* @returns {boolean}
|
|
124
|
+
*/
|
|
125
|
+
export function isJsonObject(value) {
|
|
126
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Whether a value is a string `Date.parse` reads as a time.
|
|
130
|
+
*
|
|
131
|
+
* @param value {unknown}
|
|
132
|
+
* @returns {boolean}
|
|
133
|
+
*/
|
|
134
|
+
function isTimestamp(value) {
|
|
135
|
+
return typeof value === 'string' && !Number.isNaN(Date.parse(value));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Whether a value is absent or a string.
|
|
139
|
+
*
|
|
140
|
+
* @param value {unknown}
|
|
141
|
+
* @returns {boolean}
|
|
142
|
+
*/
|
|
143
|
+
function isOptionalString(value) {
|
|
144
|
+
return value === undefined || typeof value === 'string';
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Reads a stored capability's known members, or `undefined` when one of them
|
|
148
|
+
* has the wrong shape. The capability itself is returned verbatim.
|
|
149
|
+
*
|
|
150
|
+
* @param value {unknown}
|
|
151
|
+
* @returns {ConnectionZcap | undefined}
|
|
152
|
+
*/
|
|
153
|
+
export function parseConnectionZcap(value) {
|
|
154
|
+
if (!isJsonObject(value)) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
const { id, controller, invocationTarget, allowedAction, expires } = value;
|
|
158
|
+
if (typeof id !== 'string' ||
|
|
159
|
+
id === '' ||
|
|
160
|
+
typeof controller !== 'string' ||
|
|
161
|
+
typeof invocationTarget !== 'string' ||
|
|
162
|
+
(allowedAction !== undefined &&
|
|
163
|
+
typeof allowedAction !== 'string' &&
|
|
164
|
+
!(Array.isArray(allowedAction) &&
|
|
165
|
+
allowedAction.every(action => typeof action === 'string'))) ||
|
|
166
|
+
(expires !== undefined && !isTimestamp(expires))) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Reads one stored grant wrapper, or `undefined` when a known member has the
|
|
173
|
+
* wrong shape. The wrapper is returned verbatim, unknown members included.
|
|
174
|
+
*
|
|
175
|
+
* @param value {unknown}
|
|
176
|
+
* @returns {ConnectionGrantRecord | undefined}
|
|
177
|
+
*/
|
|
178
|
+
function parseGrantRecord(value) {
|
|
179
|
+
if (!isJsonObject(value)) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
if (parseConnectionZcap(value.zcap) === undefined ||
|
|
183
|
+
typeof value.grantKind !== 'string' ||
|
|
184
|
+
!isTimestamp(value.grantedAt)) {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Reads one stored writer member, or `undefined` when a known member has the
|
|
191
|
+
* wrong shape. The member is returned verbatim, unknown members included.
|
|
192
|
+
*
|
|
193
|
+
* @param value {unknown}
|
|
194
|
+
* @returns {ConnectionWriter | undefined}
|
|
195
|
+
*/
|
|
196
|
+
function parseWriter(value) {
|
|
197
|
+
if (!isJsonObject(value)) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
if (typeof value.writerId !== 'string' ||
|
|
201
|
+
value.writerId === '' ||
|
|
202
|
+
typeof value.label !== 'string' ||
|
|
203
|
+
!isTimestamp(value.lastSeen) ||
|
|
204
|
+
typeof value.active !== 'boolean') {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
const label = normalizeDisplayName({ value: value.label });
|
|
208
|
+
if (label === undefined) {
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
return { ...value, label };
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Reads a stored body as a directory entry, or `undefined` when it is not
|
|
215
|
+
* one. A body fails when any member this build knows has the wrong shape:
|
|
216
|
+
* a `version` that is not a positive integer, an empty `kind`, an `id` that
|
|
217
|
+
* is not a DID, a `name`, `label`, or writer `label` outside the display-name
|
|
218
|
+
* rule (1 to 64 code points once the control and bidi characters are stripped
|
|
219
|
+
* and the result trimmed), a timestamp `Date.parse` cannot read, a malformed
|
|
220
|
+
* grant wrapper or writer member, or no `id` beside anything but exactly one
|
|
221
|
+
* writer. Every display string a view renders is held to that one rule.
|
|
222
|
+
* Unknown members are ignored. A body with a `version` above this build's
|
|
223
|
+
* that passes every check is returned for display;
|
|
224
|
+
* {@link isWritableConnectionEntry} says it cannot be written.
|
|
225
|
+
*
|
|
226
|
+
* Where the body sits is not checked here. A reader also checks that the
|
|
227
|
+
* body sits at the resource id its own `id` (or its one writer) derives to
|
|
228
|
+
* (`read.ts`).
|
|
229
|
+
*
|
|
230
|
+
* @param body {unknown}
|
|
231
|
+
* @returns {ConnectionEntry | undefined}
|
|
232
|
+
*/
|
|
233
|
+
export function parseConnectionEntry(body) {
|
|
234
|
+
if (!isJsonObject(body)) {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
const { version, kind, id, name, label, origin, url, appKey, firstSeen, lastSeen, retired, grants, writers } = body;
|
|
238
|
+
if (typeof version !== 'number' ||
|
|
239
|
+
!Number.isInteger(version) ||
|
|
240
|
+
version < 1 ||
|
|
241
|
+
typeof kind !== 'string' ||
|
|
242
|
+
kind === '' ||
|
|
243
|
+
(id !== undefined && (typeof id !== 'string' || !id.startsWith('did:'))) ||
|
|
244
|
+
!isOptionalString(name) ||
|
|
245
|
+
!isOptionalString(label) ||
|
|
246
|
+
!isOptionalString(origin) ||
|
|
247
|
+
!isOptionalString(url) ||
|
|
248
|
+
(appKey !== undefined && (typeof appKey !== 'string' || appKey === '')) ||
|
|
249
|
+
!isTimestamp(firstSeen) ||
|
|
250
|
+
!isTimestamp(lastSeen) ||
|
|
251
|
+
(retired !== undefined && !isTimestamp(retired)) ||
|
|
252
|
+
!Array.isArray(grants) ||
|
|
253
|
+
!Array.isArray(writers)) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
const normalizedName = name === undefined ? undefined : normalizeDisplayName({ value: name });
|
|
257
|
+
const normalizedLabel = label === undefined ? undefined : normalizeDisplayName({ value: label });
|
|
258
|
+
if ((name !== undefined && normalizedName === undefined) ||
|
|
259
|
+
(label !== undefined && normalizedLabel === undefined)) {
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
const parsedGrants = grants.map(parseGrantRecord);
|
|
263
|
+
const parsedWriters = writers.map(parseWriter);
|
|
264
|
+
if (parsedGrants.some(grant => grant === undefined) ||
|
|
265
|
+
parsedWriters.some(writer => writer === undefined)) {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
if (id === undefined && parsedWriters.length !== 1) {
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
version,
|
|
273
|
+
kind,
|
|
274
|
+
...(id !== undefined && { id }),
|
|
275
|
+
...(normalizedName !== undefined && { name: normalizedName }),
|
|
276
|
+
...(normalizedLabel !== undefined && { label: normalizedLabel }),
|
|
277
|
+
...(origin !== undefined && { origin }),
|
|
278
|
+
...(url !== undefined && { url }),
|
|
279
|
+
...(appKey !== undefined && { appKey }),
|
|
280
|
+
firstSeen,
|
|
281
|
+
lastSeen,
|
|
282
|
+
...(retired !== undefined && { retired }),
|
|
283
|
+
grants: parsedGrants,
|
|
284
|
+
writers: parsedWriters
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../src/connections/entry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK;IACL,OAAO;IACP,eAAe;IACf,SAAS;CACD,CAAA;AAOV;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU,CAAA;AAuGtD,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAuBlC;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAA2B;IAC9D,eAAe,EAAE,EAAE,GAAG,MAAM;IAC5B,UAAU,EAAE,CAAC;IACb,eAAe,EAAE,MAAM;CACxB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAwC;IAExC,OAAO,EAAE,GAAG,wBAAwB,EAAE,GAAG,MAAM,EAAE,CAAA;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAsB;IAEtB,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,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AI,EAAE,KAAK,SAAS,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnD,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO;QACL,OAAO;QACP,IAAI;QACJ,GAAG,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,EAAE,EAAE,CAAC;QAC/B,GAAG,CAAC,cAAc,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;QAC7D,GAAG,CAAC,eAAe,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;QAChE,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;QACvC,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,EAAE,GAAG,EAAE,CAAC;QACjC,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;QACvC,SAAS;QACT,QAAQ;QACR,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC;QACzC,MAAM,EAAE,YAAuC;QAC/C,OAAO,EAAE,aAAmC;KAC7C,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The directory's typed refusal.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A write refused because the entry at the party's id carries another
|
|
9
|
+
* `kind` than the one the writing flow writes: a consent for an agent
|
|
10
|
+
* finding an `app` entry, or a wallet-client write finding an agent. A
|
|
11
|
+
* consent that meets it fails closed. Matched by `err.name`, since a caller
|
|
12
|
+
* may hold a second copy of this package.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ConnectionKindMismatchError extends Error {
|
|
15
|
+
/**
|
|
16
|
+
* The kind the writing flow writes.
|
|
17
|
+
*/
|
|
18
|
+
expectedKind: string;
|
|
19
|
+
/**
|
|
20
|
+
* The kind the stored entry carries.
|
|
21
|
+
*/
|
|
22
|
+
foundKind: string;
|
|
23
|
+
/**
|
|
24
|
+
* @param options {object}
|
|
25
|
+
* @param options.expectedKind {string}
|
|
26
|
+
* @param options.foundKind {string}
|
|
27
|
+
*/
|
|
28
|
+
constructor({ expectedKind, foundKind }: {
|
|
29
|
+
expectedKind: string;
|
|
30
|
+
foundKind: string;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/connections/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;GAEG;AAEH;;;;;;GAMG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;;;OAIG;gBACS,EACV,YAAY,EACZ,SAAS,EACV,EAAE;QACD,YAAY,EAAE,MAAM,CAAA;QACpB,SAAS,EAAE,MAAM,CAAA;KAClB;CASF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The directory's typed refusal.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A write refused because the entry at the party's id carries another
|
|
9
|
+
* `kind` than the one the writing flow writes: a consent for an agent
|
|
10
|
+
* finding an `app` entry, or a wallet-client write finding an agent. A
|
|
11
|
+
* consent that meets it fails closed. Matched by `err.name`, since a caller
|
|
12
|
+
* may hold a second copy of this package.
|
|
13
|
+
*/
|
|
14
|
+
export class ConnectionKindMismatchError extends Error {
|
|
15
|
+
/**
|
|
16
|
+
* The kind the writing flow writes.
|
|
17
|
+
*/
|
|
18
|
+
expectedKind;
|
|
19
|
+
/**
|
|
20
|
+
* The kind the stored entry carries.
|
|
21
|
+
*/
|
|
22
|
+
foundKind;
|
|
23
|
+
/**
|
|
24
|
+
* @param options {object}
|
|
25
|
+
* @param options.expectedKind {string}
|
|
26
|
+
* @param options.foundKind {string}
|
|
27
|
+
*/
|
|
28
|
+
constructor({ expectedKind, foundKind }) {
|
|
29
|
+
super(`The connections entry at this party's id is a "${foundKind}" entry; ` +
|
|
30
|
+
`this write is for a "${expectedKind}" entry, so it was refused.`);
|
|
31
|
+
this.name = 'ConnectionKindMismatchError';
|
|
32
|
+
this.expectedKind = expectedKind;
|
|
33
|
+
this.foundKind = foundKind;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/connections/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD;;OAEG;IACH,YAAY,CAAQ;IACpB;;OAEG;IACH,SAAS,CAAQ;IAEjB;;;;OAIG;IACH,YAAY,EACV,YAAY,EACZ,SAAS,EAIV;QACC,KAAK,CACH,kDAAkD,SAAS,WAAW;YACpE,wBAAwB,YAAY,6BAA6B,CACpE,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAA;QACzC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;CACF"}
|