You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Closescopilot-extensions#9
Previously, clients who fetched verification keys from the server had no
way to cache those keys and reuse them for other requests.
This PR proposes a change using the GitHub API's [conditional
requests](https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api?apiVersion=2022-11-28#use-conditional-requests-if-appropriate)
feature: clients can optionally specify a cache for their keys and only
fetch new ones if the cache is outdated.
BREAKING CHANGE: `verifyRequestByKeyId() now returns an object with a
`isValid` property and a`cache` property.
Before
```js
const isValid = await verifyRequestByKeyId();
```
After
```js
const { isValid, cache } = await verifyRequestByKeyId();
```
BREAKING CHANGE: `fetchVerificationKeys()` now returns an object with a
`keys` property and a`cache` property.
Before
```js
const keys = await fetchVerificationKeys();
```
After
```js
const { keys, cache } = await fetchVerificationKeys();
```
---------
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
Verify the request payload using the provided signature and key ID. The method will request the public key from GitHub's API for the given keyId and then verify the payload.
78
79
79
-
The `options` argument is optional. It can contain a `token` to authenticate the request to GitHub's API, or a custom `request` instance to use for the request.
80
+
The `requestOptions` argument is optional. It can contain:
81
+
82
+
- a `token` to authenticate the request to GitHub's API
83
+
- a custom [octokit `request`](https://github.com/octokit/request.js) instance to use for the request
Fetches public keys for verifying copilot extension requests [from GitHub's API](https://api.github.com/meta/public_keys/copilot_api)
100
-
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.
126
+
Fetches public keys for verifying copilot extension requests [from GitHub's API](https://api.github.com/meta/public_keys/copilot_api) 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.
0 commit comments