Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 90 lines 2.9 kB view raw
1import type { DidDocument } from "@atp/common-web"; 2 3export { didDocument } from "@atp/common-web"; 4export type { DidDocument } from "@atp/common-web"; 5 6/** 7 * Options for a combined handle and did resolver. 8 * @property timeout - Timeout in milliseconds for resolving handles. 9 * @property plcUrl - URL of the PLC registry or mirror used for the `did:plc` method. 10 * @property didCache - Cache for storing recently resolved DID documents. 11 * @property backupNameservers - List of backup nameservers to use for handle resolution. 12 */ 13export type IdentityResolverOpts = { 14 timeout?: number; 15 plcUrl?: string; 16 didCache?: DidCache; 17 backupNameservers?: string[]; 18}; 19 20/** 21 * Options for a handle resolver. 22 * @property timeout - Timeout in milliseconds for resolving handles. 23 * @property backupNameservers - List of backup nameservers to use if the primary DNS nameservers fails. 24 */ 25export type HandleResolverOpts = { 26 timeout?: number; 27 backupNameservers?: string[]; 28}; 29 30/** 31 * Options for a DID resolver. 32 * @property timeout - Timeout in milliseconds for resolving DIDs. 33 * @property plcUrl - URL of the PLC registry or mirror used for the `did:plc` method. 34 * @property didCache - Cache for storing recently resolved DID documents. 35 */ 36export type DidResolverOpts = { 37 timeout?: number; 38 plcUrl?: string; 39 didCache?: DidCache; 40}; 41 42/** 43 * Data associated with an AT Protocol repository. 44 * @property did - The decentralized identifier of the repository. Never changes. 45 * @property signingKey - The public key used for signing records and operations. 46 * @property handle - The domain used for representing the repository to users, can change over time. 47 * @property pds - The URL of the repository's personal data server, where the repository's data is stored. 48 */ 49export type AtprotoData = { 50 did: string; 51 signingKey: string; 52 handle: string; 53 pds: string; 54}; 55 56/** 57 * Stored when caching resolved DID documents. 58 * @property did - Decentralized identifier of the repository 59 * @property doc - The resolved DID document 60 * @property updatedAt - Timestamp of when the cache entry was last updated 61 * @property stale - Whether the cache entry is too old and needs to be refreshed 62 * @property expired - Whether the cache entry has expired and should be removed 63 */ 64export type CacheResult = { 65 did: string; 66 doc: DidDocument; 67 updatedAt: number; 68 stale: boolean; 69 expired: boolean; 70}; 71 72/** 73 * An optional configured cache for caching resolved 74 * did documents and getting the cached did docs. 75 */ 76export interface DidCache { 77 cacheDid( 78 did: string, 79 doc: DidDocument, 80 prevResult?: CacheResult, 81 ): void; 82 checkCache(did: string): CacheResult | null; 83 refreshCache( 84 did: string, 85 getDoc: () => Promise<DidDocument | null>, 86 prevResult?: CacheResult, 87 ): Promise<void>; 88 clearEntry(did: string): void; 89 clear(): void; 90}