@getcirrus/pds 0.19.0 → 0.20.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.d.ts CHANGED
@@ -1,81 +1,14 @@
1
- import { DurableObject } from "cloudflare:workers";
2
- import { BlockMap, CommitData, ReadableBlockstore, Repo, RepoStorage } from "@atproto/repo";
3
- import { Secp256k1Keypair } from "@atproto/crypto";
1
+ import { DurableObject, RpcTarget } from "cloudflare:workers";
4
2
  import { CID } from "@atproto/lex-data";
5
- import * as _getcirrus_oauth_provider0 from "@getcirrus/oauth-provider";
3
+ import { BlockMap, CommitData, ReadableBlockstore, RecordWriteOp, Repo, RepoStorage } from "@atproto/repo";
6
4
  import { AuthCodeData, ClientMetadata, LexiconPermissionSet, OAuthStorage, PARData, TokenData } from "@getcirrus/oauth-provider";
5
+ import { Secp256k1Keypair } from "@atproto/crypto";
7
6
  import { Hono } from "hono";
8
7
  import { SpaceDurableObject as SpaceDurableObject$1, SpaceHostConfig, SpaceIndexDurableObject as SpaceIndexDurableObject$1 } from "@getcirrus/spaces";
9
8
  import "@atcute/identity";
10
9
  import * as hono_types0 from "hono/types";
11
10
 
12
- //#region src/oauth-storage.d.ts
13
- /**
14
- * A cached permission-set lookup. `stale` means the entry has passed its
15
- * 24h soft-expiry: it is still safe to use but should be refreshed
16
- * opportunistically.
17
- */
18
- interface CachedPermissionSet {
19
- set: LexiconPermissionSet;
20
- fetchedAt: number;
21
- stale: boolean;
22
- }
23
- /**
24
- * SQLite-backed OAuth storage for Cloudflare Durable Objects.
25
- *
26
- * Implements the OAuthStorage interface from @getcirrus/oauth-provider,
27
- * storing OAuth data in SQLite tables within a Durable Object.
28
- */
29
- declare class SqliteOAuthStorage implements OAuthStorage {
30
- private sql;
31
- constructor(sql: SqlStorage);
32
- /**
33
- * Initialize the OAuth database schema. Should be called once on DO startup.
34
- */
35
- initSchema(): void;
36
- private migrateClientTable;
37
- private migrateTokensTable;
38
- private ensureTokenIndexes;
39
- /**
40
- * Clean up expired entries. Should be called periodically.
41
- */
42
- cleanup(): void;
43
- saveAuthCode(code: string, data: AuthCodeData): Promise<void>;
44
- getAuthCode(code: string): Promise<AuthCodeData | null>;
45
- deleteAuthCode(code: string): Promise<void>;
46
- saveTokens(data: TokenData): Promise<void>;
47
- getTokenByAccess(accessToken: string): Promise<TokenData | null>;
48
- getTokenByRefresh(refreshToken: string): Promise<TokenData | null>;
49
- revokeToken(accessToken: string): Promise<void>;
50
- revokeAllTokens(sub: string): Promise<void>;
51
- saveClient(clientId: string, metadata: ClientMetadata): Promise<void>;
52
- getClient(clientId: string): Promise<ClientMetadata | null>;
53
- savePAR(requestUri: string, data: PARData): Promise<void>;
54
- getPAR(requestUri: string): Promise<PARData | null>;
55
- deletePAR(requestUri: string): Promise<void>;
56
- checkAndSaveNonce(nonce: string): Promise<boolean>;
57
- /**
58
- * Clear all OAuth data (for testing).
59
- */
60
- destroy(): void;
61
- /** Soft-expiry: serve stale, but try to refresh. */
62
- static readonly PERMISSION_SET_STALE_MS: number;
63
- /** Hard-expiry: drop entirely. */
64
- static readonly PERMISSION_SET_EXPIRY_MS: number;
65
- savePermissionSet(nsid: string, set: LexiconPermissionSet, now?: number): void;
66
- getPermissionSet(nsid: string): CachedPermissionSet | null;
67
- /**
68
- * Save a WebAuthn challenge for later verification
69
- */
70
- saveWebAuthnChallenge(challenge: string): void;
71
- /**
72
- * Consume a WebAuthn challenge (single-use, deleted after retrieval)
73
- * @returns true if challenge was valid and consumed, false if not found or expired
74
- */
75
- consumeWebAuthnChallenge(challenge: string): boolean;
76
- }
77
- //#endregion
78
- //#region src/storage.d.ts
11
+ //#region src/repo/storage.d.ts
79
12
  /**
80
13
  * SQLite-backed repository storage for Cloudflare Durable Objects.
81
14
  *
@@ -141,14 +74,6 @@ declare class SqliteRepoStorage extends ReadableBlockstore implements RepoStorag
141
74
  * Count the number of blocks stored.
142
75
  */
143
76
  countBlocks(): Promise<number>;
144
- /**
145
- * Get user preferences.
146
- */
147
- getPreferences(): Promise<unknown[]>;
148
- /**
149
- * Update user preferences.
150
- */
151
- putPreferences(preferences: unknown[]): Promise<void>;
152
77
  /**
153
78
  * Get the activation state of the account.
154
79
  */
@@ -157,14 +82,6 @@ declare class SqliteRepoStorage extends ReadableBlockstore implements RepoStorag
157
82
  * Set the activation state of the account.
158
83
  */
159
84
  setActive(active: boolean): Promise<void>;
160
- /**
161
- * Get the stored email address.
162
- */
163
- getEmail(): string | null;
164
- /**
165
- * Set the email address.
166
- */
167
- setEmail(email: string): void;
168
85
  /**
169
86
  * Get all cached collection names.
170
87
  */
@@ -227,6 +144,118 @@ declare class SqliteRepoStorage extends ReadableBlockstore implements RepoStorag
227
144
  * Clear all blob tracking data (for testing).
228
145
  */
229
146
  clearBlobTracking(): void;
147
+ }
148
+ //#endregion
149
+ //#region src/oauth-storage.d.ts
150
+ /**
151
+ * A cached permission-set lookup. `stale` means the entry has passed its
152
+ * 24h soft-expiry: it is still safe to use but should be refreshed
153
+ * opportunistically.
154
+ */
155
+ interface CachedPermissionSet {
156
+ set: LexiconPermissionSet;
157
+ fetchedAt: number;
158
+ stale: boolean;
159
+ }
160
+ /**
161
+ * SQLite-backed OAuth storage for Cloudflare Durable Objects.
162
+ *
163
+ * Implements the OAuthStorage interface from @getcirrus/oauth-provider,
164
+ * storing OAuth data in SQLite tables within a Durable Object.
165
+ *
166
+ * Extends RpcTarget so the Durable Object can hand it to the Worker as a
167
+ * stub (via authStore()) — callers invoke storage methods directly over
168
+ * RPC instead of going through per-method proxies on the DO class.
169
+ */
170
+ declare class SqliteOAuthStorage extends RpcTarget implements OAuthStorage {
171
+ private sql;
172
+ constructor(sql: SqlStorage);
173
+ /**
174
+ * Initialize the OAuth database schema. Should be called once on DO startup.
175
+ */
176
+ initSchema(): void;
177
+ private migrateClientTable;
178
+ private migrateTokensTable;
179
+ private ensureTokenIndexes;
180
+ /**
181
+ * Clean up expired entries. Should be called periodically.
182
+ */
183
+ cleanup(): void;
184
+ saveAuthCode(code: string, data: AuthCodeData): Promise<void>;
185
+ getAuthCode(code: string): Promise<AuthCodeData | null>;
186
+ deleteAuthCode(code: string): Promise<void>;
187
+ saveTokens(data: TokenData): Promise<void>;
188
+ getTokenByAccess(accessToken: string): Promise<TokenData | null>;
189
+ getTokenByRefresh(refreshToken: string): Promise<TokenData | null>;
190
+ revokeToken(accessToken: string): Promise<void>;
191
+ revokeAllTokens(sub: string): Promise<void>;
192
+ saveClient(clientId: string, metadata: ClientMetadata): Promise<void>;
193
+ getClient(clientId: string): Promise<ClientMetadata | null>;
194
+ savePAR(requestUri: string, data: PARData): Promise<void>;
195
+ getPAR(requestUri: string): Promise<PARData | null>;
196
+ deletePAR(requestUri: string): Promise<void>;
197
+ checkAndSaveNonce(nonce: string): Promise<boolean>;
198
+ /**
199
+ * Clear all OAuth data (for testing).
200
+ */
201
+ destroy(): void;
202
+ /** Soft-expiry: serve stale, but try to refresh. */
203
+ static readonly PERMISSION_SET_STALE_MS: number;
204
+ /** Hard-expiry: drop entirely. */
205
+ static readonly PERMISSION_SET_EXPIRY_MS: number;
206
+ savePermissionSet(nsid: string, set: LexiconPermissionSet, now?: number): void;
207
+ getPermissionSet(nsid: string): CachedPermissionSet | null;
208
+ /**
209
+ * Save a WebAuthn challenge for later verification
210
+ */
211
+ saveWebAuthnChallenge(challenge: string): void;
212
+ /**
213
+ * Consume a WebAuthn challenge (single-use, deleted after retrieval)
214
+ * @returns true if challenge was valid and consumed, false if not found or expired
215
+ */
216
+ consumeWebAuthnChallenge(challenge: string): boolean;
217
+ }
218
+ //#endregion
219
+ //#region src/account/store.d.ts
220
+ /**
221
+ * SQLite-backed storage for person-account data: preferences, email,
222
+ * handle, passkeys, and app passwords. Shares the Durable Object's SQLite
223
+ * database with SqliteRepoStorage; the email accessors read the email column
224
+ * of the repo_state table, whose schema SqliteRepoStorage owns.
225
+ *
226
+ * Extends RpcTarget so the Durable Object can hand it to the Worker as a
227
+ * stub (via account()) — callers invoke store methods directly over RPC.
228
+ */
229
+ declare class AccountStore extends RpcTarget {
230
+ private sql;
231
+ constructor(sql: SqlStorage);
232
+ initSchema(): void;
233
+ /**
234
+ * Get the account's current handle. Returns the handle stored by
235
+ * updateHandle, unless the HANDLE var has changed since it was stored,
236
+ * in which case the var wins.
237
+ */
238
+ getHandle(envHandle: string): string;
239
+ /**
240
+ * Store a new handle, overriding the HANDLE var.
241
+ */
242
+ setHandle(handle: string, envHandle: string): void;
243
+ /**
244
+ * Get user preferences.
245
+ */
246
+ getPreferences(): Promise<unknown[]>;
247
+ /**
248
+ * Update user preferences.
249
+ */
250
+ putPreferences(preferences: unknown[]): Promise<void>;
251
+ /**
252
+ * Get the stored email address.
253
+ */
254
+ getEmail(): string | null;
255
+ /**
256
+ * Set the email address.
257
+ */
258
+ setEmail(email: string): void;
230
259
  /**
231
260
  * Save a passkey credential.
232
261
  */
@@ -302,150 +331,234 @@ declare class SqliteRepoStorage extends ReadableBlockstore implements RepoStorag
302
331
  }>;
303
332
  }
304
333
  //#endregion
305
- //#region src/spaces.d.ts
334
+ //#region src/repo/sequencer.d.ts
306
335
  /**
307
- * The account's space DO: host identity comes from the PDS environment.
308
- * This is the only place `env.DID` crosses into the engine.
336
+ * Commit event payload for the firehose
309
337
  */
310
- declare class SpaceDurableObject extends SpaceDurableObject$1<PDSEnv> {
311
- private keypairPromise;
312
- protected getHostConfig(): SpaceHostConfig;
338
+ interface CommitEvent {
339
+ seq: number;
340
+ rebase: boolean;
341
+ tooBig: boolean;
342
+ repo: string;
343
+ commit: CID;
344
+ rev: string;
345
+ since: string | null;
346
+ prevData: CID | null;
347
+ blocks: Uint8Array;
348
+ ops: RepoOp[];
349
+ blobs: CID[];
350
+ time: string;
313
351
  }
314
- declare class SpaceIndexDurableObject extends SpaceIndexDurableObject$1<PDSEnv> {}
315
- //#endregion
316
- //#region src/types.d.ts
317
352
  /**
318
- * Data location options for Durable Object placement.
319
- *
320
- * - "auto": No location constraint (default, recommended)
321
- * - "eu": European Union - hard guarantee data never leaves EU
322
- * - Location hints (best-effort, not guaranteed):
323
- * - "wnam": Western North America
324
- * - "enam": Eastern North America
325
- * - "sam": South America
326
- * - "weur": Western Europe
327
- * - "eeur": Eastern Europe
328
- * - "apac": Asia-Pacific
329
- * - "oc": Oceania
330
- * - "afr": Africa
331
- * - "me": Middle East
332
- *
333
- * IMPORTANT: This setting only affects newly-created Durable Objects.
334
- * Changing this after initial deployment will NOT migrate existing data.
335
- * To relocate data, you must export and re-import to a new PDS.
353
+ * Identity event payload for the firehose
336
354
  */
337
- type DataLocation = "auto" | "eu" | "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
355
+ interface IdentityEvent {
356
+ seq: number;
357
+ did: string;
358
+ handle?: string;
359
+ time: string;
360
+ }
338
361
  /**
339
- * Environment bindings required by the PDS worker.
340
- * Consumers must provide these bindings in their wrangler config.
362
+ * Sync event payload — broadcast after operations that change repo state
363
+ * without a commit diff (rebase, key rotation, repo import).
364
+ * `blocks` is a CAR containing just the current commit block.
341
365
  */
342
- interface PDSEnv {
343
- /** The account's DID (e.g., did:web:example.com) */
344
- DID: string;
345
- /** The account's handle (e.g., alice.example.com) */
346
- HANDLE: string;
347
- /** Public hostname of the PDS */
348
- PDS_HOSTNAME: string;
349
- /** Bearer token for write operations */
350
- AUTH_TOKEN: string;
351
- /** Private signing key (hex-encoded) */
352
- SIGNING_KEY: string;
353
- /** Public signing key (multibase-encoded) */
354
- SIGNING_KEY_PUBLIC: string;
355
- /** Secret for signing session JWTs */
356
- JWT_SECRET: string;
357
- /** Bcrypt hash of account password */
358
- PASSWORD_HASH: string;
359
- /** Durable Object namespace for account storage */
360
- ACCOUNT: DurableObjectNamespace<AccountDurableObject>;
361
- /** R2 bucket for blob storage (optional) */
362
- BLOBS?: R2Bucket;
363
- /**
364
- * Atproto spaces (alpha). Unset or anything but "true" disables every
365
- * space and simplespace route; they fall through to the proxy like any
366
- * unknown method.
367
- */
368
- SPACES_ENABLED?: string;
369
- /** Durable Object namespace for spaces (one per space URI). */
370
- SPACES?: DurableObjectNamespace<SpaceDurableObject>;
371
- /** Durable Object namespace for the space index singleton. */
372
- SPACES_INDEX?: DurableObjectNamespace<SpaceIndexDurableObject>;
373
- /** Account email address (optional, used by some clients) */
374
- EMAIL?: string;
375
- /** Initial activation state for new accounts (default: true) */
376
- INITIAL_ACTIVE?: string;
377
- /**
378
- * Data location for Durable Object placement.
379
- *
380
- * WARNING: DO NOT CHANGE THIS AFTER INITIAL DEPLOYMENT.
381
- * This setting only affects newly-created DOs. Changing it will NOT
382
- * migrate existing data and may cause issues.
383
- *
384
- * Options:
385
- * - "auto" or unset: No location constraint (default, recommended)
386
- * - "eu": European Union - hard guarantee data never leaves EU
387
- * - Location hints (best-effort, not guaranteed):
388
- * "wnam", "enam", "sam", "weur", "eeur", "apac", "oc", "afr", "me"
389
- */
390
- DATA_LOCATION?: DataLocation;
366
+ interface SyncEvent {
367
+ seq: number;
368
+ did: string;
369
+ rev: string;
370
+ blocks: Uint8Array;
371
+ time: string;
391
372
  }
392
- //#endregion
393
- //#region src/validation.d.ts
394
- type ValidationStatus = "valid" | "unknown";
395
- //#endregion
396
- //#region src/account-do.d.ts
397
373
  /**
398
- * Account Durable Object - manages a single user's AT Protocol repository.
374
+ * Account event payload — broadcast on activation, deactivation, takedown,
375
+ * or deletion. `status` is omitted when active=true.
376
+ */
377
+ type AccountStatus = "takendown" | "suspended" | "deleted" | "deactivated";
378
+ interface AccountEvent {
379
+ seq: number;
380
+ did: string;
381
+ active: boolean;
382
+ status?: AccountStatus;
383
+ time: string;
384
+ }
385
+ /**
386
+ * Repository operation in a commit
387
+ */
388
+ interface RepoOp {
389
+ action: "create" | "update" | "delete";
390
+ path: string;
391
+ cid: CID | null;
392
+ prev?: CID;
393
+ }
394
+ /**
395
+ * Sequenced commit event wrapper
396
+ */
397
+ interface SeqCommitEvent {
398
+ seq: number;
399
+ type: "commit";
400
+ event: CommitEvent;
401
+ time: string;
402
+ }
403
+ /**
404
+ * Sequenced identity event wrapper
405
+ */
406
+ interface SeqIdentityEvent {
407
+ seq: number;
408
+ type: "identity";
409
+ event: IdentityEvent;
410
+ time: string;
411
+ }
412
+ /**
413
+ * Sequenced sync event wrapper
414
+ */
415
+ interface SeqSyncEvent {
416
+ seq: number;
417
+ type: "sync";
418
+ event: SyncEvent;
419
+ time: string;
420
+ }
421
+ /**
422
+ * Sequenced account event wrapper
423
+ */
424
+ interface SeqAccountEvent {
425
+ seq: number;
426
+ type: "account";
427
+ event: AccountEvent;
428
+ time: string;
429
+ }
430
+ /**
431
+ * Sequenced event (commit, identity, sync, or account)
432
+ */
433
+ type SeqEvent = SeqCommitEvent | SeqIdentityEvent | SeqSyncEvent | SeqAccountEvent;
434
+ /**
435
+ * Data needed to sequence a commit. Pass `newBlocks` and `relevantBlocks`
436
+ * from @atproto/repo's CommitData; both are needed in the CAR slice so
437
+ * relays can run the sync 1.1 MST inversion check.
438
+ */
439
+ interface CommitData$1 {
440
+ did: string;
441
+ commit: CID;
442
+ rev: string;
443
+ since: string | null;
444
+ prevData: CID | null;
445
+ newBlocks: BlockMap;
446
+ relevantBlocks: BlockMap;
447
+ ops: Array<RecordWriteOp & {
448
+ cid?: CID | null;
449
+ prev?: CID;
450
+ }>;
451
+ }
452
+ /**
453
+ * Data needed to sequence a sync event.
454
+ */
455
+ interface SyncEventData {
456
+ did: string;
457
+ rev: string;
458
+ cid: CID;
459
+ blocks: BlockMap;
460
+ }
461
+ /**
462
+ * Sequencer manages the firehose event log.
399
463
  *
400
- * This DO provides:
401
- * - SQLite-backed block storage for the repository
402
- * - AT Protocol Repo instance for repository operations
403
- * - Firehose WebSocket connections
404
- * - Sequence number management
464
+ * Stores commit events in SQLite and provides methods for:
465
+ * - Sequencing new commits, identity, sync, and account events
466
+ * - Backfilling events from a cursor
467
+ * - Getting the latest sequence number
405
468
  */
406
- declare class AccountDurableObject extends DurableObject<PDSEnv> {
407
- private storage;
408
- private oauthStorage;
409
- private repo;
410
- private keypair;
411
- private sequencer;
412
- private blobStore;
413
- private storageInitialized;
414
- private repoInitialized;
415
- constructor(ctx: DurableObjectState, env: PDSEnv);
469
+ declare class Sequencer {
470
+ private sql;
471
+ constructor(sql: SqlStorage);
416
472
  /**
417
- * Initialize the storage adapter. Called lazily on first storage access.
473
+ * Add a commit to the firehose sequence.
474
+ * Returns the complete sequenced event for broadcasting.
418
475
  */
419
- private ensureStorageInitialized;
476
+ sequenceCommit(data: CommitData$1): Promise<SeqCommitEvent>;
420
477
  /**
421
- * Run cleanup on storage to remove expired entries
478
+ * Add an identity event to the firehose.
479
+ * `handle` is optional per sync 1.1; presence does not signal change.
422
480
  */
423
- private runCleanup;
481
+ sequenceIdentity(input: {
482
+ did: string;
483
+ handle?: string;
484
+ }): Promise<SeqIdentityEvent>;
424
485
  /**
425
- * Alarm handler for periodic cleanup
426
- * Called by Cloudflare Workers when the alarm fires
486
+ * Add a sync event to the firehose.
487
+ * Used after repo state changes that don't produce a commit diff
488
+ * (import, rebase, key rotation, account activation).
427
489
  */
428
- alarm(): Promise<void>;
490
+ sequenceSync(data: SyncEventData): Promise<SeqSyncEvent>;
429
491
  /**
430
- * Initialize the Repo instance. Called lazily on first repo access.
492
+ * Add an account status event to the firehose.
431
493
  */
432
- private ensureRepoInitialized;
494
+ sequenceAccount(input: {
495
+ did: string;
496
+ active: boolean;
497
+ status?: AccountStatus;
498
+ }): Promise<SeqAccountEvent>;
433
499
  /**
434
- * Get the storage adapter for direct access (used by tests and internal operations).
500
+ * Get events from a cursor position.
501
+ * Returns up to `limit` events after the cursor.
502
+ * Skips identity events that have empty payloads.
435
503
  */
436
- getStorage(): Promise<SqliteRepoStorage>;
504
+ getEventsSince(cursor: number, limit?: number): Promise<SeqEvent[]>;
437
505
  /**
438
- * Get the OAuth storage adapter for OAuth operations.
506
+ * Get the latest sequence number.
507
+ * Returns 0 if no events have been sequenced yet.
439
508
  */
440
- getOAuthStorage(): Promise<SqliteOAuthStorage>;
509
+ getLatestSeq(): number;
441
510
  /**
442
- * Get the Repo instance for repository operations.
511
+ * Get the earliest sequence number still in the log.
512
+ * Used to detect cursors that fall before the backfill window
513
+ * (so the firehose can send an OutdatedCursor info frame).
443
514
  */
444
- getRepo(): Promise<Repo>;
515
+ getEarliestSeq(): number | null;
445
516
  /**
446
- * Ensure the account is active. Throws error if deactivated.
517
+ * Prune old events to keep the log from growing indefinitely.
518
+ * Keeps the most recent `keepCount` events.
447
519
  */
448
- ensureActive(): Promise<void>;
520
+ pruneOldEvents(keepCount?: number): Promise<void>;
521
+ }
522
+ //#endregion
523
+ //#region src/validation.d.ts
524
+ type ValidationStatus = "valid" | "unknown";
525
+ //#endregion
526
+ //#region src/repo/engine.d.ts
527
+ interface RepoEngineOpts {
528
+ storage: SqliteRepoStorage;
529
+ sequencer: Sequencer;
530
+ did: string;
531
+ signingKey: string;
532
+ /** Serializes repo initialization; the DO backs this with blockConcurrencyWhile. */
533
+ lock: <T>(fn: () => Promise<T>) => Promise<T>;
534
+ broadcast: (event: SeqEvent) => Promise<void>;
535
+ }
536
+ /**
537
+ * The repository engine: owns the @atproto/repo instance and signing
538
+ * keypair, and implements record reads and writes, firehose sequencing,
539
+ * account activation, CAR import and migration reset. Depends only on
540
+ * SQLite-backed storage, the sequencer and a broadcast callback — no
541
+ * Durable Object or person-account concerns.
542
+ */
543
+ declare class RepoEngine {
544
+ private storage;
545
+ private sequencer;
546
+ private did;
547
+ private signingKey;
548
+ private lock;
549
+ private broadcast;
550
+ private repo;
551
+ private keypair;
552
+ private initialized;
553
+ constructor(opts: RepoEngineOpts);
554
+ /**
555
+ * Initialize the Repo instance. Called lazily on first repo access.
556
+ */
557
+ private ensureInitialized;
558
+ /**
559
+ * Get the Repo instance for repository operations.
560
+ */
561
+ getRepo(): Promise<Repo>;
449
562
  /**
450
563
  * Get the signing keypair for repository operations.
451
564
  */
@@ -453,7 +566,7 @@ declare class AccountDurableObject extends DurableObject<PDSEnv> {
453
566
  /**
454
567
  * Update the Repo instance after mutations.
455
568
  */
456
- setRepo(repo: Repo): Promise<void>;
569
+ setRepo(repo: Repo): void;
457
570
  /**
458
571
  * Drop the in-memory repo so the next access reloads from storage.
459
572
  * Used after a write fails post-applyWrites: Cloudflare rolls back the
@@ -461,26 +574,31 @@ declare class AccountDurableObject extends DurableObject<PDSEnv> {
461
574
  * end up ahead of storage. That mismatch produces firehose events whose
462
575
  * `since` rev the relay never saw, causing it to mark us desynced.
463
576
  */
464
- private invalidateRepoCache;
577
+ private invalidate;
578
+ /**
579
+ * Ensure the account is active. Throws error if deactivated.
580
+ */
581
+ ensureActive(): Promise<void>;
465
582
  /**
466
- * RPC method: Get repo metadata for describeRepo
583
+ * Get repo metadata for describeRepo.
467
584
  */
468
- rpcDescribeRepo(): Promise<{
585
+ describeRepo(): Promise<{
469
586
  did: string;
470
587
  collections: string[];
471
588
  cid: string;
472
589
  }>;
473
590
  /**
474
- * RPC method: Get a single record
591
+ * Get a single record.
475
592
  */
476
- rpcGetRecord(collection: string, rkey: string): Promise<{
593
+ getRecord(collection: string, rkey: string): Promise<{
477
594
  cid: string;
478
- record: Rpc.Serializable<any>;
595
+ record: unknown;
479
596
  } | null>;
480
597
  /**
481
- * RPC method: List records in a collection
598
+ * List records in a collection, newest first unless `reverse` is set.
599
+ * The cursor is the rkey of the last record returned.
482
600
  */
483
- rpcListRecords(collection: string, opts: {
601
+ listRecords(collection: string, opts: {
484
602
  limit: number;
485
603
  cursor?: string;
486
604
  reverse?: boolean;
@@ -493,9 +611,9 @@ declare class AccountDurableObject extends DurableObject<PDSEnv> {
493
611
  cursor?: string;
494
612
  }>;
495
613
  /**
496
- * RPC method: Create a record
614
+ * Create a record.
497
615
  */
498
- rpcCreateRecord(collection: string, rkey: string | undefined, record: unknown, validationStatus?: ValidationStatus): Promise<{
616
+ createRecord(collection: string, rkey: string | undefined, record: unknown, validationStatus?: ValidationStatus): Promise<{
499
617
  uri: string;
500
618
  cid: string;
501
619
  commit: {
@@ -505,18 +623,18 @@ declare class AccountDurableObject extends DurableObject<PDSEnv> {
505
623
  validationStatus?: ValidationStatus;
506
624
  }>;
507
625
  /**
508
- * RPC method: Delete a record
626
+ * Delete a record.
509
627
  */
510
- rpcDeleteRecord(collection: string, rkey: string): Promise<{
628
+ deleteRecord(collection: string, rkey: string): Promise<{
511
629
  commit: {
512
630
  cid: string;
513
631
  rev: string;
514
632
  };
515
633
  } | null>;
516
634
  /**
517
- * RPC method: Put a record (create or update)
635
+ * Put a record (create or update).
518
636
  */
519
- rpcPutRecord(collection: string, rkey: string, record: unknown, validationStatus?: ValidationStatus): Promise<{
637
+ putRecord(collection: string, rkey: string, record: unknown, validationStatus?: ValidationStatus): Promise<{
520
638
  uri: string;
521
639
  cid: string;
522
640
  commit: {
@@ -526,9 +644,9 @@ declare class AccountDurableObject extends DurableObject<PDSEnv> {
526
644
  validationStatus?: ValidationStatus;
527
645
  }>;
528
646
  /**
529
- * RPC method: Apply multiple writes (batch create/update/delete)
647
+ * Apply multiple writes (batch create/update/delete).
530
648
  */
531
- rpcApplyWrites(writes: Array<{
649
+ applyWrites(writes: Array<{
532
650
  $type: string;
533
651
  collection: string;
534
652
  rkey?: string;
@@ -547,41 +665,171 @@ declare class AccountDurableObject extends DurableObject<PDSEnv> {
547
665
  }>;
548
666
  }>;
549
667
  /**
550
- * RPC method: Get repo status
668
+ * Get repo status.
551
669
  */
552
- rpcGetRepoStatus(): Promise<{
670
+ getStatus(): Promise<{
553
671
  did: string;
554
672
  head: string;
555
673
  rev: string;
556
674
  }>;
557
675
  /**
558
- * Handle streaming getRepo via fetch (not RPC, to enable streaming response).
676
+ * Count records in the repository.
559
677
  */
560
- private handleGetRepo;
678
+ countRecords(): Promise<number>;
679
+ /**
680
+ * Activate the account.
681
+ * Emits #account + #identity + #sync per sync 1.1, so relays pick up
682
+ * the new state without polling. #sync is only emitted when a repo
683
+ * root exists (i.e. after migration import or initial commit).
684
+ */
685
+ activateAccount(): Promise<void>;
686
+ /**
687
+ * Deactivate the account.
688
+ * Emits #account(active=false, status='deactivated') per sync 1.1.
689
+ */
690
+ deactivateAccount(): Promise<void>;
561
691
  /**
562
- * RPC method: Get specific blocks by CID as CAR file
563
- * Used for partial sync and migration.
692
+ * Emit an identity event to notify downstream services to refresh
693
+ * identity cache. `handle` is optional per sync 1.1.
564
694
  */
565
- rpcGetBlocks(cids: string[]): Promise<Uint8Array>;
695
+ emitIdentityEvent(handle?: string): Promise<{
696
+ seq: number;
697
+ }>;
566
698
  /**
567
- * RPC method: Get record with proof as CAR file.
568
- * Returns the commit block and all MST blocks needed to verify
569
- * the existence (or non-existence) of a record.
570
- * Used by com.atproto.sync.getRecord for record verification.
699
+ * Import a repo from a CAR file. Used for account migration —
700
+ * importing an existing repository from another PDS.
571
701
  */
572
- rpcGetRecordProof(collection: string, rkey: string): Promise<Uint8Array>;
702
+ importRepo(carBytes: Uint8Array): Promise<{
703
+ did: string;
704
+ rev: string;
705
+ cid: string;
706
+ }>;
573
707
  /**
574
- * RPC method: Import repo from CAR file
575
- * This is used for account migration - importing an existing repository
576
- * from another PDS.
708
+ * Reset migration state.
709
+ * Clears imported repo and blob tracking to allow re-import.
710
+ * Only works when account is deactivated.
577
711
  */
578
- rpcImportRepo(carBytes: Uint8Array): Promise<{
712
+ resetMigration(): Promise<{
713
+ blocksDeleted: number;
714
+ blobsCleared: number;
715
+ }>;
716
+ }
717
+ //#endregion
718
+ //#region src/repo/facet.d.ts
719
+ /**
720
+ * The repo host's remote surface: the subset of engine and storage
721
+ * operations that is safe to call over Workers RPC. The Durable Object
722
+ * hands this to the Worker as a stub (via repo()); methods returning
723
+ * non-serializable objects (Repo, Keypair) stay off it by design.
724
+ */
725
+ declare class RepoFacet extends RpcTarget {
726
+ private engine;
727
+ private storage;
728
+ constructor(engine: RepoEngine, storage: SqliteRepoStorage);
729
+ describeRepo(): Promise<{
730
+ did: string;
731
+ collections: string[];
732
+ cid: string;
733
+ }>;
734
+ getRecord(collection: string, rkey: string): Promise<{
735
+ cid: string;
736
+ record: Rpc.Serializable<any>;
737
+ } | null>;
738
+ listRecords(collection: string, opts: {
739
+ limit: number;
740
+ cursor?: string;
741
+ reverse?: boolean;
742
+ }): Promise<{
743
+ records: Array<{
744
+ uri: string;
745
+ cid: string;
746
+ value: unknown;
747
+ }>;
748
+ cursor?: string;
749
+ }>;
750
+ createRecord(collection: string, rkey: string | undefined, record: unknown, validationStatus?: ValidationStatus): Promise<{
751
+ uri: string;
752
+ cid: string;
753
+ commit: {
754
+ cid: string;
755
+ rev: string;
756
+ };
757
+ validationStatus?: ValidationStatus;
758
+ }>;
759
+ deleteRecord(collection: string, rkey: string): Promise<{
760
+ commit: {
761
+ cid: string;
762
+ rev: string;
763
+ };
764
+ } | null>;
765
+ putRecord(collection: string, rkey: string, record: unknown, validationStatus?: ValidationStatus): Promise<{
766
+ uri: string;
767
+ cid: string;
768
+ commit: {
769
+ cid: string;
770
+ rev: string;
771
+ };
772
+ validationStatus?: ValidationStatus;
773
+ }>;
774
+ applyWrites(writes: Array<{
775
+ $type: string;
776
+ collection: string;
777
+ rkey?: string;
778
+ value?: unknown;
779
+ validationStatus?: ValidationStatus;
780
+ }>): Promise<{
781
+ commit: {
782
+ cid: string;
783
+ rev: string;
784
+ };
785
+ results: Array<{
786
+ $type: string;
787
+ uri?: string;
788
+ cid?: string;
789
+ validationStatus?: ValidationStatus;
790
+ }>;
791
+ }>;
792
+ getStatus(): Promise<{
793
+ did: string;
794
+ head: string;
795
+ rev: string;
796
+ }>;
797
+ getActive(): Promise<boolean>;
798
+ countRecords(): Promise<number>;
799
+ activateAccount(): Promise<void>;
800
+ deactivateAccount(): Promise<void>;
801
+ emitIdentityEvent(handle?: string): Promise<{
802
+ seq: number;
803
+ }>;
804
+ importRepo(carBytes: Uint8Array): Promise<{
579
805
  did: string;
580
806
  rev: string;
581
807
  cid: string;
582
808
  }>;
809
+ resetMigration(): Promise<{
810
+ blocksDeleted: number;
811
+ blobsCleared: number;
812
+ }>;
813
+ /**
814
+ * Get specific blocks by CID as a CAR file.
815
+ */
816
+ getBlocks(cids: string[]): Promise<Uint8Array>;
817
+ /**
818
+ * Get a record with proof as a CAR file.
819
+ */
820
+ getRecordProof(collection: string, rkey: string): Promise<Uint8Array>;
821
+ countBlocks(): Promise<number>;
822
+ countExpectedBlobs(): number;
823
+ countImportedBlobs(): number;
824
+ listMissingBlobs(limit?: number, cursor?: string): {
825
+ blobs: Array<{
826
+ cid: string;
827
+ recordUri: string;
828
+ }>;
829
+ cursor?: string;
830
+ };
583
831
  /**
584
- * RPC method: Record an already-stored blob's metadata.
832
+ * Record an already-stored blob's metadata.
585
833
  *
586
834
  * The blob bytes are written to R2 by the stateless Worker, not here.
587
835
  * This DO is single-threaded and also holds the relay's firehose
@@ -591,142 +839,187 @@ declare class AccountDurableObject extends DurableObject<PDSEnv> {
591
839
  * dropping the firehose and desyncing the relay. Only the tiny tracking
592
840
  * row needs the DO's SQLite.
593
841
  */
594
- rpcTrackBlob(cid: string, size: number, mimeType: string): Promise<{
842
+ trackBlob(cid: string, size: number, mimeType: string): {
595
843
  referenced: boolean;
596
- }>;
597
- /**
598
- * RPC method: Get a blob from R2
599
- */
600
- rpcGetBlob(cidStr: string): Promise<R2ObjectBody | null>;
601
- /**
602
- * Encode a firehose frame (header + body CBOR).
603
- */
604
- private encodeFrame;
605
- /**
606
- * Encode any event frame based on its type.
607
- */
608
- private encodeEventFrame;
609
- /**
610
- * Encode an error frame.
611
- */
612
- private encodeErrorFrame;
613
- /**
614
- * Encode an #info message (op:1, t:'#info'). Used for non-fatal
615
- * conditions like OutdatedCursor where the stream continues.
616
- */
617
- private encodeInfoFrame;
618
- /**
619
- * Backfill firehose events from a cursor.
620
- */
621
- private backfillFirehose;
622
- /**
623
- * Broadcast a sequenced event to all connected firehose clients.
624
- */
625
- private broadcastEvent;
626
- /**
627
- * Handle WebSocket upgrade for firehose (subscribeRepos).
628
- */
629
- handleFirehoseUpgrade(request: Request): Promise<Response>;
630
- /**
631
- * WebSocket message handler (hibernation API).
632
- */
633
- webSocketMessage(_ws: WebSocket, _message: string | ArrayBuffer): void;
634
- /**
635
- * WebSocket close handler (hibernation API).
636
- */
637
- webSocketClose(_ws: WebSocket, _code: number, _reason: string, _wasClean: boolean): void;
638
- /**
639
- * WebSocket error handler (hibernation API).
640
- */
641
- webSocketError(_ws: WebSocket, error: Error): void;
844
+ };
845
+ }
846
+ //#endregion
847
+ //#region src/spaces.d.ts
848
+ /**
849
+ * The account's space DO: host identity comes from the PDS environment.
850
+ * This is the only place `env.DID` crosses into the engine.
851
+ */
852
+ declare class SpaceDurableObject extends SpaceDurableObject$1<PDSEnv> {
853
+ private keypairPromise;
854
+ protected getHostConfig(): SpaceHostConfig;
855
+ }
856
+ declare class SpaceIndexDurableObject extends SpaceIndexDurableObject$1<PDSEnv> {}
857
+ //#endregion
858
+ //#region src/types.d.ts
859
+ /**
860
+ * Data location options for Durable Object placement.
861
+ *
862
+ * - "auto": No location constraint (default, recommended)
863
+ * - "eu": European Union - hard guarantee data never leaves EU
864
+ * - Location hints (best-effort, not guaranteed):
865
+ * - "wnam": Western North America
866
+ * - "enam": Eastern North America
867
+ * - "sam": South America
868
+ * - "weur": Western Europe
869
+ * - "eeur": Eastern Europe
870
+ * - "apac": Asia-Pacific
871
+ * - "oc": Oceania
872
+ * - "afr": Africa
873
+ * - "me": Middle East
874
+ *
875
+ * IMPORTANT: This setting only affects newly-created Durable Objects.
876
+ * Changing this after initial deployment will NOT migrate existing data.
877
+ * To relocate data, you must export and re-import to a new PDS.
878
+ */
879
+ type DataLocation = "auto" | "eu" | "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
880
+ /**
881
+ * Environment bindings required by the PDS worker.
882
+ * Consumers must provide these bindings in their wrangler config.
883
+ */
884
+ interface PDSEnv {
885
+ /** The account's DID (e.g., did:web:example.com) */
886
+ DID: string;
887
+ /** The account's handle (e.g., alice.example.com) */
888
+ HANDLE: string;
889
+ /** Public hostname of the PDS */
890
+ PDS_HOSTNAME: string;
891
+ /** Bearer token for write operations */
892
+ AUTH_TOKEN: string;
893
+ /** Private signing key (hex-encoded) */
894
+ SIGNING_KEY: string;
895
+ /** Public signing key (multibase-encoded) */
896
+ SIGNING_KEY_PUBLIC: string;
897
+ /** Secret for signing session JWTs */
898
+ JWT_SECRET: string;
899
+ /** Bcrypt hash of account password */
900
+ PASSWORD_HASH: string;
901
+ /** Durable Object namespace for account storage */
902
+ ACCOUNT: DurableObjectNamespace<AccountDurableObject>;
903
+ /** R2 bucket for blob storage (optional) */
904
+ BLOBS?: R2Bucket;
642
905
  /**
643
- * RPC method: Get user preferences
906
+ * Comma-separated relay URLs to send requestCrawl to when a write
907
+ * commits with no firehose subscriber connected. Defaults to
908
+ * https://bsky.network
644
909
  */
645
- rpcGetPreferences(): Promise<{
646
- preferences: unknown[];
647
- }>;
910
+ RELAYS?: string;
648
911
  /**
649
- * RPC method: Put user preferences
912
+ * Atproto spaces (alpha). Unset or anything but "true" disables every
913
+ * space and memberspace route; they fall through to the proxy like any
914
+ * unknown method.
650
915
  */
651
- rpcPutPreferences(preferences: unknown[]): Promise<void>;
916
+ SPACES_ENABLED?: string;
652
917
  /**
653
- * RPC method: Get stored email
918
+ * The account's `#atproto_kem` P-256 private key (hex), with which the
919
+ * spaces alpha MACs space data for syncers. Secret.
654
920
  */
655
- rpcGetEmail(): Promise<{
656
- email: string | null;
657
- }>;
921
+ SPACES_KEM_KEY?: string;
658
922
  /**
659
- * RPC method: Update stored email
923
+ * Public half of SPACES_KEM_KEY (multibase), published as the
924
+ * `#atproto_kem` verification method in the DID document.
660
925
  */
661
- rpcUpdateEmail(email: string): Promise<void>;
926
+ SPACES_KEM_KEY_PUBLIC?: string;
927
+ /** Durable Object namespace for spaces (one per space URI). */
928
+ SPACES?: DurableObjectNamespace<SpaceDurableObject>;
929
+ /** Durable Object namespace for the space index singleton. */
930
+ SPACES_INDEX?: DurableObjectNamespace<SpaceIndexDurableObject>;
931
+ /** Account email address (optional, used by some clients) */
932
+ EMAIL?: string;
933
+ /** Initial activation state for new accounts (default: true) */
934
+ INITIAL_ACTIVE?: string;
662
935
  /**
663
- * RPC method: Get account activation state
936
+ * Data location for Durable Object placement.
937
+ *
938
+ * WARNING: DO NOT CHANGE THIS AFTER INITIAL DEPLOYMENT.
939
+ * This setting only affects newly-created DOs. Changing it will NOT
940
+ * migrate existing data and may cause issues.
941
+ *
942
+ * Options:
943
+ * - "auto" or unset: No location constraint (default, recommended)
944
+ * - "eu": European Union - hard guarantee data never leaves EU
945
+ * - Location hints (best-effort, not guaranteed):
946
+ * "wnam", "enam", "sam", "weur", "eeur", "apac", "oc", "afr", "me"
664
947
  */
665
- rpcGetActive(): Promise<boolean>;
948
+ DATA_LOCATION?: DataLocation;
949
+ }
950
+ //#endregion
951
+ //#region src/account-do.d.ts
952
+ /**
953
+ * Account Durable Object - manages a single user's AT Protocol repository.
954
+ *
955
+ * This DO provides:
956
+ * - SQLite-backed block storage for the repository
957
+ * - AT Protocol Repo instance for repository operations
958
+ * - Firehose WebSocket connections
959
+ * - Sequence number management
960
+ *
961
+ * The Worker talks to it through three RpcTarget facets — repo(),
962
+ * account() and authStore() — plus the fetch handler for WebSocket
963
+ * upgrades and streaming responses.
964
+ */
965
+ declare class AccountDurableObject extends DurableObject<PDSEnv> {
966
+ private storage;
967
+ private accountStore;
968
+ private oauthStorage;
969
+ private sequencer;
970
+ private firehose;
971
+ private engine;
972
+ private repoFacet;
973
+ private storageInitialized;
974
+ constructor(ctx: DurableObjectState, env: PDSEnv);
666
975
  /**
667
- * RPC method: Activate account.
668
- * Emits #account + #identity + #sync per sync 1.1, so relays pick up
669
- * the new state without polling. #sync is only emitted when a repo
670
- * root exists (i.e. after migration import or initial commit).
976
+ * Initialize the storage adapter. Called lazily on first storage access.
671
977
  */
672
- rpcActivateAccount(): Promise<void>;
978
+ private ensureStorageInitialized;
673
979
  /**
674
- * RPC method: Deactivate account.
675
- * Emits #account(active=false, status='deactivated') per sync 1.1.
980
+ * Run cleanup on storage to remove expired entries
676
981
  */
677
- rpcDeactivateAccount(): Promise<void>;
982
+ private runCleanup;
678
983
  /**
679
- * RPC method: Count blocks in storage
984
+ * Alarm handler for periodic cleanup
985
+ * Called by Cloudflare Workers when the alarm fires
680
986
  */
681
- rpcCountBlocks(): Promise<number>;
987
+ alarm(): Promise<void>;
682
988
  /**
683
- * RPC method: Count records in repository
989
+ * Get the storage adapter for direct access (used by tests and internal operations).
684
990
  */
685
- rpcCountRecords(): Promise<number>;
991
+ getStorage(): Promise<SqliteRepoStorage>;
686
992
  /**
687
- * RPC method: Count expected blobs (referenced in records)
993
+ * Get the repo engine for repository operations.
688
994
  */
689
- rpcCountExpectedBlobs(): Promise<number>;
995
+ private getEngine;
690
996
  /**
691
- * RPC method: Count imported blobs
997
+ * RPC facet: repository operations (records, sync, migration, blobs).
692
998
  */
693
- rpcCountImportedBlobs(): Promise<number>;
999
+ repo(): Promise<RepoFacet>;
694
1000
  /**
695
- * RPC method: List missing blobs (referenced but not imported)
1001
+ * RPC facet: person-account data (passkeys, app passwords, preferences, email).
696
1002
  */
697
- rpcListMissingBlobs(limit?: number, cursor?: string): Promise<{
698
- blobs: Array<{
699
- cid: string;
700
- recordUri: string;
701
- }>;
702
- cursor?: string;
703
- }>;
1003
+ account(): Promise<AccountStore>;
704
1004
  /**
705
- * RPC method: Reset migration state.
706
- * Clears imported repo and blob tracking to allow re-import.
707
- * Only works when account is deactivated.
1005
+ * RPC facet: OAuth storage (codes, tokens, clients, PAR, nonces,
1006
+ * permission sets, WebAuthn challenges).
708
1007
  */
709
- rpcResetMigration(): Promise<{
710
- blocksDeleted: number;
711
- blobsCleared: number;
712
- }>;
1008
+ authStore(): Promise<SqliteOAuthStorage>;
713
1009
  /**
714
- * Emit an identity event to notify downstream services to refresh identity cache.
715
- * `handle` is optional per sync 1.1.
1010
+ * Get the Repo instance for repository operations.
716
1011
  */
717
- rpcEmitIdentityEvent(handle?: string): Promise<{
718
- seq: number;
719
- }>;
1012
+ getRepo(): Promise<Repo>;
720
1013
  /**
721
1014
  * RPC method: Health check - verifies storage is accessible
722
1015
  */
723
- rpcHealthCheck(): Promise<{
1016
+ healthCheck(): Promise<{
724
1017
  ok: true;
725
1018
  }>;
726
1019
  /**
727
1020
  * RPC method: Firehose status - returns subscriber count and latest sequence
728
1021
  */
729
- rpcGetFirehoseStatus(): Promise<{
1022
+ getFirehoseStatus(): Promise<{
730
1023
  subscribers: Array<{
731
1024
  connectedAt: number;
732
1025
  cursor: number;
@@ -734,91 +1027,26 @@ declare class AccountDurableObject extends DurableObject<PDSEnv> {
734
1027
  }>;
735
1028
  latestSeq: number | null;
736
1029
  }>;
737
- /** Save an authorization code */
738
- rpcSaveAuthCode(code: string, data: _getcirrus_oauth_provider0.AuthCodeData): Promise<void>;
739
- /** Get authorization code data */
740
- rpcGetAuthCode(code: string): Promise<_getcirrus_oauth_provider0.AuthCodeData | null>;
741
- /** Delete an authorization code */
742
- rpcDeleteAuthCode(code: string): Promise<void>;
743
- /** Save token data */
744
- rpcSaveTokens(data: _getcirrus_oauth_provider0.TokenData): Promise<void>;
745
- /** Get token data by access token */
746
- rpcGetTokenByAccess(accessToken: string): Promise<_getcirrus_oauth_provider0.TokenData | null>;
747
- /** Get token data by refresh token */
748
- rpcGetTokenByRefresh(refreshToken: string): Promise<_getcirrus_oauth_provider0.TokenData | null>;
749
- /** Revoke a token */
750
- rpcRevokeToken(accessToken: string): Promise<void>;
751
- /** Revoke all tokens for a user */
752
- rpcRevokeAllTokens(sub: string): Promise<void>;
753
- /** Save client metadata */
754
- rpcSaveClient(clientId: string, metadata: _getcirrus_oauth_provider0.ClientMetadata): Promise<void>;
755
- /** Get client metadata */
756
- rpcGetClient(clientId: string): Promise<_getcirrus_oauth_provider0.ClientMetadata | null>;
757
- /** Save PAR data */
758
- rpcSavePAR(requestUri: string, data: _getcirrus_oauth_provider0.PARData): Promise<void>;
759
- /** Get PAR data */
760
- rpcGetPAR(requestUri: string): Promise<_getcirrus_oauth_provider0.PARData | null>;
761
- /** Delete PAR data */
762
- rpcDeletePAR(requestUri: string): Promise<void>;
763
- /** Check and save DPoP nonce */
764
- rpcCheckAndSaveNonce(nonce: string): Promise<boolean>;
765
- /**
766
- * Look up a cached permission-set lexicon by NSID. Returns the cached
767
- * value (with `stale: true` when past its 24h soft-expiry) or null when
768
- * not cached or hard-expired.
769
- */
770
- rpcGetPermissionSet(nsid: string): Promise<CachedPermissionSet | null>;
771
- /** Cache a fetched permission-set lexicon. */
772
- rpcSavePermissionSet(nsid: string, set: _getcirrus_oauth_provider0.LexiconPermissionSet): Promise<void>;
773
- /** Save a passkey credential */
774
- rpcSavePasskey(credentialId: string, publicKey: Uint8Array, counter: number, name?: string): Promise<void>;
775
- /** Get a passkey by credential ID */
776
- rpcGetPasskey(credentialId: string): Promise<{
777
- credentialId: string;
778
- publicKey: Uint8Array;
779
- counter: number;
780
- name: string | null;
781
- createdAt: string;
782
- lastUsedAt: string | null;
783
- } | null>;
784
- /** List all passkeys */
785
- rpcListPasskeys(): Promise<Array<{
786
- credentialId: string;
787
- name: string | null;
788
- createdAt: string;
789
- lastUsedAt: string | null;
790
- }>>;
791
- /** Delete a passkey */
792
- rpcDeletePasskey(credentialId: string): Promise<boolean>;
793
- /** Update passkey counter after authentication */
794
- rpcUpdatePasskeyCounter(credentialId: string, counter: number): Promise<void>;
795
- /** Check if passkeys exist */
796
- rpcHasPasskeys(): Promise<boolean>;
797
- /** Save a registration token */
798
- rpcSavePasskeyToken(token: string, challenge: string, expiresAt: number, name?: string): Promise<void>;
799
- /** Consume a registration token */
800
- rpcConsumePasskeyToken(token: string): Promise<{
801
- challenge: string;
802
- name: string | null;
803
- } | null>;
804
- /** Save a WebAuthn challenge for passkey authentication */
805
- rpcSaveWebAuthnChallenge(challenge: string): Promise<void>;
806
- /** Consume a WebAuthn challenge (single-use) */
807
- rpcConsumeWebAuthnChallenge(challenge: string): Promise<boolean>;
808
- /** Save an app password (bcrypt hash) */
809
- rpcSaveAppPassword(name: string, passwordHash: string): Promise<void>;
810
- /** List all app passwords (names and dates only) */
811
- rpcListAppPasswords(): Promise<Array<{
812
- name: string;
813
- createdAt: string;
814
- }>>;
815
- /** Delete an app password by name */
816
- rpcDeleteAppPassword(name: string): Promise<boolean>;
817
- /** Get all app password hashes for login verification */
818
- rpcGetAppPasswordHashes(): Promise<Array<{
819
- name: string;
820
- passwordHash: string;
821
- }>>;
1030
+ /**
1031
+ * Handle streaming getRepo via fetch (not RPC, to enable streaming response).
1032
+ */
1033
+ private handleGetRepo;
1034
+ /**
1035
+ * Handle WebSocket upgrade for firehose (subscribeRepos).
1036
+ */
1037
+ handleFirehoseUpgrade(request: Request): Promise<Response>;
1038
+ /**
1039
+ * WebSocket message handler (hibernation API).
1040
+ */
1041
+ webSocketMessage(_ws: WebSocket, _message: string | ArrayBuffer): void;
1042
+ /**
1043
+ * WebSocket close handler (hibernation API).
1044
+ */
1045
+ webSocketClose(_ws: WebSocket, _code: number, _reason: string, _wasClean: boolean): void;
1046
+ /**
1047
+ * WebSocket error handler (hibernation API).
1048
+ */
1049
+ webSocketError(_ws: WebSocket, error: Error): void;
822
1050
  /**
823
1051
  * HTTP fetch handler for WebSocket upgrades and streaming responses.
824
1052
  * Used instead of RPC when the response can't be serialized (WebSocket)