(host: string, token?: string)
| 18 | } |
| 19 | |
| 20 | export function authForHost(host: string, token?: string): AuthRecipe { |
| 21 | if (!token) return {}; |
| 22 | if (host.includes("github.com")) return { authorization: basicAuth("x-access-token", token) }; |
| 23 | if (host.includes("gitlab.com")) return { authorization: basicAuth("oauth2", token) }; |
| 24 | if (host.includes("bitbucket.org")) return { authorization: basicAuth("x-token-auth", token) }; |
| 25 | // generic (Gitea/self-hosted): token as password with arbitrary username |
| 26 | return { authorization: basicAuth("git", token) }; |
| 27 | } |
| 28 | |
| 29 | function baseHeaders(auth: AuthRecipe): Record<string, string> { |
| 30 | const h: Record<string, string> = { |
no test coverage detected