keri-ts 0.6.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.
Files changed (177) hide show
  1. package/esm/cesr/mod.js +1 -0
  2. package/esm/cesr/src/core/parser-frame-parser.js +3 -0
  3. package/esm/cesr/src/primitives/mapper.js +48 -41
  4. package/esm/cesr/src/primitives/matter.js +7 -0
  5. package/esm/cesr/src/serder/native.js +62 -29
  6. package/esm/cesr/src/serder/serder.js +35 -46
  7. package/esm/cesr/src/serder/serdery.js +7 -43
  8. package/esm/cesr/src/tables/counter.tables.generated.js +1 -5
  9. package/esm/cesr/src/tables/hard-code-tables.js +39 -0
  10. package/esm/cesr/src/tables/indexer.tables.generated.js +1 -9
  11. package/esm/cesr/src/tables/matter.tables.generated.js +1 -14
  12. package/esm/cesr/src/version.js +7 -4
  13. package/esm/keri/src/acdc/index.js +1 -0
  14. package/esm/keri/src/acdc/messaging.js +491 -0
  15. package/esm/keri/src/app/agent-runtime.js +57 -8
  16. package/esm/keri/src/app/authenticating.js +15 -4
  17. package/esm/keri/src/app/cesr-http.js +9 -2
  18. package/esm/keri/src/app/cli/delegate.js +28 -0
  19. package/esm/keri/src/app/cli/index.js +4 -0
  20. package/esm/keri/src/app/cli/ipex.js +443 -0
  21. package/esm/keri/src/app/cli/notifications.js +4 -0
  22. package/esm/keri/src/app/cli/saidify.js +51 -0
  23. package/esm/keri/src/app/cli/vc.js +439 -0
  24. package/esm/keri/src/app/cli/verifier.js +104 -0
  25. package/esm/keri/src/app/delegating.js +21 -0
  26. package/esm/keri/src/app/exchanging.js +30 -0
  27. package/esm/keri/src/app/forwarding.js +102 -36
  28. package/esm/keri/src/app/grouping.js +382 -0
  29. package/esm/keri/src/app/habbing.js +1 -0
  30. package/esm/keri/src/app/httping.js +12 -7
  31. package/esm/keri/src/app/ipex-credentialing.js +227 -0
  32. package/esm/keri/src/app/ipexing.js +212 -0
  33. package/esm/keri/src/app/keeping.js +3 -3
  34. package/esm/keri/src/app/mailbox-sse.js +11 -9
  35. package/esm/keri/src/app/notifying.js +11 -0
  36. package/esm/keri/src/app/oobiery.js +65 -14
  37. package/esm/keri/src/app/parsering.js +58 -7
  38. package/esm/keri/src/app/query-transport.js +3 -0
  39. package/esm/keri/src/app/reactor.js +30 -3
  40. package/esm/keri/src/app/runtime-services.js +22 -0
  41. package/esm/keri/src/app/schema-resolving.js +28 -0
  42. package/esm/keri/src/app/verifier-agent.js +408 -0
  43. package/esm/keri/src/app/verifying.js +358 -0
  44. package/esm/keri/src/app/version.js +7 -4
  45. package/esm/keri/src/core/eventing.js +40 -0
  46. package/esm/keri/src/core/kever.js +9 -0
  47. package/esm/keri/src/core/mailbox-topics.js +2 -0
  48. package/esm/keri/src/core/protocol-eventing.js +15 -0
  49. package/esm/keri/src/core/protocol-exchanging.js +10 -6
  50. package/esm/keri/src/core/protocol-serialization.js +6 -9
  51. package/esm/keri/src/core/protocol-vdr-eventing.js +288 -0
  52. package/esm/keri/src/core/scheming.js +162 -0
  53. package/esm/keri/src/db/basing.js +2 -4
  54. package/esm/keri/src/db/index.js +1 -0
  55. package/esm/keri/src/db/noting.js +4 -0
  56. package/esm/keri/src/db/reger.js +478 -0
  57. package/esm/keri/src/db/subing.js +32 -19
  58. package/esm/keri/src/db/verifier-cueing.js +125 -0
  59. package/esm/keri/src/library/index.js +1 -0
  60. package/esm/keri/src/runtime/index.js +12 -0
  61. package/esm/keri/src/vdr/credentialing.js +556 -0
  62. package/esm/keri/src/vdr/eventing.js +931 -0
  63. package/package.json +3 -2
  64. package/types/cesr/mod.d.ts +1 -0
  65. package/types/cesr/mod.d.ts.map +1 -1
  66. package/types/cesr/src/core/parser-frame-parser.d.ts.map +1 -1
  67. package/types/cesr/src/primitives/mapper.d.ts.map +1 -1
  68. package/types/cesr/src/primitives/matter.d.ts.map +1 -1
  69. package/types/cesr/src/serder/native.d.ts +9 -0
  70. package/types/cesr/src/serder/native.d.ts.map +1 -1
  71. package/types/cesr/src/serder/serder.d.ts.map +1 -1
  72. package/types/cesr/src/serder/serdery.d.ts.map +1 -1
  73. package/types/cesr/src/tables/counter.tables.generated.d.ts +1 -1
  74. package/types/cesr/src/tables/counter.tables.generated.d.ts.map +1 -1
  75. package/types/cesr/src/tables/hard-code-tables.d.ts +15 -0
  76. package/types/cesr/src/tables/hard-code-tables.d.ts.map +1 -0
  77. package/types/cesr/src/tables/indexer.tables.generated.d.ts +1 -1
  78. package/types/cesr/src/tables/indexer.tables.generated.d.ts.map +1 -1
  79. package/types/cesr/src/tables/matter.tables.generated.d.ts +1 -1
  80. package/types/cesr/src/tables/matter.tables.generated.d.ts.map +1 -1
  81. package/types/cesr/src/version.d.ts +7 -4
  82. package/types/cesr/src/version.d.ts.map +1 -1
  83. package/types/keri/src/acdc/index.d.ts +2 -0
  84. package/types/keri/src/acdc/index.d.ts.map +1 -0
  85. package/types/keri/src/acdc/messaging.d.ts +104 -0
  86. package/types/keri/src/acdc/messaging.d.ts.map +1 -0
  87. package/types/keri/src/app/agent-runtime.d.ts +8 -2
  88. package/types/keri/src/app/agent-runtime.d.ts.map +1 -1
  89. package/types/keri/src/app/authenticating.d.ts +7 -1
  90. package/types/keri/src/app/authenticating.d.ts.map +1 -1
  91. package/types/keri/src/app/cesr-http.d.ts.map +1 -1
  92. package/types/keri/src/app/cli/delegate.d.ts +14 -0
  93. package/types/keri/src/app/cli/delegate.d.ts.map +1 -1
  94. package/types/keri/src/app/cli/index.d.ts +4 -0
  95. package/types/keri/src/app/cli/index.d.ts.map +1 -1
  96. package/types/keri/src/app/cli/ipex.d.ts +11 -0
  97. package/types/keri/src/app/cli/ipex.d.ts.map +1 -0
  98. package/types/keri/src/app/cli/notifications.d.ts +10 -0
  99. package/types/keri/src/app/cli/notifications.d.ts.map +1 -1
  100. package/types/keri/src/app/cli/saidify.d.ts +4 -0
  101. package/types/keri/src/app/cli/saidify.d.ts.map +1 -0
  102. package/types/keri/src/app/cli/vc.d.ts +11 -0
  103. package/types/keri/src/app/cli/vc.d.ts.map +1 -0
  104. package/types/keri/src/app/cli/verifier.d.ts +3 -0
  105. package/types/keri/src/app/cli/verifier.d.ts.map +1 -0
  106. package/types/keri/src/app/delegating.d.ts +23 -0
  107. package/types/keri/src/app/delegating.d.ts.map +1 -1
  108. package/types/keri/src/app/exchanging.d.ts +7 -0
  109. package/types/keri/src/app/exchanging.d.ts.map +1 -1
  110. package/types/keri/src/app/forwarding.d.ts +39 -9
  111. package/types/keri/src/app/forwarding.d.ts.map +1 -1
  112. package/types/keri/src/app/grouping.d.ts +111 -0
  113. package/types/keri/src/app/grouping.d.ts.map +1 -0
  114. package/types/keri/src/app/habbing.d.ts.map +1 -1
  115. package/types/keri/src/app/httping.d.ts +10 -4
  116. package/types/keri/src/app/httping.d.ts.map +1 -1
  117. package/types/keri/src/app/ipex-credentialing.d.ts +81 -0
  118. package/types/keri/src/app/ipex-credentialing.d.ts.map +1 -0
  119. package/types/keri/src/app/ipexing.d.ts +84 -0
  120. package/types/keri/src/app/ipexing.d.ts.map +1 -0
  121. package/types/keri/src/app/keeping.d.ts +2 -2
  122. package/types/keri/src/app/mailbox-sse.d.ts +8 -4
  123. package/types/keri/src/app/mailbox-sse.d.ts.map +1 -1
  124. package/types/keri/src/app/notifying.d.ts +23 -0
  125. package/types/keri/src/app/notifying.d.ts.map +1 -1
  126. package/types/keri/src/app/oobiery.d.ts +9 -3
  127. package/types/keri/src/app/oobiery.d.ts.map +1 -1
  128. package/types/keri/src/app/parsering.d.ts +45 -3
  129. package/types/keri/src/app/parsering.d.ts.map +1 -1
  130. package/types/keri/src/app/query-transport.d.ts.map +1 -1
  131. package/types/keri/src/app/reactor.d.ts +31 -1
  132. package/types/keri/src/app/reactor.d.ts.map +1 -1
  133. package/types/keri/src/app/runtime-services.d.ts +26 -0
  134. package/types/keri/src/app/runtime-services.d.ts.map +1 -0
  135. package/types/keri/src/app/schema-resolving.d.ts +31 -0
  136. package/types/keri/src/app/schema-resolving.d.ts.map +1 -0
  137. package/types/keri/src/app/verifier-agent.d.ts +82 -0
  138. package/types/keri/src/app/verifier-agent.d.ts.map +1 -0
  139. package/types/keri/src/app/verifying.d.ts +111 -0
  140. package/types/keri/src/app/verifying.d.ts.map +1 -0
  141. package/types/keri/src/app/version.d.ts +7 -4
  142. package/types/keri/src/app/version.d.ts.map +1 -1
  143. package/types/keri/src/core/cues.d.ts +28 -3
  144. package/types/keri/src/core/cues.d.ts.map +1 -1
  145. package/types/keri/src/core/eventing.d.ts +30 -0
  146. package/types/keri/src/core/eventing.d.ts.map +1 -1
  147. package/types/keri/src/core/kever.d.ts.map +1 -1
  148. package/types/keri/src/core/mailbox-topics.d.ts +2 -0
  149. package/types/keri/src/core/mailbox-topics.d.ts.map +1 -1
  150. package/types/keri/src/core/protocol-eventing.d.ts +8 -0
  151. package/types/keri/src/core/protocol-eventing.d.ts.map +1 -1
  152. package/types/keri/src/core/protocol-exchanging.d.ts.map +1 -1
  153. package/types/keri/src/core/protocol-serialization.d.ts.map +1 -1
  154. package/types/keri/src/core/protocol-vdr-eventing.d.ts +69 -0
  155. package/types/keri/src/core/protocol-vdr-eventing.d.ts.map +1 -0
  156. package/types/keri/src/core/scheming.d.ts +38 -0
  157. package/types/keri/src/core/scheming.d.ts.map +1 -0
  158. package/types/keri/src/db/basing.d.ts +2 -2
  159. package/types/keri/src/db/basing.d.ts.map +1 -1
  160. package/types/keri/src/db/index.d.ts +1 -0
  161. package/types/keri/src/db/index.d.ts.map +1 -1
  162. package/types/keri/src/db/noting.d.ts +2 -0
  163. package/types/keri/src/db/noting.d.ts.map +1 -1
  164. package/types/keri/src/db/reger.d.ts +91 -0
  165. package/types/keri/src/db/reger.d.ts.map +1 -0
  166. package/types/keri/src/db/subing.d.ts +18 -3
  167. package/types/keri/src/db/subing.d.ts.map +1 -1
  168. package/types/keri/src/db/verifier-cueing.d.ts +46 -0
  169. package/types/keri/src/db/verifier-cueing.d.ts.map +1 -0
  170. package/types/keri/src/library/index.d.ts +1 -0
  171. package/types/keri/src/library/index.d.ts.map +1 -1
  172. package/types/keri/src/runtime/index.d.ts +12 -0
  173. package/types/keri/src/runtime/index.d.ts.map +1 -1
  174. package/types/keri/src/vdr/credentialing.d.ts +169 -0
  175. package/types/keri/src/vdr/credentialing.d.ts.map +1 -0
  176. package/types/keri/src/vdr/eventing.d.ts +157 -0
  177. package/types/keri/src/vdr/eventing.d.ts.map +1 -0
@@ -1,11 +1,14 @@
1
1
  /**
2
- * Generated by scripts/generate_versions.ts.
3
- * Do not edit by hand.
2
+ * Template used by scripts/generate_versions.ts for package version modules.
3
+ *
4
+ * The generator token-replaces the string placeholders below, then formats and
5
+ * compares the rendered output during version checks. Do not edit generated
6
+ * `src/version.ts` files by hand; edit this template instead.
4
7
  */
5
8
  /** Package semantic version copied from the owning package manifest. */
6
- export const PACKAGE_VERSION = "0.6.0";
9
+ export const PACKAGE_VERSION = "0.8.0";
7
10
  /** Optional build metadata stamp injected by release/CI workflows. */
8
- export const BUILD_METADATA = "build.9.11f27f1a6176caac7b15d7fba862023af598592f";
11
+ export const BUILD_METADATA = "build.13.5884299463b061ec0fe2847a35a28b4189dee3f8";
9
12
  /** User-facing version string with build metadata appended when present. */
10
13
  export const DISPLAY_VERSION = BUILD_METADATA
11
14
  ? `${PACKAGE_VERSION}+${BUILD_METADATA}`
@@ -0,0 +1 @@
1
+ export * from "./messaging.js";
@@ -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
- import { ForwardHandler, MailboxPoller, mailboxTopicForRoute, Poster } from "./forwarding.js";
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";
@@ -13,8 +18,10 @@ import { isWellKnownOobiUrl, loadOobiHandlers, Oobiery, parseOobiUrl } from "./o
13
18
  import { QueryCoordinator } from "./querying.js";
14
19
  import { Reactor } from "./reactor.js";
15
20
  import { Respondant } from "./respondant.js";
21
+ import { resolveRuntimeServices } from "./runtime-services.js";
16
22
  import { runtimeTurn } from "./runtime-turn.js";
17
23
  import { Signaler } from "./signaling.js";
24
+ import { Verifier } from "./verifying.js";
18
25
  /**
19
26
  * Create the shared runtime composition root used by CLI commands and
20
27
  * `tufa agent`.
@@ -26,6 +33,7 @@ import { Signaler } from "./signaling.js";
26
33
  */
27
34
  export function* createAgentRuntime(hby, options = {}) {
28
35
  const mode = options.mode ?? "local";
36
+ const services = resolveRuntimeServices(options.services);
29
37
  const enableMailboxStore = options.enableMailboxStore ?? mode === "indirect";
30
38
  const mailboxer = options.mailboxer
31
39
  ?? (enableMailboxStore ? (yield* openMailboxerForHabery(hby)) : null);
@@ -42,12 +50,41 @@ export function* createAgentRuntime(hby, options = {}) {
42
50
  const notifier = options.notifier
43
51
  ?? (noter && signaler ? new Notifier(hby, { noter, signaler }) : null);
44
52
  const cues = new Deck();
45
- 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 });
46
81
  loadChallengeHandlers(hby.db, reactor.exchanger);
47
82
  loadDelegationHandlers(hby, reactor.exchanger, notifier);
48
83
  loadOobiHandlers(hby, reactor.exchanger, notifier);
84
+ loadMultisigHandlers(hby, reactor.exchanger, { notifier });
85
+ loadIpexHandlers(hby, reactor.exchanger, { notifier });
49
86
  const mailboxDirector = new MailboxDirector(hby, mailboxer ? { mailboxer } : {});
50
- const poster = new Poster(hby, { mailboxer });
87
+ const poster = new Poster(hby, { mailboxer, services });
51
88
  const respondant = new Respondant(hby, { poster, mailboxDirector });
52
89
  if (mailboxer) {
53
90
  reactor.exchanger.addHandler(new ForwardHandler(mailboxDirector));
@@ -61,9 +98,13 @@ export function* createAgentRuntime(hby, options = {}) {
61
98
  mailboxDirector.registerTopic(topic);
62
99
  }
63
100
  }
64
- const mailboxPoller = new MailboxPoller(hby, mailboxDirector);
101
+ const mailboxPoller = new MailboxPoller(hby, mailboxDirector, {
102
+ services,
103
+ pollTransport: options.mailboxPollTransport,
104
+ });
65
105
  for (const topic of [
66
106
  DELEGATE_MAILBOX_TOPIC,
107
+ CREDENTIAL_MAILBOX_TOPIC,
67
108
  RECEIPT_MAILBOX_TOPIC,
68
109
  REPLAY_MAILBOX_TOPIC,
69
110
  REPLY_MAILBOX_TOPIC,
@@ -72,9 +113,9 @@ export function* createAgentRuntime(hby, options = {}) {
72
113
  }
73
114
  const querying = new QueryCoordinator(hby);
74
115
  const delegating = new Anchorer(hby, { poster, querying });
75
- const oobiery = new Oobiery(hby, reactor, { cues });
116
+ const oobiery = new Oobiery(hby, reactor, { cues, services });
76
117
  oobiery.registerReplyRoutes(reactor.router);
77
- const authenticator = new Authenticator(hby);
118
+ const authenticator = new Authenticator(hby, { services });
78
119
  return {
79
120
  hby,
80
121
  mode,
@@ -92,6 +133,8 @@ export function* createAgentRuntime(hby, options = {}) {
92
133
  poster,
93
134
  delegating,
94
135
  querying,
136
+ vdr,
137
+ services,
95
138
  *close() {
96
139
  if (ownsNoter && noter?.opened) {
97
140
  yield* noter.close();
@@ -99,6 +142,9 @@ export function* createAgentRuntime(hby, options = {}) {
99
142
  if (ownsMailboxer && mailboxer?.opened) {
100
143
  yield* mailboxer.close();
101
144
  }
145
+ if (ownsReger && reger?.opened) {
146
+ yield* reger.close(hby.temp);
147
+ }
102
148
  },
103
149
  };
104
150
  }
@@ -153,7 +199,10 @@ export function settleRuntimeIngress(runtime, messages, { local, } = {}) {
153
199
  * follow-on escrow progress can occur before the next source is consumed.
154
200
  */
155
201
  export function settleMailboxPollBatch(runtime, batch) {
156
- settleRuntimeIngress(runtime, batch.messages);
202
+ for (const message of batch.messages) {
203
+ runtime.reactor.processCompleteChunk(message);
204
+ }
205
+ runtime.reactor.processEscrowsOnce();
157
206
  }
158
207
  /**
159
208
  * Drain one bounded mailbox polling turn and settle each returned batch.