auth0
Version:
Auth0 Node.js SDK for the Management API v2.
32 lines (31 loc) • 1.43 kB
JavaScript
// This file was auto-generated by Fern from our API Definition.
import { BearerAuthProvider } from "./auth/BearerAuthProvider.mjs";
import * as core from "./core/index.mjs";
export function normalizeClientOptions(options) {
return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging) });
}
export function normalizeClientOptionsWithAuth(options) {
var _a;
const normalized = normalizeClientOptions(options);
if (options.auth === false) {
normalized.authProvider = new core.NoOpAuthProvider();
return normalized;
}
if (options.auth != null) {
if (typeof options.auth === "function") {
normalized.authProvider = { getAuthRequest: options.auth };
return normalized;
}
if (core.isAuthProvider(options.auth)) {
normalized.authProvider = options.auth;
return normalized;
}
Object.assign(normalized, options.auth);
}
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider(normalizedWithNoOpAuthProvider));
return normalized;
}
function withNoOpAuthProvider(options) {
return Object.assign(Object.assign({}, options), { authProvider: new core.NoOpAuthProvider() });
}