agent-passport-system 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +25 -6
  2. package/dist/src/adapters/oauth-id-jag/index.d.ts +21 -0
  3. package/dist/src/adapters/oauth-id-jag/index.d.ts.map +1 -0
  4. package/dist/src/adapters/oauth-id-jag/index.js +224 -0
  5. package/dist/src/adapters/oauth-id-jag/index.js.map +1 -0
  6. package/dist/src/adapters/oauth-id-jag/types.d.ts +228 -0
  7. package/dist/src/adapters/oauth-id-jag/types.d.ts.map +1 -0
  8. package/dist/src/adapters/oauth-id-jag/types.js +18 -0
  9. package/dist/src/adapters/oauth-id-jag/types.js.map +1 -0
  10. package/dist/src/adapters/oauth-id-jag/verify.d.ts +12 -0
  11. package/dist/src/adapters/oauth-id-jag/verify.d.ts.map +1 -0
  12. package/dist/src/adapters/oauth-id-jag/verify.js +81 -0
  13. package/dist/src/adapters/oauth-id-jag/verify.js.map +1 -0
  14. package/dist/src/cli/index.js +36 -1
  15. package/dist/src/cli/index.js.map +1 -1
  16. package/dist/src/core/action-ref.d.ts +7 -3
  17. package/dist/src/core/action-ref.d.ts.map +1 -1
  18. package/dist/src/core/action-ref.js +7 -3
  19. package/dist/src/core/action-ref.js.map +1 -1
  20. package/dist/src/core/delegation.d.ts +5 -0
  21. package/dist/src/core/delegation.d.ts.map +1 -1
  22. package/dist/src/core/delegation.js +43 -13
  23. package/dist/src/core/delegation.js.map +1 -1
  24. package/dist/src/index.d.ts +5 -1
  25. package/dist/src/index.d.ts.map +1 -1
  26. package/dist/src/index.js +12 -1
  27. package/dist/src/index.js.map +1 -1
  28. package/dist/src/v2/index.d.ts +1 -0
  29. package/dist/src/v2/index.d.ts.map +1 -1
  30. package/dist/src/v2/index.js +3 -0
  31. package/dist/src/v2/index.js.map +1 -1
  32. package/dist/src/v2/key-resolution/did-cycles.d.ts +38 -25
  33. package/dist/src/v2/key-resolution/did-cycles.d.ts.map +1 -1
  34. package/dist/src/v2/key-resolution/did-cycles.js +147 -77
  35. package/dist/src/v2/key-resolution/did-cycles.js.map +1 -1
  36. package/dist/src/v2/key-resolution/index.d.ts +1 -1
  37. package/dist/src/v2/key-resolution/index.d.ts.map +1 -1
  38. package/dist/src/v2/key-resolution/index.js +1 -1
  39. package/dist/src/v2/key-resolution/index.js.map +1 -1
  40. package/dist/src/v2/key-resolution/resolver.d.ts.map +1 -1
  41. package/dist/src/v2/key-resolution/resolver.js +52 -13
  42. package/dist/src/v2/key-resolution/resolver.js.map +1 -1
  43. package/dist/src/v2/key-resolution/types.d.ts +27 -3
  44. package/dist/src/v2/key-resolution/types.d.ts.map +1 -1
  45. package/dist/src/v2/key-resolution/types.js.map +1 -1
  46. package/dist/src/v2/payment-rails/cycles/evidence-resolution.d.ts +5 -0
  47. package/dist/src/v2/payment-rails/cycles/evidence-resolution.d.ts.map +1 -1
  48. package/dist/src/v2/payment-rails/cycles/evidence-resolution.js +2 -0
  49. package/dist/src/v2/payment-rails/cycles/evidence-resolution.js.map +1 -1
  50. package/dist/src/v2/payment-rails/cycles/index.d.ts +77 -1
  51. package/dist/src/v2/payment-rails/cycles/index.d.ts.map +1 -1
  52. package/dist/src/v2/payment-rails/cycles/index.js +164 -5
  53. package/dist/src/v2/payment-rails/cycles/index.js.map +1 -1
  54. package/dist/src/v2/payment-rails/cycles/types.d.ts +40 -0
  55. package/dist/src/v2/payment-rails/cycles/types.d.ts.map +1 -1
  56. package/dist/src/v2/regulated-action/index.d.ts +4 -0
  57. package/dist/src/v2/regulated-action/index.d.ts.map +1 -0
  58. package/dist/src/v2/regulated-action/index.js +5 -0
  59. package/dist/src/v2/regulated-action/index.js.map +1 -0
  60. package/dist/src/v2/regulated-action/types.d.ts +142 -0
  61. package/dist/src/v2/regulated-action/types.d.ts.map +1 -0
  62. package/dist/src/v2/regulated-action/types.js +34 -0
  63. package/dist/src/v2/regulated-action/types.js.map +1 -0
  64. package/dist/src/v2/regulated-action/verify.d.ts +10 -0
  65. package/dist/src/v2/regulated-action/verify.d.ts.map +1 -0
  66. package/dist/src/v2/regulated-action/verify.js +252 -0
  67. package/dist/src/v2/regulated-action/verify.js.map +1 -0
  68. package/package.json +3 -3
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/agent-passport-system)](https://www.npmjs.com/package/agent-passport-system)
4
4
  [![license](https://img.shields.io/npm/l/agent-passport-system)](https://github.com/aeoess/agent-passport-system/blob/main/LICENSE)
5
- [![tests](https://img.shields.io/badge/tests-3615%20passing-brightgreen)](https://github.com/aeoess/agent-passport-system)
5
+ [![tests](https://img.shields.io/badge/tests-3881%20passing-brightgreen)](https://github.com/aeoess/agent-passport-system)
6
6
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18749779.svg)](https://doi.org/10.5281/zenodo.18749779)
7
7
 
8
8
  > **For AI agents:** visit [aeoess.com/llms.txt](https://aeoess.com/llms.txt) for machine-readable docs.
@@ -13,6 +13,15 @@
13
13
 
14
14
  Accepts did:key, did:web, SPIFFE SVIDs, OAuth tokens, and native did:aps. Authority can only decrease at each transfer point. The gateway is both judge and executor. Every action produces a signed receipt. Gateway evaluation under 2ms.
15
15
 
16
+ The narrowing invariant:
17
+
18
+ ```mermaid
19
+ flowchart LR
20
+ P["Principal<br/>full authority"] -->|"scope: payments<br/>limit: $500, 30 days"| A["Agent A<br/>payments, $500"]
21
+ A -->|"scope: refunds only<br/>limit: $100, 7 days"| B["Agent B<br/>refunds, $100"]
22
+ B -.->|"$200 request:<br/>exceeds chain authority"| X["denied + signed receipt"]
23
+ ```
24
+
16
25
  ```bash
17
26
  npm install agent-passport-system
18
27
  ```
@@ -21,7 +30,7 @@ Also implemented in [Python](https://pypi.org/project/agent-passport-system/) an
21
30
 
22
31
  ## Quick Start
23
32
 
24
- Lead with the curated essentials. `agent-passport-system/core` exposes the ~25 functions that 90% of integrations need: identity, delegation, enforcement, commerce, reputation, key management. The full `agent-passport-system` root import is unchanged and backward compatible: pull from it when Core does not cover your case.
33
+ Lead with the curated essentials. `agent-passport-system/core` exposes the 24 functions that 90% of integrations need: identity, delegation, enforcement, commerce, reputation, key management. The full `agent-passport-system` root import is unchanged and backward compatible: pull from it when Core does not cover your case.
25
34
 
26
35
  ```typescript
27
36
  import {
@@ -29,7 +38,7 @@ import {
29
38
  evaluateIntent, commercePreflight, generateKeyPair
30
39
  } from 'agent-passport-system/core'
31
40
 
32
- // Full 936-export API still available. Use when Core does not cover your case.
41
+ // Full 925-export API still available. Use when Core does not cover your case.
33
42
  // import { ... } from 'agent-passport-system'
34
43
  ```
35
44
 
@@ -41,6 +50,16 @@ Every primitive in this README carries one of three labels so you know how much
41
50
  - **Production-Extension** -- shipped and tested, optional, additive to the canonical core. Safe in production; the surface may still grow.
42
51
  - **Experimental** -- published for review and tested, but the shape may change. Pin a version before depending on it.
43
52
 
53
+ Where enforcement sits:
54
+
55
+ ```mermaid
56
+ flowchart LR
57
+ AG[Agent] -->|signed intent| GW{"Gateway<br/>scope / spend / revocation / values floor"}
58
+ GW -->|permit| ACT[Action executes]
59
+ GW -->|deny| STOP[Blocked]
60
+ GW --> RC[("Signed receipt<br/>every outcome, both verdicts")]
61
+ ```
62
+
44
63
  ## Core Protocol
45
64
 
46
65
  *Status: Canonical.*
@@ -176,7 +195,7 @@ Proposed by [@piiiico](https://github.com/piiiico) on the a2aproject/A2A governa
176
195
 
177
196
  Pick what you need. `import from 'agent-passport-system'` for the full API.
178
197
 
179
- Coordination (task lifecycle with 9-state machine), EU AI Act compliance (signed evidence packets), framework adapters (CrewAI, LangChain, Google ADK, A2A, MCP), bilateral receipts, execution attestation, DID resolution, data lifecycle (access receipts, derivation tracking, consent revocation).
198
+ Coordination (task lifecycle with 9-state machine), EU AI Act mapping support through signed evidence packets for accountability and audit workflows, framework adapters (CrewAI, LangChain, Google ADK, A2A, MCP), bilateral receipts, execution attestation, DID resolution, data lifecycle (access receipts, derivation tracking, consent revocation).
180
199
 
181
200
  ## Research Primitives
182
201
 
@@ -208,9 +227,9 @@ The composition contract specifies how a verifier MUST cross-check per-request s
208
227
 
209
228
  ## Numbers
210
229
 
211
- 3,792 tests. 8 protocol layers. Framework adapters for CrewAI, LangChain, ADK, A2A, MCP, OpenShell, IBAC, Gonka. Gateway evaluation under 2ms. Zero heavy dependencies. Apache-2.0.
230
+ 3,881 tests. 8 protocol layers. Framework adapters for CrewAI, LangChain, ADK, A2A, MCP, OpenShell, IBAC, Gonka. Gateway evaluation under 2ms. Zero heavy dependencies. Apache-2.0.
212
231
 
213
- The test count is one number derived from the suite, not three guesses. The badge above, this section, and the `package.json` description all carry the same `3,615`, which is the `tests` total reported by `npm test`. When the suite grows, re-run `npm test`, read the `tests` line, and update all three to match.
232
+ The test count is one number derived from the suite, not three guesses. The badge above, this section, and the `package.json` description all carry the same `3,881`, which is the `tests` total reported by `npm test`. When the suite grows, re-run `npm test`, read the `tests` line, and update all three to match.
214
233
 
215
234
  ## Papers
216
235
 
@@ -0,0 +1,21 @@
1
+ import type { Delegation } from '../../types/passport.js';
2
+ import type { IdJagClaims, VerifiedIdJagGrant, IdJagVerification, IdJagDescriptor, IdJagBindOptions } from './types.js';
3
+ export * from './types.js';
4
+ /**
5
+ * Wrap a decoded grant the caller asserts it has verified. The only constructor
6
+ * for VerifiedIdJagGrant, so an unverified grant cannot reach bindIdJagGrant.
7
+ */
8
+ export declare function verifiedIdJagGrant(grant: IdJagClaims, verification: IdJagVerification): VerifiedIdJagGrant;
9
+ /**
10
+ * Bind a caller-verified ID-JAG grant to an APS descriptor. Pure projection: it
11
+ * signs the caller verification attestation and computes the two anchors, but it
12
+ * makes no allow or deny decision, checks no signature on the grant, fetches
13
+ * nothing, and invents no spend unit. The chain is the APS-signed hops the caller
14
+ * built under the grant; this records them and hashes their content.
15
+ *
16
+ * Throws IdJagBindingError 'missing_required_claim' on an absent required claim,
17
+ * or 'missing_verified_at' when no verifiedAt is supplied (it anchors the signed
18
+ * attestation).
19
+ */
20
+ export declare function bindIdJagGrant(verified: VerifiedIdJagGrant, chain: Delegation[], callerPrivateKey: string, options?: IdJagBindOptions): IdJagDescriptor;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/oauth-id-jag/index.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAIzD,OAAO,KAAK,EACV,WAAW,EAA4B,kBAAkB,EAAE,iBAAiB,EAC5E,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB,cAAc,YAAY,CAAA;AAI1B;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,GAAG,kBAAkB,CAE1G;AAoGD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,kBAAkB,EAC5B,KAAK,EAAE,UAAU,EAAE,EACnB,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CA0EjB"}
@@ -0,0 +1,224 @@
1
+ // Copyright 2024-2026 Tymofii Pidlisnyi. Apache-2.0 license. See LICENSE.
2
+ // OAuth ID-JAG to APS delegation binding.
3
+ //
4
+ // Bridge and profile only. A caller-verified ID-JAG grant (the OAuth Identity
5
+ // Assertion JWT Authorization Grant) is imported as external authority, and APS
6
+ // adds the layer the draft leaves to profiles in section 9.7: scoped agent
7
+ // delegation, monotonic narrowing, evidence quality, and signed receipts for
8
+ // actions taken under it. APS maps onto ID-JAG at the edge; it does not become
9
+ // ID-JAG. This is a binding, not a dependency. Neither side requires the other.
10
+ //
11
+ // Pinned to draft-ietf-oauth-identity-assertion-authz-grant-04 (2026-05-21).
12
+ // Stable APS semantics; draft-pinned external protocol semantics.
13
+ //
14
+ // Proof box
15
+ // Specified and tested: a caller-verified grant projects to an APS descriptor
16
+ // with two separate anchors (delegationChainRoot over chain content,
17
+ // sourceGrantRef over grant provenance), a caller-signed verification
18
+ // attestation, an externally anchored keyless root, scope projected with raw
19
+ // authorization_details preserved, and no invented spend unit.
20
+ // Does NOT do: verify the ID-JAG signature, fetch JWKS, hold OAuth trust config,
21
+ // check revocation, decide allow or deny, aggregate, or mint authority. The
22
+ // input is a caller-verified grant; verification and enforcement stay with the
23
+ // relying party. Soundness here is by accountability (a keyed caller on the
24
+ // hook), not by construction.
25
+ import { canonicalHashJCS } from '../../core/canonical-jcs.js';
26
+ import { computeDelegationChainRoot } from '../../decisionReceipt.js';
27
+ import { createDelegationRef } from '../../core/reanchor.js';
28
+ import { sign, publicKeyFromPrivate } from '../../crypto/keys.js';
29
+ import { IDJAG_DRAFT, SOURCE_GRANT_REF_TAG, IdJagBindingError, } from './types.js';
30
+ export * from './types.js';
31
+ const REQUIRED_CLAIMS = ['iss', 'sub', 'aud', 'client_id', 'jti', 'exp', 'iat'];
32
+ /**
33
+ * Wrap a decoded grant the caller asserts it has verified. The only constructor
34
+ * for VerifiedIdJagGrant, so an unverified grant cannot reach bindIdJagGrant.
35
+ */
36
+ export function verifiedIdJagGrant(grant, verification) {
37
+ return { grant, verification };
38
+ }
39
+ function numericDateToIso(seconds) {
40
+ return new Date(seconds * 1000).toISOString();
41
+ }
42
+ /** Project the scope claim to APS scope tokens. Baseline only; RAR never widens it. */
43
+ function mapScopeBaseline(claims) {
44
+ const out = [];
45
+ if (typeof claims.scope === 'string') {
46
+ for (const tok of claims.scope.split(/\s+/)) {
47
+ if (tok.length > 0)
48
+ out.push(tok);
49
+ }
50
+ }
51
+ return out;
52
+ }
53
+ /**
54
+ * Project RAR against the scope baseline. RAR that would widen scope is flagged
55
+ * and not applied. A recognized amount with a currency refines spend; an amount
56
+ * without a currency is never stamped with a unit; anything else is carried raw
57
+ * and immutable. The raw objects are always preserved by the caller separately.
58
+ */
59
+ function projectRar(details, scopeBaseline) {
60
+ const diagnostics = [];
61
+ let spendLimit;
62
+ let spendLimitUnit;
63
+ for (const detail of details) {
64
+ const type = typeof detail.type === 'string' ? detail.type : '';
65
+ if (!scopeBaseline.includes(type)) {
66
+ diagnostics.push({ code: 'RAR_SCOPE_CONFLICT_NOT_APPLIED', detail: `RAR type "${type}" is not in the projected scope; not applied (would widen).` });
67
+ continue;
68
+ }
69
+ const amount = detail.amount;
70
+ if (typeof amount === 'number' && Number.isFinite(amount) && amount >= 0) {
71
+ const currency = detail.currency;
72
+ if (typeof currency === 'string' && currency.length > 0) {
73
+ if (spendLimit === undefined) {
74
+ spendLimit = amount;
75
+ spendLimitUnit = 'currency';
76
+ }
77
+ }
78
+ else {
79
+ diagnostics.push({ code: 'UNITLESS_AMOUNT_NOT_STAMPED', detail: `RAR type "${type}" carries amount ${amount} with no currency; carried raw, no spend unit synthesized.` });
80
+ }
81
+ }
82
+ else {
83
+ diagnostics.push({ code: 'OPAQUE_RAR_CARRIED_IMMUTABLE', detail: `RAR type "${type}" has no recognized refinement; carried raw and immutable through the chain.` });
84
+ }
85
+ }
86
+ const result = { diagnostics };
87
+ if (spendLimit !== undefined) {
88
+ result.spendLimit = spendLimit;
89
+ result.spendLimitUnit = spendLimitUnit;
90
+ }
91
+ return result;
92
+ }
93
+ function buildOpaqueContext(claims, minimize) {
94
+ const ctx = {};
95
+ if (claims.tenant !== undefined)
96
+ ctx.tenant = claims.tenant;
97
+ if (claims.aud_tenant !== undefined)
98
+ ctx.aud_tenant = claims.aud_tenant;
99
+ if (claims.acr !== undefined)
100
+ ctx.acr = claims.acr;
101
+ if (claims.amr !== undefined)
102
+ ctx.amr = claims.amr;
103
+ if (claims.auth_time !== undefined)
104
+ ctx.auth_time = claims.auth_time;
105
+ if (!minimize) {
106
+ if (claims.aud_sub !== undefined)
107
+ ctx.aud_sub = claims.aud_sub;
108
+ if (claims.email !== undefined)
109
+ ctx.email = claims.email;
110
+ if (claims.sub_id !== undefined)
111
+ ctx.sub_id = claims.sub_id;
112
+ }
113
+ return ctx;
114
+ }
115
+ /** Literal-only reconciliation of the act claim against the APS chain leaf. Advisory; never authoritative; never claims cross-domain semantic conflict. */
116
+ function reconcileAct(act, chain) {
117
+ if (!act)
118
+ return { status: 'absent', advisoryAct: null };
119
+ const actActor = typeof act.sub === 'string' ? act.sub : undefined;
120
+ const chainActor = chain.length > 0 ? chain[chain.length - 1].delegatedTo : undefined;
121
+ if (actActor === undefined || chainActor === undefined)
122
+ return { status: 'not_comparable', advisoryAct: act };
123
+ if (actActor === chainActor)
124
+ return { status: 'same_literal_identifier', advisoryAct: act };
125
+ return { status: 'different_literal_identifier_not_enforced', advisoryAct: act };
126
+ }
127
+ /** Compute the source-grant-ref preimage. Provenance and binding target ONLY: resource is included only when present so absent and present do not hash ambiguously. */
128
+ function sourceGrantRefPreimage(claims) {
129
+ const pre = {
130
+ tag: SOURCE_GRANT_REF_TAG,
131
+ draft: IDJAG_DRAFT,
132
+ iss: claims.iss,
133
+ sub: claims.sub,
134
+ jti: claims.jti,
135
+ client_id: claims.client_id,
136
+ aud: claims.aud,
137
+ exp: claims.exp,
138
+ };
139
+ if (claims.resource !== undefined)
140
+ pre.resource = claims.resource;
141
+ return pre;
142
+ }
143
+ /**
144
+ * Bind a caller-verified ID-JAG grant to an APS descriptor. Pure projection: it
145
+ * signs the caller verification attestation and computes the two anchors, but it
146
+ * makes no allow or deny decision, checks no signature on the grant, fetches
147
+ * nothing, and invents no spend unit. The chain is the APS-signed hops the caller
148
+ * built under the grant; this records them and hashes their content.
149
+ *
150
+ * Throws IdJagBindingError 'missing_required_claim' on an absent required claim,
151
+ * or 'missing_verified_at' when no verifiedAt is supplied (it anchors the signed
152
+ * attestation).
153
+ */
154
+ export function bindIdJagGrant(verified, chain, callerPrivateKey, options = {}) {
155
+ const claims = verified.grant;
156
+ const verification = verified.verification;
157
+ for (const key of REQUIRED_CLAIMS) {
158
+ const value = claims[key];
159
+ if (value === undefined || value === null || value === '') {
160
+ throw new IdJagBindingError('missing_required_claim', `ID-JAG grant is missing required claim: ${String(key)}`);
161
+ }
162
+ }
163
+ const verifiedAt = verification.verifiedAt;
164
+ if (typeof verifiedAt !== 'string' || verifiedAt.length === 0) {
165
+ throw new IdJagBindingError('missing_verified_at', 'caller verification must include verifiedAt to anchor the signed attestation');
166
+ }
167
+ const preimage = sourceGrantRefPreimage(claims);
168
+ const sourceGrantRef = canonicalHashJCS(preimage);
169
+ const message = `verified grant ${sourceGrantRef} at ${verifiedAt}`;
170
+ const signature = sign(message, callerPrivateKey);
171
+ const signerPublicKey = publicKeyFromPrivate(callerPrivateKey);
172
+ const scope = mapScopeBaseline(claims);
173
+ const rawAuthorizationDetails = claims.authorization_details ?? [];
174
+ const rar = projectRar(rawAuthorizationDetails, scope);
175
+ const resource = claims.resource;
176
+ const iatIso = numericDateToIso(claims.iat);
177
+ const descriptor = {
178
+ draft: IDJAG_DRAFT,
179
+ sourceGrantRef,
180
+ sourceGrantRefPreimage: preimage,
181
+ delegationChainRoot: computeDelegationChainRoot(chain),
182
+ chain,
183
+ rootRef: createDelegationRef({ did: claims.sub }),
184
+ externalRoot: { type: 'external_identity_assertion', protocol: 'id-jag', verifiedBy: 'caller' },
185
+ delegatedTo: claims.client_id,
186
+ scope,
187
+ rawAuthorizationDetails,
188
+ projectionLossy: true,
189
+ diagnostics: rar.diagnostics,
190
+ createdAt: iatIso,
191
+ expiresAt: numericDateToIso(claims.exp),
192
+ carriedAudience: {
193
+ enforcement: 'not_enforced_by_binding',
194
+ recipients: [claims.aud, ...(resource ? [resource] : [])],
195
+ },
196
+ externalState: { revocation: 'not_checked_by_binding' },
197
+ actReconciliation: reconcileAct(claims.act, chain),
198
+ callerVerification: {
199
+ signal: {
200
+ key: 'id_jag.grant_verified_by_caller',
201
+ valueHash: sourceGrantRef,
202
+ provenance: 'self_declared',
203
+ verificationStatus: 'declared',
204
+ stability: 'account',
205
+ attester: signerPublicKey,
206
+ observedAt: verifiedAt,
207
+ evidenceRef: signature,
208
+ },
209
+ message,
210
+ signature,
211
+ signerPublicKey,
212
+ verifiedAt,
213
+ ...(verification.kid ? { kid: verification.kid } : {}),
214
+ },
215
+ opaqueContext: buildOpaqueContext(claims, options.minimizeSensitive === true),
216
+ notCarried: { cnf: 'not_carried', dpop: 'not_carried' },
217
+ };
218
+ if (rar.spendLimit !== undefined) {
219
+ descriptor.spendLimit = rar.spendLimit;
220
+ descriptor.spendLimitUnit = rar.spendLimitUnit;
221
+ }
222
+ return descriptor;
223
+ }
224
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapters/oauth-id-jag/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0CAA0C;AAC1C,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,EAAE;AACF,6EAA6E;AAC7E,kEAAkE;AAClE,EAAE;AACF,YAAY;AACZ,8EAA8E;AAC9E,uEAAuE;AACvE,wEAAwE;AACxE,+EAA+E;AAC/E,iEAAiE;AACjE,iFAAiF;AACjF,8EAA8E;AAC9E,iFAAiF;AACjF,8EAA8E;AAC9E,gCAAgC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAEjE,OAAO,EACL,WAAW,EAAE,oBAAoB,EAAE,iBAAiB,GACrD,MAAM,YAAY,CAAA;AAOnB,cAAc,YAAY,CAAA;AAE1B,MAAM,eAAe,GAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;AAEtG;;;GAGG;AACH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/reanchor.js';
3
+ import type { AttestedSignal } from '../../types/attestation.js';
4
+ /** The pinned ID-JAG draft identifier. A version bump is a separate, deliberate change. */
5
+ export declare const IDJAG_DRAFT = "draft-ietf-oauth-identity-assertion-authz-grant-04";
6
+ /** Domain-separation tag for the source-grant-ref commitment preimage. */
7
+ export declare const SOURCE_GRANT_REF_TAG = "aps.id_jag.source_grant_ref.v1";
8
+ /**
9
+ * The decoded ID-JAG claims (draft-04 field names). This is the decoded grant,
10
+ * NOT proof that it was verified. The public path takes VerifiedIdJagGrant.
11
+ */
12
+ export interface IdJagClaims {
13
+ /** IdP Authorization Server issuer identifier. */
14
+ iss: string;
15
+ /** Subject identifier (the authenticated End-User). */
16
+ sub: string;
17
+ /** Resource Authorization Server identifier. */
18
+ aud: string;
19
+ /** OAuth 2.0 client at the Resource Authorization Server. */
20
+ client_id: string;
21
+ /** Unique JWT identifier. */
22
+ jti: string;
23
+ /** Expiration time (JWT NumericDate, seconds since epoch). */
24
+ exp: number;
25
+ /** Issued-at time (JWT NumericDate, seconds since epoch). */
26
+ iat: number;
27
+ /** Subject identifier in an alternate namespace (optional). */
28
+ sub_id?: string;
29
+ /** Resource Server identifier (optional). */
30
+ resource?: string;
31
+ /** Space-separated scopes (optional). */
32
+ scope?: string;
33
+ /** RAR authorization objects (optional). */
34
+ authorization_details?: IdJagAuthorizationDetail[];
35
+ /** Actor claim (optional). Advisory only. */
36
+ act?: Record<string, unknown>;
37
+ /** Multi-tenant issuer tenant identifier (optional). Opaque context. */
38
+ tenant?: string;
39
+ /** End-User authentication time (optional). Opaque context. */
40
+ auth_time?: number;
41
+ /** Authentication Context Class Reference (optional). Opaque context. */
42
+ acr?: string;
43
+ /** Authentication methods (optional). Opaque context. */
44
+ amr?: string[];
45
+ /** Resource AS tenant identifier (optional). Opaque context. */
46
+ aud_tenant?: string;
47
+ /** Resource AS identifier for the End-User (optional). Opaque context, minimizable. */
48
+ aud_sub?: string;
49
+ /** End-User email (optional). Opaque context, minimizable. */
50
+ email?: string;
51
+ }
52
+ /** A Rich Authorization Request object. RAR is open; only recognized fields are read. */
53
+ export interface IdJagAuthorizationDetail {
54
+ type: string;
55
+ [key: string]: unknown;
56
+ }
57
+ /** The caller's statement that it verified the grant. The grant signature itself is the caller's responsibility, never this module's. */
58
+ export interface IdJagVerification {
59
+ /** Fixed: the caller asserts it verified the grant. */
60
+ status: 'caller_verified';
61
+ /** ISO 8601 time the caller performed verification. Required to form the signed attestation. */
62
+ verifiedAt?: string;
63
+ /** Optional identifier of the verifier (DID or URI). */
64
+ verifier?: string;
65
+ /** Optional kid the caller used to verify the grant. Recorded, never folded into a commitment as proof. */
66
+ kid?: string;
67
+ }
68
+ declare const VERIFIED_BRAND: unique symbol;
69
+ /**
70
+ * A grant the caller asserts it has verified, wrapped so an unverified grant is
71
+ * unrepresentable on the public path. Construct only via verifiedIdJagGrant().
72
+ */
73
+ export interface VerifiedIdJagGrant {
74
+ readonly [VERIFIED_BRAND]: true;
75
+ readonly grant: IdJagClaims;
76
+ readonly verification: IdJagVerification;
77
+ }
78
+ /** The committed preimage for sourceGrantRef. Provenance and binding target ONLY. Never scope, spend, chain, or receipt content. */
79
+ export interface SourceGrantRefPreimage {
80
+ tag: typeof SOURCE_GRANT_REF_TAG;
81
+ draft: string;
82
+ iss: string;
83
+ sub: string;
84
+ jti: string;
85
+ client_id: string;
86
+ aud: string;
87
+ resource?: string;
88
+ exp: number;
89
+ }
90
+ /** Marks the chain root as imported external trust, not an APS-native root. APS verification begins at the first APS-signed hop. */
91
+ export interface IdJagExternalRoot {
92
+ type: 'external_identity_assertion';
93
+ protocol: 'id-jag';
94
+ verifiedBy: 'caller';
95
+ }
96
+ /** aud plus resource, carried but NOT enforced by the binding. The relying party MUST reject a mismatch. */
97
+ export interface IdJagCarriedAudience {
98
+ enforcement: 'not_enforced_by_binding';
99
+ recipients: string[];
100
+ }
101
+ /** Literal-only reconciliation of the ID-JAG act claim against the APS chain leaf. Advisory, never authoritative. */
102
+ export interface IdJagActReconciliation {
103
+ status: 'absent' | 'same_literal_identifier' | 'different_literal_identifier_not_enforced' | 'not_comparable';
104
+ advisoryAct: Record<string, unknown> | null;
105
+ }
106
+ /** The caller-signed verification attestation. Sound by accountability (a keyed party on the hook), not by construction. */
107
+ export interface IdJagCallerVerification {
108
+ /** Existing-vocabulary signal record. provenance self_declared, verificationStatus declared (APS did not re-verify the grant). */
109
+ signal: AttestedSignal;
110
+ /** The exact signed message: "verified grant <sourceGrantRef> at <verifiedAt>". */
111
+ message: string;
112
+ /** The caller's signature over message, checkable under signerPublicKey. */
113
+ signature: string;
114
+ /** The caller's APS public key (the party on the hook). */
115
+ signerPublicKey: string;
116
+ /** ISO 8601 time the caller verified the grant. */
117
+ verifiedAt: string;
118
+ /** Optional kid the caller used. Recorded only. */
119
+ kid?: string;
120
+ }
121
+ /** A non-fatal observation made during projection (for example a unitless RAR amount that was not stamped). */
122
+ export interface IdJagDiagnostic {
123
+ code: 'UNITLESS_AMOUNT_NOT_STAMPED' | 'RAR_SCOPE_CONFLICT_NOT_APPLIED' | 'OPAQUE_RAR_CARRIED_IMMUTABLE';
124
+ detail: string;
125
+ }
126
+ /** Claims carried by reference with no APS narrowing meaning. */
127
+ export interface IdJagOpaqueContext {
128
+ tenant?: string;
129
+ aud_tenant?: string;
130
+ acr?: string;
131
+ amr?: string[];
132
+ auth_time?: number;
133
+ aud_sub?: string;
134
+ email?: string;
135
+ sub_id?: string;
136
+ }
137
+ /** Options for binding. Privacy minimization defaults OFF (public SDK; the draft asks to minimize sub_id). */
138
+ export interface IdJagBindOptions {
139
+ /** When true, email, sub_id, and aud_sub are omitted from carried context. Default false. */
140
+ minimizeSensitive?: boolean;
141
+ }
142
+ /**
143
+ * The binding descriptor. A pure projection of a verified ID-JAG grant onto the
144
+ * APS envelope, plus the APS-signed chain built under it. Two anchors are kept
145
+ * separate and never merged: delegationChainRoot is canonical chain content;
146
+ * sourceGrantRef is grant provenance.
147
+ */
148
+ export interface IdJagDescriptor {
149
+ /** Pinned ID-JAG draft identifier. */
150
+ draft: string;
151
+ /** Grant provenance hash over the committed preimage. NOT chain content. */
152
+ sourceGrantRef: string;
153
+ /** The committed preimage, so a verifier can recompute sourceGrantRef. */
154
+ sourceGrantRefPreimage: SourceGrantRefPreimage;
155
+ /** Canonical chain content hash over the APS-signed hops. NOT grant identity. */
156
+ delegationChainRoot: string;
157
+ /** The APS-signed delegation hops built under the imported grant. */
158
+ chain: Delegation[];
159
+ /** Root authority by reference (the End-User sub). Keyless. */
160
+ rootRef: DelegationRef;
161
+ /** Label marking the root as imported external trust. */
162
+ externalRoot: IdJagExternalRoot;
163
+ /** First delegate: the requesting client at the Resource AS (a reference). */
164
+ delegatedTo: string;
165
+ /** Projected APS scope baseline (from the scope claim). Lossy; see rawAuthorizationDetails. */
166
+ scope: string[];
167
+ /** The raw RAR objects, always preserved verbatim. */
168
+ rawAuthorizationDetails: IdJagAuthorizationDetail[];
169
+ /** True: the scope projection is lossy relative to authorization_details. */
170
+ projectionLossy: boolean;
171
+ /** Non-fatal projection observations. */
172
+ diagnostics: IdJagDiagnostic[];
173
+ /** Spend cap, set ONLY when a recognized RAR amount carries a currency. Never invented. */
174
+ spendLimit?: number;
175
+ /** Spend unit, set ONLY alongside a recognized spendLimit. Never invented, never 'unspecified'. */
176
+ spendLimitUnit?: 'currency' | 'invocations';
177
+ /** createdAt (ISO 8601) from iat. No notBefore: draft-04 has no nbf claim. */
178
+ createdAt: string;
179
+ /** expiresAt (ISO 8601) from exp. */
180
+ expiresAt: string;
181
+ /** aud plus resource, carried, not enforced by the binding. */
182
+ carriedAudience: IdJagCarriedAudience;
183
+ /** External state the binding does not check. */
184
+ externalState: {
185
+ revocation: 'not_checked_by_binding';
186
+ };
187
+ /** Literal-only act reconciliation. Advisory. */
188
+ actReconciliation: IdJagActReconciliation;
189
+ /** The caller-signed verification attestation. */
190
+ callerVerification: IdJagCallerVerification;
191
+ /** Claims carried by reference with no APS narrowing meaning. */
192
+ opaqueContext: IdJagOpaqueContext;
193
+ /** Honestly marks confirmation/sender-constraint material that is not carried. */
194
+ notCarried: {
195
+ cnf: 'not_carried';
196
+ dpop: 'not_carried';
197
+ };
198
+ }
199
+ /** The result of the soundness verifier. */
200
+ export interface IdJagVerifyResult {
201
+ /** Structural soundness: anchors recompute, attestation signature checks, no invented unit, draft pinned. */
202
+ ok: boolean;
203
+ /**
204
+ * Never a bare safe-for-execution boolean. When ok and external constraints
205
+ * (audience, revocation) are carried but unchecked, this reports
206
+ * structurally_valid_with_unchecked_external_constraints.
207
+ */
208
+ status: 'structurally_valid_with_unchecked_external_constraints' | 'unsound';
209
+ /** Per-check booleans. */
210
+ checks: {
211
+ draftPinned: boolean;
212
+ sourceGrantRefRecomputes: boolean;
213
+ sourceGrantRefPreimageScopeClean: boolean;
214
+ delegationChainRootRecomputes: boolean;
215
+ attestationSignatureValid: boolean;
216
+ audienceMarkedUnenforced: boolean;
217
+ noSilentSpendUnit: boolean;
218
+ };
219
+ /** Human-readable failures (empty when ok). */
220
+ failures: string[];
221
+ }
222
+ /** Error raised when a verified ID-JAG grant cannot be bound (missing required claim, missing verifiedAt). */
223
+ export declare class IdJagBindingError extends Error {
224
+ readonly code: string;
225
+ constructor(code: string, message: string);
226
+ }
227
+ export {};
228
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/adapters/oauth-id-jag/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAEhE,2FAA2F;AAC3F,eAAO,MAAM,WAAW,uDAAuD,CAAA;AAE/E,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,mCAAmC,CAAA;AAEpE;;;GAGG;AACH,MAAM,WAAW,WAAW;I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,CAAA;CACnB;AAED,8GAA8G;AAC9G,qBAAa,iBAAkB,SAAQ,KAAK;aACd,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI1D"}
@@ -0,0 +1,18 @@
1
+ // Copyright 2024-2026 Tymofii Pidlisnyi. Apache-2.0 license. See LICENSE.
2
+ // Types for the OAuth ID-JAG to APS delegation binding.
3
+ // Pinned to draft-ietf-oauth-identity-assertion-authz-grant-04 (2026-05-21).
4
+ // Stable APS semantics; draft-pinned external protocol semantics.
5
+ /** The pinned ID-JAG draft identifier. A version bump is a separate, deliberate change. */
6
+ export const IDJAG_DRAFT = 'draft-ietf-oauth-identity-assertion-authz-grant-04';
7
+ /** Domain-separation tag for the source-grant-ref commitment preimage. */
8
+ export const SOURCE_GRANT_REF_TAG = 'aps.id_jag.source_grant_ref.v1';
9
+ /** Error raised when a verified ID-JAG grant cannot be bound (missing required claim, missing verifiedAt). */
10
+ export class IdJagBindingError extends Error {
11
+ code;
12
+ constructor(code, message) {
13
+ super(message);
14
+ this.code = code;
15
+ this.name = 'IdJagBindingError';
16
+ }
17
+ }
18
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/adapters/oauth-id-jag/types.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wDAAwD;AACxD,6EAA6E;AAC7E,kEAAkE;AAMlE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,WAAW,GAAG,oDAAoD,CAAA;AAE/E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,gCAAgC,CAAA;AA2OpE,8GAA8G;AAC9G,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACd;IAA5B,YAA4B,IAAY,EAAE,OAAe;QACvD,KAAK,CAAC,OAAO,CAAC,CAAA;QADY,SAAI,GAAJ,IAAI,CAAQ;QAEtC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import type { IdJagDescriptor, IdJagVerifyResult } from './types.js';
2
+ /**
3
+ * Verify an ID-JAG binding descriptor for structural soundness. Recomputes
4
+ * delegationChainRoot over chain content and sourceGrantRef over its committed
5
+ * preimage, confirms the preimage carries only provenance and binding-target
6
+ * fields, confirms the caller attestation signature verifies under the caller
7
+ * key, confirms audience is marked unenforced, and confirms no spend unit was
8
+ * silently synthesized. Returns a status that never collapses unchecked external
9
+ * constraints into a safe-for-execution boolean.
10
+ */
11
+ export declare function verifyIdJagDescriptor(descriptor: IdJagDescriptor): IdJagVerifyResult;
12
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/adapters/oauth-id-jag/verify.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAOpE;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,eAAe,GAAG,iBAAiB,CAqDpF"}