MCPcopy Create free account
hub / github.com/atomicdata-dev/atomic-data-browser / checkPublicKey

Method checkPublicKey

lib/src/agent.ts:41–54  ·  view source on GitHub ↗

Fetches the public key for the agent, checks if it matches with the current one

()

Source from the content-addressed store, hash-verified

39
40 /** Fetches the public key for the agent, checks if it matches with the current one */
41 public async checkPublicKey(): Promise<void> {
42 const resource = await fetchResource(this.subject);
43 if (resource.error) {
44 throw new Error(
45 `Could not fetch agent, and could therefore not check validity of public key. ${resource.error}`,
46 );
47 }
48 const fetchedPubKey = resource.get(properties.agent.publicKey).toString();
49 if (fetchedPubKey !== (await this.getPublicKey())) {
50 throw new Error(
51 'Fetched publickey does not match current one - is the private key correct?',
52 );
53 }
54 }
55
56 /**
57 * Parses a base64 JSON object containing a privateKey and subject, and

Callers 1

Calls 3

getPublicKeyMethod · 0.95
fetchResourceFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected