Fetches the public key for the agent, checks if it matches with the current one
()
| 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 |
no test coverage detected