// This file was auto-generated by Fern from our API Definition. import * as core from "../core/index.js"; import * as errors from "../errors/index.js"; const TOKEN_PARAM = "token" as const; export class BearerAuthProvider implements core.AuthProvider { private readonly options: BearerAuthProvider.Options; constructor(options: BearerAuthProvider.Options) { this.options = options; } public static canCreate(options: Partial): boolean { return options?.[TOKEN_PARAM] != null; } public async getAuthRequest({ endpointMetadata, }: { endpointMetadata?: core.EndpointMetadata; } = {}): Promise { const token = await core.Supplier.get(this.options[TOKEN_PARAM]); if (token == null) { throw new errors.CloudPDFError({ message: BearerAuthProvider.AUTH_CONFIG_ERROR_MESSAGE, }); } return { headers: { Authorization: `Bearer ${token}` }, }; } } export namespace BearerAuthProvider { export const AUTH_SCHEME = "apiToken" as const; export const AUTH_CONFIG_ERROR_MESSAGE: string = `Please provide '${TOKEN_PARAM}' when initializing the client` as const; export type Options = AuthOptions; export type AuthOptions = { [TOKEN_PARAM]?: core.Supplier }; export function createInstance(options: Options): core.AuthProvider { return new BearerAuthProvider(options); } }