keri-ts 0.7.0 → 0.8.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/esm/cesr/src/primitives/mapper.js +48 -41
- package/esm/cesr/src/serder/native.js +62 -29
- package/esm/cesr/src/serder/serder.js +35 -46
- package/esm/cesr/src/serder/serdery.js +7 -43
- package/esm/cesr/src/version.js +2 -2
- package/esm/keri/src/acdc/index.js +1 -0
- package/esm/keri/src/acdc/messaging.js +491 -0
- package/esm/keri/src/app/agent-runtime.js +46 -3
- package/esm/keri/src/app/cesr-http.js +9 -2
- package/esm/keri/src/app/cli/index.js +4 -0
- package/esm/keri/src/app/cli/ipex.js +443 -0
- package/esm/keri/src/app/cli/saidify.js +51 -0
- package/esm/keri/src/app/cli/vc.js +439 -0
- package/esm/keri/src/app/cli/verifier.js +104 -0
- package/esm/keri/src/app/exchanging.js +30 -0
- package/esm/keri/src/app/forwarding.js +43 -23
- package/esm/keri/src/app/grouping.js +382 -0
- package/esm/keri/src/app/ipex-credentialing.js +227 -0
- package/esm/keri/src/app/ipexing.js +212 -0
- package/esm/keri/src/app/oobiery.js +50 -10
- package/esm/keri/src/app/parsering.js +58 -7
- package/esm/keri/src/app/reactor.js +30 -3
- package/esm/keri/src/app/schema-resolving.js +28 -0
- package/esm/keri/src/app/verifier-agent.js +408 -0
- package/esm/keri/src/app/verifying.js +358 -0
- package/esm/keri/src/app/version.js +2 -2
- package/esm/keri/src/core/mailbox-topics.js +2 -0
- package/esm/keri/src/core/protocol-exchanging.js +10 -6
- package/esm/keri/src/core/protocol-serialization.js +6 -9
- package/esm/keri/src/core/protocol-vdr-eventing.js +288 -0
- package/esm/keri/src/core/scheming.js +162 -0
- package/esm/keri/src/db/basing.js +2 -4
- package/esm/keri/src/db/index.js +1 -0
- package/esm/keri/src/db/reger.js +478 -0
- package/esm/keri/src/db/subing.js +32 -19
- package/esm/keri/src/db/verifier-cueing.js +125 -0
- package/esm/keri/src/library/index.js +1 -0
- package/esm/keri/src/runtime/index.js +11 -0
- package/esm/keri/src/vdr/credentialing.js +556 -0
- package/esm/keri/src/vdr/eventing.js +931 -0
- package/package.json +3 -2
- package/types/cesr/src/primitives/mapper.d.ts.map +1 -1
- package/types/cesr/src/serder/native.d.ts +9 -0
- package/types/cesr/src/serder/native.d.ts.map +1 -1
- package/types/cesr/src/serder/serder.d.ts.map +1 -1
- package/types/cesr/src/serder/serdery.d.ts.map +1 -1
- package/types/cesr/src/version.d.ts +2 -2
- package/types/keri/src/acdc/index.d.ts +2 -0
- package/types/keri/src/acdc/index.d.ts.map +1 -0
- package/types/keri/src/acdc/messaging.d.ts +104 -0
- package/types/keri/src/acdc/messaging.d.ts.map +1 -0
- package/types/keri/src/app/agent-runtime.d.ts +3 -1
- package/types/keri/src/app/agent-runtime.d.ts.map +1 -1
- package/types/keri/src/app/cesr-http.d.ts.map +1 -1
- package/types/keri/src/app/cli/index.d.ts +4 -0
- package/types/keri/src/app/cli/index.d.ts.map +1 -1
- package/types/keri/src/app/cli/ipex.d.ts +11 -0
- package/types/keri/src/app/cli/ipex.d.ts.map +1 -0
- package/types/keri/src/app/cli/saidify.d.ts +4 -0
- package/types/keri/src/app/cli/saidify.d.ts.map +1 -0
- package/types/keri/src/app/cli/vc.d.ts +11 -0
- package/types/keri/src/app/cli/vc.d.ts.map +1 -0
- package/types/keri/src/app/cli/verifier.d.ts +3 -0
- package/types/keri/src/app/cli/verifier.d.ts.map +1 -0
- package/types/keri/src/app/exchanging.d.ts +7 -0
- package/types/keri/src/app/exchanging.d.ts.map +1 -1
- package/types/keri/src/app/forwarding.d.ts.map +1 -1
- package/types/keri/src/app/grouping.d.ts +111 -0
- package/types/keri/src/app/grouping.d.ts.map +1 -0
- package/types/keri/src/app/ipex-credentialing.d.ts +81 -0
- package/types/keri/src/app/ipex-credentialing.d.ts.map +1 -0
- package/types/keri/src/app/ipexing.d.ts +84 -0
- package/types/keri/src/app/ipexing.d.ts.map +1 -0
- package/types/keri/src/app/oobiery.d.ts +2 -0
- package/types/keri/src/app/oobiery.d.ts.map +1 -1
- package/types/keri/src/app/parsering.d.ts +45 -3
- package/types/keri/src/app/parsering.d.ts.map +1 -1
- package/types/keri/src/app/reactor.d.ts +31 -1
- package/types/keri/src/app/reactor.d.ts.map +1 -1
- package/types/keri/src/app/schema-resolving.d.ts +31 -0
- package/types/keri/src/app/schema-resolving.d.ts.map +1 -0
- package/types/keri/src/app/verifier-agent.d.ts +82 -0
- package/types/keri/src/app/verifier-agent.d.ts.map +1 -0
- package/types/keri/src/app/verifying.d.ts +111 -0
- package/types/keri/src/app/verifying.d.ts.map +1 -0
- package/types/keri/src/app/version.d.ts +2 -2
- package/types/keri/src/core/cues.d.ts +28 -3
- package/types/keri/src/core/cues.d.ts.map +1 -1
- package/types/keri/src/core/mailbox-topics.d.ts +2 -0
- package/types/keri/src/core/mailbox-topics.d.ts.map +1 -1
- package/types/keri/src/core/protocol-exchanging.d.ts.map +1 -1
- package/types/keri/src/core/protocol-serialization.d.ts.map +1 -1
- package/types/keri/src/core/protocol-vdr-eventing.d.ts +69 -0
- package/types/keri/src/core/protocol-vdr-eventing.d.ts.map +1 -0
- package/types/keri/src/core/scheming.d.ts +38 -0
- package/types/keri/src/core/scheming.d.ts.map +1 -0
- package/types/keri/src/db/basing.d.ts +2 -2
- package/types/keri/src/db/basing.d.ts.map +1 -1
- package/types/keri/src/db/index.d.ts +1 -0
- package/types/keri/src/db/index.d.ts.map +1 -1
- package/types/keri/src/db/reger.d.ts +91 -0
- package/types/keri/src/db/reger.d.ts.map +1 -0
- package/types/keri/src/db/subing.d.ts +18 -3
- package/types/keri/src/db/subing.d.ts.map +1 -1
- package/types/keri/src/db/verifier-cueing.d.ts +46 -0
- package/types/keri/src/db/verifier-cueing.d.ts.map +1 -0
- package/types/keri/src/library/index.d.ts +1 -0
- package/types/keri/src/library/index.d.ts.map +1 -1
- package/types/keri/src/runtime/index.d.ts +11 -0
- package/types/keri/src/runtime/index.d.ts.map +1 -1
- package/types/keri/src/vdr/credentialing.d.ts +169 -0
- package/types/keri/src/vdr/credentialing.d.ts.map +1 -0
- package/types/keri/src/vdr/eventing.d.ts +157 -0
- package/types/keri/src/vdr/eventing.d.ts.map +1 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ACDC v2 message factory helpers.
|
|
3
|
+
*
|
|
4
|
+
* This module mirrors KERIpy's `keri.acdc.messaging` builder surface. Callers
|
|
5
|
+
* provide semantic values and the helpers preserve KERIpy field order, default
|
|
6
|
+
* schema content, compact-form SAID rules, and v2 registry-update SAD shapes
|
|
7
|
+
* before delegating serialization to `SerderACDC`.
|
|
8
|
+
*/
|
|
9
|
+
import { Ilks, Kinds, Mapper, NonceDex, Noncer, Protocols, SerderACDC, versify, Vrsn_2_0, } from "../../../cesr/mod.js";
|
|
10
|
+
import { ValidationError } from "../core/errors.js";
|
|
11
|
+
import { makeNowIso8601 } from "../time/mod.js";
|
|
12
|
+
function versionString({ pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json, } = {}) {
|
|
13
|
+
return versify({
|
|
14
|
+
proto: Protocols.acdc,
|
|
15
|
+
pvrsn,
|
|
16
|
+
gvrsn,
|
|
17
|
+
kind,
|
|
18
|
+
size: 0,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function sequenceHex(sn) {
|
|
22
|
+
const value = BigInt(sn);
|
|
23
|
+
if (value < 0n) {
|
|
24
|
+
throw new ValidationError(`ACDC sequence number must be non-negative: ${sn}`);
|
|
25
|
+
}
|
|
26
|
+
return value.toString(16);
|
|
27
|
+
}
|
|
28
|
+
function randomNonce() {
|
|
29
|
+
return new Noncer({
|
|
30
|
+
code: NonceDex.Salt_128,
|
|
31
|
+
raw: crypto.getRandomValues(new Uint8Array(16)),
|
|
32
|
+
}).qb64;
|
|
33
|
+
}
|
|
34
|
+
function cloneMapperValue(value) {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
return value.map((entry) => cloneMapperValue(entry));
|
|
37
|
+
}
|
|
38
|
+
if (value && typeof value === "object") {
|
|
39
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, cloneMapperValue(entry)]));
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
function defaultSchema(schema, kind) {
|
|
44
|
+
const mapper = new Mapper({
|
|
45
|
+
mad: schema,
|
|
46
|
+
makify: true,
|
|
47
|
+
strict: false,
|
|
48
|
+
saids: { "$id": "E" },
|
|
49
|
+
saidive: true,
|
|
50
|
+
kind,
|
|
51
|
+
});
|
|
52
|
+
const said = mapper.said;
|
|
53
|
+
if (said === null) {
|
|
54
|
+
throw new ValidationError("Default ACDC schema did not produce an $id SAID.");
|
|
55
|
+
}
|
|
56
|
+
return [said, mapper.mad];
|
|
57
|
+
}
|
|
58
|
+
function schemaSaidAndSad(schema, fallback, kind) {
|
|
59
|
+
if (schema === undefined || schema === null) {
|
|
60
|
+
return fallback;
|
|
61
|
+
}
|
|
62
|
+
if (typeof schema === "string") {
|
|
63
|
+
return [schema, schema];
|
|
64
|
+
}
|
|
65
|
+
return defaultSchema(cloneMapperValue(schema), kind);
|
|
66
|
+
}
|
|
67
|
+
function withIssuee(attribute, issuee) {
|
|
68
|
+
const cloned = cloneMapperValue(attribute);
|
|
69
|
+
if (issuee !== undefined && issuee !== null && cloned && typeof cloned === "object" && !Array.isArray(cloned)) {
|
|
70
|
+
cloned.i = issuee;
|
|
71
|
+
}
|
|
72
|
+
return cloned;
|
|
73
|
+
}
|
|
74
|
+
function validateAttributeAggregatePair(attribute, aggregate) {
|
|
75
|
+
if ((attribute !== undefined && attribute !== null) === (aggregate !== undefined && aggregate !== null)) {
|
|
76
|
+
throw new ValidationError("Either one or the other but not both of attribute and aggregate is required.");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** Create an ACDC v2 registry inception (`rip`) message. */
|
|
80
|
+
export function regcept(issuer, options = {}) {
|
|
81
|
+
const { uuid, stamp, pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json } = options;
|
|
82
|
+
return new SerderACDC({
|
|
83
|
+
sad: {
|
|
84
|
+
v: versionString({ pvrsn, gvrsn, kind }),
|
|
85
|
+
t: Ilks.rip,
|
|
86
|
+
d: "",
|
|
87
|
+
u: uuid ?? randomNonce(),
|
|
88
|
+
i: issuer,
|
|
89
|
+
n: sequenceHex(0),
|
|
90
|
+
dt: stamp ?? makeNowIso8601(),
|
|
91
|
+
},
|
|
92
|
+
makify: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** Create an ACDC v2 blindable registry update (`bup`) message. */
|
|
96
|
+
export function blindate(regid, prior, blid, options = {}) {
|
|
97
|
+
const { sn = 1, stamp, pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json } = options;
|
|
98
|
+
return new SerderACDC({
|
|
99
|
+
sad: {
|
|
100
|
+
v: versionString({ pvrsn, gvrsn, kind }),
|
|
101
|
+
t: Ilks.bup,
|
|
102
|
+
d: "",
|
|
103
|
+
rd: regid,
|
|
104
|
+
n: sequenceHex(sn),
|
|
105
|
+
p: prior,
|
|
106
|
+
dt: stamp ?? makeNowIso8601(),
|
|
107
|
+
b: blid,
|
|
108
|
+
},
|
|
109
|
+
makify: true,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/** Create an ACDC v2 registry transaction-state update (`upd`) message. */
|
|
113
|
+
export function update(regid, prior, acdc, state, options = {}) {
|
|
114
|
+
const { sn = 1, stamp, pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json } = options;
|
|
115
|
+
return new SerderACDC({
|
|
116
|
+
sad: {
|
|
117
|
+
v: versionString({ pvrsn, gvrsn, kind }),
|
|
118
|
+
t: Ilks.upd,
|
|
119
|
+
d: "",
|
|
120
|
+
rd: regid,
|
|
121
|
+
n: sequenceHex(sn),
|
|
122
|
+
p: prior,
|
|
123
|
+
dt: stamp ?? makeNowIso8601(),
|
|
124
|
+
td: acdc,
|
|
125
|
+
ts: state,
|
|
126
|
+
},
|
|
127
|
+
makify: true,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** Create the default schema block for ACDC v2 map-style (`acm`) messages. */
|
|
131
|
+
export function acmSchemaDefault(kind = Kinds.json) {
|
|
132
|
+
return defaultSchema({
|
|
133
|
+
"$id": "",
|
|
134
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
135
|
+
title: "ACM Default Schema",
|
|
136
|
+
description: "Default JSON Schema for acm ACDC.",
|
|
137
|
+
credentialType: "ACDC_acm_message",
|
|
138
|
+
version: "2.0.0",
|
|
139
|
+
type: "object",
|
|
140
|
+
required: ["v", "d", "i", "s"],
|
|
141
|
+
properties: {
|
|
142
|
+
v: { description: "ACDC version string", type: "string" },
|
|
143
|
+
t: { description: "Message type", type: "string" },
|
|
144
|
+
d: { description: "Message SAID", type: "string" },
|
|
145
|
+
u: { description: "Message UUID", type: "string" },
|
|
146
|
+
i: { description: "Issuer AID", type: "string" },
|
|
147
|
+
rd: { description: "Registry SAID", type: "string" },
|
|
148
|
+
s: {
|
|
149
|
+
description: "Schema Section",
|
|
150
|
+
oneOf: [
|
|
151
|
+
{ description: "Schema Section SAID", type: "string" },
|
|
152
|
+
{ description: "Uncompacted Schema Section", type: "object" },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
a: {
|
|
156
|
+
description: "Attribute Section",
|
|
157
|
+
oneOf: [
|
|
158
|
+
{ description: "Attribute Section SAID", type: "string" },
|
|
159
|
+
{ description: "Uncompacted Attribute Section", type: "object" },
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
A: {
|
|
163
|
+
description: "Aggregate Section",
|
|
164
|
+
oneOf: [
|
|
165
|
+
{ description: "Aggregate Section AGID", type: "string" },
|
|
166
|
+
{ description: "Uncompacted Aggregate Section", type: "array" },
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
e: {
|
|
170
|
+
description: "Edge Section",
|
|
171
|
+
oneOf: [
|
|
172
|
+
{ description: "Edge Section SAID", type: "string" },
|
|
173
|
+
{ description: "Uncompacted Edge Section", type: "object" },
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
r: {
|
|
177
|
+
description: "Rule Section",
|
|
178
|
+
oneOf: [
|
|
179
|
+
{ description: "Rule Section SAID", type: "string" },
|
|
180
|
+
{ description: "Uncompacted Rule Section", type: "object" },
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
additionalProperties: false,
|
|
185
|
+
}, kind);
|
|
186
|
+
}
|
|
187
|
+
/** Create the default schema block for ACDC v2 fixed-attribute (`act`) messages. */
|
|
188
|
+
export function actSchemaDefault(kind = Kinds.json) {
|
|
189
|
+
return defaultSchema({
|
|
190
|
+
"$id": "",
|
|
191
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
192
|
+
title: "ACT Default Schema",
|
|
193
|
+
description: "Default JSON Schema for act ACDC.",
|
|
194
|
+
credentialType: "ACDC_act_message",
|
|
195
|
+
version: "2.0.0",
|
|
196
|
+
type: "object",
|
|
197
|
+
required: ["v", "t", "d", "u", "i", "rd", "s", "a", "e", "r"],
|
|
198
|
+
properties: {
|
|
199
|
+
v: { description: "ACDC version string", type: "string" },
|
|
200
|
+
t: { description: "Message type", type: "string" },
|
|
201
|
+
d: { description: "Message SAID", type: "string" },
|
|
202
|
+
u: { description: "Message UUID", type: "string" },
|
|
203
|
+
i: { description: "Issuer AID", type: "string" },
|
|
204
|
+
rd: { description: "Registry SAID", type: "string" },
|
|
205
|
+
s: {
|
|
206
|
+
description: "Schema Section",
|
|
207
|
+
oneOf: [
|
|
208
|
+
{ description: "Schema Section SAID", type: "string" },
|
|
209
|
+
{ description: "Uncompacted Schema Section", type: "object" },
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
a: {
|
|
213
|
+
description: "Attribute Section",
|
|
214
|
+
oneOf: [
|
|
215
|
+
{ description: "Attribute Section SAID", type: "string" },
|
|
216
|
+
{ description: "Uncompacted Attribute Section", type: "object" },
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
e: {
|
|
220
|
+
description: "Edge Section",
|
|
221
|
+
oneOf: [
|
|
222
|
+
{ description: "Edge Section SAID", type: "string" },
|
|
223
|
+
{ description: "Uncompacted Edge Section", type: "object" },
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
r: {
|
|
227
|
+
description: "Rule Section",
|
|
228
|
+
oneOf: [
|
|
229
|
+
{ description: "Rule Section SAID", type: "string" },
|
|
230
|
+
{ description: "Uncompacted Rule Section", type: "object" },
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
additionalProperties: false,
|
|
235
|
+
}, kind);
|
|
236
|
+
}
|
|
237
|
+
/** Create the default schema block for ACDC v2 fixed-aggregate (`acg`) messages. */
|
|
238
|
+
export function acgSchemaDefault(kind = Kinds.json) {
|
|
239
|
+
return defaultSchema({
|
|
240
|
+
"$id": "",
|
|
241
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
242
|
+
title: "ACG Default Schema",
|
|
243
|
+
description: "Default JSON Schema for acg ACDC.",
|
|
244
|
+
credentialType: "ACDC_acg_message",
|
|
245
|
+
version: "2.0.0",
|
|
246
|
+
type: "object",
|
|
247
|
+
required: ["v", "t", "d", "u", "i", "rd", "s", "A", "e", "r"],
|
|
248
|
+
properties: {
|
|
249
|
+
v: { description: "ACDC version string", type: "string" },
|
|
250
|
+
t: { description: "Message type", type: "string" },
|
|
251
|
+
d: { description: "Message SAID", type: "string" },
|
|
252
|
+
u: { description: "Message UUID", type: "string" },
|
|
253
|
+
i: { description: "Issuer AID", type: "string" },
|
|
254
|
+
rd: { description: "Registry SAID", type: "string" },
|
|
255
|
+
s: {
|
|
256
|
+
description: "Schema Section",
|
|
257
|
+
oneOf: [
|
|
258
|
+
{ description: "Schema Section SAID", type: "string" },
|
|
259
|
+
{ description: "Uncompacted Schema Section", type: "object" },
|
|
260
|
+
],
|
|
261
|
+
},
|
|
262
|
+
A: {
|
|
263
|
+
description: "Aggregate Section",
|
|
264
|
+
oneOf: [
|
|
265
|
+
{ description: "Aggregate Section AGID", type: "string" },
|
|
266
|
+
{ description: "Uncompacted Aggregate Section", type: "array" },
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
e: {
|
|
270
|
+
description: "Edge Section",
|
|
271
|
+
oneOf: [
|
|
272
|
+
{ description: "Edge Section SAID", type: "string" },
|
|
273
|
+
{ description: "Uncompacted Edge Section", type: "object" },
|
|
274
|
+
],
|
|
275
|
+
},
|
|
276
|
+
r: {
|
|
277
|
+
description: "Rule Section",
|
|
278
|
+
oneOf: [
|
|
279
|
+
{ description: "Rule Section SAID", type: "string" },
|
|
280
|
+
{ description: "Uncompacted Rule Section", type: "object" },
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
additionalProperties: false,
|
|
285
|
+
}, kind);
|
|
286
|
+
}
|
|
287
|
+
/** Create a top-level field-map ACDC v2 message (`acm` or implicit map ACDC). */
|
|
288
|
+
export function acdcmap(issuer, options = {}) {
|
|
289
|
+
const { ilk = Ilks.acm, uuid, regid, schema, attribute, issuee, aggregate, edge, rule, pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json, compactify = false, } = options;
|
|
290
|
+
validateAttributeAggregatePair(attribute, aggregate);
|
|
291
|
+
const actualAttribute = withIssuee(attribute, issuee);
|
|
292
|
+
const [, schemaSad] = schemaSaidAndSad(schema, acmSchemaDefault(kind), kind);
|
|
293
|
+
const sad = {
|
|
294
|
+
v: versionString({ pvrsn, gvrsn, kind }),
|
|
295
|
+
};
|
|
296
|
+
if (ilk !== null) {
|
|
297
|
+
sad.t = ilk;
|
|
298
|
+
}
|
|
299
|
+
sad.d = "";
|
|
300
|
+
if (uuid !== undefined && uuid !== null) {
|
|
301
|
+
sad.u = uuid;
|
|
302
|
+
}
|
|
303
|
+
sad.i = issuer;
|
|
304
|
+
if (regid !== undefined && regid !== null) {
|
|
305
|
+
sad.rd = regid;
|
|
306
|
+
}
|
|
307
|
+
sad.s = schemaSad;
|
|
308
|
+
if (actualAttribute !== undefined && actualAttribute !== null) {
|
|
309
|
+
sad.a = actualAttribute;
|
|
310
|
+
}
|
|
311
|
+
if (aggregate !== undefined && aggregate !== null) {
|
|
312
|
+
sad.A = cloneMapperValue(aggregate);
|
|
313
|
+
}
|
|
314
|
+
if (edge !== undefined && edge !== null) {
|
|
315
|
+
sad.e = cloneMapperValue(edge);
|
|
316
|
+
}
|
|
317
|
+
if (rule !== undefined && rule !== null) {
|
|
318
|
+
sad.r = cloneMapperValue(rule);
|
|
319
|
+
}
|
|
320
|
+
return new SerderACDC({ sad, makify: true, compactify });
|
|
321
|
+
}
|
|
322
|
+
/** Create a top-level fixed-attribute ACDC v2 message (`act`). */
|
|
323
|
+
export function acdcatt(issuer, options = {}) {
|
|
324
|
+
const { uuid, regid, schema, attribute, issuee, edge, rule, pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json, compactify = false, } = options;
|
|
325
|
+
const [, schemaSad] = schemaSaidAndSad(schema, actSchemaDefault(kind), kind);
|
|
326
|
+
return new SerderACDC({
|
|
327
|
+
sad: {
|
|
328
|
+
v: versionString({ pvrsn, gvrsn, kind }),
|
|
329
|
+
t: Ilks.act,
|
|
330
|
+
d: "",
|
|
331
|
+
u: uuid ?? "",
|
|
332
|
+
i: issuer,
|
|
333
|
+
rd: regid ?? "",
|
|
334
|
+
s: schemaSad,
|
|
335
|
+
a: withIssuee(attribute ?? {}, issuee),
|
|
336
|
+
e: cloneMapperValue(edge ?? {}),
|
|
337
|
+
r: cloneMapperValue(rule ?? {}),
|
|
338
|
+
},
|
|
339
|
+
makify: true,
|
|
340
|
+
compactify,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/** Create a top-level fixed-aggregate ACDC v2 message (`acg`). */
|
|
344
|
+
export function acdcagg(issuer, options = {}) {
|
|
345
|
+
const { uuid, regid, schema, aggregate, edge, rule, pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json, compactify = false, } = options;
|
|
346
|
+
const [, schemaSad] = schemaSaidAndSad(schema, acgSchemaDefault(kind), kind);
|
|
347
|
+
return new SerderACDC({
|
|
348
|
+
sad: {
|
|
349
|
+
v: versionString({ pvrsn, gvrsn, kind }),
|
|
350
|
+
t: Ilks.acg,
|
|
351
|
+
d: "",
|
|
352
|
+
u: uuid ?? "",
|
|
353
|
+
i: issuer,
|
|
354
|
+
rd: regid ?? "",
|
|
355
|
+
s: schemaSad,
|
|
356
|
+
A: cloneMapperValue(aggregate ?? []),
|
|
357
|
+
e: cloneMapperValue(edge ?? {}),
|
|
358
|
+
r: cloneMapperValue(rule ?? {}),
|
|
359
|
+
},
|
|
360
|
+
makify: true,
|
|
361
|
+
compactify,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
/** Create a compact schema-section (`sch`) disclosure message. */
|
|
365
|
+
export function sectschema(schema, options = {}) {
|
|
366
|
+
const { pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json } = options;
|
|
367
|
+
return new SerderACDC({
|
|
368
|
+
sad: { v: versionString({ pvrsn, gvrsn, kind }), t: Ilks.sch, d: "", s: cloneMapperValue(schema) },
|
|
369
|
+
makify: true,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
/** Create a compact attribute-section (`att`) disclosure message. */
|
|
373
|
+
export function sectattr(attribute, options = {}) {
|
|
374
|
+
const { pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json } = options;
|
|
375
|
+
return new SerderACDC({
|
|
376
|
+
sad: { v: versionString({ pvrsn, gvrsn, kind }), t: Ilks.att, d: "", a: cloneMapperValue(attribute) },
|
|
377
|
+
makify: true,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
/** Create a compact aggregate-section (`agg`) disclosure message. */
|
|
381
|
+
export function sectaggr(aggregate, options = {}) {
|
|
382
|
+
const { pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json } = options;
|
|
383
|
+
return new SerderACDC({
|
|
384
|
+
sad: { v: versionString({ pvrsn, gvrsn, kind }), t: Ilks.agg, d: "", A: cloneMapperValue(aggregate) },
|
|
385
|
+
makify: true,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
/** Create a compact edge-section (`edg`) disclosure message. */
|
|
389
|
+
export function sectedge(edge, options = {}) {
|
|
390
|
+
const { pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json } = options;
|
|
391
|
+
return new SerderACDC({
|
|
392
|
+
sad: { v: versionString({ pvrsn, gvrsn, kind }), t: Ilks.edg, d: "", e: cloneMapperValue(edge ?? {}) },
|
|
393
|
+
makify: true,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
/** Create a compact rule-section (`rul`) disclosure message. */
|
|
397
|
+
export function sectrule(rule, options = {}) {
|
|
398
|
+
const { pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json } = options;
|
|
399
|
+
return new SerderACDC({
|
|
400
|
+
sad: { v: versionString({ pvrsn, gvrsn, kind }), t: Ilks.rul, d: "", r: cloneMapperValue(rule ?? {}) },
|
|
401
|
+
makify: true,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Create a compact top-level ACDC plus the section disclosure messages needed
|
|
406
|
+
* to re-expand it.
|
|
407
|
+
*/
|
|
408
|
+
export function sectionate(issuer, options = {}) {
|
|
409
|
+
const { ilk = Ilks.acm, uuid, regid, schema, attribute, issuee, aggregate, edge, rule, pvrsn = Vrsn_2_0, gvrsn = Vrsn_2_0, kind = Kinds.json, } = options;
|
|
410
|
+
if (ilk !== null && ilk !== Ilks.acm && ilk !== Ilks.act && ilk !== Ilks.acg) {
|
|
411
|
+
throw new ValidationError(`Invalid ACDC message ilk=${ilk}.`);
|
|
412
|
+
}
|
|
413
|
+
validateAttributeAggregatePair(attribute, aggregate);
|
|
414
|
+
if (ilk === Ilks.act && (attribute === undefined || attribute === null)) {
|
|
415
|
+
throw new ValidationError("Invalid attribute=null for ilk=act.");
|
|
416
|
+
}
|
|
417
|
+
if (ilk === Ilks.acg && (aggregate === undefined || aggregate === null)) {
|
|
418
|
+
throw new ValidationError("Invalid aggregate=null for ilk=acg.");
|
|
419
|
+
}
|
|
420
|
+
const actualAttribute = withIssuee(attribute, issuee);
|
|
421
|
+
const fallback = ilk === Ilks.act
|
|
422
|
+
? actSchemaDefault(kind)
|
|
423
|
+
: ilk === Ilks.acg
|
|
424
|
+
? acgSchemaDefault(kind)
|
|
425
|
+
: acmSchemaDefault(kind);
|
|
426
|
+
const [schemaSaid, schemaSad] = schemaSaidAndSad(schema, fallback, kind);
|
|
427
|
+
const versionOptions = { pvrsn, gvrsn, kind };
|
|
428
|
+
const sch = sectschema(schemaSad, versionOptions);
|
|
429
|
+
if (ilk === Ilks.act) {
|
|
430
|
+
const acdc = acdcatt(issuer, {
|
|
431
|
+
uuid,
|
|
432
|
+
regid,
|
|
433
|
+
schema: schemaSaid,
|
|
434
|
+
attribute: actualAttribute,
|
|
435
|
+
issuee,
|
|
436
|
+
edge,
|
|
437
|
+
rule,
|
|
438
|
+
...versionOptions,
|
|
439
|
+
compactify: true,
|
|
440
|
+
});
|
|
441
|
+
return [
|
|
442
|
+
acdc,
|
|
443
|
+
sch,
|
|
444
|
+
sectattr(actualAttribute, versionOptions),
|
|
445
|
+
null,
|
|
446
|
+
sectedge(edge, versionOptions),
|
|
447
|
+
sectrule(rule, versionOptions),
|
|
448
|
+
];
|
|
449
|
+
}
|
|
450
|
+
if (ilk === Ilks.acg) {
|
|
451
|
+
const acdc = acdcagg(issuer, {
|
|
452
|
+
uuid,
|
|
453
|
+
regid,
|
|
454
|
+
schema: schemaSaid,
|
|
455
|
+
aggregate,
|
|
456
|
+
edge,
|
|
457
|
+
rule,
|
|
458
|
+
...versionOptions,
|
|
459
|
+
compactify: true,
|
|
460
|
+
});
|
|
461
|
+
return [
|
|
462
|
+
acdc,
|
|
463
|
+
sch,
|
|
464
|
+
null,
|
|
465
|
+
sectaggr(aggregate, versionOptions),
|
|
466
|
+
sectedge(edge, versionOptions),
|
|
467
|
+
sectrule(rule, versionOptions),
|
|
468
|
+
];
|
|
469
|
+
}
|
|
470
|
+
const acdc = acdcmap(issuer, {
|
|
471
|
+
ilk,
|
|
472
|
+
uuid,
|
|
473
|
+
regid,
|
|
474
|
+
schema: schemaSaid,
|
|
475
|
+
attribute: actualAttribute,
|
|
476
|
+
issuee,
|
|
477
|
+
aggregate,
|
|
478
|
+
edge,
|
|
479
|
+
rule,
|
|
480
|
+
...versionOptions,
|
|
481
|
+
compactify: true,
|
|
482
|
+
});
|
|
483
|
+
return [
|
|
484
|
+
acdc,
|
|
485
|
+
sch,
|
|
486
|
+
actualAttribute !== undefined && actualAttribute !== null ? sectattr(actualAttribute, versionOptions) : null,
|
|
487
|
+
aggregate !== undefined && aggregate !== null ? sectaggr(aggregate, versionOptions) : null,
|
|
488
|
+
sectedge(edge, versionOptions),
|
|
489
|
+
sectrule(rule, versionOptions),
|
|
490
|
+
];
|
|
491
|
+
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { spawn } from "effection";
|
|
2
2
|
import { Deck } from "../core/deck.js";
|
|
3
|
-
import { DELEGATE_MAILBOX_TOPIC, RECEIPT_MAILBOX_TOPIC, REPLAY_MAILBOX_TOPIC, REPLY_MAILBOX_TOPIC, } from "../core/mailbox-topics.js";
|
|
3
|
+
import { CREDENTIAL_MAILBOX_TOPIC, DELEGATE_MAILBOX_TOPIC, RECEIPT_MAILBOX_TOPIC, REPLAY_MAILBOX_TOPIC, REPLY_MAILBOX_TOPIC, } from "../core/mailbox-topics.js";
|
|
4
|
+
import { createReger, Reger } from "../db/reger.js";
|
|
5
|
+
import { Regery } from "../vdr/credentialing.js";
|
|
6
|
+
import { Tevery } from "../vdr/eventing.js";
|
|
4
7
|
import { Authenticator } from "./authenticating.js";
|
|
5
8
|
import { loadChallengeHandlers } from "./challenging.js";
|
|
6
9
|
import { cueDo, processCuesOnce } from "./cue-runtime.js";
|
|
7
10
|
import { Anchorer, loadDelegationHandlers } from "./delegating.js";
|
|
8
11
|
import { ForwardHandler, MailboxPoller, mailboxTopicForRoute, Poster, } from "./forwarding.js";
|
|
12
|
+
import { loadMultisigHandlers } from "./grouping.js";
|
|
13
|
+
import { loadIpexHandlers } from "./ipexing.js";
|
|
9
14
|
import { MailboxDirector } from "./mailbox-director.js";
|
|
10
15
|
import { openMailboxerForHabery } from "./mailboxing.js";
|
|
11
16
|
import { Notifier, openNoterForHabery } from "./notifying.js";
|
|
@@ -16,6 +21,7 @@ import { Respondant } from "./respondant.js";
|
|
|
16
21
|
import { resolveRuntimeServices } from "./runtime-services.js";
|
|
17
22
|
import { runtimeTurn } from "./runtime-turn.js";
|
|
18
23
|
import { Signaler } from "./signaling.js";
|
|
24
|
+
import { Verifier } from "./verifying.js";
|
|
19
25
|
/**
|
|
20
26
|
* Create the shared runtime composition root used by CLI commands and
|
|
21
27
|
* `tufa agent`.
|
|
@@ -44,10 +50,39 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
44
50
|
const notifier = options.notifier
|
|
45
51
|
?? (noter && signaler ? new Notifier(hby, { noter, signaler }) : null);
|
|
46
52
|
const cues = new Deck();
|
|
47
|
-
const
|
|
53
|
+
const vdr = { ...(options.vdr ?? {}) };
|
|
54
|
+
let ownsReger = false;
|
|
55
|
+
if (!vdr.reger && !hby.readonly) {
|
|
56
|
+
vdr.reger = yield* createReger({
|
|
57
|
+
name: hby.name,
|
|
58
|
+
base: hby.base,
|
|
59
|
+
temp: hby.temp,
|
|
60
|
+
headDirPath: hby.headDirPath,
|
|
61
|
+
compat: hby.compat,
|
|
62
|
+
});
|
|
63
|
+
ownsReger = true;
|
|
64
|
+
}
|
|
65
|
+
const reger = vdr.reger instanceof Reger ? vdr.reger : null;
|
|
66
|
+
if (reger && !vdr.tvy) {
|
|
67
|
+
vdr.tvy = new Tevery({ db: hby.db, reger, cues });
|
|
68
|
+
}
|
|
69
|
+
if (reger && !vdr.vry) {
|
|
70
|
+
vdr.vry = new Verifier(hby, { reger, cues });
|
|
71
|
+
}
|
|
72
|
+
if (reger && vdr.tvy instanceof Tevery && vdr.vry instanceof Verifier && !vdr.rgy) {
|
|
73
|
+
vdr.rgy = new Regery(hby, {
|
|
74
|
+
reger,
|
|
75
|
+
tvy: vdr.tvy,
|
|
76
|
+
vry: vdr.vry,
|
|
77
|
+
cues,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const reactor = new Reactor(hby, { cues, vdr });
|
|
48
81
|
loadChallengeHandlers(hby.db, reactor.exchanger);
|
|
49
82
|
loadDelegationHandlers(hby, reactor.exchanger, notifier);
|
|
50
83
|
loadOobiHandlers(hby, reactor.exchanger, notifier);
|
|
84
|
+
loadMultisigHandlers(hby, reactor.exchanger, { notifier });
|
|
85
|
+
loadIpexHandlers(hby, reactor.exchanger, { notifier });
|
|
51
86
|
const mailboxDirector = new MailboxDirector(hby, mailboxer ? { mailboxer } : {});
|
|
52
87
|
const poster = new Poster(hby, { mailboxer, services });
|
|
53
88
|
const respondant = new Respondant(hby, { poster, mailboxDirector });
|
|
@@ -69,6 +104,7 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
69
104
|
});
|
|
70
105
|
for (const topic of [
|
|
71
106
|
DELEGATE_MAILBOX_TOPIC,
|
|
107
|
+
CREDENTIAL_MAILBOX_TOPIC,
|
|
72
108
|
RECEIPT_MAILBOX_TOPIC,
|
|
73
109
|
REPLAY_MAILBOX_TOPIC,
|
|
74
110
|
REPLY_MAILBOX_TOPIC,
|
|
@@ -97,6 +133,7 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
97
133
|
poster,
|
|
98
134
|
delegating,
|
|
99
135
|
querying,
|
|
136
|
+
vdr,
|
|
100
137
|
services,
|
|
101
138
|
*close() {
|
|
102
139
|
if (ownsNoter && noter?.opened) {
|
|
@@ -105,6 +142,9 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
105
142
|
if (ownsMailboxer && mailboxer?.opened) {
|
|
106
143
|
yield* mailboxer.close();
|
|
107
144
|
}
|
|
145
|
+
if (ownsReger && reger?.opened) {
|
|
146
|
+
yield* reger.close(hby.temp);
|
|
147
|
+
}
|
|
108
148
|
},
|
|
109
149
|
};
|
|
110
150
|
}
|
|
@@ -159,7 +199,10 @@ export function settleRuntimeIngress(runtime, messages, { local, } = {}) {
|
|
|
159
199
|
* follow-on escrow progress can occur before the next source is consumed.
|
|
160
200
|
*/
|
|
161
201
|
export function settleMailboxPollBatch(runtime, batch) {
|
|
162
|
-
|
|
202
|
+
for (const message of batch.messages) {
|
|
203
|
+
runtime.reactor.processCompleteChunk(message);
|
|
204
|
+
}
|
|
205
|
+
runtime.reactor.processEscrowsOnce();
|
|
163
206
|
}
|
|
164
207
|
/**
|
|
165
208
|
* Drain one bounded mailbox polling turn and settle each returned batch.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* full CESR payload is sent in the body instead of splitting attachments into
|
|
13
13
|
* the header
|
|
14
14
|
*/
|
|
15
|
-
import { concatBytes, createParser, parseSerder, SerderKERI, } from "../../../cesr/mod.js";
|
|
15
|
+
import { concatBytes, createParser, parseSerder, SerderKERI, smell, } from "../../../cesr/mod.js";
|
|
16
16
|
import { ValidationError } from "../core/errors.js";
|
|
17
17
|
/** Default interop mode matching KERIpy mailbox behavior. */
|
|
18
18
|
export const DEFAULT_CESR_BODY_MODE = "header";
|
|
@@ -193,7 +193,14 @@ export async function readMailboxAdminRequest(req) {
|
|
|
193
193
|
}
|
|
194
194
|
/** Parse and return the first CESR message in one request body. */
|
|
195
195
|
export function inspectCesrRequest(bytes) {
|
|
196
|
-
|
|
196
|
+
try {
|
|
197
|
+
const { smellage } = smell(bytes);
|
|
198
|
+
const serder = parseSerder(bytes.slice(0, smellage.size), smellage);
|
|
199
|
+
return serder instanceof SerderKERI ? serder : null;
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
197
204
|
}
|
|
198
205
|
/** Parse and return the final CESR message in one request body. */
|
|
199
206
|
export function inspectCesrTerminalMessage(bytes) {
|
|
@@ -16,11 +16,15 @@ export { exportCommand } from "./export.js";
|
|
|
16
16
|
export { inceptCommand } from "./incept.js";
|
|
17
17
|
export { initCommand } from "./init.js";
|
|
18
18
|
export { interactCommand } from "./interact.js";
|
|
19
|
+
export { ipexAdmitCommand, ipexAgreeCommand, ipexApplyCommand, ipexGrantCommand, ipexJoinCommand, ipexListCommand, ipexOfferCommand, ipexPollCommand, ipexSpurnCommand, } from "./ipex.js";
|
|
19
20
|
export { listCommand } from "./list.js";
|
|
20
21
|
export { locAddCommand } from "./loc.js";
|
|
21
22
|
export { notificationsListCommand, notificationsMarkReadCommand, notificationsRemoveCommand } from "./notifications.js";
|
|
22
23
|
export { oobiGenerateCommand, oobiRequestCommand, oobiResolveCommand } from "./oobi.js";
|
|
23
24
|
export { queryCommand } from "./query.js";
|
|
24
25
|
export { rotateCommand } from "./rotate.js";
|
|
26
|
+
export { saidifyCommand } from "./saidify.js";
|
|
25
27
|
export { signCommand } from "./sign.js";
|
|
28
|
+
export { vcCreateCommand, vcExportCommand, vcImportCommand, vcListCommand, vcRegistryInceptCommand, vcRegistryListCommand, vcRegistryStatusCommand, vcRevokeCommand, vcSchemaImportCommand, } from "./vc.js";
|
|
29
|
+
export { verifierRunCommand } from "./verifier.js";
|
|
26
30
|
export { verifyCommand } from "./verify.js";
|