tenzro-sdk 0.1.0 → 0.3.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 (172) hide show
  1. package/LICENSE +4 -15
  2. package/README.md +197 -4
  3. package/dist/adaptive-burn.d.ts +40 -0
  4. package/dist/adaptive-burn.d.ts.map +1 -0
  5. package/dist/adaptive-burn.js +53 -0
  6. package/dist/adaptive-burn.js.map +1 -0
  7. package/dist/agent.d.ts +127 -12
  8. package/dist/agent.d.ts.map +1 -1
  9. package/dist/agent.js +176 -15
  10. package/dist/agent.js.map +1 -1
  11. package/dist/ap2.d.ts +96 -0
  12. package/dist/ap2.d.ts.map +1 -1
  13. package/dist/ap2.js +65 -0
  14. package/dist/ap2.js.map +1 -1
  15. package/dist/app.js +5 -5
  16. package/dist/app.js.map +1 -1
  17. package/dist/auth.d.ts +394 -0
  18. package/dist/auth.d.ts.map +1 -0
  19. package/dist/auth.js +237 -0
  20. package/dist/auth.js.map +1 -0
  21. package/dist/bond.d.ts +70 -0
  22. package/dist/bond.d.ts.map +1 -0
  23. package/dist/bond.js +172 -0
  24. package/dist/bond.js.map +1 -0
  25. package/dist/cct.d.ts +53 -0
  26. package/dist/cct.d.ts.map +1 -0
  27. package/dist/cct.js +30 -0
  28. package/dist/cct.js.map +1 -0
  29. package/dist/client.d.ts +215 -2
  30. package/dist/client.d.ts.map +1 -1
  31. package/dist/client.js +295 -12
  32. package/dist/client.js.map +1 -1
  33. package/dist/cortex.d.ts +227 -0
  34. package/dist/cortex.d.ts.map +1 -0
  35. package/dist/cortex.js +137 -0
  36. package/dist/cortex.js.map +1 -0
  37. package/dist/custody.d.ts +251 -0
  38. package/dist/custody.d.ts.map +1 -1
  39. package/dist/custody.js +216 -0
  40. package/dist/custody.js.map +1 -1
  41. package/dist/eip6963.d.ts +63 -0
  42. package/dist/eip6963.d.ts.map +1 -0
  43. package/dist/eip6963.js +67 -0
  44. package/dist/eip6963.js.map +1 -0
  45. package/dist/eip7702.d.ts +110 -0
  46. package/dist/eip7702.d.ts.map +1 -0
  47. package/dist/eip7702.js +73 -0
  48. package/dist/eip7702.js.map +1 -0
  49. package/dist/erc7683.d.ts +79 -0
  50. package/dist/erc7683.d.ts.map +1 -0
  51. package/dist/erc7683.js +82 -0
  52. package/dist/erc7683.js.map +1 -0
  53. package/dist/erc8004.d.ts +97 -0
  54. package/dist/erc8004.d.ts.map +1 -0
  55. package/dist/erc8004.js +182 -0
  56. package/dist/erc8004.js.map +1 -0
  57. package/dist/events.d.ts +45 -15
  58. package/dist/events.d.ts.map +1 -1
  59. package/dist/events.js +38 -8
  60. package/dist/events.js.map +1 -1
  61. package/dist/identity.d.ts +16 -2
  62. package/dist/identity.d.ts.map +1 -1
  63. package/dist/identity.js +19 -1
  64. package/dist/identity.js.map +1 -1
  65. package/dist/index.d.ts +52 -6
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +83 -1
  68. package/dist/index.js.map +1 -1
  69. package/dist/insurance.d.ts +38 -0
  70. package/dist/insurance.d.ts.map +1 -0
  71. package/dist/insurance.js +51 -0
  72. package/dist/insurance.js.map +1 -0
  73. package/dist/iroh.d.ts +104 -0
  74. package/dist/iroh.d.ts.map +1 -0
  75. package/dist/iroh.js +102 -0
  76. package/dist/iroh.js.map +1 -0
  77. package/dist/lifecycle.d.ts +41 -0
  78. package/dist/lifecycle.d.ts.map +1 -0
  79. package/dist/lifecycle.js +56 -0
  80. package/dist/lifecycle.js.map +1 -0
  81. package/dist/marketplace.d.ts +30 -2
  82. package/dist/marketplace.d.ts.map +1 -1
  83. package/dist/marketplace.js +36 -2
  84. package/dist/marketplace.js.map +1 -1
  85. package/dist/memory.d.ts +78 -0
  86. package/dist/memory.d.ts.map +1 -0
  87. package/dist/memory.js +60 -0
  88. package/dist/memory.js.map +1 -0
  89. package/dist/multimodal.d.ts +294 -0
  90. package/dist/multimodal.d.ts.map +1 -0
  91. package/dist/multimodal.js +160 -0
  92. package/dist/multimodal.js.map +1 -0
  93. package/dist/passkey.d.ts +193 -0
  94. package/dist/passkey.d.ts.map +1 -0
  95. package/dist/passkey.js +481 -0
  96. package/dist/passkey.js.map +1 -0
  97. package/dist/payment.d.ts +14 -1
  98. package/dist/payment.d.ts.map +1 -1
  99. package/dist/payment.js +15 -0
  100. package/dist/payment.js.map +1 -1
  101. package/dist/principal-chain.d.ts +41 -0
  102. package/dist/principal-chain.d.ts.map +1 -0
  103. package/dist/principal-chain.js +56 -0
  104. package/dist/principal-chain.js.map +1 -0
  105. package/dist/provider.d.ts +7 -6
  106. package/dist/provider.d.ts.map +1 -1
  107. package/dist/provider.js +9 -6
  108. package/dist/provider.js.map +1 -1
  109. package/dist/quota.d.ts +54 -0
  110. package/dist/quota.d.ts.map +1 -0
  111. package/dist/quota.js +71 -0
  112. package/dist/quota.js.map +1 -0
  113. package/dist/rpc.d.ts +43 -4
  114. package/dist/rpc.d.ts.map +1 -1
  115. package/dist/rpc.js +110 -3
  116. package/dist/rpc.js.map +1 -1
  117. package/dist/seed-agent.d.ts +52 -0
  118. package/dist/seed-agent.d.ts.map +1 -0
  119. package/dist/seed-agent.js +69 -0
  120. package/dist/seed-agent.js.map +1 -0
  121. package/dist/settlement.d.ts +69 -10
  122. package/dist/settlement.d.ts.map +1 -1
  123. package/dist/settlement.js +220 -16
  124. package/dist/settlement.js.map +1 -1
  125. package/dist/signer.d.ts +181 -0
  126. package/dist/signer.d.ts.map +1 -0
  127. package/dist/signer.js +69 -0
  128. package/dist/signer.js.map +1 -0
  129. package/dist/sla.d.ts +95 -0
  130. package/dist/sla.d.ts.map +1 -0
  131. package/dist/sla.js +70 -0
  132. package/dist/sla.js.map +1 -0
  133. package/dist/snapshot.d.ts +122 -0
  134. package/dist/snapshot.d.ts.map +1 -0
  135. package/dist/snapshot.js +80 -0
  136. package/dist/snapshot.js.map +1 -0
  137. package/dist/staking.d.ts +5 -5
  138. package/dist/staking.d.ts.map +1 -1
  139. package/dist/staking.js +8 -6
  140. package/dist/staking.js.map +1 -1
  141. package/dist/streaming.js.map +1 -1
  142. package/dist/svm-cross-vm.d.ts +109 -0
  143. package/dist/svm-cross-vm.d.ts.map +1 -0
  144. package/dist/svm-cross-vm.js +215 -0
  145. package/dist/svm-cross-vm.js.map +1 -0
  146. package/dist/task.d.ts +56 -22
  147. package/dist/task.d.ts.map +1 -1
  148. package/dist/task.js +65 -31
  149. package/dist/task.js.map +1 -1
  150. package/dist/token.d.ts +41 -11
  151. package/dist/token.d.ts.map +1 -1
  152. package/dist/token.js.map +1 -1
  153. package/dist/training.d.ts +108 -0
  154. package/dist/training.d.ts.map +1 -0
  155. package/dist/training.js +53 -0
  156. package/dist/training.js.map +1 -0
  157. package/dist/types.d.ts +247 -17
  158. package/dist/types.d.ts.map +1 -1
  159. package/dist/types.js.map +1 -1
  160. package/dist/validator.d.ts +76 -0
  161. package/dist/validator.d.ts.map +1 -0
  162. package/dist/validator.js +47 -0
  163. package/dist/validator.js.map +1 -0
  164. package/dist/wallet.d.ts +26 -9
  165. package/dist/wallet.d.ts.map +1 -1
  166. package/dist/wallet.js +34 -19
  167. package/dist/wallet.js.map +1 -1
  168. package/dist/wormhole.d.ts +76 -0
  169. package/dist/wormhole.d.ts.map +1 -0
  170. package/dist/wormhole.js +56 -0
  171. package/dist/wormhole.js.map +1 -0
  172. package/package.json +3 -2
package/dist/auth.d.ts ADDED
@@ -0,0 +1,394 @@
1
+ import { RpcClient } from "./rpc";
2
+ /**
3
+ * Client for OAuth 2.1 + DPoP onboarding RPCs.
4
+ *
5
+ * Onboarding uses OAuth 2.1 (RFC 6749 successor) + DPoP-bound JWTs
6
+ * (RFC 9449) + Rich Authorization Requests (RFC 9396). Participants —
7
+ * humans, delegated agents under a human controller, and fully autonomous
8
+ * agents — onboard via the three RPCs exposed here. Each call provisions
9
+ * a TDIP identity (+ MPC wallet) and returns a JWT bound to a
10
+ * holder-supplied DPoP `jkt` (RFC 7638 thumbprint of the holder's
11
+ * Ed25519 public key).
12
+ *
13
+ * Subsequent privileged calls (sign + send transaction, escrow create,
14
+ * release/refund, etc.) authenticate by sending the JWT in the
15
+ * `Authorization: DPoP <jwt>` header alongside a per-request DPoP proof
16
+ * in the `DPoP` header. The SDK forwards both headers automatically when
17
+ * the `TENZRO_BEARER_JWT` and `TENZRO_DPOP_PROOF` environment variables
18
+ * are set in Node — see {@link RpcClient} for the transport-level wiring.
19
+ */
20
+ export declare class AuthClient {
21
+ private rpc;
22
+ constructor(rpc: RpcClient);
23
+ /**
24
+ * Onboard a new **human** participant — provisions a TDIP `did:tenzro:human:*`
25
+ * identity, a fresh MPC wallet, and returns an OAuth 2.1 access token.
26
+ *
27
+ * @param displayName - human-readable label surfaced in approver UIs
28
+ * @param dpopJkt - optional RFC 7638 JWK thumbprint of the holder's
29
+ * Ed25519 public key. If supplied, the issued JWT is DPoP-bound to
30
+ * that key and every subsequent privileged call must accompany the
31
+ * bearer with a fresh DPoP proof signed by the same key. Strongly
32
+ * recommended.
33
+ */
34
+ onboardHuman(displayName: string, dpopJkt?: string): Promise<OnboardSession>;
35
+ /**
36
+ * Onboard a **delegated agent** that acts on behalf of an existing
37
+ * `controllerDid` (typically a human). The agent inherits the
38
+ * controller's act-chain and is bounded by `delegationScope`.
39
+ *
40
+ * Revoking the controller DID via {@link revokeDid} cascades and
41
+ * invalidates this agent's token automatically.
42
+ */
43
+ onboardDelegatedAgent(controllerDid: string, capabilities: string[], delegationScope: unknown, dpopJkt?: string): Promise<OnboardSession>;
44
+ /**
45
+ * Onboard a **fully autonomous agent**. Unlike a delegated agent, this
46
+ * has no human controller — instead the agent must post a TNZO bond
47
+ * (slashable on misbehaviour) at `bondFundingAddress` before
48
+ * onboarding succeeds.
49
+ */
50
+ onboardAutonomousAgent(bondFundingAddress: string, dpopJkt?: string): Promise<OnboardSession>;
51
+ /**
52
+ * Exchange a long-lived refresh token for a fresh access token. Mirrors
53
+ * OAuth 2.1 `grant_type=refresh_token`. Refresh tokens are opaque UUIDs
54
+ * with a 30-day TTL; access tokens are HS256 JWTs with a 1-hour TTL.
55
+ *
56
+ * If `dpopJkt` is supplied, the new access token is DPoP-bound to that
57
+ * thumbprint. The refresh token itself is **not** rotated in V1.
58
+ */
59
+ refreshToken(refreshToken: string, dpopJkt?: string): Promise<RefreshedToken>;
60
+ /**
61
+ * Mint a fresh access + refresh token pair against an existing MPC
62
+ * wallet. Useful when the holder already provisioned a wallet via
63
+ * `tenzro_createWallet` and now wants OAuth-style auth credentials
64
+ * without re-running the full onboarding flow.
65
+ *
66
+ * Returns the same shape as the three onboard variants —
67
+ * {@link OnboardSession} — so it slots into existing session-management
68
+ * code.
69
+ */
70
+ linkWalletForAuth(walletId: string, options?: {
71
+ dpopJkt?: string;
72
+ displayName?: string;
73
+ ttlSecs?: number;
74
+ }): Promise<OnboardSession>;
75
+ /**
76
+ * Revoke a single JWT by its `jti` claim. The token is added to the
77
+ * engine's revocation set and any subsequent validation fails.
78
+ */
79
+ revokeJwt(jti: string, reason?: string): Promise<RevokeResponse>;
80
+ /**
81
+ * Revoke an entire identity by DID. Every JWT minted under this DID
82
+ * (and every descendant DID in the act-chain) is invalidated
83
+ * transitively.
84
+ */
85
+ revokeDid(did: string, reason?: string): Promise<RevokeResponse>;
86
+ /**
87
+ * TDIP/GDPR Article 17 right-to-erasure. Hard-deletes a previously
88
+ * revoked identity from the registry and persistent storage.
89
+ *
90
+ * The identity MUST already be `Revoked` — call {@link revokeDid} first,
91
+ * allow the cascading revocation broadcaster to propagate, and then
92
+ * call this. Distinct from `revokeDid` which is a logical delete.
93
+ */
94
+ forgetIdentity(did: string): Promise<{
95
+ did: string;
96
+ status: string;
97
+ note: string;
98
+ }>;
99
+ /**
100
+ * List approvals in `Pending` status for the given approver DID.
101
+ * Returns the records the approver should review and decide on.
102
+ */
103
+ listPendingApprovals(approverDid: string): Promise<PendingApprovals>;
104
+ /**
105
+ * Decide a pending approval — either `"approved"` or `"denied"`. Only
106
+ * the recorded approver DID may decide; mismatched approvers are
107
+ * rejected with JSON-RPC error code `-32001` (forbidden).
108
+ */
109
+ decideApproval(approvalId: string, decision: "approved" | "denied", approverDid: string): Promise<ApprovalDecision>;
110
+ /**
111
+ * Fetch a single approval record by id. The engine lazy-transitions
112
+ * an expired `Pending` record to `Expired` on this read path, so a
113
+ * returned `Pending` record is guaranteed to still be live. Returns
114
+ * JSON-RPC `-32000` if the id is unknown.
115
+ */
116
+ getApproval(approvalId: string): Promise<ApprovalRecord>;
117
+ /**
118
+ * **RFC 8693 OAuth 2.0 Token Exchange.** Exchange a parent JWT for a
119
+ * narrower child JWT bound to a different DPoP key, with a strictly
120
+ * subset of the parent's RAR grants and AAP capabilities. The child
121
+ * token's `controller_did` is set to the parent's `sub`, extending the
122
+ * act-chain by one hop.
123
+ *
124
+ * Subset enforcement is performed by the AS — `requestedRar` and
125
+ * `requestedAapCapabilities` must be a strict subset of what the parent
126
+ * already holds. Anything outside the parent's authority is rejected
127
+ * with JSON-RPC error code `-32002`.
128
+ *
129
+ * @param subjectToken - the parent JWT (validated for signature, exp,
130
+ * and revocation by the AS)
131
+ * @param childBearerDid - DID that will be the `sub` of the child JWT
132
+ * @param childDpopJkt - RFC 7638 JWK thumbprint of the child holder's
133
+ * Ed25519 public key. The child token will be DPoP-bound to it.
134
+ * @param requestedRar - typed scope envelope (RFC 9396) the child should
135
+ * carry. Must be a subset of the parent's `authorization_details`.
136
+ * @param requestedAapCapabilities - AAP `aap_capabilities` claim list.
137
+ * Must be a subset of the parent's capabilities.
138
+ * @param requestedTtlSecs - optional override; clamped to the engine's
139
+ * `max_ttl_secs` and parent's remaining lifetime.
140
+ */
141
+ exchangeToken(subjectToken: string, childBearerDid: string, childDpopJkt: string, requestedRar: unknown, requestedAapCapabilities: unknown[], requestedTtlSecs?: number): Promise<TokenExchangeResult>;
142
+ /**
143
+ * **RFC 7662 OAuth 2.0 Token Introspection.** Ask the AS whether a
144
+ * token is currently active and, if so, return its full claim set
145
+ * (RAR, AAP, cnf, controller_did, etc.). Per RFC 7662 §2.2 a failed
146
+ * validation returns `{ active: false }` with no other fields — the AS
147
+ * deliberately does not leak why the token is inactive.
148
+ *
149
+ * Use this from a downstream resource server that wants to validate a
150
+ * bearer token without re-implementing JWT signature checking.
151
+ */
152
+ introspectToken(token: string): Promise<IntrospectionResult>;
153
+ /**
154
+ * **RFC 8414 / RFC 9728 OAuth Authorization Server / Protected Resource
155
+ * Metadata.** Returns the same metadata document the AS publishes at
156
+ * `GET /.well-known/openid-configuration`. Useful for JSON-RPC-only
157
+ * clients (CLI, agents) that don't want to also speak HTTP discovery.
158
+ */
159
+ oauthDiscovery(): Promise<OAuthDiscovery>;
160
+ }
161
+ /**
162
+ * One of the three onboarding RPCs (or `linkWalletForAuth`) returns this
163
+ * session bundle.
164
+ */
165
+ export interface OnboardSession {
166
+ /** Provisioned TDIP identity record. */
167
+ identity: unknown;
168
+ /** Provisioned MPC wallet record (id + address). */
169
+ wallet: unknown;
170
+ /**
171
+ * OAuth 2.1 access token (HS256 JWT, optionally DPoP-bound). Send as
172
+ * `Authorization: Bearer <token>` on subsequent privileged calls. When
173
+ * DPoP-bound, also send a fresh `DPoP: <proof>` header.
174
+ */
175
+ access_token: string;
176
+ /** Always `"Bearer"` (RFC 6750 token type, even though DPoP-bound). */
177
+ token_type?: string;
178
+ /** Access-token lifetime in seconds (default 3600). */
179
+ expires_in?: number;
180
+ /**
181
+ * Long-lived refresh token (opaque UUID, 30-day TTL). Exchange via
182
+ * {@link AuthClient.refreshToken} when the access token expires. Treat
183
+ * as a secret — leakage allows minting access tokens until revocation.
184
+ */
185
+ refresh_token?: string;
186
+ /** Refresh-token lifetime in seconds (default 30 days). */
187
+ refresh_token_expires_in?: number;
188
+ /** `true` iff the access token requires a DPoP proof on every call. */
189
+ dpop_bound?: boolean;
190
+ /**
191
+ * RFC 9396 Rich Authorization Request payload echoed back, describing
192
+ * the act-chain and capabilities the token is authorized for.
193
+ */
194
+ authorization_details?: unknown;
195
+ }
196
+ /**
197
+ * Result of {@link AuthClient.refreshToken}. The refresh token is **not**
198
+ * rotated in V1 — only the access token changes.
199
+ */
200
+ export interface RefreshedToken {
201
+ /** New access-token JWT. */
202
+ access_token: string;
203
+ /** Always `"Bearer"`. */
204
+ token_type?: string;
205
+ /** Access-token lifetime in seconds. */
206
+ expires_in?: number;
207
+ /**
208
+ * `true` iff the new access token is DPoP-bound (i.e., the request
209
+ * supplied `dpopJkt` and the engine encoded a `cnf.jkt` claim).
210
+ */
211
+ dpop_bound?: boolean;
212
+ }
213
+ /** Result of `revokeJwt` / `revokeDid`. */
214
+ export interface RevokeResponse {
215
+ /** Engine status string — typically `"revoked"`. */
216
+ status?: string;
217
+ /** Number of JTIs invalidated by this call (>1 indicates cascade). */
218
+ affected_jti_count?: number;
219
+ }
220
+ /** Result of `listPendingApprovals`. */
221
+ export interface PendingApprovals {
222
+ /** Number of pending records returned. */
223
+ count?: number;
224
+ /**
225
+ * The records themselves — opaque JSON to keep the SDK decoupled
226
+ * from `tenzro-auth` storage internals.
227
+ */
228
+ pending?: unknown[];
229
+ }
230
+ /** Result of `decideApproval`. */
231
+ export interface ApprovalDecision {
232
+ /** New status — `"Approved"` or `"Denied"`. */
233
+ status?: string;
234
+ /** Echo of the approval id. */
235
+ approval_id?: string;
236
+ }
237
+ /**
238
+ * Result of `getApproval` — a single approval record. Matches the wire
239
+ * shape produced by `approval_to_json` in `tenzro-node`.
240
+ */
241
+ export interface ApprovalRecord {
242
+ /** Engine-assigned unique identifier for this approval. */
243
+ approval_id?: string;
244
+ /** DID that initiated the request and is waiting on a decision. */
245
+ requester_did?: string;
246
+ /** DID that must approve or deny the request. */
247
+ approver_did?: string;
248
+ /** Creation time (Unix epoch, ms). */
249
+ created_at_ms?: number;
250
+ /**
251
+ * Hard expiry — past this point the engine lazy-transitions the
252
+ * record to `Expired` on the next read.
253
+ */
254
+ expires_at_ms?: number;
255
+ /**
256
+ * Lifecycle state as a debug-printed enum string
257
+ * (`"Pending"` / `"Approved"` / `"Denied"` / `"Expired"`).
258
+ */
259
+ status?: string;
260
+ /** Decision timestamp (Unix epoch, ms). `null`/absent while pending. */
261
+ decided_at_ms?: number | null;
262
+ /** Short human-readable summary of the request. */
263
+ summary?: string;
264
+ /** Action identifier (free-form, e.g. `"wallet.transfer"`). */
265
+ action?: string;
266
+ }
267
+ /**
268
+ * Result of {@link AuthClient.exchangeToken} — the issued child JWT and
269
+ * its delegation envelope per RFC 8693 §2.2.
270
+ */
271
+ export interface TokenExchangeResult {
272
+ /** The newly-issued child JWT (HS256, DPoP-bound to `child_dpop_jkt`). */
273
+ access_token: string;
274
+ /** Lifetime of the child token in seconds. */
275
+ expires_in: number;
276
+ /** Always `"DPoP"` — child tokens are always DPoP-bound (RFC 9449). */
277
+ token_type: string;
278
+ /**
279
+ * Always `"urn:ietf:params:oauth:token-type:jwt"` — the format of the
280
+ * issued token (RFC 8693 §2.2).
281
+ */
282
+ issued_token_type: string;
283
+ /**
284
+ * Echo of the delegation envelope: `{ controller_did, depth, … }`. The
285
+ * exact shape is defined by `tenzro_auth::TokenExchangeOutcome` — kept
286
+ * as opaque JSON in the SDK to avoid recapitulating every AAP claim
287
+ * type.
288
+ */
289
+ delegation: unknown;
290
+ }
291
+ /**
292
+ * Result of {@link AuthClient.introspectToken} — the RFC 7662 §2.2
293
+ * introspection response. When `active` is `false`, all other fields are
294
+ * absent (the AS does not leak why the token is inactive).
295
+ *
296
+ * The full claim set (RAR `authorization_details`, AAP `aap_*` claims,
297
+ * `cnf`, `controller_did`, etc.) is returned as flat JSON properties to
298
+ * keep the SDK decoupled from `tenzro-auth` internals — callers that
299
+ * need typed access can narrow the fields themselves.
300
+ */
301
+ export interface IntrospectionResult {
302
+ /**
303
+ * `true` iff the token validates and its controller chain is not
304
+ * revoked.
305
+ */
306
+ active: boolean;
307
+ /** Subject — bearer DID. Present iff `active`. */
308
+ sub?: string;
309
+ /** Issuer — node DID. Present iff `active`. */
310
+ iss?: string;
311
+ /** Audience — typically the resource server URL. Present iff `active`. */
312
+ aud?: string;
313
+ /** Issued-at, Unix seconds. Present iff `active`. */
314
+ iat?: number;
315
+ /** Not-before, Unix seconds. Present iff `active`. */
316
+ nbf?: number;
317
+ /** Expires-at, Unix seconds. Present iff `active`. */
318
+ exp?: number;
319
+ /** JWT id. Present iff `active`. */
320
+ jti?: string;
321
+ /** `"DPoP"` for tokens with a `cnf.jkt`; absent otherwise. */
322
+ token_type?: string;
323
+ /**
324
+ * RFC 7800 confirmation claim — `{ jkt: "<thumbprint>" }` for
325
+ * DPoP-bound tokens.
326
+ */
327
+ cnf?: {
328
+ jkt: string;
329
+ };
330
+ /** The authorizing DID (parent of `sub` in the act-chain). */
331
+ controller_did?: string;
332
+ /** RFC 9396 typed scope envelope. */
333
+ authorization_details?: unknown;
334
+ /** AAP claims — present only when set on the token. */
335
+ aap_agent?: unknown;
336
+ aap_task?: unknown;
337
+ aap_capabilities?: unknown;
338
+ aap_oversight?: unknown;
339
+ aap_delegation?: unknown;
340
+ aap_context?: unknown;
341
+ aap_audit?: unknown;
342
+ }
343
+ /**
344
+ * Result of {@link AuthClient.oauthDiscovery} — the OAuth 2.0
345
+ * authorization-server metadata document (RFC 8414) augmented with the
346
+ * AAP-specific extensions.
347
+ *
348
+ * Mirrors the document published at
349
+ * `GET /.well-known/openid-configuration` on the AS.
350
+ */
351
+ export interface OAuthDiscovery {
352
+ /** Issuer DID — typically `did:tenzro:node:<node_id>`. */
353
+ issuer: string;
354
+ /**
355
+ * `POST` endpoint for authorization-code, refresh-token, and
356
+ * token-exchange grants.
357
+ */
358
+ token_endpoint: string;
359
+ /** `POST` endpoint for RFC 7662 token introspection. */
360
+ introspection_endpoint: string;
361
+ /** `POST` endpoint for RFC 7009 token revocation. */
362
+ revocation_endpoint: string;
363
+ /**
364
+ * All grant types the AS accepts. Includes
365
+ * `urn:ietf:params:oauth:grant-type:token-exchange`,
366
+ * `authorization_code`, and `refresh_token`.
367
+ */
368
+ grant_types_supported: string[];
369
+ /**
370
+ * Authentication methods at the token endpoint (`"none"` for public
371
+ * clients, `"private_key_jwt"`).
372
+ */
373
+ token_endpoint_auth_methods_supported: string[];
374
+ /** Authorization-code response types — currently `["code"]`. */
375
+ response_types_supported: string[];
376
+ /**
377
+ * DPoP signing algorithms accepted on proofs — currently `["EdDSA"]`
378
+ * (Ed25519 per RFC 8037).
379
+ */
380
+ dpop_signing_alg_values_supported: string[];
381
+ /**
382
+ * RFC 9396 RAR `type` values the AS recognises: `transfer`,
383
+ * `create_escrow`, `discharge_escrow`, `inference`, `stake`, `vote`,
384
+ * `contract`, `register_identity`.
385
+ */
386
+ authorization_details_types_supported: string[];
387
+ /**
388
+ * AAP claim names the AS issues — `aap_agent`, `aap_task`,
389
+ * `aap_capabilities`, `aap_oversight`, `aap_delegation`, `aap_context`,
390
+ * `aap_audit`.
391
+ */
392
+ aap_claims_supported: string[];
393
+ }
394
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,UAAU;IACT,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAElC;;;;;;;;;;OAUG;IACG,YAAY,CAChB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC;IAM1B;;;;;;;OAOG;IACG,qBAAqB,CACzB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EAAE,EACtB,eAAe,EAAE,OAAO,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC;IAa1B;;;;;OAKG;IACG,sBAAsB,CAC1B,kBAAkB,EAAE,MAAM,EAC1B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC;IAW1B;;;;;;;OAOG;IACG,YAAY,CAChB,YAAY,EAA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object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthClient = void 0;
4
+ /**
5
+ * Client for OAuth 2.1 + DPoP onboarding RPCs.
6
+ *
7
+ * Onboarding uses OAuth 2.1 (RFC 6749 successor) + DPoP-bound JWTs
8
+ * (RFC 9449) + Rich Authorization Requests (RFC 9396). Participants —
9
+ * humans, delegated agents under a human controller, and fully autonomous
10
+ * agents — onboard via the three RPCs exposed here. Each call provisions
11
+ * a TDIP identity (+ MPC wallet) and returns a JWT bound to a
12
+ * holder-supplied DPoP `jkt` (RFC 7638 thumbprint of the holder's
13
+ * Ed25519 public key).
14
+ *
15
+ * Subsequent privileged calls (sign + send transaction, escrow create,
16
+ * release/refund, etc.) authenticate by sending the JWT in the
17
+ * `Authorization: DPoP <jwt>` header alongside a per-request DPoP proof
18
+ * in the `DPoP` header. The SDK forwards both headers automatically when
19
+ * the `TENZRO_BEARER_JWT` and `TENZRO_DPOP_PROOF` environment variables
20
+ * are set in Node — see {@link RpcClient} for the transport-level wiring.
21
+ */
22
+ class AuthClient {
23
+ rpc;
24
+ constructor(rpc) {
25
+ this.rpc = rpc;
26
+ }
27
+ /**
28
+ * Onboard a new **human** participant — provisions a TDIP `did:tenzro:human:*`
29
+ * identity, a fresh MPC wallet, and returns an OAuth 2.1 access token.
30
+ *
31
+ * @param displayName - human-readable label surfaced in approver UIs
32
+ * @param dpopJkt - optional RFC 7638 JWK thumbprint of the holder's
33
+ * Ed25519 public key. If supplied, the issued JWT is DPoP-bound to
34
+ * that key and every subsequent privileged call must accompany the
35
+ * bearer with a fresh DPoP proof signed by the same key. Strongly
36
+ * recommended.
37
+ */
38
+ async onboardHuman(displayName, dpopJkt) {
39
+ const params = { display_name: displayName };
40
+ if (dpopJkt)
41
+ params.dpop_jkt = dpopJkt;
42
+ return this.rpc.call("tenzro_onboardHuman", params);
43
+ }
44
+ /**
45
+ * Onboard a **delegated agent** that acts on behalf of an existing
46
+ * `controllerDid` (typically a human). The agent inherits the
47
+ * controller's act-chain and is bounded by `delegationScope`.
48
+ *
49
+ * Revoking the controller DID via {@link revokeDid} cascades and
50
+ * invalidates this agent's token automatically.
51
+ */
52
+ async onboardDelegatedAgent(controllerDid, capabilities, delegationScope, dpopJkt) {
53
+ const params = {
54
+ controller_did: controllerDid,
55
+ capabilities,
56
+ delegation_scope: delegationScope,
57
+ };
58
+ if (dpopJkt)
59
+ params.dpop_jkt = dpopJkt;
60
+ return this.rpc.call("tenzro_onboardDelegatedAgent", params);
61
+ }
62
+ /**
63
+ * Onboard a **fully autonomous agent**. Unlike a delegated agent, this
64
+ * has no human controller — instead the agent must post a TNZO bond
65
+ * (slashable on misbehaviour) at `bondFundingAddress` before
66
+ * onboarding succeeds.
67
+ */
68
+ async onboardAutonomousAgent(bondFundingAddress, dpopJkt) {
69
+ const params = {
70
+ bond_funding_address: bondFundingAddress,
71
+ };
72
+ if (dpopJkt)
73
+ params.dpop_jkt = dpopJkt;
74
+ return this.rpc.call("tenzro_onboardAutonomousAgent", params);
75
+ }
76
+ /**
77
+ * Exchange a long-lived refresh token for a fresh access token. Mirrors
78
+ * OAuth 2.1 `grant_type=refresh_token`. Refresh tokens are opaque UUIDs
79
+ * with a 30-day TTL; access tokens are HS256 JWTs with a 1-hour TTL.
80
+ *
81
+ * If `dpopJkt` is supplied, the new access token is DPoP-bound to that
82
+ * thumbprint. The refresh token itself is **not** rotated in V1.
83
+ */
84
+ async refreshToken(refreshToken, dpopJkt) {
85
+ const params = { refresh_token: refreshToken };
86
+ if (dpopJkt)
87
+ params.dpop_jkt = dpopJkt;
88
+ return this.rpc.call("tenzro_refreshToken", params);
89
+ }
90
+ /**
91
+ * Mint a fresh access + refresh token pair against an existing MPC
92
+ * wallet. Useful when the holder already provisioned a wallet via
93
+ * `tenzro_createWallet` and now wants OAuth-style auth credentials
94
+ * without re-running the full onboarding flow.
95
+ *
96
+ * Returns the same shape as the three onboard variants —
97
+ * {@link OnboardSession} — so it slots into existing session-management
98
+ * code.
99
+ */
100
+ async linkWalletForAuth(walletId, options) {
101
+ const params = { wallet_id: walletId };
102
+ if (options?.dpopJkt)
103
+ params.dpop_jkt = options.dpopJkt;
104
+ if (options?.displayName)
105
+ params.display_name = options.displayName;
106
+ if (options?.ttlSecs)
107
+ params.ttl_secs = options.ttlSecs;
108
+ return this.rpc.call("tenzro_linkWalletForAuth", params);
109
+ }
110
+ /**
111
+ * Revoke a single JWT by its `jti` claim. The token is added to the
112
+ * engine's revocation set and any subsequent validation fails.
113
+ */
114
+ async revokeJwt(jti, reason) {
115
+ return this.rpc.call("tenzro_revokeJwt", {
116
+ jti,
117
+ reason: reason ?? "revoked via SDK",
118
+ });
119
+ }
120
+ /**
121
+ * Revoke an entire identity by DID. Every JWT minted under this DID
122
+ * (and every descendant DID in the act-chain) is invalidated
123
+ * transitively.
124
+ */
125
+ async revokeDid(did, reason) {
126
+ return this.rpc.call("tenzro_revokeDid", {
127
+ did,
128
+ reason: reason ?? "revoked via SDK",
129
+ });
130
+ }
131
+ /**
132
+ * TDIP/GDPR Article 17 right-to-erasure. Hard-deletes a previously
133
+ * revoked identity from the registry and persistent storage.
134
+ *
135
+ * The identity MUST already be `Revoked` — call {@link revokeDid} first,
136
+ * allow the cascading revocation broadcaster to propagate, and then
137
+ * call this. Distinct from `revokeDid` which is a logical delete.
138
+ */
139
+ async forgetIdentity(did) {
140
+ return this.rpc.call("tenzro_forgetIdentity", { did });
141
+ }
142
+ /**
143
+ * List approvals in `Pending` status for the given approver DID.
144
+ * Returns the records the approver should review and decide on.
145
+ */
146
+ async listPendingApprovals(approverDid) {
147
+ return this.rpc.call("tenzro_listPendingApprovals", {
148
+ approver_did: approverDid,
149
+ });
150
+ }
151
+ /**
152
+ * Decide a pending approval — either `"approved"` or `"denied"`. Only
153
+ * the recorded approver DID may decide; mismatched approvers are
154
+ * rejected with JSON-RPC error code `-32001` (forbidden).
155
+ */
156
+ async decideApproval(approvalId, decision, approverDid) {
157
+ return this.rpc.call("tenzro_decideApproval", {
158
+ approval_id: approvalId,
159
+ decision,
160
+ approver_did: approverDid,
161
+ });
162
+ }
163
+ /**
164
+ * Fetch a single approval record by id. The engine lazy-transitions
165
+ * an expired `Pending` record to `Expired` on this read path, so a
166
+ * returned `Pending` record is guaranteed to still be live. Returns
167
+ * JSON-RPC `-32000` if the id is unknown.
168
+ */
169
+ async getApproval(approvalId) {
170
+ return this.rpc.call("tenzro_getApproval", {
171
+ approval_id: approvalId,
172
+ });
173
+ }
174
+ /**
175
+ * **RFC 8693 OAuth 2.0 Token Exchange.** Exchange a parent JWT for a
176
+ * narrower child JWT bound to a different DPoP key, with a strictly
177
+ * subset of the parent's RAR grants and AAP capabilities. The child
178
+ * token's `controller_did` is set to the parent's `sub`, extending the
179
+ * act-chain by one hop.
180
+ *
181
+ * Subset enforcement is performed by the AS — `requestedRar` and
182
+ * `requestedAapCapabilities` must be a strict subset of what the parent
183
+ * already holds. Anything outside the parent's authority is rejected
184
+ * with JSON-RPC error code `-32002`.
185
+ *
186
+ * @param subjectToken - the parent JWT (validated for signature, exp,
187
+ * and revocation by the AS)
188
+ * @param childBearerDid - DID that will be the `sub` of the child JWT
189
+ * @param childDpopJkt - RFC 7638 JWK thumbprint of the child holder's
190
+ * Ed25519 public key. The child token will be DPoP-bound to it.
191
+ * @param requestedRar - typed scope envelope (RFC 9396) the child should
192
+ * carry. Must be a subset of the parent's `authorization_details`.
193
+ * @param requestedAapCapabilities - AAP `aap_capabilities` claim list.
194
+ * Must be a subset of the parent's capabilities.
195
+ * @param requestedTtlSecs - optional override; clamped to the engine's
196
+ * `max_ttl_secs` and parent's remaining lifetime.
197
+ */
198
+ async exchangeToken(subjectToken, childBearerDid, childDpopJkt, requestedRar, requestedAapCapabilities, requestedTtlSecs) {
199
+ const params = {
200
+ subject_token: subjectToken,
201
+ child_bearer_did: childBearerDid,
202
+ child_dpop_jkt: childDpopJkt,
203
+ requested_rar: requestedRar,
204
+ requested_aap_capabilities: requestedAapCapabilities,
205
+ };
206
+ if (requestedTtlSecs !== undefined) {
207
+ params.requested_ttl_secs = requestedTtlSecs;
208
+ }
209
+ return this.rpc.call("tenzro_exchangeToken", params);
210
+ }
211
+ /**
212
+ * **RFC 7662 OAuth 2.0 Token Introspection.** Ask the AS whether a
213
+ * token is currently active and, if so, return its full claim set
214
+ * (RAR, AAP, cnf, controller_did, etc.). Per RFC 7662 §2.2 a failed
215
+ * validation returns `{ active: false }` with no other fields — the AS
216
+ * deliberately does not leak why the token is inactive.
217
+ *
218
+ * Use this from a downstream resource server that wants to validate a
219
+ * bearer token without re-implementing JWT signature checking.
220
+ */
221
+ async introspectToken(token) {
222
+ return this.rpc.call("tenzro_introspectToken", {
223
+ token,
224
+ });
225
+ }
226
+ /**
227
+ * **RFC 8414 / RFC 9728 OAuth Authorization Server / Protected Resource
228
+ * Metadata.** Returns the same metadata document the AS publishes at
229
+ * `GET /.well-known/openid-configuration`. Useful for JSON-RPC-only
230
+ * clients (CLI, agents) that don't want to also speak HTTP discovery.
231
+ */
232
+ async oauthDiscovery() {
233
+ return this.rpc.call("tenzro_oauthDiscovery", []);
234
+ }
235
+ }
236
+ exports.AuthClient = AuthClient;
237
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,UAAU;IACD;IAApB,YAAoB,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAEtC;;;;;;;;;;OAUG;IACH,KAAK,CAAC,YAAY,CAChB,WAAmB,EACnB,OAAgB;QAEhB,MAAM,MAAM,GAA4B,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;QACtE,IAAI,OAAO;YAAE,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC;QACvC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAiB,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;OAOG;IAC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