octokit-next.js
octokit-next.js copied to clipboard
Make the `authStrategy` parameter work with the static `.withDefaults()` method
follow up to #18 and related to #11
What we want is the following
import { Octokit } from "@octokit-next/core";
type CallbackStrategyOptions = {
callback: () => string | Promise<string>;
};
function createCallbackAuth(options: CallbackStrategyOptions) {
return async function auth() {
return options.callback();
};
}
const OctokitWithCallbackAuth = Octokit.withDefaults({
authStrategy: createCallbackAuth,
});
// compiler should complain: `{ auth }` should be required because `authStrategy` is set to `createCallbackAuth` by default
new OctokitWithCallbackAuth();
Here is how auth strategies work in Octokit via the authStrategy and auth options:
https://github.com/octokit/authentication-strategies.js#authenticationstrategystrategyoptions
I got some of the necessary work done, but it's not fully working yet, I left a few TODO: comments in the code
https://github.com/octokit/octokit-next.js/blob/af7fdecc699591c4045f9e96b8d1c41869f60703/tests/js/auth/index.test-d.ts#L63-L75
:tada: This issue has been resolved in version 1.15.6 :tada:
The release is available on:
- GitHub release
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
- npm package (@latest dist-tag)
Your semantic-release bot :package::rocket: