UNPKG

@rdfc/http-utils-processor-ts

Version:
15 lines (14 loc) 486 B
import { HttpUtilsError } from "../error.js"; import { HttpBasicAuth } from "./basic.js"; import { OAuth2PasswordAuth } from "./oauth/password.js"; export class Auth { static from(config) { if (config.type == "basic") { return HttpBasicAuth.from(config); } if (config.type === "oauth2") { return OAuth2PasswordAuth.from(config); } throw HttpUtilsError.illegalParameters(`Unknown auth type: '${config.type}'`); } }