@agents24/client 0.2.31 → 0.2.32

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.
@@ -1,6 +1,587 @@
1
- import { createAgents24Client } from '../chunk-3WC6DOBA.js';
2
- import '../chunk-LPCITIHI.js';
1
+ import { createDpopProofSigner, createFencedRefreshCoordinator, createManagedSessionProviderInternal } from '../chunk-D3ILKDVB.js';
2
+ import { createAgents24Client } from '../chunk-CBKEVJV6.js';
3
+ import { defaultIds, defaultClock, Agents24ClientError, encodePath } from '../chunk-JAIXMKE7.js';
3
4
  import '../chunk-OD5SQZ4O.js';
5
+ import { generateKeyPair, webcrypto, createHash, randomBytes, createPublicKey, createPrivateKey } from 'node:crypto';
6
+ import { promisify } from 'node:util';
7
+ import { join, dirname } from 'node:path';
8
+ import { constants } from 'node:fs';
9
+ import { unlink, open, rename, readFile, stat, mkdir, lstat, chmod, link } from 'node:fs/promises';
10
+
11
+ var generateKeyPairAsync = promisify(generateKeyPair);
12
+ var KEY_RECORD_VERSION = 1;
13
+ var ECDSA_P256 = { name: "ECDSA", namedCurve: "P-256" };
14
+ function invalidKey() {
15
+ return new Agents24ClientError("The stored DPoP key is invalid.", {
16
+ kind: "configuration",
17
+ code: "INVALID_STORED_DPOP_KEY"
18
+ });
19
+ }
20
+ function parseKeyRecord(serialized) {
21
+ let record;
22
+ try {
23
+ record = JSON.parse(serialized);
24
+ } catch {
25
+ throw invalidKey();
26
+ }
27
+ if (!record || record.v !== KEY_RECORD_VERSION || record.kty !== "EC" || record.crv !== "P-256" || typeof record.pkcs8 !== "string" || !/^[A-Za-z0-9_-]+$/.test(record.pkcs8)) {
28
+ throw invalidKey();
29
+ }
30
+ const der = Buffer.from(record.pkcs8, "base64url");
31
+ try {
32
+ const key = createPrivateKey({ key: der, format: "der", type: "pkcs8" });
33
+ if (key.asymmetricKeyType !== "ec" || key.asymmetricKeyDetails?.namedCurve !== "prime256v1") throw invalidKey();
34
+ } catch {
35
+ der.fill(0);
36
+ throw invalidKey();
37
+ }
38
+ return der;
39
+ }
40
+ function isUsableKeyRecord(serialized) {
41
+ try {
42
+ parseKeyRecord(serialized).fill(0);
43
+ return true;
44
+ } catch {
45
+ return false;
46
+ }
47
+ }
48
+ async function generateKeyRecord() {
49
+ const { privateKey } = await generateKeyPairAsync("ec", { namedCurve: "P-256" });
50
+ const der = privateKey.export({ format: "der", type: "pkcs8" });
51
+ try {
52
+ return JSON.stringify({ v: KEY_RECORD_VERSION, kty: "EC", crv: "P-256", pkcs8: der.toString("base64url") });
53
+ } finally {
54
+ der.fill(0);
55
+ }
56
+ }
57
+ async function importKeyRecord(serialized) {
58
+ const der = parseKeyRecord(serialized);
59
+ try {
60
+ const publicJwk = createPublicKey(createPrivateKey({ key: der, format: "der", type: "pkcs8" })).export({ format: "jwk" });
61
+ const privateKey = await webcrypto.subtle.importKey("pkcs8", der, ECDSA_P256, false, ["sign"]);
62
+ const publicKey = await webcrypto.subtle.importKey("jwk", publicJwk, ECDSA_P256, true, ["verify"]);
63
+ return { privateKey, publicKey };
64
+ } finally {
65
+ der.fill(0);
66
+ }
67
+ }
68
+ async function generateEphemeralHandle() {
69
+ const pair = await webcrypto.subtle.generateKey(ECDSA_P256, false, ["sign", "verify"]);
70
+ return { privateKey: pair.privateKey, publicKey: pair.publicKey };
71
+ }
72
+ function createNodeDpopKeyProvider(options = {}) {
73
+ const storage = options.storage;
74
+ let handle;
75
+ const load = () => {
76
+ const pending = storage ? storage.loadOrCreate({ generate: generateKeyRecord, isUsable: isUsableKeyRecord }).then(importKeyRecord) : generateEphemeralHandle();
77
+ handle = pending;
78
+ pending.catch(() => {
79
+ if (handle === pending) handle = void 0;
80
+ });
81
+ return pending;
82
+ };
83
+ const signer = createDpopProofSigner({
84
+ crypto: webcrypto,
85
+ clock: options.clock ?? defaultClock(),
86
+ ids: options.ids ?? defaultIds(),
87
+ encoder: new TextEncoder(),
88
+ getHandle: () => handle ?? load()
89
+ });
90
+ return {
91
+ ...signer,
92
+ async reload() {
93
+ if (storage) handle = void 0;
94
+ }
95
+ };
96
+ }
97
+ var POSIX = process.platform !== "win32";
98
+ var NO_FOLLOW = POSIX ? constants.O_NOFOLLOW : 0;
99
+ function errorCode(error) {
100
+ return error && typeof error === "object" && "code" in error ? String(error.code) : void 0;
101
+ }
102
+ function storeConfigurationError(message) {
103
+ return new Agents24ClientError(message, { kind: "configuration", code: "INSECURE_SESSION_STORE" });
104
+ }
105
+ function assertOwnedByCurrentUser(uid, label) {
106
+ if (POSIX && typeof process.getuid === "function" && uid !== process.getuid()) {
107
+ throw storeConfigurationError(`The session store ${label} is owned by another user.`);
108
+ }
109
+ }
110
+ async function ensurePrivateDirectory(directory) {
111
+ await mkdir(directory, { recursive: true, mode: 448 });
112
+ const info = await lstat(directory);
113
+ if (!info.isDirectory()) throw storeConfigurationError("The session store path is not a directory.");
114
+ assertOwnedByCurrentUser(info.uid, "directory");
115
+ if (POSIX && (info.mode & 63) !== 0) await chmod(directory, 448);
116
+ }
117
+ async function readPrivateFile(path) {
118
+ let handle;
119
+ try {
120
+ handle = await open(path, constants.O_RDONLY | NO_FOLLOW);
121
+ } catch (error) {
122
+ if (errorCode(error) === "ENOENT") return null;
123
+ if (errorCode(error) === "ELOOP") throw storeConfigurationError("The session store refuses symlinked files.");
124
+ throw error;
125
+ }
126
+ try {
127
+ const info = await handle.stat();
128
+ if (!info.isFile()) throw storeConfigurationError("The session store entry is not a regular file.");
129
+ assertOwnedByCurrentUser(info.uid, "file");
130
+ if (POSIX && (info.mode & 63) !== 0) await handle.chmod(384);
131
+ return await handle.readFile({ encoding: "utf8" });
132
+ } finally {
133
+ await handle.close();
134
+ }
135
+ }
136
+ async function syncDirectory(directory) {
137
+ if (!POSIX) return;
138
+ const handle = await open(directory, constants.O_RDONLY);
139
+ try {
140
+ await handle.sync();
141
+ } finally {
142
+ await handle.close();
143
+ }
144
+ }
145
+ async function writePrivateFileAtomic(path, content) {
146
+ const temporary = `${path}.${randomBytes(8).toString("hex")}.tmp`;
147
+ const handle = await open(temporary, "wx", 384);
148
+ try {
149
+ try {
150
+ await handle.writeFile(content, { encoding: "utf8" });
151
+ await handle.sync();
152
+ } finally {
153
+ await handle.close();
154
+ }
155
+ await rename(temporary, path);
156
+ } catch (error) {
157
+ await unlink(temporary).catch(() => void 0);
158
+ throw error;
159
+ }
160
+ await syncDirectory(dirname(path));
161
+ }
162
+ async function removeFile(path) {
163
+ try {
164
+ await unlink(path);
165
+ } catch (error) {
166
+ if (errorCode(error) !== "ENOENT") throw error;
167
+ }
168
+ }
169
+ function lockLost() {
170
+ return new Agents24ClientError("The session store lock changed owner before the write.", {
171
+ kind: "conflict",
172
+ code: "SESSION_STORE_LOCK_LOST",
173
+ retryable: true
174
+ });
175
+ }
176
+ async function breakStaleLock(path, observed) {
177
+ const quarantine = `${path}.${randomBytes(8).toString("hex")}.stale`;
178
+ try {
179
+ await rename(path, quarantine);
180
+ } catch (error) {
181
+ if (errorCode(error) === "ENOENT") return;
182
+ throw error;
183
+ }
184
+ const moved = await readFile(quarantine, "utf8").catch(() => null);
185
+ if (moved !== observed) {
186
+ await link(quarantine, path).catch(() => void 0);
187
+ }
188
+ await unlink(quarantine).catch(() => void 0);
189
+ }
190
+ async function withFileMutex(path, options, operation) {
191
+ const token = `${process.pid}:${randomBytes(16).toString("hex")}`;
192
+ const deadline = Date.now() + options.timeoutMs;
193
+ while (true) {
194
+ try {
195
+ const handle = await open(path, "wx", 384);
196
+ try {
197
+ await handle.writeFile(token, { encoding: "utf8" });
198
+ } finally {
199
+ await handle.close();
200
+ }
201
+ break;
202
+ } catch (error) {
203
+ if (errorCode(error) !== "EEXIST") throw error;
204
+ }
205
+ const observed = await readFile(path, "utf8").catch(() => null);
206
+ const info = await stat(path).catch(() => null);
207
+ if (observed !== null && info && Date.now() - info.mtimeMs > options.staleMs) {
208
+ await breakStaleLock(path, observed);
209
+ continue;
210
+ }
211
+ if (Date.now() > deadline) {
212
+ throw new Agents24ClientError("Timed out waiting for the session store lock.", {
213
+ kind: "conflict",
214
+ code: "SESSION_STORE_LOCK_TIMEOUT",
215
+ retryable: true
216
+ });
217
+ }
218
+ await new Promise((resolve) => setTimeout(resolve, 10 + Math.floor(Math.random() * 15)));
219
+ }
220
+ const assertHeld = async () => {
221
+ if (await readFile(path, "utf8").catch(() => null) !== token) throw lockLost();
222
+ };
223
+ try {
224
+ return await operation(assertHeld);
225
+ } finally {
226
+ if (await readFile(path, "utf8").catch(() => null) === token) await removeFile(path);
227
+ }
228
+ }
229
+
230
+ // src/adapters/node/persistence.ts
231
+ var SECRET_NAME = /^[A-Za-z0-9._-]{1,200}$/;
232
+ var SESSION_RECORD_VERSION = 1;
233
+ function secretPath(directory, name) {
234
+ if (!SECRET_NAME.test(name) || name.startsWith(".")) {
235
+ throw new Agents24ClientError("Invalid session store entry name.", {
236
+ kind: "configuration",
237
+ code: "INVALID_SESSION_STORE_NAME"
238
+ });
239
+ }
240
+ return join(directory, `${name}.secret`);
241
+ }
242
+ function createFileSecretStore(options) {
243
+ let ready;
244
+ const prepared = () => {
245
+ ready ??= ensurePrivateDirectory(options.directory).catch((error) => {
246
+ ready = void 0;
247
+ throw error;
248
+ });
249
+ return ready;
250
+ };
251
+ return {
252
+ async get(name) {
253
+ await prepared();
254
+ return readPrivateFile(secretPath(options.directory, name));
255
+ },
256
+ async set(name, value) {
257
+ await prepared();
258
+ await writePrivateFileAtomic(secretPath(options.directory, name), value);
259
+ },
260
+ async delete(name) {
261
+ await prepared();
262
+ await removeFile(secretPath(options.directory, name));
263
+ }
264
+ };
265
+ }
266
+ function invalidStoredSession() {
267
+ return new Agents24ClientError("Stored session state is invalid.", {
268
+ kind: "authentication",
269
+ code: "INVALID_STORED_SESSION"
270
+ });
271
+ }
272
+ function parseStoredSession(serialized) {
273
+ let value;
274
+ try {
275
+ value = JSON.parse(serialized);
276
+ } catch {
277
+ return null;
278
+ }
279
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
280
+ const record = value;
281
+ const optionalString = (field) => field === void 0 || typeof field === "string";
282
+ if (record.v !== SESSION_RECORD_VERSION || typeof record.refreshGrant !== "string" || !record.refreshGrant || /[\r\n\0]/.test(record.refreshGrant) || typeof record.dpopJkt !== "string" || !record.dpopJkt || !optionalString(record.sessionId) || !optionalString(record.absoluteExpiresAt)) {
283
+ return null;
284
+ }
285
+ return record;
286
+ }
287
+ function parseFence(serialized) {
288
+ if (serialized === null) return null;
289
+ try {
290
+ const value = JSON.parse(serialized);
291
+ if (typeof value.active === "boolean" && typeof value.expiresAt === "number" && Number.isSafeInteger(value.fence) && typeof value.operationId === "string" && typeof value.ownerId === "string") {
292
+ return value;
293
+ }
294
+ } catch {
295
+ }
296
+ return null;
297
+ }
298
+ function createNodeSessionPersistence(options) {
299
+ if (!options.directory || !options.namespace) {
300
+ throw new Agents24ClientError("Node session persistence requires a directory and namespace.", {
301
+ kind: "configuration",
302
+ code: "INVALID_SESSION_STORE"
303
+ });
304
+ }
305
+ const digest = createHash("sha256").update(options.namespace).digest("hex").slice(0, 32);
306
+ const prefix = `agents24-client.${digest}`;
307
+ const keyName = `${prefix}.dpop-key`;
308
+ const sessionName = `${prefix}.session`;
309
+ const fencePath = join(options.directory, `${prefix}.refresh-fence.json`);
310
+ const fenceLock = join(options.directory, `${prefix}.refresh-fence.lock`);
311
+ const keyLock = join(options.directory, `${prefix}.dpop-key.lock`);
312
+ const mutex = {
313
+ staleMs: Math.max(1e3, options.lockStaleMs ?? 1e4),
314
+ timeoutMs: Math.max(1e3, options.lockTimeoutMs ?? 3e4)
315
+ };
316
+ const secrets = options.secretStore ?? createFileSecretStore({ directory: options.directory });
317
+ const report = (event) => {
318
+ try {
319
+ options.onRecovery?.(event);
320
+ } catch {
321
+ }
322
+ };
323
+ let directoryReady;
324
+ const directory = () => {
325
+ directoryReady ??= ensurePrivateDirectory(options.directory).catch((error) => {
326
+ directoryReady = void 0;
327
+ throw error;
328
+ });
329
+ return directoryReady;
330
+ };
331
+ const keyStorage = {
332
+ async loadOrCreate({ generate, isUsable }) {
333
+ const existing = await secrets.get(keyName);
334
+ if (existing !== null && isUsable(existing)) return existing;
335
+ await directory();
336
+ return withFileMutex(keyLock, mutex, async (assertHeld) => {
337
+ const current = await secrets.get(keyName);
338
+ if (current !== null && isUsable(current)) return current;
339
+ if (current !== null) report({ record: "dpop_key", reason: "unreadable" });
340
+ const created = await generate();
341
+ await assertHeld();
342
+ await secrets.delete(sessionName);
343
+ await secrets.set(keyName, created);
344
+ return created;
345
+ });
346
+ }
347
+ };
348
+ const dpopKeyProvider = createNodeDpopKeyProvider({ storage: keyStorage });
349
+ const sessionStorage = {
350
+ async load() {
351
+ const thumbprint = await dpopKeyProvider.getThumbprint();
352
+ const serialized = await secrets.get(sessionName);
353
+ if (serialized === null) return null;
354
+ const stored = parseStoredSession(serialized);
355
+ if (!stored) {
356
+ report({ record: "session", reason: "unreadable" });
357
+ throw invalidStoredSession();
358
+ }
359
+ if (stored.dpopJkt !== thumbprint) {
360
+ await dpopKeyProvider.reload();
361
+ if (stored.dpopJkt !== await dpopKeyProvider.getThumbprint()) {
362
+ report({ record: "session", reason: "key_mismatch" });
363
+ throw invalidStoredSession();
364
+ }
365
+ }
366
+ return {
367
+ refreshGrant: stored.refreshGrant,
368
+ ...stored.sessionId ? { sessionId: stored.sessionId } : {},
369
+ ...stored.absoluteExpiresAt ? { absoluteExpiresAt: stored.absoluteExpiresAt } : {}
370
+ };
371
+ },
372
+ async save(record) {
373
+ if (!record.refreshGrant || /[\r\n\0]/.test(record.refreshGrant)) throw invalidStoredSession();
374
+ const stored = {
375
+ v: SESSION_RECORD_VERSION,
376
+ refreshGrant: record.refreshGrant,
377
+ ...record.sessionId ? { sessionId: record.sessionId } : {},
378
+ ...record.absoluteExpiresAt ? { absoluteExpiresAt: record.absoluteExpiresAt } : {},
379
+ dpopJkt: await dpopKeyProvider.getThumbprint()
380
+ };
381
+ await secrets.set(sessionName, JSON.stringify(stored));
382
+ },
383
+ async clear() {
384
+ await secrets.delete(sessionName);
385
+ }
386
+ };
387
+ const fenceStorage = {
388
+ async load() {
389
+ await directory();
390
+ return parseFence(await readPrivateFile(fencePath));
391
+ },
392
+ async compareAndSwap(expectedFence, next) {
393
+ await directory();
394
+ return withFileMutex(fenceLock, mutex, async (assertHeld) => {
395
+ const current = parseFence(await readPrivateFile(fencePath));
396
+ if ((current?.fence ?? null) !== expectedFence) return false;
397
+ await assertHeld();
398
+ await writePrivateFileAtomic(fencePath, JSON.stringify(next));
399
+ return true;
400
+ });
401
+ }
402
+ };
403
+ return {
404
+ dpopKeyProvider,
405
+ sessionStorage,
406
+ refreshCoordinator: createFencedRefreshCoordinator({ storage: fenceStorage }),
407
+ async forgetDevice() {
408
+ await directory();
409
+ await withFileMutex(keyLock, mutex, async () => {
410
+ await secrets.delete(sessionName);
411
+ await secrets.delete(keyName);
412
+ await removeFile(fencePath);
413
+ });
414
+ await dpopKeyProvider.reload();
415
+ }
416
+ };
417
+ }
418
+
419
+ // src/adapters/node/session-controller.ts
420
+ var NOTHING_TO_REVOKE = /* @__PURE__ */ new Set(["SIGNED_OUT", "SESSION_REVOKED", "SESSION_EXPIRED", "INVALID_STORED_SESSION"]);
421
+ function signedOut() {
422
+ return new Agents24ClientError("The desktop session is signed out. Start the session controller to sign in again.", {
423
+ kind: "authentication",
424
+ code: "SIGNED_OUT"
425
+ });
426
+ }
427
+ function assertPersistentDpopSession(body) {
428
+ const record = body && typeof body === "object" && !Array.isArray(body) ? body : {};
429
+ if (record.token_type !== "DPoP" || typeof record.refresh_grant !== "string" || !record.refresh_grant) {
430
+ throw new Agents24ClientError(
431
+ "The host must mint a persistent DPoP session (persistent: true with this device's dpop_public_jwk).",
432
+ { kind: "protocol", code: "INVALID_TOKEN_PROFILE" }
433
+ );
434
+ }
435
+ }
436
+ function errorView(error) {
437
+ return error instanceof Agents24ClientError ? { code: error.code, message: error.message } : { code: "SESSION_START_FAILED", message: "The desktop session could not be started." };
438
+ }
439
+ function createNodeSessionController(options) {
440
+ const { persistence } = options;
441
+ const keyProvider = persistence.dpopKeyProvider;
442
+ const tokenPath = `/client-runtime/deployments/${encodePath(options.deploymentId)}/session-tokens`;
443
+ const listeners = /* @__PURE__ */ new Set();
444
+ let snapshot = { state: "idle" };
445
+ let starting;
446
+ const lifecycleOwnsSnapshot = () => snapshot.state === "signed_out" || snapshot.state === "starting";
447
+ const publish = (next) => {
448
+ snapshot = next;
449
+ listeners.forEach((listener) => listener());
450
+ };
451
+ const createDpopProof = async (input) => {
452
+ let url;
453
+ try {
454
+ url = new URL(input.url);
455
+ } catch {
456
+ url = new URL("invalid:");
457
+ }
458
+ if (!/^https?:$/.test(url.protocol) || url.search || url.hash || !url.pathname.endsWith(tokenPath) || url.pathname.includes("/public/") || typeof input.nonce !== "string" || !input.nonce || /[\r\n\0]/.test(input.nonce)) {
459
+ throw new Agents24ClientError("Device proofs are issued only for this deployment's session-tokens request with a server nonce.", {
460
+ kind: "configuration",
461
+ code: "INVALID_DPOP_PROOF_REQUEST"
462
+ });
463
+ }
464
+ return keyProvider.signProof({ method: "POST", url: input.url, nonce: input.nonce });
465
+ };
466
+ const createInner = () => createManagedSessionProviderInternal(
467
+ {
468
+ baseUrl: options.baseUrl,
469
+ deploymentId: options.deploymentId,
470
+ dpopKeyProvider: keyProvider,
471
+ storage: persistence.sessionStorage,
472
+ coordinator: persistence.refreshCoordinator,
473
+ ...options.fetch ? { fetch: options.fetch } : {},
474
+ ...options.clock ? { clock: options.clock } : {},
475
+ ...options.ids ? { ids: options.ids } : {},
476
+ ...options.telemetry ? { telemetry: options.telemetry } : {},
477
+ async mint({ signal }) {
478
+ if (snapshot.state === "signed_out") throw signedOut();
479
+ try {
480
+ const body = await options.mintSession({
481
+ dpopPublicJwk: await keyProvider.getPublicJwk(),
482
+ createDpopProof,
483
+ signal
484
+ });
485
+ assertPersistentDpopSession(body);
486
+ const sessionId = body.session_id;
487
+ if (!lifecycleOwnsSnapshot()) {
488
+ publish({ state: "active", ...typeof sessionId === "string" ? { sessionId } : {} });
489
+ }
490
+ return body;
491
+ } catch (error) {
492
+ if (!lifecycleOwnsSnapshot()) {
493
+ publish({ state: "error", error: errorView(error) });
494
+ }
495
+ throw error;
496
+ }
497
+ }
498
+ },
499
+ true
500
+ );
501
+ let inner = createInner();
502
+ const gate = () => {
503
+ if (snapshot.state === "signed_out") throw signedOut();
504
+ return inner;
505
+ };
506
+ const sessionProvider = {
507
+ async getAccess(context) {
508
+ return gate().getAccess(context);
509
+ },
510
+ async refresh(context) {
511
+ const provider = gate();
512
+ if (!provider.refresh) throw signedOut();
513
+ return provider.refresh(context);
514
+ },
515
+ async revoke(input) {
516
+ return gate().revoke?.(input);
517
+ }
518
+ };
519
+ const client = createAgents24Client({
520
+ ...options.client,
521
+ baseUrl: options.baseUrl,
522
+ deploymentId: options.deploymentId,
523
+ sessionProvider,
524
+ ...options.fetch ? { fetch: options.fetch } : {},
525
+ ...options.clock ? { clock: options.clock } : {},
526
+ ...options.ids ? { ids: options.ids } : {},
527
+ ...options.telemetry ? { telemetry: options.telemetry } : {}
528
+ });
529
+ const clearStoredSession = async () => {
530
+ let cleared = false;
531
+ while (!cleared) {
532
+ await persistence.refreshCoordinator.runExclusive(async (lease) => {
533
+ await lease.assertActive();
534
+ await persistence.sessionStorage.clear();
535
+ cleared = true;
536
+ });
537
+ }
538
+ };
539
+ const start = () => {
540
+ if (snapshot.state === "active") return Promise.resolve(snapshot);
541
+ if (starting) return starting;
542
+ starting = (async () => {
543
+ if (snapshot.state === "signed_out") inner = createInner();
544
+ publish({ state: "starting" });
545
+ try {
546
+ const access = await inner.refresh({ reason: "request" });
547
+ publish({ state: "active", ...access.sessionId ? { sessionId: access.sessionId } : {} });
548
+ } catch (error) {
549
+ publish({ state: "error", error: errorView(error) });
550
+ throw error;
551
+ }
552
+ return snapshot;
553
+ })().finally(() => {
554
+ starting = void 0;
555
+ });
556
+ return starting;
557
+ };
558
+ return {
559
+ client,
560
+ getSnapshot: () => snapshot,
561
+ subscribe(listener) {
562
+ listeners.add(listener);
563
+ return () => listeners.delete(listener);
564
+ },
565
+ start,
566
+ async signOut() {
567
+ if (starting) await starting.catch(() => void 0);
568
+ const provider = inner;
569
+ publish({ state: "signed_out" });
570
+ let failure;
571
+ let revoked = false;
572
+ try {
573
+ await provider.revoke?.();
574
+ revoked = true;
575
+ } catch (error) {
576
+ if (!(error instanceof Agents24ClientError && NOTHING_TO_REVOKE.has(error.code))) failure = error;
577
+ } finally {
578
+ await clearStoredSession();
579
+ }
580
+ if (failure) throw failure;
581
+ return { revoked };
582
+ }
583
+ };
584
+ }
4
585
 
5
586
  // src/adapters/node.ts
6
587
  var runtimeAdapter = "node";
@@ -8,6 +589,6 @@ function createNodeAgentClient(options) {
8
589
  return createAgents24Client(options);
9
590
  }
10
591
 
11
- export { createNodeAgentClient, runtimeAdapter };
592
+ export { createFileSecretStore, createNodeAgentClient, createNodeDpopKeyProvider, createNodeSessionController, createNodeSessionPersistence, runtimeAdapter };
12
593
  //# sourceMappingURL=node.js.map
13
594
  //# sourceMappingURL=node.js.map