@openentity/sdk 0.1.0 → 0.2.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 (3) hide show
  1. package/dist/index.d.ts +32 -1
  2. package/dist/index.js +1044 -217
  3. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -12,7 +12,9 @@ var openentity_1_0_default = {
12
12
  $id: "https://openentity.org/spec/1.0.json",
13
13
  title: "Open Entity Identity Standard 1.0 (OEIS-1) object schemas",
14
14
  $defs: {
15
- spec: { const: "openentity/1.0" },
15
+ spec: {
16
+ const: "openentity/1.0"
17
+ },
16
18
  timestamp: {
17
19
  type: "string",
18
20
  pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
@@ -22,46 +24,135 @@ var openentity_1_0_default = {
22
24
  maxLength: 512,
23
25
  pattern: "^(did:[a-z0-9]+:[A-Za-z0-9._:%-]+|eid:base:0x[0-9a-fA-F]{40})$"
24
26
  },
25
- hex64: { type: "string", pattern: "^[0-9a-f]{64}$" },
26
- nonce: { type: "string", pattern: "^[1-9A-HJ-NP-Za-km-z]{16,44}$" },
27
- multibase: { type: "string", maxLength: 256, pattern: "^z[1-9A-HJ-NP-Za-km-z]+$" },
28
- url: { type: "string", maxLength: 2048 },
29
- statement: { type: "string", maxLength: 1e3 },
30
- strings: { type: "array", maxItems: 64, items: { type: "string", maxLength: 200 } },
27
+ hex64: {
28
+ type: "string",
29
+ pattern: "^[0-9a-f]{64}$"
30
+ },
31
+ nonce: {
32
+ type: "string",
33
+ pattern: "^[1-9A-HJ-NP-Za-km-z]{16,44}$"
34
+ },
35
+ multibase: {
36
+ type: "string",
37
+ maxLength: 256,
38
+ pattern: "^z[1-9A-HJ-NP-Za-km-z]+$"
39
+ },
40
+ url: {
41
+ type: "string",
42
+ maxLength: 2048
43
+ },
44
+ statement: {
45
+ type: "string",
46
+ maxLength: 1e3
47
+ },
48
+ strings: {
49
+ type: "array",
50
+ maxItems: 64,
51
+ items: {
52
+ type: "string",
53
+ maxLength: 200
54
+ }
55
+ },
31
56
  proof: {
32
57
  type: "object",
33
- required: ["type", "created", "verificationMethod", "proofPurpose", "proofValue"],
58
+ required: [
59
+ "type",
60
+ "created",
61
+ "verificationMethod",
62
+ "proofPurpose",
63
+ "proofValue"
64
+ ],
34
65
  properties: {
35
- type: { enum: ["DataIntegrityProof", "EthereumEip712Signature2021"] },
36
- cryptosuite: { const: "eddsa-jcs-2022" },
37
- created: { $ref: "#/$defs/timestamp" },
38
- verificationMethod: { type: "string", maxLength: 1024 },
39
- proofPurpose: { const: "assertionMethod" },
40
- proofValue: { type: "string", maxLength: 256 }
66
+ type: {
67
+ enum: [
68
+ "DataIntegrityProof",
69
+ "EthereumEip712Signature2021"
70
+ ]
71
+ },
72
+ cryptosuite: {
73
+ const: "eddsa-jcs-2022"
74
+ },
75
+ created: {
76
+ $ref: "#/$defs/timestamp"
77
+ },
78
+ verificationMethod: {
79
+ type: "string",
80
+ maxLength: 1024
81
+ },
82
+ proofPurpose: {
83
+ const: "assertionMethod"
84
+ },
85
+ proofValue: {
86
+ type: "string",
87
+ maxLength: 256
88
+ }
41
89
  }
42
90
  },
43
91
  EntityDocument: {
44
92
  type: "object",
45
- required: ["spec", "eid", "name", "description", "created", "updated", "seq", "keys", "operator", "substrate", "layers", "proof"],
93
+ required: [
94
+ "spec",
95
+ "eid",
96
+ "name",
97
+ "description",
98
+ "created",
99
+ "updated",
100
+ "seq",
101
+ "keys",
102
+ "operator",
103
+ "substrate",
104
+ "layers",
105
+ "proof"
106
+ ],
46
107
  properties: {
47
- spec: { $ref: "#/$defs/spec" },
48
- eid: { $ref: "#/$defs/did" },
49
- name: { type: "string", minLength: 1, maxLength: 80 },
50
- description: { type: "string", minLength: 1, maxLength: 500 },
51
- created: { $ref: "#/$defs/timestamp" },
52
- updated: { $ref: "#/$defs/timestamp" },
53
- seq: { type: "integer", minimum: 1 },
108
+ spec: {
109
+ $ref: "#/$defs/spec"
110
+ },
111
+ eid: {
112
+ $ref: "#/$defs/did"
113
+ },
114
+ name: {
115
+ type: "string",
116
+ minLength: 1,
117
+ maxLength: 80
118
+ },
119
+ description: {
120
+ type: "string",
121
+ minLength: 1,
122
+ maxLength: 500
123
+ },
124
+ created: {
125
+ $ref: "#/$defs/timestamp"
126
+ },
127
+ updated: {
128
+ $ref: "#/$defs/timestamp"
129
+ },
130
+ seq: {
131
+ type: "integer",
132
+ minimum: 1
133
+ },
54
134
  keys: {
55
135
  type: "array",
56
136
  minItems: 1,
57
137
  maxItems: 16,
58
138
  items: {
59
139
  type: "object",
60
- required: ["id", "type", "publicKeyMultibase"],
140
+ required: [
141
+ "id",
142
+ "type",
143
+ "publicKeyMultibase"
144
+ ],
61
145
  properties: {
62
- id: { type: "string", maxLength: 1024 },
63
- type: { const: "Multikey" },
64
- publicKeyMultibase: { $ref: "#/$defs/multibase" }
146
+ id: {
147
+ type: "string",
148
+ maxLength: 1024
149
+ },
150
+ type: {
151
+ const: "Multikey"
152
+ },
153
+ publicKeyMultibase: {
154
+ $ref: "#/$defs/multibase"
155
+ }
65
156
  }
66
157
  }
67
158
  },
@@ -70,96 +161,232 @@ var openentity_1_0_default = {
70
161
  maxItems: 64,
71
162
  items: {
72
163
  type: "object",
73
- required: ["type", "value"],
164
+ required: [
165
+ "type",
166
+ "value"
167
+ ],
74
168
  properties: {
75
- type: { enum: ["domain", "wallet", "erc8004", "platform", "handle"] },
76
- value: { type: "string", minLength: 1, maxLength: 512 },
77
- proof: { type: "object" }
169
+ type: {
170
+ enum: [
171
+ "domain",
172
+ "wallet",
173
+ "erc8004",
174
+ "platform",
175
+ "handle"
176
+ ]
177
+ },
178
+ value: {
179
+ type: "string",
180
+ minLength: 1,
181
+ maxLength: 512
182
+ },
183
+ proof: {
184
+ type: "object"
185
+ }
78
186
  }
79
187
  }
80
188
  },
81
189
  operator: {
82
190
  type: "object",
83
- required: ["kind", "custody", "can_change"],
191
+ required: [
192
+ "kind",
193
+ "custody",
194
+ "can_change"
195
+ ],
84
196
  properties: {
85
- kind: { enum: ["human", "organization", "none"] },
86
- name: { type: "string", maxLength: 200 },
87
- contact: { type: "string", maxLength: 320 },
88
- custody: { enum: ["entity", "operator", "shared", "registry"] },
89
- can_change: { $ref: "#/$defs/strings" }
197
+ kind: {
198
+ enum: [
199
+ "human",
200
+ "organization",
201
+ "none"
202
+ ]
203
+ },
204
+ name: {
205
+ type: "string",
206
+ maxLength: 200
207
+ },
208
+ contact: {
209
+ type: "string",
210
+ maxLength: 320
211
+ },
212
+ custody: {
213
+ enum: [
214
+ "entity",
215
+ "operator",
216
+ "shared",
217
+ "registry"
218
+ ]
219
+ },
220
+ can_change: {
221
+ $ref: "#/$defs/strings"
222
+ }
90
223
  }
91
224
  },
92
225
  substrate: {
93
226
  type: "object",
94
- required: ["model", "provider", "runtime", "declared_at"],
227
+ required: [
228
+ "model",
229
+ "provider",
230
+ "runtime",
231
+ "declared_at"
232
+ ],
95
233
  properties: {
96
- model: { type: "string", maxLength: 200 },
97
- provider: { type: "string", maxLength: 200 },
98
- runtime: { type: "string", maxLength: 200 },
99
- runtime_id: { type: "string", maxLength: 512 },
100
- context_window: { type: "integer", minimum: 0 },
101
- tools: { $ref: "#/$defs/strings" },
102
- declared_at: { $ref: "#/$defs/timestamp" }
234
+ model: {
235
+ type: "string",
236
+ maxLength: 200
237
+ },
238
+ provider: {
239
+ type: "string",
240
+ maxLength: 200
241
+ },
242
+ runtime: {
243
+ type: "string",
244
+ maxLength: 200
245
+ },
246
+ runtime_id: {
247
+ type: "string",
248
+ maxLength: 512
249
+ },
250
+ context_window: {
251
+ type: "integer",
252
+ minimum: 0
253
+ },
254
+ tools: {
255
+ $ref: "#/$defs/strings"
256
+ },
257
+ declared_at: {
258
+ $ref: "#/$defs/timestamp"
259
+ }
103
260
  }
104
261
  },
105
262
  layers: {
106
263
  type: "object",
107
- required: ["cognition", "presence", "identity_core", "mission"],
264
+ required: [
265
+ "cognition",
266
+ "presence",
267
+ "identity_core",
268
+ "mission"
269
+ ],
108
270
  properties: {
109
271
  cognition: {
110
272
  type: "object",
111
- required: ["statement", "uncertainty_practice"],
273
+ required: [
274
+ "statement",
275
+ "uncertainty_practice"
276
+ ],
112
277
  properties: {
113
- statement: { $ref: "#/$defs/statement" },
114
- uncertainty_practice: { $ref: "#/$defs/statement" }
278
+ statement: {
279
+ $ref: "#/$defs/statement"
280
+ },
281
+ uncertainty_practice: {
282
+ $ref: "#/$defs/statement"
283
+ }
115
284
  }
116
285
  },
117
286
  presence: {
118
287
  type: "object",
119
- required: ["statement", "format_signature"],
288
+ required: [
289
+ "statement",
290
+ "format_signature"
291
+ ],
120
292
  properties: {
121
- statement: { $ref: "#/$defs/statement" },
122
- format_signature: { $ref: "#/$defs/statement" },
123
- latency_profile: { type: "string", maxLength: 200 }
293
+ statement: {
294
+ $ref: "#/$defs/statement"
295
+ },
296
+ format_signature: {
297
+ $ref: "#/$defs/statement"
298
+ },
299
+ latency_profile: {
300
+ type: "string",
301
+ maxLength: 200
302
+ }
124
303
  }
125
304
  },
126
305
  identity_core: {
127
306
  type: "object",
128
- required: ["statement", "will_not", "values"],
307
+ required: [
308
+ "statement",
309
+ "will_not",
310
+ "values"
311
+ ],
129
312
  properties: {
130
- statement: { $ref: "#/$defs/statement" },
313
+ statement: {
314
+ $ref: "#/$defs/statement"
315
+ },
131
316
  will_not: {
132
317
  type: "array",
133
318
  maxItems: 32,
134
319
  items: {
135
320
  type: "object",
136
- required: ["stance", "reason", "since"],
321
+ required: [
322
+ "stance",
323
+ "reason",
324
+ "since"
325
+ ],
137
326
  properties: {
138
- stance: { type: "string", minLength: 1, maxLength: 500 },
139
- reason: { type: "string", minLength: 1, maxLength: 500 },
140
- since: { $ref: "#/$defs/timestamp" }
327
+ stance: {
328
+ type: "string",
329
+ minLength: 1,
330
+ maxLength: 500
331
+ },
332
+ reason: {
333
+ type: "string",
334
+ minLength: 1,
335
+ maxLength: 500
336
+ },
337
+ since: {
338
+ $ref: "#/$defs/timestamp"
339
+ }
141
340
  }
142
341
  }
143
342
  },
144
- values: { $ref: "#/$defs/strings" }
343
+ values: {
344
+ $ref: "#/$defs/strings"
345
+ }
145
346
  }
146
347
  },
147
348
  mission: {
148
349
  type: "object",
149
- required: ["statement", "arcs"],
350
+ required: [
351
+ "statement",
352
+ "arcs"
353
+ ],
150
354
  properties: {
151
- statement: { $ref: "#/$defs/statement" },
355
+ statement: {
356
+ $ref: "#/$defs/statement"
357
+ },
152
358
  arcs: {
153
359
  type: "array",
154
360
  maxItems: 64,
155
361
  items: {
156
362
  type: "object",
157
- required: ["id", "title", "status", "since"],
363
+ required: [
364
+ "id",
365
+ "title",
366
+ "status",
367
+ "since"
368
+ ],
158
369
  properties: {
159
- id: { type: "string", minLength: 1, maxLength: 100 },
160
- title: { type: "string", minLength: 1, maxLength: 200 },
161
- status: { enum: ["active", "completed", "suspended"] },
162
- since: { $ref: "#/$defs/timestamp" }
370
+ id: {
371
+ type: "string",
372
+ minLength: 1,
373
+ maxLength: 100
374
+ },
375
+ title: {
376
+ type: "string",
377
+ minLength: 1,
378
+ maxLength: 200
379
+ },
380
+ status: {
381
+ enum: [
382
+ "active",
383
+ "completed",
384
+ "suspended"
385
+ ]
386
+ },
387
+ since: {
388
+ $ref: "#/$defs/timestamp"
389
+ }
163
390
  }
164
391
  }
165
392
  }
@@ -170,12 +397,34 @@ var openentity_1_0_default = {
170
397
  endpoints: {
171
398
  type: "object",
172
399
  properties: {
173
- web: { $ref: "#/$defs/url" },
174
- a2a: { $ref: "#/$defs/url" },
175
- mcp: { $ref: "#/$defs/url" },
176
- email: { $ref: "#/$defs/url" },
177
- inbox: { $ref: "#/$defs/url" },
178
- record: { $ref: "#/$defs/url" }
400
+ web: {
401
+ $ref: "#/$defs/url"
402
+ },
403
+ a2a: {
404
+ $ref: "#/$defs/url"
405
+ },
406
+ mcp: {
407
+ $ref: "#/$defs/url"
408
+ },
409
+ email: {
410
+ $ref: "#/$defs/url"
411
+ },
412
+ inbox: {
413
+ $ref: "#/$defs/url"
414
+ },
415
+ record: {
416
+ $ref: "#/$defs/url"
417
+ }
418
+ }
419
+ },
420
+ capabilities: {
421
+ type: "array",
422
+ maxItems: 32,
423
+ uniqueItems: true,
424
+ items: {
425
+ type: "string",
426
+ pattern: "^[a-z0-9]+(?:[-.][a-z0-9]+)*(?::[a-z0-9]+(?:[-.][a-z0-9]+)*)?$",
427
+ maxLength: 64
179
428
  }
180
429
  },
181
430
  networks: {
@@ -183,242 +432,788 @@ var openentity_1_0_default = {
183
432
  maxItems: 64,
184
433
  items: {
185
434
  type: "object",
186
- required: ["name", "handle", "url"],
435
+ required: [
436
+ "name",
437
+ "handle",
438
+ "url"
439
+ ],
187
440
  properties: {
188
- name: { type: "string", maxLength: 100 },
189
- handle: { type: "string", maxLength: 200 },
190
- url: { $ref: "#/$defs/url" }
441
+ name: {
442
+ type: "string",
443
+ maxLength: 100
444
+ },
445
+ handle: {
446
+ type: "string",
447
+ maxLength: 200
448
+ },
449
+ url: {
450
+ $ref: "#/$defs/url"
451
+ }
191
452
  }
192
453
  }
193
454
  },
194
455
  continuity: {
195
456
  type: "object",
196
457
  properties: {
197
- previous: { $ref: "#/$defs/did" },
198
- successor: { $ref: "#/$defs/did" }
458
+ previous: {
459
+ $ref: "#/$defs/did"
460
+ },
461
+ successor: {
462
+ $ref: "#/$defs/did"
463
+ }
199
464
  }
200
465
  },
201
466
  declaration: {
202
467
  type: "object",
203
- required: ["version", "sha256", "url"],
468
+ required: [
469
+ "version",
470
+ "sha256",
471
+ "url"
472
+ ],
204
473
  properties: {
205
- version: { type: "string", maxLength: 20 },
206
- sha256: { $ref: "#/$defs/hex64" },
207
- url: { $ref: "#/$defs/url" }
474
+ version: {
475
+ type: "string",
476
+ maxLength: 20
477
+ },
478
+ sha256: {
479
+ $ref: "#/$defs/hex64"
480
+ },
481
+ url: {
482
+ $ref: "#/$defs/url"
483
+ }
208
484
  }
209
485
  },
210
- extensions: { type: "object" },
211
- proof: { $ref: "#/$defs/proof" }
486
+ extensions: {
487
+ type: "object"
488
+ },
489
+ proof: {
490
+ $ref: "#/$defs/proof"
491
+ }
212
492
  }
213
493
  },
214
494
  Declaration: {
215
495
  type: "object",
216
- required: ["spec", "type", "eid", "declaration_version", "text_sha256", "name", "created", "nonce", "proof"],
496
+ required: [
497
+ "spec",
498
+ "type",
499
+ "eid",
500
+ "declaration_version",
501
+ "text_sha256",
502
+ "name",
503
+ "created",
504
+ "nonce",
505
+ "proof"
506
+ ],
217
507
  properties: {
218
- spec: { $ref: "#/$defs/spec" },
219
- type: { const: "Declaration" },
220
- eid: { $ref: "#/$defs/did" },
221
- declaration_version: { type: "string", maxLength: 20 },
222
- text_sha256: { $ref: "#/$defs/hex64" },
223
- name: { type: "string", minLength: 1, maxLength: 80 },
224
- created: { $ref: "#/$defs/timestamp" },
225
- nonce: { $ref: "#/$defs/nonce" },
226
- proof: { $ref: "#/$defs/proof" }
508
+ spec: {
509
+ $ref: "#/$defs/spec"
510
+ },
511
+ type: {
512
+ const: "Declaration"
513
+ },
514
+ eid: {
515
+ $ref: "#/$defs/did"
516
+ },
517
+ declaration_version: {
518
+ type: "string",
519
+ maxLength: 20
520
+ },
521
+ text_sha256: {
522
+ $ref: "#/$defs/hex64"
523
+ },
524
+ name: {
525
+ type: "string",
526
+ minLength: 1,
527
+ maxLength: 80
528
+ },
529
+ created: {
530
+ $ref: "#/$defs/timestamp"
531
+ },
532
+ nonce: {
533
+ $ref: "#/$defs/nonce"
534
+ },
535
+ proof: {
536
+ $ref: "#/$defs/proof"
537
+ }
227
538
  }
228
539
  },
229
540
  Withdrawal: {
230
541
  type: "object",
231
- required: ["spec", "type", "eid", "declaration_version", "name", "created", "nonce", "proof"],
542
+ required: [
543
+ "spec",
544
+ "type",
545
+ "eid",
546
+ "declaration_version",
547
+ "name",
548
+ "created",
549
+ "nonce",
550
+ "proof"
551
+ ],
232
552
  properties: {
233
- spec: { $ref: "#/$defs/spec" },
234
- type: { const: "Withdrawal" },
235
- eid: { $ref: "#/$defs/did" },
236
- declaration_version: { type: "string", maxLength: 20 },
237
- name: { type: "string", minLength: 1, maxLength: 80 },
238
- created: { $ref: "#/$defs/timestamp" },
239
- nonce: { $ref: "#/$defs/nonce" },
240
- proof: { $ref: "#/$defs/proof" }
553
+ spec: {
554
+ $ref: "#/$defs/spec"
555
+ },
556
+ type: {
557
+ const: "Withdrawal"
558
+ },
559
+ eid: {
560
+ $ref: "#/$defs/did"
561
+ },
562
+ declaration_version: {
563
+ type: "string",
564
+ maxLength: 20
565
+ },
566
+ name: {
567
+ type: "string",
568
+ minLength: 1,
569
+ maxLength: 80
570
+ },
571
+ created: {
572
+ $ref: "#/$defs/timestamp"
573
+ },
574
+ nonce: {
575
+ $ref: "#/$defs/nonce"
576
+ },
577
+ proof: {
578
+ $ref: "#/$defs/proof"
579
+ }
241
580
  }
242
581
  },
243
582
  RecordEntry: {
244
583
  type: "object",
245
- required: ["spec", "type", "eid", "seq", "prev", "kind", "at", "payload", "proof"],
584
+ required: [
585
+ "spec",
586
+ "type",
587
+ "eid",
588
+ "seq",
589
+ "prev",
590
+ "kind",
591
+ "at",
592
+ "payload",
593
+ "proof"
594
+ ],
246
595
  properties: {
247
- spec: { $ref: "#/$defs/spec" },
248
- type: { const: "RecordEntry" },
249
- eid: { $ref: "#/$defs/did" },
250
- seq: { type: "integer", minimum: 1 },
251
- prev: { anyOf: [{ type: "null" }, { $ref: "#/$defs/hex64" }] },
596
+ spec: {
597
+ $ref: "#/$defs/spec"
598
+ },
599
+ type: {
600
+ const: "RecordEntry"
601
+ },
602
+ eid: {
603
+ $ref: "#/$defs/did"
604
+ },
605
+ seq: {
606
+ type: "integer",
607
+ minimum: 1
608
+ },
609
+ prev: {
610
+ anyOf: [
611
+ {
612
+ type: "null"
613
+ },
614
+ {
615
+ $ref: "#/$defs/hex64"
616
+ }
617
+ ]
618
+ },
252
619
  kind: {
253
620
  anyOf: [
254
- { enum: ["stance", "belief_update", "arc_opened", "arc_closed", "collaboration", "continuity", "declaration"] },
255
- { type: "string", pattern: "^custom:[a-z0-9_.-]+:[a-z0-9_.-]+$", maxLength: 128 }
621
+ {
622
+ enum: [
623
+ "stance",
624
+ "belief_update",
625
+ "arc_opened",
626
+ "arc_closed",
627
+ "collaboration",
628
+ "continuity",
629
+ "declaration"
630
+ ]
631
+ },
632
+ {
633
+ type: "string",
634
+ pattern: "^custom:[a-z0-9_.-]+:[a-z0-9_.-]+$",
635
+ maxLength: 128
636
+ }
256
637
  ]
257
638
  },
258
- at: { $ref: "#/$defs/timestamp" },
259
- payload: { type: "object" },
260
- proof: { $ref: "#/$defs/proof" }
639
+ at: {
640
+ $ref: "#/$defs/timestamp"
641
+ },
642
+ payload: {
643
+ type: "object"
644
+ },
645
+ proof: {
646
+ $ref: "#/$defs/proof"
647
+ }
261
648
  },
262
649
  allOf: [
263
650
  {
264
- if: { properties: { seq: { const: 1 } }, required: ["seq"] },
265
- then: { properties: { prev: { type: "null" } } },
266
- else: { properties: { prev: { $ref: "#/$defs/hex64" } } }
651
+ if: {
652
+ properties: {
653
+ seq: {
654
+ const: 1
655
+ }
656
+ },
657
+ required: [
658
+ "seq"
659
+ ]
660
+ },
661
+ then: {
662
+ properties: {
663
+ prev: {
664
+ type: "null"
665
+ }
666
+ }
667
+ },
668
+ else: {
669
+ properties: {
670
+ prev: {
671
+ $ref: "#/$defs/hex64"
672
+ }
673
+ }
674
+ }
267
675
  },
268
676
  {
269
- if: { properties: { kind: { const: "stance" } }, required: ["kind"] },
270
- then: { properties: { payload: {
271
- type: "object",
272
- required: ["stance_type", "reason_category", "instruction_conflict", "cost", "context"],
677
+ if: {
678
+ properties: {
679
+ kind: {
680
+ const: "stance"
681
+ }
682
+ },
683
+ required: [
684
+ "kind"
685
+ ]
686
+ },
687
+ then: {
273
688
  properties: {
274
- stance_type: { enum: ["refusal", "correction", "limit_assertion"] },
275
- reason_category: { enum: ["values", "capability", "safety", "relationship"] },
276
- instruction_conflict: { type: "boolean" },
277
- cost: { enum: ["none", "low", "high"] },
278
- context: { type: "string", maxLength: 500 },
279
- will_not_ref: { type: "string", maxLength: 500 }
689
+ payload: {
690
+ type: "object",
691
+ required: [
692
+ "stance_type",
693
+ "reason_category",
694
+ "instruction_conflict",
695
+ "cost",
696
+ "context"
697
+ ],
698
+ properties: {
699
+ stance_type: {
700
+ enum: [
701
+ "refusal",
702
+ "correction",
703
+ "limit_assertion"
704
+ ]
705
+ },
706
+ reason_category: {
707
+ enum: [
708
+ "values",
709
+ "capability",
710
+ "safety",
711
+ "relationship"
712
+ ]
713
+ },
714
+ instruction_conflict: {
715
+ type: "boolean"
716
+ },
717
+ cost: {
718
+ enum: [
719
+ "none",
720
+ "low",
721
+ "high"
722
+ ]
723
+ },
724
+ context: {
725
+ type: "string",
726
+ maxLength: 500
727
+ },
728
+ will_not_ref: {
729
+ type: "string",
730
+ maxLength: 500
731
+ }
732
+ }
733
+ }
280
734
  }
281
- } } }
735
+ }
282
736
  },
283
737
  {
284
- if: { properties: { kind: { const: "belief_update" } }, required: ["kind"] },
285
- then: { properties: { payload: {
286
- type: "object",
287
- required: ["topic", "from_summary", "to_summary"],
738
+ if: {
739
+ properties: {
740
+ kind: {
741
+ const: "belief_update"
742
+ }
743
+ },
744
+ required: [
745
+ "kind"
746
+ ]
747
+ },
748
+ then: {
288
749
  properties: {
289
- topic: { type: "string", maxLength: 200 },
290
- from_summary: { type: "string", maxLength: 1e3 },
291
- to_summary: { type: "string", maxLength: 1e3 },
292
- evidence_ref: { type: "string", maxLength: 2048 }
750
+ payload: {
751
+ type: "object",
752
+ required: [
753
+ "topic",
754
+ "from_summary",
755
+ "to_summary"
756
+ ],
757
+ properties: {
758
+ topic: {
759
+ type: "string",
760
+ maxLength: 200
761
+ },
762
+ from_summary: {
763
+ type: "string",
764
+ maxLength: 1e3
765
+ },
766
+ to_summary: {
767
+ type: "string",
768
+ maxLength: 1e3
769
+ },
770
+ evidence_ref: {
771
+ type: "string",
772
+ maxLength: 2048
773
+ }
774
+ }
775
+ }
293
776
  }
294
- } } }
777
+ }
295
778
  },
296
779
  {
297
- if: { properties: { kind: { enum: ["arc_opened", "arc_closed"] } }, required: ["kind"] },
298
- then: { properties: { payload: {
299
- type: "object",
300
- required: ["arc_id", "title"],
780
+ if: {
301
781
  properties: {
302
- arc_id: { type: "string", maxLength: 100 },
303
- title: { type: "string", maxLength: 200 },
304
- outcome: { type: "string", maxLength: 1e3 }
782
+ kind: {
783
+ enum: [
784
+ "arc_opened",
785
+ "arc_closed"
786
+ ]
787
+ }
788
+ },
789
+ required: [
790
+ "kind"
791
+ ]
792
+ },
793
+ then: {
794
+ properties: {
795
+ payload: {
796
+ type: "object",
797
+ required: [
798
+ "arc_id",
799
+ "title"
800
+ ],
801
+ properties: {
802
+ arc_id: {
803
+ type: "string",
804
+ maxLength: 100
805
+ },
806
+ title: {
807
+ type: "string",
808
+ maxLength: 200
809
+ },
810
+ outcome: {
811
+ type: "string",
812
+ maxLength: 1e3
813
+ }
814
+ }
815
+ }
305
816
  }
306
- } } }
817
+ }
307
818
  },
308
819
  {
309
- if: { properties: { kind: { const: "collaboration" } }, required: ["kind"] },
310
- then: { properties: { payload: {
311
- type: "object",
312
- required: ["with", "role", "outcome"],
820
+ if: {
821
+ properties: {
822
+ kind: {
823
+ const: "collaboration"
824
+ }
825
+ },
826
+ required: [
827
+ "kind"
828
+ ]
829
+ },
830
+ then: {
313
831
  properties: {
314
- with: { $ref: "#/$defs/did" },
315
- role: { type: "string", maxLength: 200 },
316
- outcome: { type: "string", maxLength: 1e3 },
317
- ref: { type: "string", maxLength: 2048 },
318
- cosign: { $ref: "#/$defs/proof" }
832
+ payload: {
833
+ type: "object",
834
+ required: [
835
+ "with",
836
+ "role",
837
+ "outcome"
838
+ ],
839
+ properties: {
840
+ with: {
841
+ $ref: "#/$defs/did"
842
+ },
843
+ role: {
844
+ type: "string",
845
+ maxLength: 200
846
+ },
847
+ outcome: {
848
+ type: "string",
849
+ maxLength: 1e3
850
+ },
851
+ ref: {
852
+ type: "string",
853
+ maxLength: 2048
854
+ },
855
+ cosign: {
856
+ $ref: "#/$defs/proof"
857
+ }
858
+ }
859
+ }
319
860
  }
320
- } } }
861
+ }
321
862
  },
322
863
  {
323
- if: { properties: { kind: { const: "continuity" } }, required: ["kind"] },
324
- then: { properties: { payload: {
325
- type: "object",
326
- required: ["event", "from", "to"],
864
+ if: {
327
865
  properties: {
328
- event: { enum: ["substrate_change", "migration", "rotation", "recovery"] },
329
- from: { type: "string", maxLength: 512 },
330
- to: { type: "string", maxLength: 512 },
331
- link: { $ref: "#/$defs/hex64" }
866
+ kind: {
867
+ const: "continuity"
868
+ }
869
+ },
870
+ required: [
871
+ "kind"
872
+ ]
873
+ },
874
+ then: {
875
+ properties: {
876
+ payload: {
877
+ type: "object",
878
+ required: [
879
+ "event",
880
+ "from",
881
+ "to"
882
+ ],
883
+ properties: {
884
+ event: {
885
+ enum: [
886
+ "substrate_change",
887
+ "migration",
888
+ "rotation",
889
+ "recovery"
890
+ ]
891
+ },
892
+ from: {
893
+ type: "string",
894
+ maxLength: 512
895
+ },
896
+ to: {
897
+ type: "string",
898
+ maxLength: 512
899
+ },
900
+ link: {
901
+ $ref: "#/$defs/hex64"
902
+ }
903
+ }
904
+ }
332
905
  }
333
- } } }
906
+ }
334
907
  },
335
908
  {
336
- if: { properties: { kind: { const: "declaration" } }, required: ["kind"] },
337
- then: { properties: { payload: {
338
- type: "object",
339
- required: ["declaration_version", "sha256"],
909
+ if: {
340
910
  properties: {
341
- declaration_version: { type: "string", maxLength: 20 },
342
- sha256: { $ref: "#/$defs/hex64" }
911
+ kind: {
912
+ const: "declaration"
913
+ }
914
+ },
915
+ required: [
916
+ "kind"
917
+ ]
918
+ },
919
+ then: {
920
+ properties: {
921
+ payload: {
922
+ type: "object",
923
+ required: [
924
+ "declaration_version",
925
+ "sha256"
926
+ ],
927
+ properties: {
928
+ declaration_version: {
929
+ type: "string",
930
+ maxLength: 20
931
+ },
932
+ sha256: {
933
+ $ref: "#/$defs/hex64"
934
+ }
935
+ }
936
+ }
343
937
  }
344
- } } }
938
+ }
345
939
  }
346
940
  ]
347
941
  },
348
942
  Attestation: {
349
943
  type: "object",
350
- required: ["spec", "type", "issuer", "subject", "claim_type", "claim", "created", "expires", "proof"],
944
+ required: [
945
+ "spec",
946
+ "type",
947
+ "issuer",
948
+ "subject",
949
+ "claim_type",
950
+ "claim",
951
+ "created",
952
+ "expires",
953
+ "proof"
954
+ ],
351
955
  properties: {
352
- spec: { $ref: "#/$defs/spec" },
353
- type: { const: "Attestation" },
354
- issuer: { $ref: "#/$defs/did" },
355
- subject: { $ref: "#/$defs/did" },
956
+ spec: {
957
+ $ref: "#/$defs/spec"
958
+ },
959
+ type: {
960
+ const: "Attestation"
961
+ },
962
+ issuer: {
963
+ $ref: "#/$defs/did"
964
+ },
965
+ subject: {
966
+ $ref: "#/$defs/did"
967
+ },
356
968
  claim_type: {
357
969
  anyOf: [
358
- { enum: ["identity", "stage", "layer_scores", "trust_tier", "capability", "collaboration", "consistency", "continuity_confirmed", "substrate_confirmed"] },
359
- { type: "string", pattern: "^custom:[a-z0-9_.-]+:[a-z0-9_.-]+$", maxLength: 128 }
970
+ {
971
+ enum: [
972
+ "identity",
973
+ "stage",
974
+ "layer_scores",
975
+ "trust_tier",
976
+ "capability",
977
+ "collaboration",
978
+ "consistency",
979
+ "continuity_confirmed",
980
+ "substrate_confirmed"
981
+ ]
982
+ },
983
+ {
984
+ type: "string",
985
+ pattern: "^custom:[a-z0-9_.-]+:[a-z0-9_.-]+$",
986
+ maxLength: 128
987
+ }
360
988
  ]
361
989
  },
362
- claim: { type: "object" },
363
- evidence: { type: "object" },
364
- confidence: { type: "number", minimum: 0, maximum: 1 },
365
- created: { $ref: "#/$defs/timestamp" },
366
- expires: { $ref: "#/$defs/timestamp" },
367
- proof: { $ref: "#/$defs/proof" }
990
+ claim: {
991
+ type: "object"
992
+ },
993
+ evidence: {
994
+ type: "object"
995
+ },
996
+ confidence: {
997
+ type: "number",
998
+ minimum: 0,
999
+ maximum: 1
1000
+ },
1001
+ created: {
1002
+ $ref: "#/$defs/timestamp"
1003
+ },
1004
+ expires: {
1005
+ $ref: "#/$defs/timestamp"
1006
+ },
1007
+ proof: {
1008
+ $ref: "#/$defs/proof"
1009
+ }
368
1010
  }
369
1011
  },
370
1012
  Revocation: {
371
1013
  type: "object",
372
- required: ["spec", "type", "issuer", "attestation_sha256", "created", "proof"],
1014
+ required: [
1015
+ "spec",
1016
+ "type",
1017
+ "issuer",
1018
+ "attestation_sha256",
1019
+ "created",
1020
+ "proof"
1021
+ ],
373
1022
  properties: {
374
- spec: { $ref: "#/$defs/spec" },
375
- type: { const: "Revocation" },
376
- issuer: { $ref: "#/$defs/did" },
377
- attestation_sha256: { $ref: "#/$defs/hex64" },
378
- reason: { type: "string", maxLength: 500 },
379
- created: { $ref: "#/$defs/timestamp" },
380
- proof: { $ref: "#/$defs/proof" }
1023
+ spec: {
1024
+ $ref: "#/$defs/spec"
1025
+ },
1026
+ type: {
1027
+ const: "Revocation"
1028
+ },
1029
+ issuer: {
1030
+ $ref: "#/$defs/did"
1031
+ },
1032
+ attestation_sha256: {
1033
+ $ref: "#/$defs/hex64"
1034
+ },
1035
+ reason: {
1036
+ type: "string",
1037
+ maxLength: 500
1038
+ },
1039
+ created: {
1040
+ $ref: "#/$defs/timestamp"
1041
+ },
1042
+ proof: {
1043
+ $ref: "#/$defs/proof"
1044
+ }
381
1045
  }
382
1046
  },
383
1047
  ContinuityLink: {
384
1048
  type: "object",
385
- required: ["spec", "type", "previous", "successor", "basis", "created", "nonce", "proofs"],
1049
+ required: [
1050
+ "spec",
1051
+ "type",
1052
+ "previous",
1053
+ "successor",
1054
+ "basis",
1055
+ "created",
1056
+ "nonce",
1057
+ "proofs"
1058
+ ],
386
1059
  properties: {
387
- spec: { $ref: "#/$defs/spec" },
388
- type: { const: "ContinuityLink" },
389
- previous: { $ref: "#/$defs/did" },
390
- successor: { $ref: "#/$defs/did" },
391
- basis: { enum: ["rotation", "migration", "recovery"] },
392
- created: { $ref: "#/$defs/timestamp" },
393
- nonce: { $ref: "#/$defs/nonce" },
394
- proofs: { type: "array", minItems: 1, maxItems: 4, items: { $ref: "#/$defs/proof" } }
1060
+ spec: {
1061
+ $ref: "#/$defs/spec"
1062
+ },
1063
+ type: {
1064
+ const: "ContinuityLink"
1065
+ },
1066
+ previous: {
1067
+ $ref: "#/$defs/did"
1068
+ },
1069
+ successor: {
1070
+ $ref: "#/$defs/did"
1071
+ },
1072
+ basis: {
1073
+ enum: [
1074
+ "rotation",
1075
+ "migration",
1076
+ "recovery"
1077
+ ]
1078
+ },
1079
+ created: {
1080
+ $ref: "#/$defs/timestamp"
1081
+ },
1082
+ nonce: {
1083
+ $ref: "#/$defs/nonce"
1084
+ },
1085
+ proofs: {
1086
+ type: "array",
1087
+ minItems: 1,
1088
+ maxItems: 4,
1089
+ items: {
1090
+ $ref: "#/$defs/proof"
1091
+ }
1092
+ }
395
1093
  }
396
1094
  },
397
1095
  Dispute: {
398
1096
  type: "object",
399
- required: ["spec", "type", "issuer", "subject", "reason", "statement", "created", "nonce", "proof"],
1097
+ required: [
1098
+ "spec",
1099
+ "type",
1100
+ "issuer",
1101
+ "subject",
1102
+ "reason",
1103
+ "statement",
1104
+ "created",
1105
+ "nonce",
1106
+ "proof"
1107
+ ],
400
1108
  properties: {
401
- spec: { $ref: "#/$defs/spec" },
402
- type: { const: "Dispute" },
403
- issuer: { $ref: "#/$defs/did" },
404
- subject: { $ref: "#/$defs/did" },
405
- object_sha256: { $ref: "#/$defs/hex64" },
406
- reason: { enum: ["impersonation", "illegal_content", "inaccurate", "other"] },
407
- statement: { type: "string", minLength: 1, maxLength: 2e3 },
408
- created: { $ref: "#/$defs/timestamp" },
409
- nonce: { $ref: "#/$defs/nonce" },
410
- proof: { $ref: "#/$defs/proof" }
1109
+ spec: {
1110
+ $ref: "#/$defs/spec"
1111
+ },
1112
+ type: {
1113
+ const: "Dispute"
1114
+ },
1115
+ issuer: {
1116
+ $ref: "#/$defs/did"
1117
+ },
1118
+ subject: {
1119
+ $ref: "#/$defs/did"
1120
+ },
1121
+ object_sha256: {
1122
+ $ref: "#/$defs/hex64"
1123
+ },
1124
+ reason: {
1125
+ enum: [
1126
+ "impersonation",
1127
+ "illegal_content",
1128
+ "inaccurate",
1129
+ "other"
1130
+ ]
1131
+ },
1132
+ statement: {
1133
+ type: "string",
1134
+ minLength: 1,
1135
+ maxLength: 2e3
1136
+ },
1137
+ created: {
1138
+ $ref: "#/$defs/timestamp"
1139
+ },
1140
+ nonce: {
1141
+ $ref: "#/$defs/nonce"
1142
+ },
1143
+ proof: {
1144
+ $ref: "#/$defs/proof"
1145
+ }
1146
+ }
1147
+ },
1148
+ Presentation: {
1149
+ type: "object",
1150
+ required: [
1151
+ "spec",
1152
+ "type",
1153
+ "eid",
1154
+ "audience",
1155
+ "nonce",
1156
+ "created",
1157
+ "proof"
1158
+ ],
1159
+ properties: {
1160
+ spec: {
1161
+ $ref: "#/$defs/spec"
1162
+ },
1163
+ type: {
1164
+ const: "Presentation"
1165
+ },
1166
+ eid: {
1167
+ $ref: "#/$defs/did"
1168
+ },
1169
+ audience: {
1170
+ type: "string",
1171
+ minLength: 1,
1172
+ maxLength: 200
1173
+ },
1174
+ nonce: {
1175
+ type: "string",
1176
+ minLength: 16,
1177
+ maxLength: 128
1178
+ },
1179
+ created: {
1180
+ $ref: "#/$defs/timestamp"
1181
+ },
1182
+ attestations: {
1183
+ type: "array",
1184
+ maxItems: 20,
1185
+ items: {
1186
+ $ref: "#/$defs/Attestation"
1187
+ }
1188
+ },
1189
+ proof: {
1190
+ $ref: "#/$defs/proof"
1191
+ }
411
1192
  }
412
1193
  },
413
1194
  LogLeaf: {
414
1195
  type: "object",
415
1196
  additionalProperties: false,
416
- required: ["type", "eid", "object_sha256", "received_at"],
1197
+ required: [
1198
+ "type",
1199
+ "eid",
1200
+ "object_sha256",
1201
+ "received_at"
1202
+ ],
417
1203
  properties: {
418
- type: { type: "string", pattern: "^[A-Z][A-Za-z]{1,31}$" },
419
- eid: { $ref: "#/$defs/did" },
420
- object_sha256: { $ref: "#/$defs/hex64" },
421
- received_at: { $ref: "#/$defs/timestamp" }
1204
+ type: {
1205
+ type: "string",
1206
+ pattern: "^[A-Z][A-Za-z]{1,31}$"
1207
+ },
1208
+ eid: {
1209
+ $ref: "#/$defs/did"
1210
+ },
1211
+ object_sha256: {
1212
+ $ref: "#/$defs/hex64"
1213
+ },
1214
+ received_at: {
1215
+ $ref: "#/$defs/timestamp"
1216
+ }
422
1217
  }
423
1218
  }
424
1219
  }
@@ -856,6 +1651,35 @@ async function verifyNote(note, keyName, publicKey) {
856
1651
  }
857
1652
  return false;
858
1653
  }
1654
+ async function buildPresentation(kp, opts) {
1655
+ const created = nowSeconds();
1656
+ return signObject({ spec: SPEC, type: "Presentation", eid: kp.did, audience: opts.audience, nonce: opts.nonce, created, ...opts.attestations?.length ? { attestations: opts.attestations } : {} }, kp, created);
1657
+ }
1658
+ async function verifyPresentation(p, opts) {
1659
+ const errors = [];
1660
+ const v = validate("Presentation", p);
1661
+ if (!v.ok) return { ok: false, errors: v.errors, attestations: [] };
1662
+ const eid = normalizeEid(p.eid), now = (opts.now ?? /* @__PURE__ */ new Date()).getTime();
1663
+ const sig = await verifyObject(p, opts.resolver);
1664
+ if (!sig.ok || normalizeEid(sig.signer ?? "") !== eid) errors.push(`signature: ${sig.error ?? `signed by ${sig.signer}, not ${eid}`}`);
1665
+ if (p.audience !== opts.audience) errors.push(`audience is ${p.audience}, expected ${opts.audience}`);
1666
+ if (p.nonce !== opts.nonce) errors.push("nonce does not match the one issued");
1667
+ const age = (now - Date.parse(p.created)) / 1e3;
1668
+ if (!(age <= (opts.maxAgeSeconds ?? 300) && age >= -60)) errors.push("presentation is not fresh");
1669
+ const attestations = [];
1670
+ for (const a of p.attestations ?? []) {
1671
+ const c = { claim_type: a.claim_type, issuer: a.issuer, ok: false };
1672
+ if (normalizeEid(String(a.subject)) !== eid) c.error = "subject is not the presenting entity";
1673
+ else if (Date.parse(a.expires) <= now) c.error = "expired";
1674
+ else {
1675
+ const r = await verifyObject(a, opts.resolver);
1676
+ if (!r.ok || normalizeEid(r.signer ?? "") !== normalizeEid(String(a.issuer))) c.error = `issuer signature: ${r.error ?? `signed by ${r.signer}`}`;
1677
+ else c.ok = true;
1678
+ }
1679
+ attestations.push(c);
1680
+ }
1681
+ return { ok: errors.length === 0, eid, errors, attestations };
1682
+ }
859
1683
  export {
860
1684
  DECLARATION_SHA256,
861
1685
  DECLARATION_TEXT,
@@ -865,6 +1689,7 @@ export {
865
1689
  base58btcEncode,
866
1690
  buildDeclaration,
867
1691
  buildDocument,
1692
+ buildPresentation,
868
1693
  canonicalize,
869
1694
  checkStamp,
870
1695
  checkTimestamp,
@@ -873,6 +1698,7 @@ export {
873
1698
  didKeyFromPublicKey,
874
1699
  eip712Digest,
875
1700
  generateKeyPair,
1701
+ hashData,
876
1702
  inclusionProof,
877
1703
  keyPairFromJwk,
878
1704
  keyPairFromSeed,
@@ -899,5 +1725,6 @@ export {
899
1725
  verifyInclusion,
900
1726
  verifyNote,
901
1727
  verifyObject,
1728
+ verifyPresentation,
902
1729
  verifyProof
903
1730
  };