@agents24/client 0.2.0 → 0.2.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.
package/dist/index.js CHANGED
@@ -1,558 +1,6 @@
1
- export { createAgents24Client } from './chunk-QAIOKNUK.js';
2
- import { defaultClock, defaultIds, resolveEncoder, canonicalHtu, Agents24ClientError, missingCapability, normalizeBaseUrl, resolveFetch, dpopTokenRequest, absoluteUrl, encodePath, responseError, responseJson, AuthenticatedHttp } from './chunk-SCZMUBXD.js';
3
- export { Agents24ClientError, createByteMultipartEncoder } from './chunk-SCZMUBXD.js';
4
- import './chunk-NGZUJ3YT.js';
5
-
6
- // src/base64url.ts
7
- function base64UrlEncode(bytes) {
8
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
9
- let output = "";
10
- for (let index = 0; index < bytes.length; index += 3) {
11
- const first = bytes[index] ?? 0;
12
- const second = bytes[index + 1];
13
- const third = bytes[index + 2];
14
- const packed = first << 16 | (second ?? 0) << 8 | (third ?? 0);
15
- output += alphabet[packed >>> 18 & 63];
16
- output += alphabet[packed >>> 12 & 63];
17
- output += second === void 0 ? "=" : alphabet[packed >>> 6 & 63];
18
- output += third === void 0 ? "=" : alphabet[packed & 63];
19
- }
20
- return output.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
21
- }
22
-
23
- // src/dpop.ts
24
- function resolveCrypto(injected) {
25
- const value = injected ?? globalThis.crypto;
26
- if (!value?.subtle) throw missingCapability("crypto.subtle");
27
- return value;
28
- }
29
- function publicJwkOnly(jwk) {
30
- if (jwk.kty !== "EC" || jwk.crv !== "P-256" || !jwk.x || !jwk.y) {
31
- throw new Agents24ClientError("DPoP requires a P-256 public key.", {
32
- kind: "configuration",
33
- code: "INVALID_DPOP_KEY"
34
- });
35
- }
36
- return { kty: "EC", crv: "P-256", x: jwk.x, y: jwk.y };
37
- }
38
- async function hash(subtle, encoder, input) {
39
- return base64UrlEncode(new Uint8Array(await subtle.digest("SHA-256", encoder.encode(input))));
40
- }
41
- function createWebCryptoDpopKeyProvider(options = {}) {
42
- const crypto = resolveCrypto(options.crypto);
43
- const clock = options.clock ?? defaultClock();
44
- const ids = options.ids ?? defaultIds();
45
- const encoder = resolveEncoder(options.encoder);
46
- let handlePromise;
47
- let jwkPromise;
48
- const getHandle = () => {
49
- if (!handlePromise) {
50
- handlePromise = (async () => {
51
- const stored = await options.storage?.load();
52
- if (stored) return stored;
53
- const generated = await crypto.subtle.generateKey(
54
- { name: "ECDSA", namedCurve: "P-256" },
55
- false,
56
- ["sign", "verify"]
57
- );
58
- await options.storage?.save(generated);
59
- return generated;
60
- })();
61
- }
62
- return handlePromise;
63
- };
64
- const getPublicJwk = () => {
65
- if (!jwkPromise) {
66
- jwkPromise = getHandle().then(async (handle) => publicJwkOnly(await crypto.subtle.exportKey("jwk", handle.publicKey)));
67
- }
68
- return jwkPromise;
69
- };
70
- return {
71
- getPublicJwk,
72
- async getThumbprint() {
73
- const jwk = await getPublicJwk();
74
- return hash(crypto.subtle, encoder, JSON.stringify({ crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }));
75
- },
76
- async signProof(input) {
77
- const jwk = await getPublicJwk();
78
- const header = base64UrlEncode(encoder.encode(JSON.stringify({ typ: "dpop+jwt", alg: "ES256", jwk })));
79
- const claims = {
80
- jti: ids.createId(),
81
- htm: input.method.toUpperCase(),
82
- htu: canonicalHtu(input.url),
83
- iat: Math.floor(clock.now() / 1e3)
84
- };
85
- if (input.accessToken) claims.ath = await hash(crypto.subtle, encoder, input.accessToken);
86
- if (input.nonce) claims.nonce = input.nonce;
87
- const payload = base64UrlEncode(encoder.encode(JSON.stringify(claims)));
88
- const signingInput = `${header}.${payload}`;
89
- const handle = await getHandle();
90
- const signature = new Uint8Array(
91
- await crypto.subtle.sign({ name: "ECDSA", hash: "SHA-256" }, handle.privateKey, encoder.encode(signingInput))
92
- );
93
- if (signature.byteLength !== 64) {
94
- throw new Agents24ClientError("The WebCrypto provider returned a non-JOSE ECDSA signature.", {
95
- kind: "configuration",
96
- code: "INVALID_DPOP_SIGNATURE"
97
- });
98
- }
99
- return `${signingInput}.${base64UrlEncode(signature)}`;
100
- }
101
- };
102
- }
103
- async function createPkcePair(cryptoInput, encoderInput) {
104
- const crypto = resolveCrypto(cryptoInput);
105
- const encoder = resolveEncoder(encoderInput);
106
- const random = new Uint8Array(32);
107
- const getRandomValues = crypto.getRandomValues?.bind(crypto);
108
- if (!getRandomValues) throw missingCapability("crypto.getRandomValues");
109
- getRandomValues(random);
110
- const verifier = base64UrlEncode(random);
111
- return { verifier, challenge: await hash(crypto.subtle, encoder, verifier) };
112
- }
113
-
114
- // src/sessions.ts
115
- function parseSessionToken(value, options) {
116
- if (!value || typeof value !== "object" || Array.isArray(value)) {
117
- throw new Agents24ClientError("The session endpoint returned an invalid response.", {
118
- kind: "protocol",
119
- code: "INVALID_SESSION_RESPONSE"
120
- });
121
- }
122
- const body = value;
123
- if (typeof body.access_token !== "string" || !body.access_token || /[\r\n\0]/.test(body.access_token)) {
124
- throw new Agents24ClientError("The session endpoint returned an invalid access token.", {
125
- kind: "protocol",
126
- code: "INVALID_SESSION_RESPONSE"
127
- });
128
- }
129
- const tokenType = body.token_type === "DPoP" ? "DPoP" : body.token_type === "Bearer" ? "Bearer" : void 0;
130
- if (!tokenType || tokenType === "DPoP" && !options.dpopKeyProvider) {
131
- throw new Agents24ClientError("The session endpoint returned an unsupported token profile.", {
132
- kind: "protocol",
133
- code: "INVALID_TOKEN_PROFILE"
134
- });
135
- }
136
- const parsedExpiresAt = typeof body.expires_at === "string" ? Date.parse(body.expires_at) : Number.NaN;
137
- const expiresIn = typeof body.expires_in === "number" && Number.isFinite(body.expires_in) ? body.expires_in : 0;
138
- const expiresAt = Number.isFinite(parsedExpiresAt) ? parsedExpiresAt : options.clock.now() + expiresIn * 1e3;
139
- if (!Number.isFinite(expiresAt) || expiresAt <= options.clock.now()) {
140
- throw new Agents24ClientError("The session endpoint returned an expired access token.", {
141
- kind: "protocol",
142
- code: "INVALID_SESSION_EXPIRY"
143
- });
144
- }
145
- const refreshGrant = typeof body.refresh_grant === "string" && body.refresh_grant && !/[\r\n\0]/.test(body.refresh_grant) ? body.refresh_grant : void 0;
146
- if (body.refresh_grant !== void 0 && !refreshGrant) {
147
- throw new Agents24ClientError("The session endpoint returned an invalid refresh grant.", {
148
- kind: "protocol",
149
- code: "INVALID_SESSION_RESPONSE"
150
- });
151
- }
152
- if (refreshGrant && (tokenType !== "DPoP" || !options.dpopKeyProvider)) {
153
- throw new Agents24ClientError("Persistent sessions require a DPoP-bound token profile.", {
154
- kind: "protocol",
155
- code: "INVALID_TOKEN_PROFILE"
156
- });
157
- }
158
- return {
159
- access: {
160
- accessToken: body.access_token,
161
- tokenType,
162
- expiresAt,
163
- ...typeof body.session_id === "string" ? { sessionId: body.session_id } : {},
164
- ...Array.isArray(body.capabilities) && body.capabilities.every((item) => typeof item === "string") ? { capabilities: body.capabilities } : {},
165
- ...options.dpopKeyProvider ? { dpopKeyProvider: options.dpopKeyProvider } : {},
166
- ...typeof body.dpop_nonce === "string" ? { dpopNonce: body.dpop_nonce } : {}
167
- },
168
- ...refreshGrant ? { refreshGrant } : {},
169
- ...typeof (body.refresh_expires_at ?? body.refresh_grant_absolute_expires_at) === "string" ? { absoluteExpiresAt: body.refresh_expires_at ?? body.refresh_grant_absolute_expires_at } : {}
170
- };
171
- }
172
- function refreshFenceLost() {
173
- return new Agents24ClientError("Refresh coordination ownership changed before completion.", {
174
- kind: "conflict",
175
- code: "REFRESH_FENCE_LOST",
176
- retryable: true
177
- });
178
- }
179
- function defaultWait(milliseconds) {
180
- const schedule = globalThis.setTimeout;
181
- if (!schedule) {
182
- throw new Agents24ClientError("Cross-runtime refresh coordination requires a wait capability.", {
183
- kind: "missing_capability",
184
- code: "MISSING_WAIT_CAPABILITY"
185
- });
186
- }
187
- return new Promise((resolve) => schedule(resolve, milliseconds));
188
- }
189
- function createFencedRefreshCoordinator(options) {
190
- const clock = options.clock ?? defaultClock();
191
- const ids = options.ids ?? defaultIds();
192
- const ownerId = options.ownerId ?? ids.createId();
193
- const leaseDurationMs = Math.max(1e3, options.leaseDurationMs ?? 6e4);
194
- const pollIntervalMs = Math.max(10, options.pollIntervalMs ?? 100);
195
- const wait = options.wait ?? defaultWait;
196
- let local;
197
- const assertActive = async (record) => {
198
- const current = await options.storage.load();
199
- if (!current?.active || current.fence !== record.fence || current.operationId !== record.operationId || current.ownerId !== ownerId || current.expiresAt <= clock.now()) {
200
- throw refreshFenceLost();
201
- }
202
- };
203
- const acquire = async () => {
204
- while (true) {
205
- const current = await options.storage.load();
206
- const now = clock.now();
207
- if (current?.active && current.expiresAt > now) {
208
- await wait(Math.max(1, Math.min(pollIntervalMs, current.expiresAt - now)));
209
- continue;
210
- }
211
- const next = {
212
- active: true,
213
- expiresAt: now + leaseDurationMs,
214
- fence: (current?.fence ?? 0) + 1,
215
- operationId: current?.active ? current.operationId : ids.createId(),
216
- ownerId
217
- };
218
- if (await options.storage.compareAndSwap(current?.fence ?? null, next)) return next;
219
- }
220
- };
221
- return {
222
- async runExclusive(operation) {
223
- if (local) return local;
224
- const pending = (async () => {
225
- const record = await acquire();
226
- const lease = {
227
- fence: record.fence,
228
- operationId: record.operationId,
229
- assertActive: () => assertActive(record)
230
- };
231
- try {
232
- return await operation(lease);
233
- } finally {
234
- const current = await options.storage.load();
235
- if (current?.active && current.fence === record.fence && current.operationId === record.operationId && current.ownerId === ownerId) {
236
- await options.storage.compareAndSwap(current.fence, {
237
- ...current,
238
- active: false,
239
- expiresAt: clock.now()
240
- });
241
- }
242
- }
243
- })();
244
- local = pending;
245
- try {
246
- return await pending;
247
- } finally {
248
- if (local === pending) local = void 0;
249
- }
250
- }
251
- };
252
- }
253
- function createInMemoryRefreshCoordinator() {
254
- let active;
255
- let fence = 0;
256
- return {
257
- async runExclusive(operation) {
258
- if (active) return active;
259
- fence += 1;
260
- const ownedFence = fence;
261
- const current = Promise.resolve().then(() => operation({
262
- fence: ownedFence,
263
- operationId: `memory-refresh-${ownedFence}`,
264
- async assertActive() {
265
- if (active !== current) throw refreshFenceLost();
266
- }
267
- }));
268
- active = current;
269
- try {
270
- return await current;
271
- } finally {
272
- if (active === current) active = void 0;
273
- }
274
- }
275
- };
276
- }
277
- function createStaticSessionProvider(access) {
278
- return {
279
- async getAccess() {
280
- return access;
281
- }
282
- };
283
- }
284
- function createManagedSessionProvider(options) {
285
- if (options.storage && !options.dpopKeyProvider) {
286
- throw new Agents24ClientError("Persistent session storage requires a DPoP key provider.", {
287
- kind: "configuration",
288
- code: "PERSISTENT_SESSION_REQUIRES_DPOP"
289
- });
290
- }
291
- const baseUrl = normalizeBaseUrl(options.baseUrl);
292
- const fetch = resolveFetch(options.fetch);
293
- const clock = options.clock ?? defaultClock();
294
- const ids = options.ids ?? defaultIds();
295
- const coordinator = options.coordinator ?? createInMemoryRefreshCoordinator();
296
- let current;
297
- let refreshGrant;
298
- let minting;
299
- const emit = async (event) => {
300
- try {
301
- await options.telemetry?.emit(event);
302
- } catch {
303
- }
304
- };
305
- const loadStored = async () => {
306
- const stored = await options.storage?.load() ?? null;
307
- if (!stored) return null;
308
- if (!stored.refreshGrant || /[\r\n\0]/.test(stored.refreshGrant)) {
309
- throw new Agents24ClientError("Stored session state is invalid.", {
310
- kind: "authentication",
311
- code: "INVALID_STORED_SESSION"
312
- });
313
- }
314
- if (stored.absoluteExpiresAt) {
315
- const absoluteExpiry = Date.parse(stored.absoluteExpiresAt);
316
- if (!Number.isFinite(absoluteExpiry) || absoluteExpiry <= clock.now()) {
317
- await options.storage?.clear();
318
- throw new Agents24ClientError("The persistent session has expired.", {
319
- kind: "authentication",
320
- code: "SESSION_EXPIRED"
321
- });
322
- }
323
- }
324
- return stored;
325
- };
326
- const save = async (parsed) => {
327
- current = parsed.access;
328
- if (parsed.refreshGrant) refreshGrant = parsed.refreshGrant;
329
- if (refreshGrant && options.storage) {
330
- await options.storage.save({
331
- refreshGrant,
332
- ...current.sessionId ? { sessionId: current.sessionId } : {},
333
- ...parsed.absoluteExpiresAt ? { absoluteExpiresAt: parsed.absoluteExpiresAt } : {}
334
- });
335
- }
336
- };
337
- const mint = async (signal) => {
338
- if (!minting) {
339
- const url = absoluteUrl(baseUrl, `/public/client-runtime/deployments/${encodePath(options.deploymentId)}/sessions/anonymous`);
340
- minting = options.mint({ fetch, url, dpopKeyProvider: options.dpopKeyProvider, signal }).then(async (value) => {
341
- const parsed = parseSessionToken(value, { clock, dpopKeyProvider: options.dpopKeyProvider });
342
- await save(parsed);
343
- return parsed.access;
344
- }).finally(() => {
345
- minting = void 0;
346
- });
347
- }
348
- return minting;
349
- };
350
- const refresh = async (signal) => coordinator.runExclusive(async (lease) => {
351
- if (!refreshGrant && options.storage) {
352
- const stored = await loadStored();
353
- refreshGrant = stored?.refreshGrant;
354
- }
355
- if (!refreshGrant) return mint(signal);
356
- await lease.assertActive();
357
- const response = await dpopTokenRequest({
358
- fetch,
359
- url: absoluteUrl(baseUrl, "/public/client-runtime/sessions/refresh"),
360
- body: { refresh_grant: refreshGrant },
361
- dpopKeyProvider: options.dpopKeyProvider,
362
- signal,
363
- idempotencyKey: lease.operationId
364
- });
365
- if (!response.ok) {
366
- if (response.status === 400 || response.status === 401 || response.status === 403) {
367
- await lease.assertActive();
368
- await options.storage?.clear();
369
- refreshGrant = void 0;
370
- current = void 0;
371
- }
372
- throw await responseError(response);
373
- }
374
- await lease.assertActive();
375
- const parsed = parseSessionToken(await responseJson(response), { clock, dpopKeyProvider: options.dpopKeyProvider });
376
- await save(parsed);
377
- await emit({ type: "session.refreshed", operation: "session" });
378
- return parsed.access;
379
- });
380
- let provider;
381
- provider = {
382
- async getAccess(context) {
383
- if (current && current.expiresAt > clock.now()) return current;
384
- if (refreshGrant || (await loadStored())?.refreshGrant) return refresh(context.signal);
385
- return mint(context.signal);
386
- },
387
- async refresh(context) {
388
- return refresh(context.signal);
389
- },
390
- async revoke(input) {
391
- const authenticated = new AuthenticatedHttp({
392
- baseUrl,
393
- sessionProvider: provider,
394
- fetch,
395
- clock
396
- });
397
- await authenticated.json("POST", "/public/client-runtime/sessions/revoke", {
398
- operation: "sessions.revoke",
399
- idempotencyKey: input?.idempotencyKey ?? ids.createId(),
400
- ...input?.signal ? { signal: input.signal } : {}
401
- });
402
- current = void 0;
403
- refreshGrant = void 0;
404
- await options.storage?.clear();
405
- await emit({ type: "session.revoked", operation: "session" });
406
- }
407
- };
408
- return provider;
409
- }
410
- function createAnonymousSessionProvider(options) {
411
- if ((options.persistent || options.nativeProfileId) && !options.dpopKeyProvider) {
412
- throw new Agents24ClientError("Persistent and native anonymous sessions require a DPoP key provider.", {
413
- kind: "configuration",
414
- code: "MISSING_DPOP_PROVIDER"
415
- });
416
- }
417
- const ids = options.ids ?? defaultIds();
418
- return createManagedSessionProvider({
419
- ...options,
420
- async mint({ fetch, url, dpopKeyProvider, signal }) {
421
- const response = await dpopTokenRequest({
422
- fetch,
423
- url,
424
- body: {
425
- persistent: options.persistent ?? false,
426
- requested_capabilities: [...options.requestedCapabilities ?? []],
427
- ...options.nativeProfileId ? { native_profile_id: options.nativeProfileId } : {},
428
- ...dpopKeyProvider ? { dpop_public_jwk: await dpopKeyProvider.getPublicJwk() } : {},
429
- ...options.attestation ? { attestation: options.attestation } : {}
430
- },
431
- dpopKeyProvider,
432
- prooflessInitialRequest: Boolean(dpopKeyProvider),
433
- signal,
434
- idempotencyKey: ids.createId()
435
- });
436
- if (!response.ok) throw await responseError(response);
437
- return responseJson(response);
438
- }
439
- });
440
- }
441
- function createHostedOidcSessionProvider(options) {
442
- const baseUrl = normalizeBaseUrl(options.baseUrl);
443
- const fetch = resolveFetch(options.fetch);
444
- const clock = options.clock ?? defaultClock();
445
- let current;
446
- let refreshGrant;
447
- let enrollmentNonce;
448
- const ids = options.ids ?? defaultIds();
449
- let memoryRecord = null;
450
- const effectiveStorage = {
451
- async load() {
452
- return await options.storage?.load() ?? memoryRecord;
453
- },
454
- async save(record) {
455
- memoryRecord = record;
456
- await options.storage?.save(record);
457
- },
458
- async clear() {
459
- memoryRecord = null;
460
- await options.storage?.clear();
461
- }
462
- };
463
- const baseProvider = createManagedSessionProvider({
464
- ...options,
465
- storage: effectiveStorage,
466
- async mint() {
467
- throw new Agents24ClientError("Complete the hosted OIDC authorization before requesting access.", {
468
- kind: "authentication",
469
- code: "OIDC_AUTHORIZATION_REQUIRED"
470
- });
471
- }
472
- });
473
- return {
474
- async beginAuthorization(input) {
475
- const url = absoluteUrl(
476
- baseUrl,
477
- `/public/client-runtime/deployments/${encodePath(options.deploymentId)}/sessions/oidc/authorize`
478
- );
479
- const response = await dpopTokenRequest({
480
- fetch,
481
- url,
482
- dpopKeyProvider: options.dpopKeyProvider,
483
- signal: input.signal,
484
- idempotencyKey: ids.createId(),
485
- body: {
486
- redirect_uri: input.redirectUri,
487
- code_challenge: input.codeChallenge,
488
- code_challenge_method: "S256",
489
- persistent: true,
490
- dpop_public_jwk: await options.dpopKeyProvider.getPublicJwk(),
491
- ...input.nativeProfileId ? { native_profile_id: input.nativeProfileId } : {}
492
- }
493
- });
494
- if (!response.ok) throw await responseError(response);
495
- const body = await responseJson(response);
496
- if (typeof body.authorization_url !== "string") {
497
- throw new Agents24ClientError("The OIDC endpoint returned an invalid authorization URL.", {
498
- kind: "protocol",
499
- code: "INVALID_OIDC_RESPONSE"
500
- });
501
- }
502
- if (typeof body.dpop_nonce !== "string" || !body.dpop_nonce) {
503
- throw new Agents24ClientError("The OIDC endpoint did not return a DPoP enrollment nonce.", {
504
- kind: "protocol",
505
- code: "INVALID_OIDC_RESPONSE"
506
- });
507
- }
508
- enrollmentNonce = body.dpop_nonce;
509
- return { authorizationUrl: body.authorization_url };
510
- },
511
- async exchange(input) {
512
- const response = await dpopTokenRequest({
513
- fetch,
514
- url: absoluteUrl(
515
- baseUrl,
516
- `/public/client-runtime/deployments/${encodePath(options.deploymentId)}/sessions/oidc/exchange`
517
- ),
518
- dpopKeyProvider: options.dpopKeyProvider,
519
- signal: input.signal,
520
- idempotencyKey: ids.createId(),
521
- nonce: enrollmentNonce,
522
- body: { code: input.code, code_verifier: input.codeVerifier }
523
- });
524
- if (!response.ok) throw await responseError(response);
525
- const parsed = parseSessionToken(await responseJson(response), {
526
- clock,
527
- dpopKeyProvider: options.dpopKeyProvider
528
- });
529
- current = parsed.access;
530
- enrollmentNonce = void 0;
531
- refreshGrant = parsed.refreshGrant;
532
- if (refreshGrant) {
533
- await effectiveStorage.save({
534
- refreshGrant,
535
- ...current.sessionId ? { sessionId: current.sessionId } : {},
536
- ...parsed.absoluteExpiresAt ? { absoluteExpiresAt: parsed.absoluteExpiresAt } : {}
537
- });
538
- }
539
- return current;
540
- },
541
- async getAccess(context) {
542
- if (current && current.expiresAt > clock.now()) return current;
543
- return baseProvider.getAccess(context);
544
- },
545
- async refresh(context) {
546
- return baseProvider.refresh?.(context) ?? Promise.reject(new Error("Refresh unavailable"));
547
- },
548
- async revoke(input) {
549
- await baseProvider.revoke?.(input);
550
- current = void 0;
551
- refreshGrant = void 0;
552
- }
553
- };
554
- }
555
-
556
- export { createAnonymousSessionProvider, createFencedRefreshCoordinator, createHostedOidcSessionProvider, createInMemoryRefreshCoordinator, createManagedSessionProvider, createPkcePair, createStaticSessionProvider, createWebCryptoDpopKeyProvider };
1
+ export { createAnonymousSessionProvider, createFencedRefreshCoordinator, createHostedOidcSessionProvider, createInMemoryRefreshCoordinator, createManagedSessionProvider, createPkcePair, createStaticSessionProvider, createWebCryptoDpopKeyProvider } from './chunk-FNR3KPB6.js';
2
+ export { createAgents24Client } from './chunk-SPWEZFHZ.js';
3
+ export { Agents24ClientError, createByteMultipartEncoder } from './chunk-GXISGBVW.js';
4
+ import './chunk-IOVCURGW.js';
557
5
  //# sourceMappingURL=index.js.map
558
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/base64url.ts","../src/dpop.ts","../src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rB,MAAA,OAAO,YAAA,CAAa,UAAU,OAAO,CAAA,IAAK,QAAQ,MAAA,CAAO,IAAI,KAAA,CAAM,qBAAqB,CAAC,CAAA;AAAA,IAC3F,CAAA;AAAA,IACA,MAAM,OAAO,KAAA,EAAO;AAClB,MAAA,MAAM,YAAA,CAAa,SAAS,KAAK,CAAA;AACjC,MAAA,OAAA,GAAU,MAAA;AACV,MAAA,YAAA,GAAe,MAAA;AAAA,IACjB;AAAA,GACF;AACF","file":"index.js","sourcesContent":["export function base64UrlEncode(bytes: Uint8Array): string {\n const alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n let output = \"\";\n for (let index = 0; index < bytes.length; index += 3) {\n const first = bytes[index] ?? 0;\n const second = bytes[index + 1];\n const third = bytes[index + 2];\n const packed = (first << 16) | ((second ?? 0) << 8) | (third ?? 0);\n output += alphabet[(packed >>> 18) & 63];\n output += alphabet[(packed >>> 12) & 63];\n output += second === undefined ? \"=\" : alphabet[(packed >>> 6) & 63];\n output += third === undefined ? \"=\" : alphabet[packed & 63];\n }\n return output.replace(/=/g, \"\").replace(/\\+/g, \"-\").replace(/\\//g, \"_\");\n}\n\nexport function utf8Bytes(input: string): Uint8Array {\n const Constructor = (globalThis as unknown as { TextEncoder?: new () => { encode(value: string): Uint8Array } }).TextEncoder;\n if (!Constructor) {\n throw new Error(\"TextEncoder capability is required.\");\n }\n return new Constructor().encode(input);\n}\n","import { base64UrlEncode } from \"./base64url.js\";\nimport { defaultClock, defaultIds, resolveEncoder } from \"./capabilities.js\";\nimport { Agents24ClientError, missingCapability } from \"./errors.js\";\nimport { canonicalHtu } from \"./url.js\";\nimport type { Clock, DpopKeyProvider, DpopProofInput, IdProvider, PublicJwk, TextEncoderLike } from \"./types.js\";\n\ntype CryptoKeyLike = object;\n\ninterface SubtleCryptoLike {\n generateKey(\n algorithm: { name: \"ECDSA\"; namedCurve: \"P-256\" },\n extractable: false,\n usages: readonly [\"sign\", \"verify\"],\n ): Promise<{ privateKey: CryptoKeyLike; publicKey: CryptoKeyLike }>;\n exportKey(format: \"jwk\", key: CryptoKeyLike): Promise<PublicJwk>;\n sign(algorithm: { name: \"ECDSA\"; hash: \"SHA-256\" }, key: CryptoKeyLike, data: Uint8Array): Promise<ArrayBuffer>;\n digest(algorithm: \"SHA-256\", data: Uint8Array): Promise<ArrayBuffer>;\n}\n\nexport interface WebCryptoLike {\n subtle: SubtleCryptoLike;\n getRandomValues?<T extends Uint8Array>(target: T): T;\n}\n\nexport interface DpopKeyHandle {\n privateKey: CryptoKeyLike;\n publicKey: CryptoKeyLike;\n}\n\nexport interface DpopKeyHandleStorage {\n load(): Promise<DpopKeyHandle | null>;\n save(handle: DpopKeyHandle): Promise<void>;\n clear?(): Promise<void>;\n}\n\nexport interface WebCryptoDpopOptions {\n crypto?: WebCryptoLike;\n storage?: DpopKeyHandleStorage;\n clock?: Clock;\n ids?: IdProvider;\n encoder?: TextEncoderLike;\n}\n\nfunction resolveCrypto(injected?: WebCryptoLike): WebCryptoLike {\n const value = injected ?? (globalThis as unknown as { crypto?: WebCryptoLike }).crypto;\n if (!value?.subtle) throw missingCapability(\"crypto.subtle\");\n return value;\n}\n\nfunction publicJwkOnly(jwk: PublicJwk): PublicJwk {\n if (jwk.kty !== \"EC\" || jwk.crv !== \"P-256\" || !jwk.x || !jwk.y) {\n throw new Agents24ClientError(\"DPoP requires a P-256 public key.\", {\n kind: \"configuration\",\n code: \"INVALID_DPOP_KEY\",\n });\n }\n return { kty: \"EC\", crv: \"P-256\", x: jwk.x, y: jwk.y };\n}\n\nasync function hash(subtle: SubtleCryptoLike, encoder: TextEncoderLike, input: string): Promise<string> {\n return base64UrlEncode(new Uint8Array(await subtle.digest(\"SHA-256\", encoder.encode(input))));\n}\n\nexport function createWebCryptoDpopKeyProvider(options: WebCryptoDpopOptions = {}): DpopKeyProvider {\n const crypto = resolveCrypto(options.crypto);\n const clock = options.clock ?? defaultClock();\n const ids = options.ids ?? defaultIds();\n const encoder = resolveEncoder(options.encoder);\n let handlePromise: Promise<DpopKeyHandle> | undefined;\n let jwkPromise: Promise<PublicJwk> | undefined;\n\n const getHandle = (): Promise<DpopKeyHandle> => {\n if (!handlePromise) {\n handlePromise = (async () => {\n const stored = await options.storage?.load();\n if (stored) return stored;\n const generated = await crypto.subtle.generateKey(\n { name: \"ECDSA\", namedCurve: \"P-256\" },\n false,\n [\"sign\", \"verify\"],\n );\n await options.storage?.save(generated);\n return generated;\n })();\n }\n return handlePromise;\n };\n\n const getPublicJwk = (): Promise<PublicJwk> => {\n if (!jwkPromise) {\n jwkPromise = getHandle().then(async (handle) => publicJwkOnly(await crypto.subtle.exportKey(\"jwk\", handle.publicKey)));\n }\n return jwkPromise;\n };\n\n return {\n getPublicJwk,\n async getThumbprint() {\n const jwk = await getPublicJwk();\n return hash(crypto.subtle, encoder, JSON.stringify({ crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }));\n },\n async signProof(input: DpopProofInput) {\n const jwk = await getPublicJwk();\n const header = base64UrlEncode(encoder.encode(JSON.stringify({ typ: \"dpop+jwt\", alg: \"ES256\", jwk })));\n const claims: Record<string, string | number> = {\n jti: ids.createId(),\n htm: input.method.toUpperCase(),\n htu: canonicalHtu(input.url),\n iat: Math.floor(clock.now() / 1000),\n };\n if (input.accessToken) claims.ath = await hash(crypto.subtle, encoder, input.accessToken);\n if (input.nonce) claims.nonce = input.nonce;\n const payload = base64UrlEncode(encoder.encode(JSON.stringify(claims)));\n const signingInput = `${header}.${payload}`;\n const handle = await getHandle();\n const signature = new Uint8Array(\n await crypto.subtle.sign({ name: \"ECDSA\", hash: \"SHA-256\" }, handle.privateKey, encoder.encode(signingInput)),\n );\n if (signature.byteLength !== 64) {\n throw new Agents24ClientError(\"The WebCrypto provider returned a non-JOSE ECDSA signature.\", {\n kind: \"configuration\",\n code: \"INVALID_DPOP_SIGNATURE\",\n });\n }\n return `${signingInput}.${base64UrlEncode(signature)}`;\n },\n };\n}\n\nexport async function createPkcePair(\n cryptoInput?: WebCryptoLike,\n encoderInput?: TextEncoderLike,\n): Promise<{ verifier: string; challenge: string }> {\n const crypto = resolveCrypto(cryptoInput);\n const encoder = resolveEncoder(encoderInput);\n const random = new Uint8Array(32);\n const getRandomValues = crypto.getRandomValues?.bind(crypto);\n if (!getRandomValues) throw missingCapability(\"crypto.getRandomValues\");\n getRandomValues(random);\n const verifier = base64UrlEncode(random);\n return { verifier, challenge: await hash(crypto.subtle, encoder, verifier) };\n}\n","import { defaultClock, defaultIds, resolveFetch } from \"./capabilities.js\";\nimport { Agents24ClientError } from \"./errors.js\";\nimport { AuthenticatedHttp, dpopTokenRequest, responseError, responseJson } from \"./http.js\";\nimport { absoluteUrl, encodePath, normalizeBaseUrl } from \"./url.js\";\nimport type {\n AbortSignalLike,\n ClientSessionAccess,\n ClientSessionProvider,\n ClientSessionStorage,\n Clock,\n DpopKeyProvider,\n FetchLike,\n IdProvider,\n SessionRefreshCoordinator,\n SessionRefreshFenceRecord,\n SessionRefreshFenceStorage,\n SessionRefreshLease,\n TelemetrySink,\n WaitCapability,\n} from \"./types.js\";\n\ntype SessionTokenBody = {\n access_token?: unknown;\n token_type?: unknown;\n expires_in?: unknown;\n expires_at?: unknown;\n refresh_grant?: unknown;\n refresh_expires_at?: unknown;\n refresh_grant_absolute_expires_at?: unknown;\n session_id?: unknown;\n capabilities?: unknown;\n dpop_nonce?: unknown;\n};\n\nfunction parseSessionToken(\n value: unknown,\n options: { clock: Clock; dpopKeyProvider?: DpopKeyProvider | undefined },\n): { access: ClientSessionAccess; refreshGrant?: string; absoluteExpiresAt?: string } {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Agents24ClientError(\"The session endpoint returned an invalid response.\", {\n kind: \"protocol\",\n code: \"INVALID_SESSION_RESPONSE\",\n });\n }\n const body = value as SessionTokenBody;\n if (typeof body.access_token !== \"string\" || !body.access_token || /[\\r\\n\\0]/.test(body.access_token)) {\n throw new Agents24ClientError(\"The session endpoint returned an invalid access token.\", {\n kind: \"protocol\",\n code: \"INVALID_SESSION_RESPONSE\",\n });\n }\n const tokenType = body.token_type === \"DPoP\" ? \"DPoP\" : body.token_type === \"Bearer\" ? \"Bearer\" : undefined;\n if (!tokenType || (tokenType === \"DPoP\" && !options.dpopKeyProvider)) {\n throw new Agents24ClientError(\"The session endpoint returned an unsupported token profile.\", {\n kind: \"protocol\",\n code: \"INVALID_TOKEN_PROFILE\",\n });\n }\n const parsedExpiresAt = typeof body.expires_at === \"string\" ? Date.parse(body.expires_at) : Number.NaN;\n const expiresIn = typeof body.expires_in === \"number\" && Number.isFinite(body.expires_in) ? body.expires_in : 0;\n const expiresAt = Number.isFinite(parsedExpiresAt) ? parsedExpiresAt : options.clock.now() + expiresIn * 1000;\n if (!Number.isFinite(expiresAt) || expiresAt <= options.clock.now()) {\n throw new Agents24ClientError(\"The session endpoint returned an expired access token.\", {\n kind: \"protocol\",\n code: \"INVALID_SESSION_EXPIRY\",\n });\n }\n const refreshGrant = typeof body.refresh_grant === \"string\" && body.refresh_grant && !/[\\r\\n\\0]/.test(body.refresh_grant)\n ? body.refresh_grant\n : undefined;\n if (body.refresh_grant !== undefined && !refreshGrant) {\n throw new Agents24ClientError(\"The session endpoint returned an invalid refresh grant.\", {\n kind: \"protocol\",\n code: \"INVALID_SESSION_RESPONSE\",\n });\n }\n if (refreshGrant && (tokenType !== \"DPoP\" || !options.dpopKeyProvider)) {\n throw new Agents24ClientError(\"Persistent sessions require a DPoP-bound token profile.\", {\n kind: \"protocol\",\n code: \"INVALID_TOKEN_PROFILE\",\n });\n }\n return {\n access: {\n accessToken: body.access_token,\n tokenType,\n expiresAt,\n ...(typeof body.session_id === \"string\" ? { sessionId: body.session_id } : {}),\n ...(Array.isArray(body.capabilities) && body.capabilities.every((item) => typeof item === \"string\")\n ? { capabilities: body.capabilities as string[] }\n : {}),\n ...(options.dpopKeyProvider ? { dpopKeyProvider: options.dpopKeyProvider } : {}),\n ...(typeof body.dpop_nonce === \"string\" ? { dpopNonce: body.dpop_nonce } : {}),\n },\n ...(refreshGrant ? { refreshGrant } : {}),\n ...(typeof (body.refresh_expires_at ?? body.refresh_grant_absolute_expires_at) === \"string\"\n ? { absoluteExpiresAt: (body.refresh_expires_at ?? body.refresh_grant_absolute_expires_at) as string }\n : {}),\n };\n}\n\nfunction refreshFenceLost(): Agents24ClientError {\n return new Agents24ClientError(\"Refresh coordination ownership changed before completion.\", {\n kind: \"conflict\",\n code: \"REFRESH_FENCE_LOST\",\n retryable: true,\n });\n}\n\nfunction defaultWait(milliseconds: number): Promise<void> {\n const schedule = (globalThis as unknown as {\n setTimeout?: (callback: () => void, delay: number) => unknown;\n }).setTimeout;\n if (!schedule) {\n throw new Agents24ClientError(\"Cross-runtime refresh coordination requires a wait capability.\", {\n kind: \"missing_capability\",\n code: \"MISSING_WAIT_CAPABILITY\",\n });\n }\n return new Promise((resolve) => schedule(resolve, milliseconds));\n}\n\nexport interface FencedRefreshCoordinatorOptions {\n storage: SessionRefreshFenceStorage;\n clock?: Clock;\n ids?: IdProvider;\n ownerId?: string;\n leaseDurationMs?: number;\n pollIntervalMs?: number;\n wait?: WaitCapability;\n}\n\n/**\n * Coordinates refresh-grant rotation across tabs/processes through an injected\n * atomic compare-and-swap store. Takeovers retain the same operation ID so a\n * timed-out owner and its successor address one server idempotency record.\n */\nexport function createFencedRefreshCoordinator(\n options: FencedRefreshCoordinatorOptions,\n): SessionRefreshCoordinator {\n const clock = options.clock ?? defaultClock();\n const ids = options.ids ?? defaultIds();\n const ownerId = options.ownerId ?? ids.createId();\n const leaseDurationMs = Math.max(1_000, options.leaseDurationMs ?? 60_000);\n const pollIntervalMs = Math.max(10, options.pollIntervalMs ?? 100);\n const wait = options.wait ?? defaultWait;\n let local: Promise<unknown> | undefined;\n\n const assertActive = async (record: SessionRefreshFenceRecord): Promise<void> => {\n const current = await options.storage.load();\n if (\n !current?.active ||\n current.fence !== record.fence ||\n current.operationId !== record.operationId ||\n current.ownerId !== ownerId ||\n current.expiresAt <= clock.now()\n ) {\n throw refreshFenceLost();\n }\n };\n\n const acquire = async (): Promise<SessionRefreshFenceRecord> => {\n while (true) {\n const current = await options.storage.load();\n const now = clock.now();\n if (current?.active && current.expiresAt > now) {\n await wait(Math.max(1, Math.min(pollIntervalMs, current.expiresAt - now)));\n continue;\n }\n const next: SessionRefreshFenceRecord = {\n active: true,\n expiresAt: now + leaseDurationMs,\n fence: (current?.fence ?? 0) + 1,\n operationId: current?.active ? current.operationId : ids.createId(),\n ownerId,\n };\n if (await options.storage.compareAndSwap(current?.fence ?? null, next)) return next;\n }\n };\n\n return {\n async runExclusive<T>(operation: (lease: SessionRefreshLease) => Promise<T>): Promise<T> {\n if (local) return local as Promise<T>;\n const pending = (async () => {\n const record = await acquire();\n const lease: SessionRefreshLease = {\n fence: record.fence,\n operationId: record.operationId,\n assertActive: () => assertActive(record),\n };\n try {\n return await operation(lease);\n } finally {\n const current = await options.storage.load();\n if (\n current?.active &&\n current.fence === record.fence &&\n current.operationId === record.operationId &&\n current.ownerId === ownerId\n ) {\n await options.storage.compareAndSwap(current.fence, {\n ...current,\n active: false,\n expiresAt: clock.now(),\n });\n }\n }\n })();\n local = pending;\n try {\n return await pending;\n } finally {\n if (local === pending) local = undefined;\n }\n },\n };\n}\n\nexport function createInMemoryRefreshCoordinator(): SessionRefreshCoordinator {\n let active: Promise<unknown> | undefined;\n let fence = 0;\n return {\n async runExclusive<T>(operation: (lease: SessionRefreshLease) => Promise<T>): Promise<T> {\n if (active) return active as Promise<T>;\n fence += 1;\n const ownedFence = fence;\n const current = Promise.resolve().then(() => operation({\n fence: ownedFence,\n operationId: `memory-refresh-${ownedFence}`,\n async assertActive() {\n if (active !== current) throw refreshFenceLost();\n },\n }));\n active = current;\n try {\n return await current;\n } finally {\n if (active === current) active = undefined;\n }\n },\n };\n}\n\nexport function createStaticSessionProvider(access: ClientSessionAccess): ClientSessionProvider {\n return {\n async getAccess() {\n return access;\n },\n };\n}\n\nexport interface ManagedSessionProviderOptions {\n baseUrl: string;\n deploymentId: string;\n fetch?: FetchLike;\n dpopKeyProvider?: DpopKeyProvider | undefined;\n storage?: ClientSessionStorage;\n coordinator?: SessionRefreshCoordinator;\n clock?: Clock;\n ids?: IdProvider;\n telemetry?: TelemetrySink;\n mint(input: {\n fetch: FetchLike;\n url: string;\n dpopKeyProvider?: DpopKeyProvider | undefined;\n signal?: AbortSignalLike | undefined;\n }): Promise<unknown>;\n}\n\nexport function createManagedSessionProvider(options: ManagedSessionProviderOptions): ClientSessionProvider {\n if (options.storage && !options.dpopKeyProvider) {\n throw new Agents24ClientError(\"Persistent session storage requires a DPoP key provider.\", {\n kind: \"configuration\",\n code: \"PERSISTENT_SESSION_REQUIRES_DPOP\",\n });\n }\n const baseUrl = normalizeBaseUrl(options.baseUrl);\n const fetch = resolveFetch(options.fetch);\n const clock = options.clock ?? defaultClock();\n const ids = options.ids ?? defaultIds();\n const coordinator = options.coordinator ?? createInMemoryRefreshCoordinator();\n let current: ClientSessionAccess | undefined;\n let refreshGrant: string | undefined;\n let minting: Promise<ClientSessionAccess> | undefined;\n\n const emit = async (event: Parameters<TelemetrySink[\"emit\"]>[0]): Promise<void> => {\n try {\n await options.telemetry?.emit(event);\n } catch {\n // Session telemetry is noncredential and cannot affect authentication.\n }\n };\n\n const loadStored = async (): Promise<Awaited<ReturnType<ClientSessionStorage[\"load\"]>>> => {\n const stored = await options.storage?.load() ?? null;\n if (!stored) return null;\n if (!stored.refreshGrant || /[\\r\\n\\0]/.test(stored.refreshGrant)) {\n throw new Agents24ClientError(\"Stored session state is invalid.\", {\n kind: \"authentication\",\n code: \"INVALID_STORED_SESSION\",\n });\n }\n if (stored.absoluteExpiresAt) {\n const absoluteExpiry = Date.parse(stored.absoluteExpiresAt);\n if (!Number.isFinite(absoluteExpiry) || absoluteExpiry <= clock.now()) {\n await options.storage?.clear();\n throw new Agents24ClientError(\"The persistent session has expired.\", {\n kind: \"authentication\",\n code: \"SESSION_EXPIRED\",\n });\n }\n }\n return stored;\n };\n\n const save = async (parsed: ReturnType<typeof parseSessionToken>): Promise<void> => {\n current = parsed.access;\n if (parsed.refreshGrant) refreshGrant = parsed.refreshGrant;\n if (refreshGrant && options.storage) {\n await options.storage.save({\n refreshGrant,\n ...(current.sessionId ? { sessionId: current.sessionId } : {}),\n ...(parsed.absoluteExpiresAt ? { absoluteExpiresAt: parsed.absoluteExpiresAt } : {}),\n });\n }\n };\n\n const mint = async (signal?: AbortSignalLike): Promise<ClientSessionAccess> => {\n if (!minting) {\n const url = absoluteUrl(baseUrl, `/public/client-runtime/deployments/${encodePath(options.deploymentId)}/sessions/anonymous`);\n minting = options\n .mint({ fetch, url, dpopKeyProvider: options.dpopKeyProvider, signal })\n .then(async (value) => {\n const parsed = parseSessionToken(value, { clock, dpopKeyProvider: options.dpopKeyProvider });\n await save(parsed);\n return parsed.access;\n })\n .finally(() => {\n minting = undefined;\n });\n }\n return minting;\n };\n\n const refresh = async (signal?: AbortSignalLike): Promise<ClientSessionAccess> =>\n coordinator.runExclusive(async (lease) => {\n if (!refreshGrant && options.storage) {\n const stored = await loadStored();\n refreshGrant = stored?.refreshGrant;\n }\n if (!refreshGrant) return mint(signal);\n await lease.assertActive();\n const response = await dpopTokenRequest({\n fetch,\n url: absoluteUrl(baseUrl, \"/public/client-runtime/sessions/refresh\"),\n body: { refresh_grant: refreshGrant },\n dpopKeyProvider: options.dpopKeyProvider,\n signal,\n idempotencyKey: lease.operationId,\n });\n if (!response.ok) {\n if (response.status === 400 || response.status === 401 || response.status === 403) {\n await lease.assertActive();\n await options.storage?.clear();\n refreshGrant = undefined;\n current = undefined;\n }\n throw await responseError(response);\n }\n await lease.assertActive();\n const parsed = parseSessionToken(await responseJson(response), { clock, dpopKeyProvider: options.dpopKeyProvider });\n await save(parsed);\n await emit({ type: \"session.refreshed\", operation: \"session\" });\n return parsed.access;\n });\n\n let provider: ClientSessionProvider;\n provider = {\n async getAccess(context) {\n if (current && current.expiresAt > clock.now()) return current;\n if (refreshGrant || (await loadStored())?.refreshGrant) return refresh(context.signal);\n return mint(context.signal);\n },\n async refresh(context) {\n return refresh(context.signal);\n },\n async revoke(input) {\n const authenticated = new AuthenticatedHttp({\n baseUrl,\n sessionProvider: provider,\n fetch,\n clock,\n });\n await authenticated.json<unknown>(\"POST\", \"/public/client-runtime/sessions/revoke\", {\n operation: \"sessions.revoke\",\n idempotencyKey: input?.idempotencyKey ?? ids.createId(),\n ...(input?.signal ? { signal: input.signal } : {}),\n });\n current = undefined;\n refreshGrant = undefined;\n await options.storage?.clear();\n await emit({ type: \"session.revoked\", operation: \"session\" });\n },\n };\n return provider;\n}\n\nexport interface AnonymousSessionProviderOptions\n extends Omit<ManagedSessionProviderOptions, \"mint\"> {\n persistent?: boolean;\n nativeProfileId?: string;\n requestedCapabilities?: readonly string[];\n attestation?: string;\n}\n\nexport function createAnonymousSessionProvider(options: AnonymousSessionProviderOptions): ClientSessionProvider {\n if ((options.persistent || options.nativeProfileId) && !options.dpopKeyProvider) {\n throw new Agents24ClientError(\"Persistent and native anonymous sessions require a DPoP key provider.\", {\n kind: \"configuration\",\n code: \"MISSING_DPOP_PROVIDER\",\n });\n }\n const ids = options.ids ?? defaultIds();\n return createManagedSessionProvider({\n ...options,\n async mint({ fetch, url, dpopKeyProvider, signal }) {\n const response = await dpopTokenRequest({\n fetch,\n url,\n body: {\n persistent: options.persistent ?? false,\n requested_capabilities: [...(options.requestedCapabilities ?? [])],\n ...(options.nativeProfileId ? { native_profile_id: options.nativeProfileId } : {}),\n ...(dpopKeyProvider ? { dpop_public_jwk: await dpopKeyProvider.getPublicJwk() } : {}),\n ...(options.attestation ? { attestation: options.attestation } : {}),\n },\n dpopKeyProvider,\n prooflessInitialRequest: Boolean(dpopKeyProvider),\n signal,\n idempotencyKey: ids.createId(),\n });\n if (!response.ok) throw await responseError(response);\n return responseJson(response);\n },\n });\n}\n\nexport interface HostedOidcSessionProvider extends ClientSessionProvider {\n beginAuthorization(input: {\n redirectUri: string;\n codeChallenge: string;\n nativeProfileId?: string;\n signal?: AbortSignalLike;\n }): Promise<{ authorizationUrl: string }>;\n exchange(input: { code: string; codeVerifier: string; signal?: AbortSignalLike }): Promise<ClientSessionAccess>;\n}\n\nexport interface HostedOidcSessionProviderOptions\n extends Omit<ManagedSessionProviderOptions, \"mint\"> {\n dpopKeyProvider: DpopKeyProvider;\n redirectUri?: string;\n}\n\nexport function createHostedOidcSessionProvider(options: HostedOidcSessionProviderOptions): HostedOidcSessionProvider {\n const baseUrl = normalizeBaseUrl(options.baseUrl);\n const fetch = resolveFetch(options.fetch);\n const clock = options.clock ?? defaultClock();\n let current: ClientSessionAccess | undefined;\n let refreshGrant: string | undefined;\n let enrollmentNonce: string | undefined;\n const ids = options.ids ?? defaultIds();\n let memoryRecord: Awaited<ReturnType<ClientSessionStorage[\"load\"]>> = null;\n const effectiveStorage: ClientSessionStorage = {\n async load() {\n return (await options.storage?.load()) ?? memoryRecord;\n },\n async save(record) {\n memoryRecord = record;\n await options.storage?.save(record);\n },\n async clear() {\n memoryRecord = null;\n await options.storage?.clear();\n },\n };\n const baseProvider = createManagedSessionProvider({\n ...options,\n storage: effectiveStorage,\n async mint() {\n throw new Agents24ClientError(\"Complete the hosted OIDC authorization before requesting access.\", {\n kind: \"authentication\",\n code: \"OIDC_AUTHORIZATION_REQUIRED\",\n });\n },\n });\n\n return {\n async beginAuthorization(input) {\n const url = absoluteUrl(\n baseUrl,\n `/public/client-runtime/deployments/${encodePath(options.deploymentId)}/sessions/oidc/authorize`,\n );\n const response = await dpopTokenRequest({\n fetch,\n url,\n dpopKeyProvider: options.dpopKeyProvider,\n signal: input.signal,\n idempotencyKey: ids.createId(),\n body: {\n redirect_uri: input.redirectUri,\n code_challenge: input.codeChallenge,\n code_challenge_method: \"S256\",\n persistent: true,\n dpop_public_jwk: await options.dpopKeyProvider.getPublicJwk(),\n ...(input.nativeProfileId ? { native_profile_id: input.nativeProfileId } : {}),\n },\n });\n if (!response.ok) throw await responseError(response);\n const body = (await responseJson(response)) as Record<string, unknown>;\n if (typeof body.authorization_url !== \"string\") {\n throw new Agents24ClientError(\"The OIDC endpoint returned an invalid authorization URL.\", {\n kind: \"protocol\",\n code: \"INVALID_OIDC_RESPONSE\",\n });\n }\n if (typeof body.dpop_nonce !== \"string\" || !body.dpop_nonce) {\n throw new Agents24ClientError(\"The OIDC endpoint did not return a DPoP enrollment nonce.\", {\n kind: \"protocol\",\n code: \"INVALID_OIDC_RESPONSE\",\n });\n }\n enrollmentNonce = body.dpop_nonce;\n return { authorizationUrl: body.authorization_url };\n },\n async exchange(input) {\n const response = await dpopTokenRequest({\n fetch,\n url: absoluteUrl(\n baseUrl,\n `/public/client-runtime/deployments/${encodePath(options.deploymentId)}/sessions/oidc/exchange`,\n ),\n dpopKeyProvider: options.dpopKeyProvider,\n signal: input.signal,\n idempotencyKey: ids.createId(),\n nonce: enrollmentNonce,\n body: { code: input.code, code_verifier: input.codeVerifier },\n });\n if (!response.ok) throw await responseError(response);\n const parsed = parseSessionToken(await responseJson(response), {\n clock,\n dpopKeyProvider: options.dpopKeyProvider,\n });\n current = parsed.access;\n enrollmentNonce = undefined;\n refreshGrant = parsed.refreshGrant;\n if (refreshGrant) {\n await effectiveStorage.save({\n refreshGrant,\n ...(current.sessionId ? { sessionId: current.sessionId } : {}),\n ...(parsed.absoluteExpiresAt ? { absoluteExpiresAt: parsed.absoluteExpiresAt } : {}),\n });\n }\n return current;\n },\n async getAccess(context) {\n if (current && current.expiresAt > clock.now()) return current;\n return baseProvider.getAccess(context);\n },\n async refresh(context) {\n return baseProvider.refresh?.(context) ?? Promise.reject(new Error(\"Refresh unavailable\"));\n },\n async revoke(input) {\n await baseProvider.revoke?.(input);\n current = undefined;\n refreshGrant = undefined;\n },\n };\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}