Skip to content

Make the authStrategy parameter work with the static .withDefaults() method #20

@gr2m

Description

@gr2m

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions