keri-ts 0.7.0 → 0.9.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.
Files changed (172) hide show
  1. package/README.md +10 -0
  2. package/esm/cesr/src/primitives/counter.js +64 -9
  3. package/esm/cesr/src/primitives/mapper.js +48 -41
  4. package/esm/cesr/src/serder/native.js +62 -29
  5. package/esm/cesr/src/serder/serder.js +35 -46
  6. package/esm/cesr/src/serder/serdery.js +7 -43
  7. package/esm/cesr/src/version.js +2 -2
  8. package/esm/keri/src/acdc/index.js +1 -0
  9. package/esm/keri/src/acdc/messaging.js +491 -0
  10. package/esm/keri/src/app/agent-runtime.js +46 -3
  11. package/esm/keri/src/app/cesr-http.js +13 -5
  12. package/esm/keri/src/app/cli/delegate.js +106 -10
  13. package/esm/keri/src/app/cli/did.js +182 -0
  14. package/esm/keri/src/app/cli/ends.js +40 -0
  15. package/esm/keri/src/app/cli/index.js +6 -0
  16. package/esm/keri/src/app/cli/ipex.js +786 -0
  17. package/esm/keri/src/app/cli/multisig.js +1089 -0
  18. package/esm/keri/src/app/cli/saidify.js +51 -0
  19. package/esm/keri/src/app/cli/vc.js +696 -0
  20. package/esm/keri/src/app/cli/verifier.js +104 -0
  21. package/esm/keri/src/app/delegating.js +26 -11
  22. package/esm/keri/src/app/endpoint-roleing.js +140 -0
  23. package/esm/keri/src/app/exchanging.js +44 -15
  24. package/esm/keri/src/app/forwarding.js +132 -58
  25. package/esm/keri/src/app/grouping.js +382 -0
  26. package/esm/keri/src/app/habbing.js +189 -36
  27. package/esm/keri/src/app/ipex-credentialing.js +245 -0
  28. package/esm/keri/src/app/ipexing.js +212 -0
  29. package/esm/keri/src/app/oobiery.js +62 -11
  30. package/esm/keri/src/app/parsering.js +58 -7
  31. package/esm/keri/src/app/reactor.js +30 -3
  32. package/esm/keri/src/app/schema-resolving.js +28 -0
  33. package/esm/keri/src/app/verifier-agent.js +408 -0
  34. package/esm/keri/src/app/verifying.js +358 -0
  35. package/esm/keri/src/app/version.js +2 -2
  36. package/esm/keri/src/app/witnessing.js +82 -49
  37. package/esm/keri/src/core/attachment-countering.js +105 -0
  38. package/esm/keri/src/core/mailbox-topics.js +2 -0
  39. package/esm/keri/src/core/protocol-exchanging.js +21 -15
  40. package/esm/keri/src/core/protocol-serialization.js +109 -86
  41. package/esm/keri/src/core/protocol-vdr-eventing.js +288 -0
  42. package/esm/keri/src/core/scheming.js +162 -0
  43. package/esm/keri/src/db/basing.js +34 -47
  44. package/esm/keri/src/db/index.js +1 -0
  45. package/esm/keri/src/db/reger.js +472 -0
  46. package/esm/keri/src/db/subing.js +32 -19
  47. package/esm/keri/src/db/verifier-cueing.js +125 -0
  48. package/esm/keri/src/did/index.js +7 -0
  49. package/esm/keri/src/did/keri/resolving.js +26 -0
  50. package/esm/keri/src/did/webs/artifacts.js +86 -0
  51. package/esm/keri/src/did/webs/designated-aliases-public-schema.js +156 -0
  52. package/esm/keri/src/did/webs/designated-aliases.js +235 -0
  53. package/esm/keri/src/did/webs/dids.js +186 -0
  54. package/esm/keri/src/did/webs/documenting.js +190 -0
  55. package/esm/keri/src/did/webs/resolving.js +115 -0
  56. package/esm/keri/src/library/index.js +1 -0
  57. package/esm/keri/src/runtime/index.js +13 -0
  58. package/esm/keri/src/vdr/credentialing.js +557 -0
  59. package/esm/keri/src/vdr/eventing.js +931 -0
  60. package/package.json +3 -2
  61. package/types/cesr/src/primitives/counter.d.ts +8 -0
  62. package/types/cesr/src/primitives/counter.d.ts.map +1 -1
  63. package/types/cesr/src/primitives/mapper.d.ts.map +1 -1
  64. package/types/cesr/src/serder/native.d.ts +9 -0
  65. package/types/cesr/src/serder/native.d.ts.map +1 -1
  66. package/types/cesr/src/serder/serder.d.ts.map +1 -1
  67. package/types/cesr/src/serder/serdery.d.ts.map +1 -1
  68. package/types/cesr/src/version.d.ts +2 -2
  69. package/types/keri/src/acdc/index.d.ts +2 -0
  70. package/types/keri/src/acdc/index.d.ts.map +1 -0
  71. package/types/keri/src/acdc/messaging.d.ts +104 -0
  72. package/types/keri/src/acdc/messaging.d.ts.map +1 -0
  73. package/types/keri/src/app/agent-runtime.d.ts +3 -1
  74. package/types/keri/src/app/agent-runtime.d.ts.map +1 -1
  75. package/types/keri/src/app/cesr-http.d.ts +2 -1
  76. package/types/keri/src/app/cesr-http.d.ts.map +1 -1
  77. package/types/keri/src/app/cli/delegate.d.ts.map +1 -1
  78. package/types/keri/src/app/cli/did.d.ts +10 -0
  79. package/types/keri/src/app/cli/did.d.ts.map +1 -0
  80. package/types/keri/src/app/cli/ends.d.ts.map +1 -1
  81. package/types/keri/src/app/cli/index.d.ts +6 -0
  82. package/types/keri/src/app/cli/index.d.ts.map +1 -1
  83. package/types/keri/src/app/cli/ipex.d.ts +20 -0
  84. package/types/keri/src/app/cli/ipex.d.ts.map +1 -0
  85. package/types/keri/src/app/cli/multisig.d.ts +12 -0
  86. package/types/keri/src/app/cli/multisig.d.ts.map +1 -0
  87. package/types/keri/src/app/cli/saidify.d.ts +4 -0
  88. package/types/keri/src/app/cli/saidify.d.ts.map +1 -0
  89. package/types/keri/src/app/cli/vc.d.ts +20 -0
  90. package/types/keri/src/app/cli/vc.d.ts.map +1 -0
  91. package/types/keri/src/app/cli/verifier.d.ts +3 -0
  92. package/types/keri/src/app/cli/verifier.d.ts.map +1 -0
  93. package/types/keri/src/app/delegating.d.ts +1 -0
  94. package/types/keri/src/app/delegating.d.ts.map +1 -1
  95. package/types/keri/src/app/endpoint-roleing.d.ts +46 -0
  96. package/types/keri/src/app/endpoint-roleing.d.ts.map +1 -0
  97. package/types/keri/src/app/exchanging.d.ts +7 -0
  98. package/types/keri/src/app/exchanging.d.ts.map +1 -1
  99. package/types/keri/src/app/forwarding.d.ts +7 -1
  100. package/types/keri/src/app/forwarding.d.ts.map +1 -1
  101. package/types/keri/src/app/grouping.d.ts +111 -0
  102. package/types/keri/src/app/grouping.d.ts.map +1 -0
  103. package/types/keri/src/app/habbing.d.ts +51 -4
  104. package/types/keri/src/app/habbing.d.ts.map +1 -1
  105. package/types/keri/src/app/ipex-credentialing.d.ts +88 -0
  106. package/types/keri/src/app/ipex-credentialing.d.ts.map +1 -0
  107. package/types/keri/src/app/ipexing.d.ts +84 -0
  108. package/types/keri/src/app/ipexing.d.ts.map +1 -0
  109. package/types/keri/src/app/oobiery.d.ts +3 -0
  110. package/types/keri/src/app/oobiery.d.ts.map +1 -1
  111. package/types/keri/src/app/parsering.d.ts +45 -3
  112. package/types/keri/src/app/parsering.d.ts.map +1 -1
  113. package/types/keri/src/app/protocol-host-policy.d.ts +8 -0
  114. package/types/keri/src/app/protocol-host-policy.d.ts.map +1 -1
  115. package/types/keri/src/app/reactor.d.ts +31 -1
  116. package/types/keri/src/app/reactor.d.ts.map +1 -1
  117. package/types/keri/src/app/schema-resolving.d.ts +31 -0
  118. package/types/keri/src/app/schema-resolving.d.ts.map +1 -0
  119. package/types/keri/src/app/verifier-agent.d.ts +82 -0
  120. package/types/keri/src/app/verifier-agent.d.ts.map +1 -0
  121. package/types/keri/src/app/verifying.d.ts +111 -0
  122. package/types/keri/src/app/verifying.d.ts.map +1 -0
  123. package/types/keri/src/app/version.d.ts +2 -2
  124. package/types/keri/src/app/witnessing.d.ts.map +1 -1
  125. package/types/keri/src/core/attachment-countering.d.ts +39 -0
  126. package/types/keri/src/core/attachment-countering.d.ts.map +1 -0
  127. package/types/keri/src/core/cues.d.ts +28 -3
  128. package/types/keri/src/core/cues.d.ts.map +1 -1
  129. package/types/keri/src/core/mailbox-topics.d.ts +2 -0
  130. package/types/keri/src/core/mailbox-topics.d.ts.map +1 -1
  131. package/types/keri/src/core/protocol-exchanging.d.ts +2 -1
  132. package/types/keri/src/core/protocol-exchanging.d.ts.map +1 -1
  133. package/types/keri/src/core/protocol-serialization.d.ts +38 -4
  134. package/types/keri/src/core/protocol-serialization.d.ts.map +1 -1
  135. package/types/keri/src/core/protocol-vdr-eventing.d.ts +69 -0
  136. package/types/keri/src/core/protocol-vdr-eventing.d.ts.map +1 -0
  137. package/types/keri/src/core/scheming.d.ts +38 -0
  138. package/types/keri/src/core/scheming.d.ts.map +1 -0
  139. package/types/keri/src/db/basing.d.ts +2 -2
  140. package/types/keri/src/db/basing.d.ts.map +1 -1
  141. package/types/keri/src/db/index.d.ts +1 -0
  142. package/types/keri/src/db/index.d.ts.map +1 -1
  143. package/types/keri/src/db/reger.d.ts +91 -0
  144. package/types/keri/src/db/reger.d.ts.map +1 -0
  145. package/types/keri/src/db/subing.d.ts +18 -3
  146. package/types/keri/src/db/subing.d.ts.map +1 -1
  147. package/types/keri/src/db/verifier-cueing.d.ts +46 -0
  148. package/types/keri/src/db/verifier-cueing.d.ts.map +1 -0
  149. package/types/keri/src/did/index.d.ts +8 -0
  150. package/types/keri/src/did/index.d.ts.map +1 -0
  151. package/types/keri/src/did/keri/resolving.d.ts +19 -0
  152. package/types/keri/src/did/keri/resolving.d.ts.map +1 -0
  153. package/types/keri/src/did/webs/artifacts.d.ts +19 -0
  154. package/types/keri/src/did/webs/artifacts.d.ts.map +1 -0
  155. package/types/keri/src/did/webs/designated-aliases-public-schema.d.ts +147 -0
  156. package/types/keri/src/did/webs/designated-aliases-public-schema.d.ts.map +1 -0
  157. package/types/keri/src/did/webs/designated-aliases.d.ts +46 -0
  158. package/types/keri/src/did/webs/designated-aliases.d.ts.map +1 -0
  159. package/types/keri/src/did/webs/dids.d.ts +65 -0
  160. package/types/keri/src/did/webs/dids.d.ts.map +1 -0
  161. package/types/keri/src/did/webs/documenting.d.ts +29 -0
  162. package/types/keri/src/did/webs/documenting.d.ts.map +1 -0
  163. package/types/keri/src/did/webs/resolving.d.ts +22 -0
  164. package/types/keri/src/did/webs/resolving.d.ts.map +1 -0
  165. package/types/keri/src/library/index.d.ts +1 -0
  166. package/types/keri/src/library/index.d.ts.map +1 -1
  167. package/types/keri/src/runtime/index.d.ts +13 -0
  168. package/types/keri/src/runtime/index.d.ts.map +1 -1
  169. package/types/keri/src/vdr/credentialing.d.ts +169 -0
  170. package/types/keri/src/vdr/credentialing.d.ts.map +1 -0
  171. package/types/keri/src/vdr/eventing.d.ts +157 -0
  172. 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 reactor = new Reactor(hby, { cues });
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
- settleRuntimeIngress(runtime, batch.messages);
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";
@@ -62,10 +62,10 @@ export function cesrBodyModeFromGlobal(value) {
62
62
  * Body mode:
63
63
  * - the full payload is sent in the HTTP body
64
64
  */
65
- export function buildCesrRequest(message, { bodyMode = DEFAULT_CESR_BODY_MODE, destination, } = {}) {
65
+ export function buildCesrRequest(message, { bodyMode = DEFAULT_CESR_BODY_MODE, contentType = CESR_CONTENT_TYPE, destination, } = {}) {
66
66
  const mode = normalizeCesrBodyMode(bodyMode);
67
67
  const headers = {
68
- "Content-Type": CESR_CONTENT_TYPE,
68
+ "Content-Type": contentType,
69
69
  };
70
70
  if (destination) {
71
71
  headers[CESR_DESTINATION_HEADER] = destination;
@@ -76,7 +76,8 @@ export function buildCesrRequest(message, { bodyMode = DEFAULT_CESR_BODY_MODE, d
76
76
  body: arrayBufferFromBytes(message),
77
77
  };
78
78
  }
79
- const serder = new SerderKERI({ raw: message });
79
+ const { smellage } = smell(message);
80
+ const serder = parseSerder(message.slice(0, smellage.size), smellage);
80
81
  headers[CESR_ATTACHMENT_HEADER] = textDecoder.decode(message.slice(serder.size));
81
82
  return {
82
83
  headers,
@@ -193,7 +194,14 @@ export async function readMailboxAdminRequest(req) {
193
194
  }
194
195
  /** Parse and return the first CESR message in one request body. */
195
196
  export function inspectCesrRequest(bytes) {
196
- return inspectCesrStream(bytes).messages[0] ?? null;
197
+ try {
198
+ const { smellage } = smell(bytes);
199
+ const serder = parseSerder(bytes.slice(0, smellage.size), smellage);
200
+ return serder instanceof SerderKERI ? serder : null;
201
+ }
202
+ catch {
203
+ return null;
204
+ }
197
205
  }
198
206
  /** Parse and return the final CESR message in one request body. */
199
207
  export function inspectCesrTerminalMessage(bytes) {