@agenticprimitives/agent-resolution 0.0.0-alpha.1

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 (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +319 -0
  3. package/dist/admission.d.ts +14 -0
  4. package/dist/admission.d.ts.map +1 -0
  5. package/dist/admission.js +137 -0
  6. package/dist/admission.js.map +1 -0
  7. package/dist/authority-ref.d.ts +38 -0
  8. package/dist/authority-ref.d.ts.map +1 -0
  9. package/dist/authority-ref.js +69 -0
  10. package/dist/authority-ref.js.map +1 -0
  11. package/dist/canonicalization.d.ts +16 -0
  12. package/dist/canonicalization.d.ts.map +1 -0
  13. package/dist/canonicalization.js +39 -0
  14. package/dist/canonicalization.js.map +1 -0
  15. package/dist/codec.d.ts +15 -0
  16. package/dist/codec.d.ts.map +1 -0
  17. package/dist/codec.js +34 -0
  18. package/dist/codec.js.map +1 -0
  19. package/dist/compose.d.ts +79 -0
  20. package/dist/compose.d.ts.map +1 -0
  21. package/dist/compose.js +235 -0
  22. package/dist/compose.js.map +1 -0
  23. package/dist/endpoint-control.d.ts +87 -0
  24. package/dist/endpoint-control.d.ts.map +1 -0
  25. package/dist/endpoint-control.js +174 -0
  26. package/dist/endpoint-control.js.map +1 -0
  27. package/dist/errors.d.ts +33 -0
  28. package/dist/errors.d.ts.map +1 -0
  29. package/dist/errors.js +71 -0
  30. package/dist/errors.js.map +1 -0
  31. package/dist/freshness.d.ts +43 -0
  32. package/dist/freshness.d.ts.map +1 -0
  33. package/dist/freshness.js +100 -0
  34. package/dist/freshness.js.map +1 -0
  35. package/dist/grant-index.d.ts +21 -0
  36. package/dist/grant-index.d.ts.map +1 -0
  37. package/dist/grant-index.js +0 -0
  38. package/dist/grant-index.js.map +1 -0
  39. package/dist/grants.d.ts +100 -0
  40. package/dist/grants.d.ts.map +1 -0
  41. package/dist/grants.js +99 -0
  42. package/dist/grants.js.map +1 -0
  43. package/dist/index.d.ts +44 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +63 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/invitation.d.ts +43 -0
  48. package/dist/invitation.d.ts.map +1 -0
  49. package/dist/invitation.js +76 -0
  50. package/dist/invitation.js.map +1 -0
  51. package/dist/peer-attestation.d.ts +61 -0
  52. package/dist/peer-attestation.d.ts.map +1 -0
  53. package/dist/peer-attestation.js +128 -0
  54. package/dist/peer-attestation.js.map +1 -0
  55. package/dist/peer-gate.d.ts +73 -0
  56. package/dist/peer-gate.d.ts.map +1 -0
  57. package/dist/peer-gate.js +108 -0
  58. package/dist/peer-gate.js.map +1 -0
  59. package/dist/policy.d.ts +53 -0
  60. package/dist/policy.d.ts.map +1 -0
  61. package/dist/policy.js +73 -0
  62. package/dist/policy.js.map +1 -0
  63. package/dist/ports.d.ts +59 -0
  64. package/dist/ports.d.ts.map +1 -0
  65. package/dist/ports.js +10 -0
  66. package/dist/ports.js.map +1 -0
  67. package/dist/projection.d.ts +74 -0
  68. package/dist/projection.d.ts.map +1 -0
  69. package/dist/projection.js +134 -0
  70. package/dist/projection.js.map +1 -0
  71. package/dist/proof.d.ts +76 -0
  72. package/dist/proof.d.ts.map +1 -0
  73. package/dist/proof.js +207 -0
  74. package/dist/proof.js.map +1 -0
  75. package/dist/publication.d.ts +123 -0
  76. package/dist/publication.d.ts.map +1 -0
  77. package/dist/publication.js +32 -0
  78. package/dist/publication.js.map +1 -0
  79. package/dist/records.d.ts +168 -0
  80. package/dist/records.d.ts.map +1 -0
  81. package/dist/records.js +83 -0
  82. package/dist/records.js.map +1 -0
  83. package/dist/references.d.ts +61 -0
  84. package/dist/references.d.ts.map +1 -0
  85. package/dist/references.js +7 -0
  86. package/dist/references.js.map +1 -0
  87. package/dist/results.d.ts +89 -0
  88. package/dist/results.d.ts.map +1 -0
  89. package/dist/results.js +37 -0
  90. package/dist/results.js.map +1 -0
  91. package/package.json +57 -0
  92. package/spec.md +78 -0
@@ -0,0 +1,174 @@
1
+ // Endpoint-control verification (spec 338 §3; closes AR-L4).
2
+ //
3
+ // THE GAP THIS CLOSES: `verifyPublication` previously checked only that an endpoint-control proof was
4
+ // PRESENT and UNEXPIRED. "A proof was recorded" is not "the publisher controls this URI" — it is the
5
+ // claim≠control hole recorded in dntls-comparison.md §0.3 item 3.
6
+ //
7
+ // HONEST SCOPE — read before trusting an assurance level:
8
+ // Only `signed-challenge` is verified CRYPTOGRAPHICALLY here. It is a signature by the agent over a
9
+ // canonical body binding {uri, agentId, surfaceId, challenge, issuedAt}, so this package can check
10
+ // it with no I/O — the same shape as every other proof in the substrate.
11
+ //
12
+ // `http-challenge`, `dns`, `verifiable-presentation` and `transport-handshake` are inherently
13
+ // OBSERVATIONS: someone had to reach the network at a point in time. A pure Ring-0 leaf cannot
14
+ // re-perform them. For those, this package verifies that the recorded observation is well-formed,
15
+ // BOUND to the right uri/agent/surface, and FRESH — and reports assurance `observed`, never
16
+ // `cryptographic`. Do not read `observed` as "we re-checked it": it means "a party we trust to
17
+ // observe said so, recently, about the right thing."
18
+ //
19
+ // A caller that requires cryptographic control MUST check the returned `assurance`, not just `ok`.
20
+ import { canonicalizeJson } from '@agenticprimitives/types';
21
+ import { digestOf, signingDigest } from './canonicalization.js';
22
+ import { failure } from './errors.js';
23
+ const DEFAULT_MAX_OBSERVATION_AGE_MS = 24 * 60 * 60 * 1000;
24
+ /** CAIP-10 → address, for the signature read. */
25
+ function addressOf(id) {
26
+ const addr = String(id).split(':').pop();
27
+ return addr && /^0x[0-9a-fA-F]{40}$/.test(addr) ? addr.toLowerCase() : null;
28
+ }
29
+ /**
30
+ * Normalize a URI for comparison so a cosmetic difference is not treated as a different endpoint —
31
+ * and, more importantly, so `https://acme.example` and `https://acme.example:443/` cannot be used to
32
+ * claim two different things about the same host.
33
+ *
34
+ * Deliberately conservative: scheme + host + port + path only. Query and fragment are dropped
35
+ * because they are not part of endpoint identity; userinfo is REJECTED because
36
+ * `https://evil@acme.example` is a classic confusion vector.
37
+ */
38
+ export function normalizeEndpointUri(uri) {
39
+ try {
40
+ const u = new URL(uri);
41
+ if (u.username || u.password)
42
+ return null;
43
+ if (u.protocol !== 'https:' && u.protocol !== 'wss:' && u.protocol !== 'http:')
44
+ return null;
45
+ const path = u.pathname.replace(/\/+$/, '');
46
+ return `${u.protocol}//${u.hostname}${u.port ? `:${u.port}` : ''}${path}`.toLowerCase();
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ }
52
+ function sameEndpoint(a, b) {
53
+ const na = normalizeEndpointUri(a);
54
+ const nb = normalizeEndpointUri(b);
55
+ return na !== null && nb !== null && na === nb;
56
+ }
57
+ /** The digest an agent signs for `signed-challenge`. */
58
+ export async function endpointChallengeDigest(body) {
59
+ return signingDigest(await digestOf(JSON.parse(canonicalizeJson(body))));
60
+ }
61
+ /**
62
+ * Verify that the publisher controls the endpoint. Fail-closed: any missing, mis-bound, stale, or
63
+ * unverifiable evidence yields `ok: false`, and an unrecognized method is a failure rather than a pass.
64
+ */
65
+ export async function verifyEndpointControl(proof, opts) {
66
+ const failures = [];
67
+ const deny = (f) => ({
68
+ ok: false,
69
+ assurance: 'none',
70
+ failures: [...failures, f],
71
+ });
72
+ const nowMs = Date.parse(opts.now);
73
+ if (Number.isNaN(nowMs))
74
+ return deny(failure('malformed', '`now` must be a parseable ISO-8601 timestamp'));
75
+ if (proof.expiresAt) {
76
+ const exp = Date.parse(proof.expiresAt);
77
+ if (Number.isNaN(exp))
78
+ return deny(failure('malformed', 'endpoint proof expiresAt is not parseable'));
79
+ if (nowMs >= exp) {
80
+ return deny(failure('publication_endpoint_proof_expired', 'endpoint-control proof has expired'));
81
+ }
82
+ }
83
+ if (normalizeEndpointUri(opts.uri) === null) {
84
+ return deny(failure('publication_endpoint_proof_missing', 'surface uri is not a normalizable endpoint', {
85
+ surfaceId: opts.surfaceId,
86
+ }));
87
+ }
88
+ let evidence;
89
+ try {
90
+ evidence = await opts.resolveEvidence(proof.evidenceRef);
91
+ }
92
+ catch {
93
+ // An evidence store that errored did not produce evidence (ADR-0013).
94
+ evidence = null;
95
+ }
96
+ if (!evidence) {
97
+ return deny(failure('publication_endpoint_proof_missing', 'endpoint-control evidence could not be resolved', {
98
+ evidenceRef: proof.evidenceRef,
99
+ }));
100
+ }
101
+ // The evidence kind must match the method the publication claimed — otherwise a weak observation
102
+ // could be filed under a strong method's name.
103
+ if (evidence.kind !== proof.method) {
104
+ return deny(failure('publication_endpoint_proof_missing', 'evidence kind does not match the declared proof method', {
105
+ declared: proof.method,
106
+ actual: evidence.kind,
107
+ }));
108
+ }
109
+ if (evidence.kind === 'signed-challenge') {
110
+ const b = evidence.body;
111
+ if (!sameEndpoint(b.uri, opts.uri)) {
112
+ return deny(failure('publication_endpoint_proof_missing', 'challenge binds a different uri'));
113
+ }
114
+ if (b.surfaceId !== opts.surfaceId) {
115
+ return deny(failure('publication_endpoint_proof_missing', 'challenge binds a different surface'));
116
+ }
117
+ if (b.agentId !== opts.agentId) {
118
+ return deny(failure('publication_endpoint_proof_missing', 'challenge binds a different agent'));
119
+ }
120
+ // A short challenge is guessable, which would let anyone who can predict it forge control.
121
+ if (!b.challenge || b.challenge.length < 16) {
122
+ return deny(failure('publication_endpoint_proof_missing', 'challenge has insufficient entropy'));
123
+ }
124
+ const signer = addressOf(opts.agentId);
125
+ if (!signer) {
126
+ return deny(failure('publication_endpoint_proof_missing', 'agent id carries no verifiable address'));
127
+ }
128
+ let valid = false;
129
+ try {
130
+ valid = await opts.verifier.verifyHash({
131
+ address: signer,
132
+ hash: await endpointChallengeDigest(b),
133
+ signature: evidence.signature,
134
+ });
135
+ }
136
+ catch {
137
+ valid = false;
138
+ }
139
+ if (!valid) {
140
+ return deny(failure('publication_endpoint_proof_missing', 'endpoint challenge signature did not verify'));
141
+ }
142
+ return { ok: true, assurance: 'cryptographic', failures: [] };
143
+ }
144
+ // ─── Observation-based methods ────────────────────────────────────────────
145
+ const trusted = opts.trustedObservers ?? [];
146
+ if (!trusted.includes(evidence.observedBy)) {
147
+ // Fail-closed: with no configured observers, no observation is accepted.
148
+ return deny(failure('publication_endpoint_proof_missing', 'observation is not by a trusted observer', {
149
+ observedBy: evidence.observedBy,
150
+ }));
151
+ }
152
+ if (!sameEndpoint(evidence.uri, opts.uri)) {
153
+ return deny(failure('publication_endpoint_proof_missing', 'observation binds a different uri'));
154
+ }
155
+ if (evidence.surfaceId !== opts.surfaceId || evidence.agentId !== opts.agentId) {
156
+ return deny(failure('publication_endpoint_proof_missing', 'observation binds a different surface or agent'));
157
+ }
158
+ if (evidence.observation !== evidence.expected) {
159
+ return deny(failure('publication_endpoint_proof_missing', 'observed value does not match the expected value'));
160
+ }
161
+ const observedAt = Date.parse(evidence.observedAt);
162
+ if (Number.isNaN(observedAt)) {
163
+ return deny(failure('malformed', 'observedAt is not a parseable timestamp'));
164
+ }
165
+ const maxAge = opts.maxObservationAgeMs ?? DEFAULT_MAX_OBSERVATION_AGE_MS;
166
+ if (nowMs - observedAt > maxAge) {
167
+ return deny(failure('publication_endpoint_proof_expired', 'observation is older than the accepted window'));
168
+ }
169
+ if (observedAt > nowMs) {
170
+ return deny(failure('malformed', 'observation is dated in the future'));
171
+ }
172
+ return { ok: true, assurance: 'observed', failures: [] };
173
+ }
174
+ //# sourceMappingURL=endpoint-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-control.js","sourceRoot":"","sources":["../src/endpoint-control.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,sGAAsG;AACtG,qGAAqG;AACrG,kEAAkE;AAClE,EAAE;AACF,0DAA0D;AAC1D,sGAAsG;AACtG,qGAAqG;AACrG,2EAA2E;AAC3E,EAAE;AACF,gGAAgG;AAChG,iGAAiG;AACjG,oGAAoG;AACpG,8FAA8F;AAC9F,iGAAiG;AACjG,uDAAuD;AACvD,EAAE;AACF,mGAAmG;AAEnG,OAAO,EAAE,gBAAgB,EAAyB,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,QA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O,CAAC,oCAAoC,EAAE,+CAA+C,CAAC,CAAC,CAAC;IAC9G,CAAC;IACD,IAAI,UAAU,GAAG,KAAK,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,oCAAoC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,33 @@
1
+ /** Precise, local-only reason code. Never send this to an unauthenticated remote party. */
2
+ export type ResolutionErrorCode = 'publication_signature_invalid' | 'publication_digest_mismatch'
3
+ /** The post-resolve peer gate refused: whoever answered is not provably the agent we resolved. */
4
+ | 'peer_gate_refused' | 'publication_agent_mismatch' | 'publication_publisher_unauthorized' | 'publication_not_yet_valid' | 'publication_expired' | 'publication_status_not_active' | 'publication_sequence_rollback' | 'publication_equivocation' | 'publication_continuity_broken' | 'publication_endpoint_proof_missing' | 'publication_endpoint_proof_expired' | 'publication_transport_key_invalid' | 'publication_surface_exposure_violation' | 'grant_unknown' | 'grant_expired' | 'grant_not_yet_valid' | 'grant_revoked' | 'grant_subject_mismatch' | 'grant_proof_of_possession_failed' | 'grant_audience_mismatch' | 'grant_target_mismatch' | 'grant_action_not_permitted' | 'grant_resolution_budget_exhausted' | 'grant_challenge_replayed'
5
+ /** A STORED grant violates its own invariants. Distinct from `malformed`: this is only decidable
6
+ * AFTER a lookup, so it must deny uniformly or it becomes a grant-existence oracle. */
7
+ | 'grant_shape_invalid' | 'invitation_signature_invalid' | 'invitation_expired' | 'invitation_binding_mismatch' | 'policy_resolution_disabled' | 'projection_not_permitted' | 'reference_unsupported' | 'malformed';
8
+ /**
9
+ * What a resolver may return on the wire. Uniform by design (spec 338 §10): every
10
+ * grant-presentation failure is `resolution_denied` so response content is not an enumeration
11
+ * oracle. `malformed` is safe to distinguish — it is decidable before any lookup, so it leaks
12
+ * nothing about which grants exist.
13
+ */
14
+ export type ResolutionWireCode = 'resolution_denied' | 'publication_invalid' | 'publication_conflict' | 'malformed';
15
+ /** The wire-safe code for a precise reason. Resolvers MUST return this, not the precise code. */
16
+ export declare function toWireCode(code: ResolutionErrorCode): ResolutionWireCode;
17
+ export declare class AgentResolutionError extends Error {
18
+ readonly code: ResolutionErrorCode;
19
+ /** Wire-safe projection of `code` — what a resolver may return to a remote party. */
20
+ readonly wireCode: ResolutionWireCode;
21
+ /** Local-only diagnostic detail. MUST NOT be sent to an unauthenticated remote party. */
22
+ readonly detail?: Record<string, unknown>;
23
+ constructor(code: ResolutionErrorCode, message: string, detail?: Record<string, unknown>);
24
+ }
25
+ /** A single verification failure in a non-throwing verification result. */
26
+ export interface ResolutionFailure {
27
+ code: ResolutionErrorCode;
28
+ wireCode: ResolutionWireCode;
29
+ message: string;
30
+ detail?: Record<string, unknown>;
31
+ }
32
+ export declare function failure(code: ResolutionErrorCode, message: string, detail?: Record<string, unknown>): ResolutionFailure;
33
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAYA,2FAA2F;AAC3F,MAAM,MAAM,mBAAmB,GAE3B,+BAA+B,GAC/B,6BAA6B;AAC/B,kGAAkG;GAChG,mBAAmB,GACnB,4BAA4B,GAC5B,oCAAoC,GACpC,2BAA2B,GAC3B,qBAAqB,GACrB,+BAA+B,GAC/B,+BAA+B,GAC/B,0BAA0B,GAC1B,+BAA+B,GAC/B,oCAAoC,GACpC,oCAAoC,GACpC,mCAAmC,GACnC,wCAAwC,GAExC,eAAe,GACf,eAAe,GACf,qBAAqB,GACrB,eAAe,GACf,wBAAwB,GACxB,kCAAkC,GAClC,yBAAyB,GACzB,uBAAuB,GACvB,4BAA4B,GAC5B,mCAAmC,GACnC,0BAA0B;AAC5B;wFACwF;GACtF,qBAAqB,GACrB,8BAA8B,GAC9B,oBAAoB,GACpB,6BAA6B,GAE7B,4BAA4B,GAC5B,0BAA0B,GAC1B,uBAAuB,GACvB,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC1B,mBAAmB,GACnB,qBAAqB,GACrB,sBAAsB,GACtB,WAAW,CAAC;AAyChB,iGAAiG;AACjG,wBAAgB,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,kBAAkB,CAExE;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,yFAAyF;IACzF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAE9B,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOzF;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,wBAAgB,OAAO,CACrB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,iBAAiB,CAEnB"}
package/dist/errors.js ADDED
@@ -0,0 +1,71 @@
1
+ // Resolution error taxonomy (spec 338 §10).
2
+ //
3
+ // TWO audiences, and conflating them is a privacy bug:
4
+ //
5
+ // - The CALLER of this package (a resolver implementation, a client verifier) needs the precise
6
+ // reason, to log locally and to decide whether to retry, refresh, or raise a conflict.
7
+ // - The REMOTE PARTY probing a resolver must NOT learn which of "unknown grant" / "expired grant" /
8
+ // "wrong subject" / "revoked" applies, or they can enumerate valid grant ids.
9
+ //
10
+ // So every code carries a `wireCode` — what a resolver is allowed to put on the wire. All the
11
+ // grant-presentation failures collapse to `resolution_denied`, deliberately.
12
+ const WIRE = {
13
+ // The CLIENT's own conclusion, never a resolver's response — but mapped anyway so the uniform-denial
14
+ // discipline holds if it is ever surfaced across a boundary.
15
+ peer_gate_refused: 'resolution_denied',
16
+ publication_signature_invalid: 'publication_invalid',
17
+ publication_digest_mismatch: 'publication_invalid',
18
+ publication_agent_mismatch: 'publication_invalid',
19
+ publication_publisher_unauthorized: 'publication_invalid',
20
+ publication_not_yet_valid: 'publication_invalid',
21
+ publication_expired: 'publication_invalid',
22
+ publication_status_not_active: 'publication_invalid',
23
+ publication_sequence_rollback: 'publication_invalid',
24
+ publication_equivocation: 'publication_conflict',
25
+ publication_continuity_broken: 'publication_invalid',
26
+ publication_endpoint_proof_missing: 'publication_invalid',
27
+ publication_endpoint_proof_expired: 'publication_invalid',
28
+ publication_transport_key_invalid: 'publication_invalid',
29
+ publication_surface_exposure_violation: 'publication_invalid',
30
+ grant_unknown: 'resolution_denied',
31
+ grant_expired: 'resolution_denied',
32
+ grant_not_yet_valid: 'resolution_denied',
33
+ grant_revoked: 'resolution_denied',
34
+ grant_subject_mismatch: 'resolution_denied',
35
+ grant_proof_of_possession_failed: 'resolution_denied',
36
+ grant_audience_mismatch: 'resolution_denied',
37
+ grant_target_mismatch: 'resolution_denied',
38
+ grant_action_not_permitted: 'resolution_denied',
39
+ grant_resolution_budget_exhausted: 'resolution_denied',
40
+ grant_challenge_replayed: 'resolution_denied',
41
+ grant_shape_invalid: 'resolution_denied',
42
+ invitation_signature_invalid: 'resolution_denied',
43
+ invitation_expired: 'resolution_denied',
44
+ invitation_binding_mismatch: 'resolution_denied',
45
+ policy_resolution_disabled: 'resolution_denied',
46
+ projection_not_permitted: 'resolution_denied',
47
+ reference_unsupported: 'malformed',
48
+ malformed: 'malformed',
49
+ };
50
+ /** The wire-safe code for a precise reason. Resolvers MUST return this, not the precise code. */
51
+ export function toWireCode(code) {
52
+ return WIRE[code];
53
+ }
54
+ export class AgentResolutionError extends Error {
55
+ code;
56
+ /** Wire-safe projection of `code` — what a resolver may return to a remote party. */
57
+ wireCode;
58
+ /** Local-only diagnostic detail. MUST NOT be sent to an unauthenticated remote party. */
59
+ detail;
60
+ constructor(code, message, detail) {
61
+ super(message);
62
+ this.name = 'AgentResolutionError';
63
+ this.code = code;
64
+ this.wireCode = toWireCode(code);
65
+ this.detail = detail;
66
+ }
67
+ }
68
+ export function failure(code, message, detail) {
69
+ return { code, wireCode: toWireCode(code), message, detail };
70
+ }
71
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,uDAAuD;AACvD,EAAE;AACF,kGAAkG;AAClG,2FAA2F;AAC3F,sGAAsG;AACtG,kFAAkF;AAClF,EAAE;AACF,8FAA8F;AAC9F,6EAA6E;AAyD7E,MAAM,IAAI,GAAoD;IAC5D,qGAAqG;IACrG,6DAA6D;IAC7D,iBAAiB,EAAE,mBAAmB;IACtC,6BAA6B,EAAE,qBAAqB;IACpD,2BAA2B,EAAE,qBAAqB;IAClD,0BAA0B,EAAE,qBAAqB;IACjD,kCAAkC,EAAE,qBAAqB;IACzD,yBAAyB,EAAE,qBAAqB;IAChD,mBAAmB,EAAE,qBAAqB;IAC1C,6BAA6B,EAAE,qBAAqB;IACpD,6BAA6B,EAAE,qBAAqB;IACpD,wBAAwB,EAAE,sBAAsB;IAChD,6BAA6B,EAAE,qBAAqB;IACpD,kCAAkC,EAAE,qBAAqB;IACzD,kCAAkC,EAAE,qBAAqB;IACzD,iCAAiC,EAAE,qBAAqB;IACxD,sCAAsC,EAAE,qBAAqB;IAC7D,aAAa,EAAE,mBAAmB;IAClC,aAAa,EAAE,mBAAmB;IAClC,mBAAmB,EAA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';
2
+ import { type ResolutionFailure } from './errors.js';
3
+ /** What a client already knows about a publication channel. Absent ⇒ first contact. */
4
+ export interface ChannelContinuityState {
5
+ channelId: string;
6
+ latestAcceptedSequence: bigint;
7
+ latestAcceptedDigest: Sha256;
8
+ }
9
+ export interface FreshnessInput {
10
+ channelId: string;
11
+ sequence: bigint;
12
+ previousDigest?: Sha256;
13
+ digest: Sha256;
14
+ issuedAt: string;
15
+ notBefore?: string;
16
+ expiresAt: string;
17
+ /** ISO-8601, injected. */
18
+ now: string;
19
+ /** Prior state for this channel, if the client has seen it before. */
20
+ known?: ChannelContinuityState;
21
+ /** Require `previousDigest` to chain to the known digest. Default true when `known` is supplied. */
22
+ requireContinuity?: boolean;
23
+ }
24
+ export interface ResolutionFreshnessV1 {
25
+ /** True only when every check below passed. */
26
+ fresh: boolean;
27
+ sequence: bigint;
28
+ issuedAt: string;
29
+ expiresAt: string;
30
+ /** Milliseconds until `expiresAt` at `now`. Negative when already expired. */
31
+ remainingMs: number;
32
+ /** True when a differing digest was seen at the same sequence — publisher equivocation. */
33
+ conflict: boolean;
34
+ failures: readonly ResolutionFailure[];
35
+ }
36
+ export declare function checkFreshness(input: FreshnessInput): ResolutionFreshnessV1;
37
+ /** Advance a client's continuity state after a publication verified. Fail-closed: never regresses. */
38
+ export declare function advanceContinuity(known: ChannelContinuityState | undefined, accepted: {
39
+ channelId: string;
40
+ sequence: bigint;
41
+ digest: Sha256;
42
+ }): ChannelContinuityState;
43
+ //# sourceMappingURL=freshness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../src/freshness.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE9D,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,sEAAsE;IACtE,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,oGAAoG;IACpG,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,2FAA2F;IAC3F,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACxC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,qBAAqB,CAsF3E;AAED,sGAAsG;AACtG,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,sBAAsB,GAAG,SAAS,EACzC,QAAQ,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAChE,sBAAsB,CASxB"}
@@ -0,0 +1,100 @@
1
+ // Freshness + continuity (spec 338 §3.1).
2
+ //
3
+ // The rule this file exists to enforce:
4
+ // A content hash proves the publication was NOT MODIFIED. It does not prove it is CURRENT.
5
+ //
6
+ // Currency is three independent things — the publication is inside its own validity window, it is
7
+ // not a rollback to an older sequence, and it continues the chain the client already knows.
8
+ // Equivocation (two valid signatures at the same sequence) is reported rather than merely rejected,
9
+ // because it is evidence of publisher-key compromise, not a transient error.
10
+ import { failure } from './errors.js';
11
+ export function checkFreshness(input) {
12
+ const failures = [];
13
+ const now = Date.parse(input.now);
14
+ const expiresAt = Date.parse(input.expiresAt);
15
+ const notBefore = input.notBefore ? Date.parse(input.notBefore) : Date.parse(input.issuedAt);
16
+ let conflict = false;
17
+ if (Number.isNaN(now) || Number.isNaN(expiresAt) || Number.isNaN(notBefore)) {
18
+ failures.push(failure('malformed', 'now / notBefore / expiresAt MUST be parseable ISO-8601 timestamps'));
19
+ return {
20
+ fresh: false,
21
+ sequence: input.sequence,
22
+ issuedAt: input.issuedAt,
23
+ expiresAt: input.expiresAt,
24
+ remainingMs: 0,
25
+ conflict: false,
26
+ failures,
27
+ };
28
+ }
29
+ if (now < notBefore) {
30
+ failures.push(failure('publication_not_yet_valid', 'publication is not yet valid', { notBefore: input.notBefore }));
31
+ }
32
+ if (now >= expiresAt) {
33
+ failures.push(failure('publication_expired', 'publication has expired', { expiresAt: input.expiresAt }));
34
+ }
35
+ if (input.sequence < 0n) {
36
+ failures.push(failure('malformed', 'sequence MUST NOT be negative'));
37
+ }
38
+ const known = input.known;
39
+ if (known) {
40
+ if (known.channelId !== input.channelId) {
41
+ failures.push(failure('publication_continuity_broken', 'known continuity state is for a different channel', {
42
+ expected: input.channelId,
43
+ got: known.channelId,
44
+ }));
45
+ }
46
+ else if (input.sequence < known.latestAcceptedSequence) {
47
+ // Rollback: an attacker replaying an older, still-signed publication to steer a client at a
48
+ // decommissioned or compromised endpoint.
49
+ failures.push(failure('publication_sequence_rollback', 'publication sequence is older than the latest accepted', {
50
+ sequence: input.sequence.toString(10),
51
+ latestAccepted: known.latestAcceptedSequence.toString(10),
52
+ }));
53
+ }
54
+ else if (input.sequence === known.latestAcceptedSequence) {
55
+ if (input.digest !== known.latestAcceptedDigest) {
56
+ // Equivocation: two validly signed publications at the same sequence. Both digests are kept
57
+ // as evidence by the caller; this is a compromise signal, not a retryable error.
58
+ conflict = true;
59
+ failures.push(failure('publication_equivocation', 'a different publication was already accepted at this sequence', {
60
+ sequence: input.sequence.toString(10),
61
+ knownDigest: known.latestAcceptedDigest,
62
+ offeredDigest: input.digest,
63
+ }));
64
+ }
65
+ }
66
+ else {
67
+ const requireContinuity = input.requireContinuity ?? true;
68
+ // Only a direct successor can be continuity-checked; a gap (client was offline across several
69
+ // publications) is legitimate and is not a continuity break.
70
+ const isDirectSuccessor = input.sequence === known.latestAcceptedSequence + 1n;
71
+ if (requireContinuity && isDirectSuccessor && input.previousDigest !== known.latestAcceptedDigest) {
72
+ failures.push(failure('publication_continuity_broken', 'previousDigest does not chain to the last accepted publication', {
73
+ expected: known.latestAcceptedDigest,
74
+ got: input.previousDigest,
75
+ }));
76
+ }
77
+ }
78
+ }
79
+ return {
80
+ fresh: failures.length === 0,
81
+ sequence: input.sequence,
82
+ issuedAt: input.issuedAt,
83
+ expiresAt: input.expiresAt,
84
+ remainingMs: expiresAt - now,
85
+ conflict,
86
+ failures,
87
+ };
88
+ }
89
+ /** Advance a client's continuity state after a publication verified. Fail-closed: never regresses. */
90
+ export function advanceContinuity(known, accepted) {
91
+ if (known && known.channelId === accepted.channelId && known.latestAcceptedSequence >= accepted.sequence) {
92
+ return known;
93
+ }
94
+ return {
95
+ channelId: accepted.channelId,
96
+ latestAcceptedSequence: accepted.sequence,
97
+ latestAcceptedDigest: accepted.digest,
98
+ };
99
+ }
100
+ //# sourceMappingURL=freshness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freshness.js","sourceRoot":"","sources":["../src/freshness.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,wCAAwC;AACxC,6FAA6F;AAC7F,EAAE;AACF,kGAAkG;AAClG,4FAA4F;AAC5F,oGAAoG;AACpG,6EAA6E;AAG7E,OAAO,EAAE,OAAO,EAA0B,MAAM,aAAa,CAAC;AAsC9D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CAAC,MAAM;KACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ /** Domain separation: the same grant id under different purposes yields unlinkable digests, so a
2
+ * resolver's lookup index cannot be correlated against receipts written by the same resolver. */
3
+ export type GrantDigestPurpose =
4
+ /** The resolver's private lookup key. */
5
+ 'ap.resolution.index/1'
6
+ /** The `grantIdDigest` recorded on a receipt (spec 338 §11). */
7
+ | 'ap.resolution.receipt/1';
8
+ /** Minimum acceptable index-secret length. A short secret makes the whole index forgeable. */
9
+ export declare const MIN_INDEX_SECRET_BYTES = 32;
10
+ /**
11
+ * Derive the storage key for a grant id under a purpose.
12
+ *
13
+ * `indexSecret` is the resolver's own secret — it MUST NOT be shared with the issuer, the target,
14
+ * or another resolver, or the "stolen index is non-correlatable" property is lost.
15
+ */
16
+ export declare function deriveGrantDigest(grantId: string, indexSecret: Uint8Array, purpose?: GrantDigestPurpose): Promise<string>;
17
+ /** The `sha256:`-shaped digest a receipt carries (spec 338 §11). Purpose-separated from the index key. */
18
+ export declare function deriveReceiptGrantDigest(grantId: string, indexSecret: Uint8Array): Promise<`sha256:${string}`>;
19
+ /** Compare a derived digest to a stored one without short-circuiting on the first differing byte. */
20
+ export declare function grantDigestMatches(a: string, b: string): boolean;
21
+ //# sourceMappingURL=grant-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant-index.d.ts","sourceRoot":"","sources":["../src/grant-index.ts"],"names":[],"mappings":"AAuBA;kGACkG;AAClG,MAAM,MAAM,kBAAkB;AAC5B,yCAAyC;AACvC,uBAAuB;AACzB,gEAAgE;GAC9D,yBAAyB,CAAC;AAgB9B,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,UAAU,EACvB,OAAO,GAAE,kBAA4C,GACpD,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,0GAA0G;AAC1G,w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AAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,8FAA8F;AAC9F,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,WAAuB,EACvB,UAA8B,uBAAuB;IAErD,IAAI,WAAW,CAAC,MAAM,GAAG,sBAAsB,EAAE,CAAC;QAChD,+FAA+F;QAC/F,MAAM,IAAI,KAAK,CACb,mDAAmD,sBAAsB,eAAe,WAAW,CAAC,MAAM,EAAE,CAC7G,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC7E,OAAO,aAAa,CAAC,WAAW,EAAE,GAAG,OAAO,IAAI,OAAO,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,0GAA0G;AAC1G,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAAe,EACf,WAAuB;IAEvB,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,yBAAyB,CAAC,CAAC;IACrF,OAAO,UAAU,GAAG,EAAwB,CAAC;AAC/C,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,kBAAkB,CAAC,CAAS,EAAE,CAAS;IACrD,OAAO,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,100 @@
1
+ import type { CanonicalAgentId } from '@agenticprimitives/types';
2
+ /**
3
+ * How the grant is bound to whoever presents it.
4
+ *
5
+ * `subject-bound` is the default and the only one that survives a copied grant: the presenter must
6
+ * prove possession of the subject Smart Agent, so the grant alone is worthless to a third party.
7
+ */
8
+ export type ResolutionGrantMode = 'subject-bound'
9
+ /** Distinct id, projection, optional label, expiry, revocation and history PER relationship. */
10
+ | 'pairwise'
11
+ /** Only where the recipient has no Smart Agent yet. Short-lived; exchanged for a subject-bound grant. */
12
+ | 'bearer-bootstrap';
13
+ /** The one action every resolution grant must carry. Additional actions never widen it into use authority. */
14
+ export declare const RESOLVE_ACTION: "agent.resolve";
15
+ /** Which fields of the target's publication this grant may see. Fail-closed: absent list ⇒ nothing extra. */
16
+ export interface ResolutionProjectionPolicy {
17
+ /** Named projection profile — e.g. 'public' | 'authenticated' | 'partner' | 'internal' | 'pairwise'. */
18
+ profile: string;
19
+ allowedSurfaceIds?: readonly string[];
20
+ allowedProtocols?: readonly string[];
21
+ allowedFields?: readonly string[];
22
+ includeProfile?: boolean;
23
+ includeCapabilities?: boolean;
24
+ includeTransportKeys?: boolean;
25
+ }
26
+ export interface ResolutionGrantConstraints {
27
+ /** Which resolver may accept this grant. Confused-deputy defence (spec 338 §10). */
28
+ audience: string;
29
+ purpose?: string;
30
+ notBefore: string;
31
+ expiresAt: string;
32
+ maximumResolutions?: number;
33
+ region?: string;
34
+ /** When true the presenter must answer a fresh challenge. MUST be true for `subject-bound`. */
35
+ requireProofOfPossession: boolean;
36
+ }
37
+ export interface PrivateResolutionGrantV1 {
38
+ specVersion: 'ap.private-resolution-grant/1';
39
+ /** High-entropy opaque capability, e.g. `apd1_<base64url(192–256 bits)>`. Never name-derived. */
40
+ grantId: string;
41
+ issuer: CanonicalAgentId;
42
+ /** The agent this grant permits discovering. Signed in, so a grant cannot be retargeted. */
43
+ targetAgent: CanonicalAgentId;
44
+ /** Required for `subject-bound` and `pairwise`; absent for `bearer-bootstrap`. */
45
+ subject?: CanonicalAgentId;
46
+ mode: ResolutionGrantMode;
47
+ /** MUST begin with `agent.resolve`. */
48
+ actions: readonly [typeof RESOLVE_ACTION, ...string[]];
49
+ projection: ResolutionProjectionPolicy;
50
+ constraints: ResolutionGrantConstraints;
51
+ /** Where revocation status is checked. Revocation is authoritative in the issuer's vault. */
52
+ statusRef: string;
53
+ issuedAt: string;
54
+ /** Reference to the authority under which the issuer may grant discovery of `targetAgent`. */
55
+ authorityRef: string;
56
+ proof: unknown;
57
+ }
58
+ /** What a presenter sends to a resolver. Never logged raw (spec 338 §4, placement ban). */
59
+ export interface ResolutionGrantPresentationV1 {
60
+ grantId: string;
61
+ /** The resolver's fresh nonce, echoed. */
62
+ challengeNonce: string;
63
+ /** The resolver audience this presentation is bound to. */
64
+ audience: string;
65
+ requestedProjection?: string;
66
+ timestamp: string;
67
+ /** Proof of possession of `subject`. Absent only for `bearer-bootstrap`. */
68
+ subjectProof?: {
69
+ subject: CanonicalAgentId;
70
+ scheme: 'erc1271' | 'ecdsa' | 'session-key';
71
+ signature: `0x${string}`;
72
+ };
73
+ }
74
+ /** The body a `subjectProof` signature commits to. Binds nonce, audience and target together so a
75
+ * captured presentation cannot be replayed at another resolver or for another target. */
76
+ export declare function presentationBody(p: ResolutionGrantPresentationV1, targetAgent: CanonicalAgentId): Record<string, unknown>;
77
+ /**
78
+ * The canonical body the ISSUER signs when minting a grant (spec 338 §4).
79
+ *
80
+ * WHY THIS EXISTS: without it, a resolver indexing a grant can only check that whoever POSTed it held
81
+ * an operator token — which authenticates the STORE OPERATOR, not the grant. Signing this body lets a
82
+ * resolver verify that the party who claims to have issued discovery rights over `targetAgent`
83
+ * actually did, and lets an auditor re-derive it later.
84
+ *
85
+ * Excludes `proof` (it is the signature) and `grantId` is INCLUDED — a signature that did not commit
86
+ * to the id would let an operator re-file the same authorization under a different, longer-lived id.
87
+ */
88
+ export declare function grantBody(g: Omit<PrivateResolutionGrantV1, 'proof'>): Record<string, unknown>;
89
+ /** The maximum lifetime a `bearer-bootstrap` grant may carry (spec 338 §13 SHACL). */
90
+ export declare const BEARER_BOOTSTRAP_MAX_LIFETIME_MS: number;
91
+ export interface GrantShapeViolation {
92
+ field: string;
93
+ message: string;
94
+ }
95
+ /**
96
+ * Static shape validation — the invariants that hold regardless of runtime state. Revocation,
97
+ * budget, and proof-of-possession are runtime checks and live in the resolver (see `ports.ts`).
98
+ */
99
+ export declare function validateGrantShape(g: PrivateResolutionGrantV1): GrantShapeViolation[];
100
+ //# sourceMappingURL=grants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAC3B,eAAe;AACjB,gGAAgG;GAC9F,UAAU;AACZ,yGAAyG;GACvG,kBAAkB,CAAC;AAEvB,8GAA8G;AAC9G,eAAO,MAAM,cAAc,EAAG,eAAwB,CAAC;AAEvD,6GAA6G;AAC7G,MAAM,WAAW,0BAA0B;IACzC,wGAAwG;IACxG,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IACzC,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+FAA+F;IAC/F,wBAAwB,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,+BAA+B,CAAC;IAE7C,iGAAiG;IACjG,OAAO,EAAE,MAAM,CAAC;IAEhB,MAAM,EAAE,gBAAgB,CAAC;IACzB,4FAA4F;IAC5F,WAAW,EAAE,gBAAgB,CAAC;IAC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