Skip to content

Commit 693ca29

Browse files
committed
docs: update fetchVerificationKeys
1 parent 6322126 commit 693ca29

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,25 @@ await verifyRequestByKeyId(request.body, signature, key, { request });
9898
#### `async fetchVerificationKeys(options)`
9999

100100
Fetches public keys for verifying copilot extension requests [from GitHub's API](https://api.github.com/meta/public_keys/copilot_api)
101-
and returns them as an array. The request can be made without authentication, with a token, or with a custom [octokit request](https://github.com/octokit/request.js) instance.
101+
and returns them as an array. The request can be made without authentication, with a token, with a custom [octokit request](https://github.com/octokit/request.js) instance, or with a cache.
102102

103103
```js
104104
import { fetchVerificationKeys } from "@copilot-extensions/preview-sdk";
105105

106106
// fetch without authentication
107-
const [current] = await fetchVerificationKeys();
107+
const { id, keys } = await fetchVerificationKeys();
108108

109109
// with token
110-
const [current] = await fetchVerificationKeys({ token: "ghp_1234" });
110+
const { id, keys } = await fetchVerificationKeys({ token: "ghp_1234" });
111111

112112
// with custom octokit request instance
113-
const [current] = await fetchVerificationKeys({ request });)
113+
const { id, keys } = await fetchVerificationKeys({ request });
114+
115+
// with cache
116+
const cache = { id: "etag_value", keys: [{ key_identifier: "key1", key: "public_key1" }] };
117+
const { id, keys } = await fetchVerificationKeys({ cache });
114118
```
119+
````
115120
116121
#### `async verifyRequestPayload(rawBody, signature, keyId)`
117122

lib/verification.js

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export async function fetchVerificationKeys(
5151

5252
throw error;
5353
}
54-
5554
}
5655

5756
/** @type {import('..').VerifyRequestByKeyIdInterface} */

0 commit comments

Comments
 (0)