agent-passport-system 7.0.0 → 7.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 (198) hide show
  1. package/SECURITY.md +11 -0
  2. package/dist/src/core/tool-integrity.d.ts +13 -0
  3. package/dist/src/core/tool-integrity.d.ts.map +1 -1
  4. package/dist/src/core/tool-integrity.js +1 -1
  5. package/dist/src/core/tool-integrity.js.map +1 -1
  6. package/dist/src/index.d.ts +52 -2
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/index.js +282 -1
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/v2/activation/canonical.d.ts +40 -0
  11. package/dist/src/v2/activation/canonical.d.ts.map +1 -0
  12. package/dist/src/v2/activation/canonical.js +64 -0
  13. package/dist/src/v2/activation/canonical.js.map +1 -0
  14. package/dist/src/v2/activation/index.d.ts +4 -0
  15. package/dist/src/v2/activation/index.d.ts.map +1 -0
  16. package/dist/src/v2/activation/index.js +11 -0
  17. package/dist/src/v2/activation/index.js.map +1 -0
  18. package/dist/src/v2/activation/types.d.ts +268 -0
  19. package/dist/src/v2/activation/types.d.ts.map +1 -0
  20. package/dist/src/v2/activation/types.js +198 -0
  21. package/dist/src/v2/activation/types.js.map +1 -0
  22. package/dist/src/v2/activation/verify.d.ts +132 -0
  23. package/dist/src/v2/activation/verify.d.ts.map +1 -0
  24. package/dist/src/v2/activation/verify.js +406 -0
  25. package/dist/src/v2/activation/verify.js.map +1 -0
  26. package/dist/src/v2/authority-revocation/canonical.d.ts +46 -0
  27. package/dist/src/v2/authority-revocation/canonical.d.ts.map +1 -0
  28. package/dist/src/v2/authority-revocation/canonical.js +68 -0
  29. package/dist/src/v2/authority-revocation/canonical.js.map +1 -0
  30. package/dist/src/v2/authority-revocation/index.d.ts +9 -0
  31. package/dist/src/v2/authority-revocation/index.d.ts.map +1 -0
  32. package/dist/src/v2/authority-revocation/index.js +11 -0
  33. package/dist/src/v2/authority-revocation/index.js.map +1 -0
  34. package/dist/src/v2/authority-revocation/issue.d.ts +54 -0
  35. package/dist/src/v2/authority-revocation/issue.d.ts.map +1 -0
  36. package/dist/src/v2/authority-revocation/issue.js +111 -0
  37. package/dist/src/v2/authority-revocation/issue.js.map +1 -0
  38. package/dist/src/v2/authority-revocation/record.d.ts +69 -0
  39. package/dist/src/v2/authority-revocation/record.d.ts.map +1 -0
  40. package/dist/src/v2/authority-revocation/record.js +51 -0
  41. package/dist/src/v2/authority-revocation/record.js.map +1 -0
  42. package/dist/src/v2/authority-revocation/resolver.d.ts +30 -0
  43. package/dist/src/v2/authority-revocation/resolver.d.ts.map +1 -0
  44. package/dist/src/v2/authority-revocation/resolver.js +52 -0
  45. package/dist/src/v2/authority-revocation/resolver.js.map +1 -0
  46. package/dist/src/v2/authority-revocation/schema.d.ts +15 -0
  47. package/dist/src/v2/authority-revocation/schema.d.ts.map +1 -0
  48. package/dist/src/v2/authority-revocation/schema.js +107 -0
  49. package/dist/src/v2/authority-revocation/schema.js.map +1 -0
  50. package/dist/src/v2/authority-revocation/store.d.ts +55 -0
  51. package/dist/src/v2/authority-revocation/store.d.ts.map +1 -0
  52. package/dist/src/v2/authority-revocation/store.js +69 -0
  53. package/dist/src/v2/authority-revocation/store.js.map +1 -0
  54. package/dist/src/v2/authority-revocation/types.d.ts +136 -0
  55. package/dist/src/v2/authority-revocation/types.d.ts.map +1 -0
  56. package/dist/src/v2/authority-revocation/types.js +11 -0
  57. package/dist/src/v2/authority-revocation/types.js.map +1 -0
  58. package/dist/src/v2/authority-revocation/verify.d.ts +38 -0
  59. package/dist/src/v2/authority-revocation/verify.d.ts.map +1 -0
  60. package/dist/src/v2/authority-revocation/verify.js +139 -0
  61. package/dist/src/v2/authority-revocation/verify.js.map +1 -0
  62. package/dist/src/v2/authority-state/fencing.d.ts +49 -0
  63. package/dist/src/v2/authority-state/fencing.d.ts.map +1 -0
  64. package/dist/src/v2/authority-state/fencing.js +92 -0
  65. package/dist/src/v2/authority-state/fencing.js.map +1 -0
  66. package/dist/src/v2/authority-state/index.d.ts +7 -0
  67. package/dist/src/v2/authority-state/index.d.ts.map +1 -0
  68. package/dist/src/v2/authority-state/index.js +14 -0
  69. package/dist/src/v2/authority-state/index.js.map +1 -0
  70. package/dist/src/v2/authority-state/marker.d.ts +70 -0
  71. package/dist/src/v2/authority-state/marker.d.ts.map +1 -0
  72. package/dist/src/v2/authority-state/marker.js +122 -0
  73. package/dist/src/v2/authority-state/marker.js.map +1 -0
  74. package/dist/src/v2/authority-state/report.d.ts +55 -0
  75. package/dist/src/v2/authority-state/report.d.ts.map +1 -0
  76. package/dist/src/v2/authority-state/report.js +51 -0
  77. package/dist/src/v2/authority-state/report.js.map +1 -0
  78. package/dist/src/v2/authority-state/retained.d.ts +82 -0
  79. package/dist/src/v2/authority-state/retained.d.ts.map +1 -0
  80. package/dist/src/v2/authority-state/retained.js +93 -0
  81. package/dist/src/v2/authority-state/retained.js.map +1 -0
  82. package/dist/src/v2/authority-state/types.d.ts +198 -0
  83. package/dist/src/v2/authority-state/types.d.ts.map +1 -0
  84. package/dist/src/v2/authority-state/types.js +103 -0
  85. package/dist/src/v2/authority-state/types.js.map +1 -0
  86. package/dist/src/v2/authority-state/withdrawal.d.ts +80 -0
  87. package/dist/src/v2/authority-state/withdrawal.d.ts.map +1 -0
  88. package/dist/src/v2/authority-state/withdrawal.js +199 -0
  89. package/dist/src/v2/authority-state/withdrawal.js.map +1 -0
  90. package/dist/src/v2/bounds/canonical.d.ts +30 -0
  91. package/dist/src/v2/bounds/canonical.d.ts.map +1 -0
  92. package/dist/src/v2/bounds/canonical.js +69 -0
  93. package/dist/src/v2/bounds/canonical.js.map +1 -0
  94. package/dist/src/v2/bounds/evaluate.d.ts +107 -0
  95. package/dist/src/v2/bounds/evaluate.d.ts.map +1 -0
  96. package/dist/src/v2/bounds/evaluate.js +315 -0
  97. package/dist/src/v2/bounds/evaluate.js.map +1 -0
  98. package/dist/src/v2/bounds/index.d.ts +6 -0
  99. package/dist/src/v2/bounds/index.d.ts.map +1 -0
  100. package/dist/src/v2/bounds/index.js +13 -0
  101. package/dist/src/v2/bounds/index.js.map +1 -0
  102. package/dist/src/v2/bounds/purpose.d.ts +2 -0
  103. package/dist/src/v2/bounds/purpose.d.ts.map +1 -0
  104. package/dist/src/v2/bounds/purpose.js +23 -0
  105. package/dist/src/v2/bounds/purpose.js.map +1 -0
  106. package/dist/src/v2/bounds/record.d.ts +78 -0
  107. package/dist/src/v2/bounds/record.d.ts.map +1 -0
  108. package/dist/src/v2/bounds/record.js +170 -0
  109. package/dist/src/v2/bounds/record.js.map +1 -0
  110. package/dist/src/v2/bounds/types.d.ts +275 -0
  111. package/dist/src/v2/bounds/types.d.ts.map +1 -0
  112. package/dist/src/v2/bounds/types.js +124 -0
  113. package/dist/src/v2/bounds/types.js.map +1 -0
  114. package/dist/src/v2/capability-binding/binding.d.ts +67 -0
  115. package/dist/src/v2/capability-binding/binding.d.ts.map +1 -0
  116. package/dist/src/v2/capability-binding/binding.js +267 -0
  117. package/dist/src/v2/capability-binding/binding.js.map +1 -0
  118. package/dist/src/v2/capability-binding/digest.d.ts +33 -0
  119. package/dist/src/v2/capability-binding/digest.d.ts.map +1 -0
  120. package/dist/src/v2/capability-binding/digest.js +55 -0
  121. package/dist/src/v2/capability-binding/digest.js.map +1 -0
  122. package/dist/src/v2/capability-binding/identifier.d.ts +103 -0
  123. package/dist/src/v2/capability-binding/identifier.d.ts.map +1 -0
  124. package/dist/src/v2/capability-binding/identifier.js +281 -0
  125. package/dist/src/v2/capability-binding/identifier.js.map +1 -0
  126. package/dist/src/v2/capability-binding/index.d.ts +6 -0
  127. package/dist/src/v2/capability-binding/index.d.ts.map +1 -0
  128. package/dist/src/v2/capability-binding/index.js +13 -0
  129. package/dist/src/v2/capability-binding/index.js.map +1 -0
  130. package/dist/src/v2/capability-binding/pins.d.ts +30 -0
  131. package/dist/src/v2/capability-binding/pins.d.ts.map +1 -0
  132. package/dist/src/v2/capability-binding/pins.js +109 -0
  133. package/dist/src/v2/capability-binding/pins.js.map +1 -0
  134. package/dist/src/v2/capability-binding/types.d.ts +213 -0
  135. package/dist/src/v2/capability-binding/types.d.ts.map +1 -0
  136. package/dist/src/v2/capability-binding/types.js +150 -0
  137. package/dist/src/v2/capability-binding/types.js.map +1 -0
  138. package/dist/src/v2/chain-selection/index.d.ts +4 -0
  139. package/dist/src/v2/chain-selection/index.d.ts.map +1 -0
  140. package/dist/src/v2/chain-selection/index.js +11 -0
  141. package/dist/src/v2/chain-selection/index.js.map +1 -0
  142. package/dist/src/v2/chain-selection/select.d.ts +62 -0
  143. package/dist/src/v2/chain-selection/select.d.ts.map +1 -0
  144. package/dist/src/v2/chain-selection/select.js +390 -0
  145. package/dist/src/v2/chain-selection/select.js.map +1 -0
  146. package/dist/src/v2/chain-selection/types.d.ts +189 -0
  147. package/dist/src/v2/chain-selection/types.d.ts.map +1 -0
  148. package/dist/src/v2/chain-selection/types.js +81 -0
  149. package/dist/src/v2/chain-selection/types.js.map +1 -0
  150. package/dist/src/v2/lifecycle-state/index.d.ts +4 -0
  151. package/dist/src/v2/lifecycle-state/index.d.ts.map +1 -0
  152. package/dist/src/v2/lifecycle-state/index.js +10 -0
  153. package/dist/src/v2/lifecycle-state/index.js.map +1 -0
  154. package/dist/src/v2/lifecycle-state/map.d.ts +52 -0
  155. package/dist/src/v2/lifecycle-state/map.d.ts.map +1 -0
  156. package/dist/src/v2/lifecycle-state/map.js +122 -0
  157. package/dist/src/v2/lifecycle-state/map.js.map +1 -0
  158. package/dist/src/v2/lifecycle-state/state.d.ts +60 -0
  159. package/dist/src/v2/lifecycle-state/state.d.ts.map +1 -0
  160. package/dist/src/v2/lifecycle-state/state.js +157 -0
  161. package/dist/src/v2/lifecycle-state/state.js.map +1 -0
  162. package/dist/src/v2/lifecycle-state/types.d.ts +163 -0
  163. package/dist/src/v2/lifecycle-state/types.d.ts.map +1 -0
  164. package/dist/src/v2/lifecycle-state/types.js +121 -0
  165. package/dist/src/v2/lifecycle-state/types.js.map +1 -0
  166. package/dist/src/v2/receipt-core/composite.d.ts +69 -3
  167. package/dist/src/v2/receipt-core/composite.d.ts.map +1 -1
  168. package/dist/src/v2/receipt-core/composite.js +75 -9
  169. package/dist/src/v2/receipt-core/composite.js.map +1 -1
  170. package/dist/src/v2/receipt-core/predecessor.d.ts +95 -0
  171. package/dist/src/v2/receipt-core/predecessor.d.ts.map +1 -0
  172. package/dist/src/v2/receipt-core/predecessor.js +115 -0
  173. package/dist/src/v2/receipt-core/predecessor.js.map +1 -0
  174. package/dist/src/v2/status-coverage/decide.d.ts +52 -0
  175. package/dist/src/v2/status-coverage/decide.d.ts.map +1 -0
  176. package/dist/src/v2/status-coverage/decide.js +398 -0
  177. package/dist/src/v2/status-coverage/decide.js.map +1 -0
  178. package/dist/src/v2/status-coverage/index.d.ts +3 -0
  179. package/dist/src/v2/status-coverage/index.d.ts.map +1 -0
  180. package/dist/src/v2/status-coverage/index.js +10 -0
  181. package/dist/src/v2/status-coverage/index.js.map +1 -0
  182. package/dist/src/v2/status-coverage/types.d.ts +258 -0
  183. package/dist/src/v2/status-coverage/types.d.ts.map +1 -0
  184. package/dist/src/v2/status-coverage/types.js +127 -0
  185. package/dist/src/v2/status-coverage/types.js.map +1 -0
  186. package/dist/src/v2/suspension/evaluate.d.ts +88 -0
  187. package/dist/src/v2/suspension/evaluate.d.ts.map +1 -0
  188. package/dist/src/v2/suspension/evaluate.js +404 -0
  189. package/dist/src/v2/suspension/evaluate.js.map +1 -0
  190. package/dist/src/v2/suspension/index.d.ts +3 -0
  191. package/dist/src/v2/suspension/index.d.ts.map +1 -0
  192. package/dist/src/v2/suspension/index.js +10 -0
  193. package/dist/src/v2/suspension/index.js.map +1 -0
  194. package/dist/src/v2/suspension/types.d.ts +243 -0
  195. package/dist/src/v2/suspension/types.d.ts.map +1 -0
  196. package/dist/src/v2/suspension/types.js +135 -0
  197. package/dist/src/v2/suspension/types.js.map +1 -0
  198. package/package.json +10 -7
@@ -0,0 +1,406 @@
1
+ // Copyright (c) 2026 Tymofii Pidlisnyi
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ //
4
+ // PROPOSED, OPT-IN. Deciding whether an activation condition is established at an instant.
5
+ // See ./types.ts for the specification position and for the three parameters this module
6
+ // refuses to default.
7
+ import { parseRfc3339 } from '../../core/rfc3339.js';
8
+ import { verify as verifyEd25519 } from '../../crypto/keys.js';
9
+ import { mapAuthorityValidationToLifecycle } from '../lifecycle-state/map.js';
10
+ import { lifecycleState } from '../lifecycle-state/state.js';
11
+ import { activationAttestationSignatureInput } from './canonical.js';
12
+ import { ACTIVATION_ATTESTATION_TYPE, ACTIVATION_CONDITION_TYPE, ACTIVATION_GAPS_BY_REASON, ACTIVATION_INSTANT_BASES, ActivationError, } from './types.js';
13
+ /** How far through the checks a rejected attestation got. When no record was accepted, the
14
+ * reported code is the reason of the record that got FURTHEST, so the verdict names the
15
+ * closest thing to usable evidence that was presented. Ties break on `attestation_id`
16
+ * ascending, which makes the answer independent of presentation order. */
17
+ const REJECTION_RANK = Object.freeze({
18
+ ATTESTATION_RECORD_TYPE_NOT_ACCEPTED: 1,
19
+ ATTESTATION_SIGNATURE_UNVERIFIED: 2,
20
+ ATTESTATION_ATTESTOR_BINDING_MISMATCH: 3,
21
+ ATTESTATION_ATTESTOR_ROLE_UNKNOWN: 4,
22
+ ATTESTATION_ROLE_CLAIM_CONFLICT: 5,
23
+ ATTESTATION_ATTESTOR_ROLE_MISMATCH: 6,
24
+ ATTESTATION_CONDITION_MISMATCH: 7,
25
+ ATTESTATION_UNKNOWN_ASSERTION: 8,
26
+ ATTESTATION_INSTANT_MALFORMED: 9,
27
+ ATTESTATION_DOES_NOT_REACH_ACTION: 10,
28
+ // Verdict-level codes never rank: they are not rejections of a record.
29
+ ACTIVATION_ESTABLISHED: 0,
30
+ CONDITION_DATE_NOT_REACHED: 0,
31
+ CONDITION_ESTABLISHED_NOT_YET_OCCURRED: 0,
32
+ CONDITION_FIRST_OCCURRED_AFTER_ACTION: 0,
33
+ CONDITION_EVIDENCE_CONFLICT: 0,
34
+ ACTIVATION_THRESHOLD_NOT_MET: 0,
35
+ NO_ATTESTATION_PRESENTED: 0,
36
+ CONDITION_DELEGATION_MISMATCH: 0,
37
+ });
38
+ function assertInstant(value, label) {
39
+ const parsed = parseRfc3339(value);
40
+ if (!parsed.ok) {
41
+ throw new ActivationError('INSTANT_MALFORMED', `${label} is not an RFC 3339 instant with an offset (${parsed.reason})`);
42
+ }
43
+ return parsed.ms;
44
+ }
45
+ /** Shape rules, each with the reason it exists. A condition that breaks one is a programming
46
+ * error at the caller, not a verdict about evidence, so this throws.
47
+ *
48
+ * Exported so a caller can validate a condition it received before reaching a boundary. */
49
+ export function validateActivationCondition(condition) {
50
+ if (condition === null || typeof condition !== 'object') {
51
+ throw new ActivationError('CONDITION_MALFORMED', 'condition is not an object');
52
+ }
53
+ if (condition.record_type !== ACTIVATION_CONDITION_TYPE) {
54
+ throw new ActivationError('CONDITION_RECORD_TYPE_UNKNOWN', `condition record_type must be ${ACTIVATION_CONDITION_TYPE}`);
55
+ }
56
+ for (const field of ['condition_id', 'delegation_id']) {
57
+ if (typeof condition[field] !== 'string' || condition[field].length === 0) {
58
+ throw new ActivationError('CONDITION_MALFORMED', `condition ${field} must be a non-empty string`);
59
+ }
60
+ }
61
+ if (condition.condition_type === 'date') {
62
+ assertInstant(condition.activation_date, 'condition activation_date');
63
+ return condition;
64
+ }
65
+ if (condition.condition_type === 'recorded_event') {
66
+ for (const field of ['event_type', 'event_id']) {
67
+ if (typeof condition[field] !== 'string' || condition[field].length === 0) {
68
+ throw new ActivationError('CONDITION_MALFORMED', `condition ${field} must be a non-empty string`);
69
+ }
70
+ }
71
+ const roles = condition.required_attestor_roles;
72
+ if (!Array.isArray(roles) || roles.length === 0) {
73
+ // A condition naming no accepted source has not stated what it accepts. Accepting
74
+ // anything would make the role check decorative, and refusing everything would be a
75
+ // fail-closed ruling the text does not state. Refuse the CONDITION instead.
76
+ throw new ActivationError('CONDITION_ROLES_REQUIRED', 'required_attestor_roles must name at least one role');
77
+ }
78
+ for (const role of roles) {
79
+ if (typeof role !== 'string' || role.length === 0) {
80
+ throw new ActivationError('CONDITION_ROLES_REQUIRED', 'required_attestor_roles must contain only non-empty strings');
81
+ }
82
+ }
83
+ if (!Number.isInteger(condition.threshold) || condition.threshold < 1) {
84
+ throw new ActivationError('CONDITION_THRESHOLD_INVALID', 'threshold must be an integer of at least 1, and this module declares no default');
85
+ }
86
+ if (!ACTIVATION_INSTANT_BASES.includes(condition.instant_basis)) {
87
+ throw new ActivationError('CONDITION_INSTANT_BASIS_REQUIRED', `instant_basis must be one of ${ACTIVATION_INSTANT_BASES.join(', ')}, and this module declares no default`);
88
+ }
89
+ return condition;
90
+ }
91
+ throw new ActivationError('CONDITION_TYPE_UNKNOWN', 'condition_type must be date or recorded_event');
92
+ }
93
+ function classify(attestation, condition, actionMs, input) {
94
+ const usesOwnPreimage = input.attestationPreimage === undefined;
95
+ const accepted = input.acceptedAttestationRecordTypes;
96
+ // 1. Record type. A record whose type the model has not declared it accepts for this
97
+ // condition is not evidence, however well it verifies.
98
+ if (usesOwnPreimage) {
99
+ if (attestation.record_type !== ACTIVATION_ATTESTATION_TYPE) {
100
+ return { ok: false, reason: 'ATTESTATION_RECORD_TYPE_NOT_ACCEPTED' };
101
+ }
102
+ }
103
+ else if (!accepted.includes(attestation.record_type)) {
104
+ return { ok: false, reason: 'ATTESTATION_RECORD_TYPE_NOT_ACCEPTED' };
105
+ }
106
+ // 2. Signature, over the record's own bytes, under the key authorized at `attested_at`.
107
+ if (typeof attestation.attested_at !== 'string') {
108
+ return { ok: false, reason: 'ATTESTATION_INSTANT_MALFORMED' };
109
+ }
110
+ if (!parseRfc3339(attestation.attested_at).ok) {
111
+ return { ok: false, reason: 'ATTESTATION_INSTANT_MALFORMED' };
112
+ }
113
+ if (typeof attestation.verification_method !== 'string' ||
114
+ typeof attestation.signature !== 'string' ||
115
+ typeof attestation.attestor !== 'string') {
116
+ return { ok: false, reason: 'ATTESTATION_SIGNATURE_UNVERIFIED' };
117
+ }
118
+ const resolved = input.resolveVerificationKey(attestation.attestor, attestation.verification_method, attestation.attested_at);
119
+ // A resolver failure and a missing key are the same finding here: no accepted source
120
+ // produced a key, so the record is not usable evidence. The granular key-resolution
121
+ // outcomes belong to chain verification, which reports them on its own result.
122
+ if (typeof resolved !== 'string' || resolved.length === 0) {
123
+ return { ok: false, reason: 'ATTESTATION_SIGNATURE_UNVERIFIED' };
124
+ }
125
+ const preimage = usesOwnPreimage
126
+ ? activationAttestationSignatureInput(attestation)
127
+ : input.attestationPreimage(attestation);
128
+ let signatureOk = false;
129
+ try {
130
+ signatureOk = verifyEd25519(preimage, attestation.signature, resolved);
131
+ }
132
+ catch {
133
+ signatureOk = false;
134
+ }
135
+ if (!signatureOk)
136
+ return { ok: false, reason: 'ATTESTATION_SIGNATURE_UNVERIFIED' };
137
+ // 3. The verification method has to belong to the attestor the body names, or a valid
138
+ // signature says nothing about who attested.
139
+ if (!attestation.verification_method.startsWith(`${attestation.attestor}#`)) {
140
+ return { ok: false, reason: 'ATTESTATION_ATTESTOR_BINDING_MISMATCH' };
141
+ }
142
+ // 4. The attestor's own role claim, checked AGAINST the resolver. Never believed.
143
+ if (typeof attestation.attestor_role === 'string' && attestation.attestor_role.length > 0) {
144
+ const claimed = input.resolveAttestorRole(attestation.attestor, attestation.attestor_role, attestation.attested_at);
145
+ if (claimed === 'unknown')
146
+ return { ok: false, reason: 'ATTESTATION_ATTESTOR_ROLE_UNKNOWN' };
147
+ if (claimed !== 'holds')
148
+ return { ok: false, reason: 'ATTESTATION_ROLE_CLAIM_CONFLICT' };
149
+ }
150
+ // 5. Does the attestor hold a role the condition requires? A source the model does not
151
+ // accept for THIS condition is not evidence in either direction: it cannot establish the
152
+ // condition and it cannot establish that the condition was unmet.
153
+ let holdsRequired = false;
154
+ let anyUnknown = false;
155
+ for (const role of condition.required_attestor_roles) {
156
+ const standing = input.resolveAttestorRole(attestation.attestor, role, attestation.attested_at);
157
+ if (standing === 'holds') {
158
+ holdsRequired = true;
159
+ break;
160
+ }
161
+ if (standing === 'unknown')
162
+ anyUnknown = true;
163
+ }
164
+ if (!holdsRequired) {
165
+ return {
166
+ ok: false,
167
+ reason: anyUnknown
168
+ ? 'ATTESTATION_ATTESTOR_ROLE_UNKNOWN'
169
+ : 'ATTESTATION_ATTESTOR_ROLE_MISMATCH',
170
+ };
171
+ }
172
+ // 6. Condition binding.
173
+ if (attestation.condition_id !== condition.condition_id ||
174
+ attestation.event_type !== condition.event_type ||
175
+ attestation.event_id !== condition.event_id) {
176
+ return { ok: false, reason: 'ATTESTATION_CONDITION_MISMATCH' };
177
+ }
178
+ // 7. What it establishes, measured on the instant the CONDITION declares governs.
179
+ if (attestation.assertion === 'condition_occurred') {
180
+ const raw = condition.instant_basis === 'attestation_written'
181
+ ? attestation.attested_at
182
+ : attestation.occurred_at;
183
+ if (typeof raw !== 'string')
184
+ return { ok: false, reason: 'ATTESTATION_UNKNOWN_ASSERTION' };
185
+ const parsed = parseRfc3339(raw);
186
+ if (!parsed.ok)
187
+ return { ok: false, reason: 'ATTESTATION_INSTANT_MALFORMED' };
188
+ return {
189
+ ok: true,
190
+ finding: parsed.ms <= actionMs ? 'occurred_by_action' : 'occurred_after_action',
191
+ };
192
+ }
193
+ if (attestation.assertion === 'condition_not_occurred_through') {
194
+ const raw = attestation.not_occurred_through;
195
+ if (typeof raw !== 'string')
196
+ return { ok: false, reason: 'ATTESTATION_UNKNOWN_ASSERTION' };
197
+ const parsed = parseRfc3339(raw);
198
+ if (!parsed.ok)
199
+ return { ok: false, reason: 'ATTESTATION_INSTANT_MALFORMED' };
200
+ // A negative that stops short of the action instant says nothing about the interval
201
+ // between where it stops and the action. That is the coverage limb, not a source problem.
202
+ if (parsed.ms < actionMs)
203
+ return { ok: false, reason: 'ATTESTATION_DOES_NOT_REACH_ACTION' };
204
+ return { ok: true, finding: 'not_occurred_through_action' };
205
+ }
206
+ return { ok: false, reason: 'ATTESTATION_UNKNOWN_ASSERTION' };
207
+ }
208
+ function notEstablishedFor(code) {
209
+ return lifecycleState({
210
+ verdict: 'not_established',
211
+ reason_code: code,
212
+ missing: ACTIVATION_GAPS_BY_REASON[code] ?? ['source'],
213
+ });
214
+ }
215
+ /**
216
+ * Decide whether an activation condition is established for one action at one instant.
217
+ *
218
+ * Three verdicts are reachable and `invalid` is not one of them:
219
+ *
220
+ * | situation | verdict |
221
+ * |--------------------------------------------------------------|---------------------|
222
+ * | condition established at or before the action instant | `valid` |
223
+ * | established as not met at that instant, or first met after it | `not_yet_effective` |
224
+ * | the verifier cannot tell | `not_established` |
225
+ *
226
+ * NOT ESTABLISHED IS NOT THE NEGATION OF THE CLAIM. It says the verifier could not reach a
227
+ * conclusion and names which establishment limb was missing. `not_yet_effective` says the
228
+ * verifier DID reach a conclusion and it was negative; its remedy is to wait, where
229
+ * `not_established`'s remedy is a better source. Collapsing the two throws away a decidable
230
+ * answer the verifier already had.
231
+ *
232
+ * NO RETROACTIVE ACTIVATION, KEYED ON THE CONDITION'S OWN INSTANT. A record putting the
233
+ * condition's first occurrence after the action instant leaves that action
234
+ * `not_yet_effective`, and the SAME record establishes the condition for any later action.
235
+ * What the rule keys on is the condition's instant, not the instant someone wrote the record:
236
+ * learning on Thursday that a condition was met on Monday is the normal case for any model
237
+ * built around an after-the-fact determination, and under
238
+ * `instant_basis: 'condition_occurrence'` such a record establishes the condition. A model
239
+ * that reads it the other way says so with `instant_basis: 'attestation_written'`.
240
+ *
241
+ * ORDER OF RESOLUTION, and why contradiction sits above acceptance:
242
+ *
243
+ * 1. two accepted records that disagree `not_established`, `CONDITION_EVIDENCE_CONFLICT`
244
+ * 2. `threshold` records say occurred by it `valid`
245
+ * 3. `threshold` records say not occurred `not_yet_effective`
246
+ * 4. `threshold` records say occurred after `not_yet_effective`
247
+ * 5. some accepted, fewer than `threshold` `not_established`, `ACTIVATION_THRESHOLD_NOT_MET`
248
+ * 6. none accepted `not_established`, furthest rejection reason
249
+ *
250
+ * Contradiction is evaluated on PRESENCE, not on counts. Two acceptable records that disagree
251
+ * leave the verifier unable to tell which holds, and neither is discarded in favour of the
252
+ * other: preferring the later record, or the negative one, or a majority, would each be a
253
+ * precedence rule the concept text does not state.
254
+ *
255
+ * This function reads no clock and makes no network call. `actionInstant` is a parameter.
256
+ *
257
+ * Proposed. Concept source: aeoess/agent-authority-lifecycle, invariant candidates CAND-04
258
+ * and CAND-13 (activation half) and BROAD-L7. Not required by draft-pidlisnyi-aps-03.
259
+ */
260
+ export function verifyActivation(input) {
261
+ if (input === null || typeof input !== 'object') {
262
+ throw new ActivationError('INPUT_MALFORMED', 'input is not an object');
263
+ }
264
+ if (typeof input.resolveAttestorRole !== 'function') {
265
+ throw new ActivationError('ROLE_RESOLVER_REQUIRED', 'resolveAttestorRole is required: role standing is resolved outside the record, always');
266
+ }
267
+ if (typeof input.resolveVerificationKey !== 'function') {
268
+ throw new ActivationError('KEY_RESOLVER_REQUIRED', 'resolveVerificationKey is required');
269
+ }
270
+ if (input.attestationPreimage !== undefined) {
271
+ const accepted = input.acceptedAttestationRecordTypes;
272
+ if (!Array.isArray(accepted) || accepted.length === 0) {
273
+ throw new ActivationError('ACCEPTED_RECORD_TYPES_REQUIRED', 'acceptedAttestationRecordTypes must name at least one type when attestationPreimage is supplied');
274
+ }
275
+ }
276
+ if (typeof input.delegationId !== 'string' || input.delegationId.length === 0) {
277
+ throw new ActivationError('DELEGATION_ID_REQUIRED', 'delegationId must be a non-empty string');
278
+ }
279
+ const condition = validateActivationCondition(input.condition);
280
+ const actionMs = assertInstant(input.actionInstant, 'actionInstant');
281
+ const presented = input.attestations ?? [];
282
+ if (condition.delegation_id !== input.delegationId) {
283
+ return Object.freeze({
284
+ state: notEstablishedFor('CONDITION_DELEGATION_MISMATCH'),
285
+ condition_id: condition.condition_id,
286
+ condition_type: condition.condition_type,
287
+ findings: Object.freeze([]),
288
+ rejections: Object.freeze([]),
289
+ });
290
+ }
291
+ // A date condition needs no evidence at all. The verifier reads the date off the condition
292
+ // and compares it with the action instant, so an unreached date is a KNOWN negative and
293
+ // never an unknown one. Presented attestations are not consulted.
294
+ if (condition.condition_type === 'date') {
295
+ const reached = assertInstant(condition.activation_date, 'condition activation_date') <= actionMs;
296
+ return Object.freeze({
297
+ state: reached
298
+ ? lifecycleState({ verdict: 'valid', reason_code: 'ACTIVATION_ESTABLISHED' })
299
+ : lifecycleState({
300
+ verdict: 'not_yet_effective',
301
+ reason_code: 'CONDITION_DATE_NOT_REACHED',
302
+ }),
303
+ condition_id: condition.condition_id,
304
+ condition_type: condition.condition_type,
305
+ findings: Object.freeze([]),
306
+ rejections: Object.freeze([]),
307
+ });
308
+ }
309
+ const findings = [];
310
+ const rejections = [];
311
+ const counts = {
312
+ occurred_by_action: 0,
313
+ occurred_after_action: 0,
314
+ not_occurred_through_action: 0,
315
+ };
316
+ for (const attestation of presented) {
317
+ if (attestation === null || typeof attestation !== 'object') {
318
+ throw new ActivationError('ATTESTATION_MALFORMED', 'an attestation is not an object');
319
+ }
320
+ const id = typeof attestation.attestation_id === 'string' ? attestation.attestation_id : '';
321
+ const attestor = typeof attestation.attestor === 'string' ? attestation.attestor : '';
322
+ const outcome = classify(attestation, condition, actionMs, input);
323
+ if (outcome.ok) {
324
+ counts[outcome.finding] += 1;
325
+ findings.push(Object.freeze({ attestation_id: id, attestor, finding: outcome.finding }));
326
+ }
327
+ else {
328
+ rejections.push(Object.freeze({ attestation_id: id, attestor, reason_code: outcome.reason }));
329
+ }
330
+ }
331
+ const frozen = {
332
+ condition_id: condition.condition_id,
333
+ condition_type: condition.condition_type,
334
+ findings: Object.freeze([...findings]),
335
+ rejections: Object.freeze([...rejections]),
336
+ };
337
+ if (counts.occurred_by_action > 0 && counts.not_occurred_through_action > 0) {
338
+ return Object.freeze({ ...frozen, state: notEstablishedFor('CONDITION_EVIDENCE_CONFLICT') });
339
+ }
340
+ if (counts.occurred_by_action >= condition.threshold) {
341
+ return Object.freeze({
342
+ ...frozen,
343
+ state: lifecycleState({ verdict: 'valid', reason_code: 'ACTIVATION_ESTABLISHED' }),
344
+ });
345
+ }
346
+ if (counts.not_occurred_through_action >= condition.threshold) {
347
+ return Object.freeze({
348
+ ...frozen,
349
+ state: lifecycleState({
350
+ verdict: 'not_yet_effective',
351
+ reason_code: 'CONDITION_ESTABLISHED_NOT_YET_OCCURRED',
352
+ }),
353
+ });
354
+ }
355
+ if (counts.occurred_after_action >= condition.threshold) {
356
+ return Object.freeze({
357
+ ...frozen,
358
+ state: lifecycleState({
359
+ verdict: 'not_yet_effective',
360
+ reason_code: 'CONDITION_FIRST_OCCURRED_AFTER_ACTION',
361
+ }),
362
+ });
363
+ }
364
+ if (findings.length > 0) {
365
+ return Object.freeze({ ...frozen, state: notEstablishedFor('ACTIVATION_THRESHOLD_NOT_MET') });
366
+ }
367
+ if (rejections.length === 0) {
368
+ return Object.freeze({ ...frozen, state: notEstablishedFor('NO_ATTESTATION_PRESENTED') });
369
+ }
370
+ const furthest = [...rejections].sort((a, b) => {
371
+ const rank = REJECTION_RANK[b.reason_code] - REJECTION_RANK[a.reason_code];
372
+ return rank !== 0 ? rank : a.attestation_id.localeCompare(b.attestation_id);
373
+ })[0];
374
+ return Object.freeze({ ...frozen, state: notEstablishedFor(furthest.reason_code) });
375
+ }
376
+ /**
377
+ * Report an activation result ALONGSIDE a chain result, never merged into it.
378
+ *
379
+ * Two stages, in order, and the order is the point:
380
+ *
381
+ * 1. Chain verification decides whether the grant is valid at the action instant. Its
382
+ * four-value result is returned untouched in `chain`.
383
+ * 2. Activation is asked ONLY when the chain is valid. A grant that does not verify is not a
384
+ * grant that is waiting on a condition, and reporting `not_yet_effective` for a revoked
385
+ * or unparented grant would say the remedy is to wait when it is not.
386
+ *
387
+ * This is also where CAND-13's activation half lands. A pre-committed replacement grant is an
388
+ * ordinary grant with an ordinary condition, so it needs no separate machinery here, and the
389
+ * ordering is what keeps L1 intact: if the pre-committing instrument is revoked, the
390
+ * replacement's chain is invalid and no activation evidence can make it exercisable. Nothing
391
+ * in this module can turn an invalid chain into a `valid` lifecycle verdict.
392
+ *
393
+ * `activation` may be `null`, which is how a caller says no activation module ran. The
394
+ * composite then carries only the chain's own reading.
395
+ *
396
+ * Proposed. Concept source: aeoess/agent-authority-lifecycle, invariant L1 and invariant
397
+ * candidates CAND-04 and CAND-13.
398
+ */
399
+ export function composeActivation(chain, activation, options = {}) {
400
+ const mapped = mapAuthorityValidationToLifecycle(chain, options.mapping ?? {});
401
+ if (chain.state !== 'valid' || activation === null) {
402
+ return Object.freeze({ chain, lifecycle: mapped });
403
+ }
404
+ return Object.freeze({ chain, lifecycle: activation.state });
405
+ }
406
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../../src/v2/activation/verify.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,sCAAsC;AACtC,EAAE;AACF,2FAA2F;AAC3F,yFAAyF;AACzF,sBAAsB;AAEtB,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAM9D,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAK5D,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,eAAe,GAUhB,MAAM,YAAY,CAAA;AAEnB;;;2EAG2E;AAC3E,MAAM,cAAc,GAAmD,MAAM,CAAC,MAAM,CAAC;IACnF,oCAAoC,EAAE,CAAC;IACvC,gCAAgC,EAAE,CAAC;IACnC,qCAAqC,EAAE,CAAC;IACxC,iCAAiC,EAAE,CAAC;IACpC,+BAA+B,EAAE,CAAC;IAClC,kCAAkC,EAA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BAAiB,CAC/B,KAAgC,EAChC,UAAmC,EACnC,OAAO,GAAiC,EAAE;IAE1C,MAAM,MAAM,GAAG,iCAAiC,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;IAC9E,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAA;AAC9D,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { AuthorityRevocationBodyV1, AuthorityRevocationV1 } from './types.js';
2
+ /** Domain tags for the three preimages this record uses. Each is a distinct APS tag
3
+ * followed by one zero byte, the same discipline AuthorityDelegationV1 and
4
+ * PrincipalBindingRevocationV1 follow, so bytes minted for one construction can never
5
+ * be read as bytes minted for another. */
6
+ export declare const AUTHORITY_REVOCATION_ID_DOMAIN = "APS-AUTHORITY-REVOCATION-ID-V1\0";
7
+ export declare const AUTHORITY_REVOCATION_SIGNATURE_DOMAIN = "APS-AUTHORITY-REVOCATION-SIGNATURE-V1\0";
8
+ export declare const AUTHORITY_REVOCATION_CASCADE_TRANSACTION_DOMAIN = "APS-AUTHORITY-REVOCATION-CASCADE-TRANSACTION-ID-V1\0";
9
+ /** The origin content a cascade transaction identity is derived from: the revocation body
10
+ * with `cascade_transaction_id` absent, alongside `revocation_id` and `signature`.
11
+ *
12
+ * Section 3.5.1 says a cascade carries a transaction identity shared by every record it
13
+ * produces, and says nothing about how it is constructed. A content-bound derivation is
14
+ * chosen over a random value so that issuance stays byte-deterministic for fixed inputs
15
+ * and so a verifier can recompute the field instead of accepting whatever the issuer
16
+ * wrote there. Independent cascades do not collide because the origin's 16-byte `nonce`
17
+ * is inside this preimage. */
18
+ export type AuthorityRevocationCascadeOriginV1 = Omit<AuthorityRevocationBodyV1, 'cascade_transaction_id'>;
19
+ /** Exact RFC 8785 input used to derive cascade_transaction_id. */
20
+ export declare function authorityRevocationCascadeTransactionInput(origin: AuthorityRevocationCascadeOriginV1): string;
21
+ export declare function computeAuthorityRevocationCascadeTransactionId(origin: AuthorityRevocationCascadeOriginV1): string;
22
+ /** Write-boundary twin of computeAuthorityRevocationCascadeTransactionId(). */
23
+ export declare function computeAuthorityRevocationCascadeTransactionIdForWrite(origin: AuthorityRevocationCascadeOriginV1): string;
24
+ /** Exact RFC 8785 input used to derive revocation_id. */
25
+ export declare function authorityRevocationIdInput(body: AuthorityRevocationBodyV1): string;
26
+ export declare function computeAuthorityRevocationId(body: AuthorityRevocationBodyV1): string;
27
+ /** Write-boundary twin of computeAuthorityRevocationId().
28
+ *
29
+ * Emits the same bytes as computeAuthorityRevocationId() for every value it accepts; it
30
+ * only refuses an integer-valued number outside the interoperable IEEE 754 range rather
31
+ * than serializing it. Use when ISSUING. verify.ts keeps calling the unrestricted form,
32
+ * so a record minted before this rule still re-derives its identifier. */
33
+ export declare function computeAuthorityRevocationIdForWrite(body: AuthorityRevocationBodyV1): string;
34
+ /** Exact Ed25519 input: the signature domain tag plus JCS of the record with `signature`
35
+ * absent. `revocation_id` IS inside this preimage, so the identifier is signed rather
36
+ * than being an unauthenticated label beside the signature. */
37
+ export declare function authorityRevocationSignatureInput(revocation: Omit<AuthorityRevocationV1, 'signature'>): string;
38
+ export declare function signAuthorityRevocation(revocation: Omit<AuthorityRevocationV1, 'signature'>, privateKey: string): string;
39
+ export declare function verifyAuthorityRevocationSignature(revocation: AuthorityRevocationV1, publicKey: string): boolean;
40
+ /** The body a revocation_id is computed over: the record with `revocation_id` and
41
+ * `signature` removed. */
42
+ export declare function authorityRevocationBody(revocation: AuthorityRevocationV1): AuthorityRevocationBodyV1;
43
+ /** The cascade origin a cascade_transaction_id is computed over: the body with
44
+ * `cascade_transaction_id` removed. */
45
+ export declare function authorityRevocationCascadeOrigin(body: AuthorityRevocationBodyV1): AuthorityRevocationCascadeOriginV1;
46
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../../../src/v2/authority-revocation/canonical.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElF;;;2CAG2C;AAC3C,eAAO,MAAM,8BAA8B,qCAAqC,CAAA;AAChF,eAAO,MAAM,qCAAqC,4CAA4C,CAAA;AAC9F,eAAO,MAAM,+CAA+C,yDACJ,CAAA;AAMxD;;;;;;;;+BAQ+B;AAC/B,MAAM,MAAM,kCAAkC,GAAG,IAAI,CACnD,yBAAyB,EACzB,wBAAwB,CACzB,CAAA;AAED,kEAAkE;AAClE,wBAAgB,0CAA0C,CACxD,MAAM,EAAE,kCAAkC,GACzC,MAAM,CAER;AAED,wBAAgB,8CAA8C,CAC5D,MAAM,EAAE,kCAAkC,GACzC,MAAM,CAER;AAED,+EAA+E;AAC/E,wBAAgB,sDAAsD,CACpE,MAAM,EAAE,kCAAkC,GACzC,MAAM,CAIR;AAED,yDAAyD;AACzD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAElF;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAEpF;AAED;;;;;2EAK2E;AAC3E,wBAAgB,oCAAoC,CAAC,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAE5F;AAED;;gEAEgE;AAChE,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,GACnD,MAAM,CAER;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,EACpD,UAAU,EAAE,MAAM,GACjB,MAAM,CAKR;AAED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,qBAAqB,EACjC,SAAS,EAAE,MAAM,GAChB,OAAO,CAGT;AAED;2BAC2B;AAC3B,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,qBAAqB,GAChC,yBAAyB,CAG3B;AAED;wCACwC;AACxC,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,yBAAyB,GAC9B,kCAAkC,CAGpC"}
@@ -0,0 +1,68 @@
1
+ // Copyright (c) 2026 Tymofii Pidlisnyi
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { createHash } from 'node:crypto';
4
+ import { canonicalizeJCS, canonicalizeJCSForWrite } from '../../core/canonical-jcs.js';
5
+ import { sign, verify } from '../../crypto/keys.js';
6
+ /** Domain tags for the three preimages this record uses. Each is a distinct APS tag
7
+ * followed by one zero byte, the same discipline AuthorityDelegationV1 and
8
+ * PrincipalBindingRevocationV1 follow, so bytes minted for one construction can never
9
+ * be read as bytes minted for another. */
10
+ export const AUTHORITY_REVOCATION_ID_DOMAIN = 'APS-AUTHORITY-REVOCATION-ID-V1\0';
11
+ export const AUTHORITY_REVOCATION_SIGNATURE_DOMAIN = 'APS-AUTHORITY-REVOCATION-SIGNATURE-V1\0';
12
+ export const AUTHORITY_REVOCATION_CASCADE_TRANSACTION_DOMAIN = 'APS-AUTHORITY-REVOCATION-CASCADE-TRANSACTION-ID-V1\0';
13
+ function sha256Hex(value) {
14
+ return createHash('sha256').update(value, 'utf8').digest('hex');
15
+ }
16
+ /** Exact RFC 8785 input used to derive cascade_transaction_id. */
17
+ export function authorityRevocationCascadeTransactionInput(origin) {
18
+ return AUTHORITY_REVOCATION_CASCADE_TRANSACTION_DOMAIN + canonicalizeJCS(origin);
19
+ }
20
+ export function computeAuthorityRevocationCascadeTransactionId(origin) {
21
+ return `sha256:${sha256Hex(authorityRevocationCascadeTransactionInput(origin))}`;
22
+ }
23
+ /** Write-boundary twin of computeAuthorityRevocationCascadeTransactionId(). */
24
+ export function computeAuthorityRevocationCascadeTransactionIdForWrite(origin) {
25
+ return `sha256:${sha256Hex(AUTHORITY_REVOCATION_CASCADE_TRANSACTION_DOMAIN + canonicalizeJCSForWrite(origin))}`;
26
+ }
27
+ /** Exact RFC 8785 input used to derive revocation_id. */
28
+ export function authorityRevocationIdInput(body) {
29
+ return AUTHORITY_REVOCATION_ID_DOMAIN + canonicalizeJCS(body);
30
+ }
31
+ export function computeAuthorityRevocationId(body) {
32
+ return `sha256:${sha256Hex(authorityRevocationIdInput(body))}`;
33
+ }
34
+ /** Write-boundary twin of computeAuthorityRevocationId().
35
+ *
36
+ * Emits the same bytes as computeAuthorityRevocationId() for every value it accepts; it
37
+ * only refuses an integer-valued number outside the interoperable IEEE 754 range rather
38
+ * than serializing it. Use when ISSUING. verify.ts keeps calling the unrestricted form,
39
+ * so a record minted before this rule still re-derives its identifier. */
40
+ export function computeAuthorityRevocationIdForWrite(body) {
41
+ return `sha256:${sha256Hex(AUTHORITY_REVOCATION_ID_DOMAIN + canonicalizeJCSForWrite(body))}`;
42
+ }
43
+ /** Exact Ed25519 input: the signature domain tag plus JCS of the record with `signature`
44
+ * absent. `revocation_id` IS inside this preimage, so the identifier is signed rather
45
+ * than being an unauthenticated label beside the signature. */
46
+ export function authorityRevocationSignatureInput(revocation) {
47
+ return AUTHORITY_REVOCATION_SIGNATURE_DOMAIN + canonicalizeJCS(revocation);
48
+ }
49
+ export function signAuthorityRevocation(revocation, privateKey) {
50
+ return sign(AUTHORITY_REVOCATION_SIGNATURE_DOMAIN + canonicalizeJCSForWrite(revocation), privateKey);
51
+ }
52
+ export function verifyAuthorityRevocationSignature(revocation, publicKey) {
53
+ const { signature, ...unsigned } = revocation;
54
+ return verify(authorityRevocationSignatureInput(unsigned), signature, publicKey);
55
+ }
56
+ /** The body a revocation_id is computed over: the record with `revocation_id` and
57
+ * `signature` removed. */
58
+ export function authorityRevocationBody(revocation) {
59
+ const { revocation_id: _revocationId, signature: _signature, ...body } = revocation;
60
+ return body;
61
+ }
62
+ /** The cascade origin a cascade_transaction_id is computed over: the body with
63
+ * `cascade_transaction_id` removed. */
64
+ export function authorityRevocationCascadeOrigin(body) {
65
+ const { cascade_transaction_id: _cascadeTransactionId, ...origin } = body;
66
+ return origin;
67
+ }
68
+ //# sourceMappingURL=canonical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.js","sourceRoot":"","sources":["../../../../src/v2/authority-revocation/canonical.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAGnD;;;2CAG2C;AAC3C,MAAM,CAAC,MAAM,8BAA8B,GAAG,kCAAkC,CAAA;AAChF,MAAM,CAAC,MAAM,qCAAqC,GAAG,yCAAyC,CAAA;AAC9F,MAAM,CAAC,MAAM,+CAA+C,GAC1D,sDAAsD,CAAA;AAExD,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACjE,CAAC;AAgBD,kEAAkE;AAClE,MAAM,UAAU,0CAA0C,CACxD,MAA0C;IAE1C,OAAO,+CAA+C,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;AAClF,CAAC;AAED,MAAM,UAAU,8CAA8C,CAC5D,MAA0C;IAE1C,OAAO,UAAU,SAAS,CAAC,0CAA0C,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;AAClF,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,sDAAsD,CACpE,MAA0C;IAE1C,OAAO,UAAU,SAAS,CACxB,+CAA+C,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAClF,EAAE,CAAA;AACL,CAAC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,CAAA;IACzE,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './types.js';
2
+ export * from './schema.js';
3
+ export * from './canonical.js';
4
+ export * from './issue.js';
5
+ export * from './verify.js';
6
+ export * from './store.js';
7
+ export * from './record.js';
8
+ export * from './resolver.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/authority-revocation/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,11 @@
1
+ // Copyright (c) 2026 Tymofii Pidlisnyi
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export * from './types.js';
4
+ export * from './schema.js';
5
+ export * from './canonical.js';
6
+ export * from './issue.js';
7
+ export * from './verify.js';
8
+ export * from './store.js';
9
+ export * from './record.js';
10
+ export * from './resolver.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/v2/authority-revocation/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,sCAAsC;AAEtC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,54 @@
1
+ import type { AuthorityDelegationV1 } from '../authority-delegation/types.js';
2
+ import type { AuthorityRevocationV1 } from './types.js';
3
+ /** Everything issuance takes besides the target delegation and the signing key. */
4
+ export interface AuthorityRevocationIssueInput {
5
+ /** Canonical UTC-millisecond revocation time, supplied by the caller.
6
+ *
7
+ * Issuance never reads a clock. The value lands in the record's signed `revoked_at`,
8
+ * so the same inputs produce the same bytes on every run, which is what makes the
9
+ * identifier and the signature reproducible in a test and in a conformance vector.
10
+ * Named `now` to match SubAuthorityIssueOptions. */
11
+ now: string;
12
+ /** The revoking authority. Checked against the target delegation's `issuer`. */
13
+ revoker: string;
14
+ /** Which key signs. A non-empty string; no local shape rule relates it to `revoker`.
15
+ * Whether it belongs to the issuer is decided only by key resolution against
16
+ * `target.issuer` at `revoked_at`, which verifyAuthorityRevocation() performs. */
17
+ verification_method: string;
18
+ /** Machine-readable reason. A non-empty string; the draft fixes no grammar. */
19
+ reason_code: string;
20
+ /** OPTIONAL. Omitted from the record entirely when not supplied; never written as null. */
21
+ detail?: string;
22
+ nonce: string;
23
+ }
24
+ /**
25
+ * Mint a draft-03 section 3.5.1 direct revocation for one AuthorityDelegationV1.
26
+ *
27
+ * Section 3.5 line 634 states the only authorization rule this function applies: "Any
28
+ * delegation MAY be revoked by its issuer." The exact comparison is
29
+ * `input.revoker === delegation.issuer`, where `delegation` is the target record passed
30
+ * in by the caller and `issuer` is its own member. The record being minted is never
31
+ * consulted for its own authorization: a field a would-be revoker writes inside its own
32
+ * record cannot make that revoker the issuer of somebody else's delegation.
33
+ *
34
+ * The target's `delegation_id` is recomputed from its body before that comparison. A
35
+ * `delegation_id` sits outside the delegation's own identifier preimage, so a record
36
+ * whose claimed identifier does not match its body has an unauthenticated `issuer` too,
37
+ * and refusing there is what keeps the revoker check meaningful.
38
+ *
39
+ * What this function does NOT establish: that the holder of `privateKey` is in fact
40
+ * `input.revoker`, or that `input.verification_method` is one of that party's keys. An
41
+ * identifier-to-key binding is a resolver's answer, not a local one, and no string shape
42
+ * imposed on `verification_method` here could stand in for it. verifyAuthorityRevocation()
43
+ * makes that check, resolving the method under the TARGET delegation's `issuer` at
44
+ * `revoked_at`. Issuance can only refuse to mint a record that is already unverifiable; it
45
+ * cannot promise the record will verify.
46
+ *
47
+ * Nothing about a cascade over descendants is emitted here. This function produces one
48
+ * record about one delegation. Enforcement against descendants comes from chain
49
+ * verification, which rejects any chain containing a revoked ancestor.
50
+ *
51
+ * Throws on refusal; each message names its code in parentheses.
52
+ */
53
+ export declare function issueAuthorityRevocation(delegation: AuthorityDelegationV1, input: AuthorityRevocationIssueInput, privateKey: string): AuthorityRevocationV1;
54
+ //# sourceMappingURL=issue.d.ts.map