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.

fix: identity signal abort

+39 -4
+1 -1
identity/deno.json
··· 1 1 { 2 2 "name": "@atp/identity", 3 - "version": "0.1.0-alpha.2", 3 + "version": "0.1.0-alpha.3", 4 4 "exports": "./mod.ts", 5 5 "license": "MIT", 6 6 "imports": {
+1 -1
identity/did/base-resolver.ts
··· 55 55 fromCache = await this.cache.checkCache(did); 56 56 if (fromCache && !fromCache.expired) { 57 57 if (fromCache?.stale) { 58 - await this.refreshCache(did, fromCache); 58 + await this.refreshCache(did, fromCache).catch(() => undefined); 59 59 } 60 60 return fromCache.doc; 61 61 }
+7
identity/did/util.ts
··· 1 + import { IdentityResolutionTimeoutError } from "../errors.ts"; 2 + 1 3 /** A timed function to abort after a certain amount of time */ 2 4 export async function timed<F extends (signal: AbortSignal) => unknown>( 3 5 ms: number, ··· 9 11 10 12 try { 11 13 return (await fn(signal)) as Awaited<ReturnType<F>>; 14 + } catch (err) { 15 + if (signal.aborted) { 16 + throw new IdentityResolutionTimeoutError(ms, { cause: err }); 17 + } 18 + throw err; 12 19 } finally { 13 20 clearTimeout(timer); 14 21 abortController.abort();
+9
identity/errors.ts
··· 7 7 } 8 8 } 9 9 10 + /** Error thrown when DID resolution exceeds its configured timeout. 11 + * @param ms Timeout in milliseconds. 12 + */ 13 + export class IdentityResolutionTimeoutError extends Error { 14 + constructor(public ms: number, options?: ErrorOptions) { 15 + super(`DID resolution timed out after ${ms}ms`, options); 16 + } 17 + } 18 + 10 19 /** 11 20 * Error thrown when a DID is not formatted correctly. 12 21 * Most commonly, a DID missing `did:` at the beginning
+19
identity/tests/did-cache_test.ts
··· 105 105 }); 106 106 107 107 Deno.test({ 108 + name: "returns stale dids when refresh fails", 109 + async fn() { 110 + const didCache = new MemoryCache(1); 111 + const shortCacheResolver = new DidResolver({ plcUrl, didCache }); 112 + const doc = await shortCacheResolver.resolve(did); 113 + didCache.cacheDid(did, { ...doc, id: "did:example:alice" }); 114 + shortCacheResolver.resolveNoCheck = () => { 115 + throw new Error("refresh failed"); 116 + }; 117 + await wait(5); 118 + 119 + const staleGet = await shortCacheResolver.resolve(did); 120 + assertEquals(staleGet?.id, "did:example:alice"); 121 + }, 122 + sanitizeResources: false, 123 + sanitizeOps: false, 124 + }); 125 + 126 + Deno.test({ 108 127 name: "does not return expired dids & refreshes the cache", 109 128 async fn() { 110 129 const didCache = new MemoryCache(0, 1);
+1 -1
lex/deno.json
··· 1 1 { 2 2 "name": "@atp/lex", 3 - "version": "0.1.0-alpha.9", 3 + "version": "0.1.0-alpha.10", 4 4 "exports": { 5 5 ".": "./mod.ts", 6 6 "./cbor": "./cbor/mod.ts",
+1 -1
sync/deno.json
··· 1 1 { 2 2 "name": "@atp/sync", 3 - "version": "0.1.0-alpha.10", 3 + "version": "0.1.0-alpha.11", 4 4 "exports": "./mod.ts", 5 5 "license": "MIT", 6 6 "imports": {