(parsedSignature: ParsedSignature)
| 19 | } |
| 20 | |
| 21 | export async function fetchKey(parsedSignature: ParsedSignature): Promise<CryptoKey | null> { |
| 22 | const url = parsedSignature.keyId |
| 23 | const res = await fetch(url, { |
| 24 | headers: { Accept: 'application/activity+json' }, |
| 25 | }) |
| 26 | if (!res.ok) { |
| 27 | console.warn(`failed to fetch keys from "${url}", returned ${res.status}.`) |
| 28 | return null |
| 29 | } |
| 30 | |
| 31 | const parsedResponse = (await res.json()) as Profile |
| 32 | return importPublicKey(parsedResponse.publicKey.publicKeyPem) |
| 33 | } |
no test coverage detected