UNPKG

@octokit/auth-token

Version:

GitHub API token authentication for browsers and Node.js

20 lines (19 loc) 545 B
import { auth } from "./auth.js"; import { hook } from "./hook.js"; const createTokenAuth = function createTokenAuth2(token) { if (!token) { throw new Error("[@octokit/auth-token] No token passed to createTokenAuth"); } if (typeof token !== "string") { throw new Error( "[@octokit/auth-token] Token passed to createTokenAuth is not a string" ); } token = token.replace(/^(token|bearer) +/i, ""); return Object.assign(auth.bind(null, token), { hook: hook.bind(null, token) }); }; export { createTokenAuth };