auth0
Version:
Auth0 Node.js SDK for the Management API v2.
558 lines (557 loc) • 34.1 kB
JavaScript
"use strict";
// This file was auto-generated by Fern from our API Definition.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomDomainsClient = void 0;
const BaseClient_js_1 = require("../../../../BaseClient.js");
const core = __importStar(require("../../../../core/index.js"));
const headers_js_1 = require("../../../../core/headers.js");
const environments = __importStar(require("../../../../environments.js"));
const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
const errors = __importStar(require("../../../../errors/index.js"));
const Management = __importStar(require("../../../index.js"));
class CustomDomainsClient {
constructor(options) {
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
}
/**
* Retrieve details on <a href="https://auth0.com/docs/custom-domains">custom domains</a>.
*
* @param {Management.ListCustomDomainsRequestParameters} request
* @param {CustomDomainsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Management.UnauthorizedError}
* @throws {@link Management.ForbiddenError}
* @throws {@link Management.TooManyRequestsError}
*
* @example
* await client.customDomains.list({
* q: "q",
* fields: "fields",
* include_fields: true,
* sort: "sort"
* })
*/
list(request = {}, requestOptions) {
return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
}
__list() {
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
const { q, fields, include_fields: includeFields, sort } = request;
const _queryParams = {};
if (q !== undefined) {
_queryParams["q"] = q;
}
if (fields !== undefined) {
_queryParams["fields"] = fields;
}
if (includeFields !== undefined) {
_queryParams["include_fields"] = (_a = includeFields === null || includeFields === void 0 ? void 0 : includeFields.toString()) !== null && _a !== void 0 ? _a : null;
}
if (sort !== undefined) {
_queryParams["sort"] = sort;
}
const _authRequest = yield this._options.authProvider.getAuthRequest();
let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_b = this._options) === null || _b === void 0 ? void 0 : _b.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
const _response = yield ((_c = this._options.fetcher) !== null && _c !== void 0 ? _c : core.fetcher)({
url: core.url.join((_e = (_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ManagementEnvironment.Default, "custom-domains"),
method: "GET",
headers: _headers,
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return {
data: _response.body,
rawResponse: _response.rawResponse,
};
}
if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 401:
throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse);
case 403:
throw new Management.ForbiddenError(_response.error.body, _response.rawResponse);
case 429:
throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse);
default:
throw new errors.ManagementError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
}
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/custom-domains");
});
}
/**
* Create a new custom domain.
*
* Note: The custom domain will need to be verified before it will accept
* requests.
*
* Optional attributes that can be updated:
*
* - custom_client_ip_header
* - tls_policy
*
*
* TLS Policies:
*
* - recommended - for modern usage this includes TLS 1.2 only
*
* @param {Management.CreateCustomDomainRequestContent} request
* @param {CustomDomainsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Management.BadRequestError}
* @throws {@link Management.UnauthorizedError}
* @throws {@link Management.ForbiddenError}
* @throws {@link Management.ConflictError}
* @throws {@link Management.TooManyRequestsError}
*
* @example
* await client.customDomains.create({
* domain: "domain",
* type: "auth0_managed_certs"
* })
*/
create(request, requestOptions) {
return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
}
__create(request, requestOptions) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
const _authRequest = yield this._options.authProvider.getAuthRequest();
let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, "custom-domains"),
method: "POST",
headers: _headers,
contentType: "application/json",
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
requestType: "json",
body: request,
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return {
data: _response.body,
rawResponse: _response.rawResponse,
};
}
if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Management.BadRequestError(_response.error.body, _response.rawResponse);
case 401:
throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse);
case 403:
throw new Management.ForbiddenError(_response.error.body, _response.rawResponse);
case 409:
throw new Management.ConflictError(_response.error.body, _response.rawResponse);
case 429:
throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse);
default:
throw new errors.ManagementError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
}
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/custom-domains");
});
}
/**
* Retrieve a custom domain configuration and status.
*
* @param {string} id - ID of the custom domain to retrieve.
* @param {CustomDomainsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Management.BadRequestError}
* @throws {@link Management.UnauthorizedError}
* @throws {@link Management.ForbiddenError}
* @throws {@link Management.NotFoundError}
* @throws {@link Management.TooManyRequestsError}
*
* @example
* await client.customDomains.get("id")
*/
get(id, requestOptions) {
return core.HttpResponsePromise.fromPromise(this.__get(id, requestOptions));
}
__get(id, requestOptions) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
const _authRequest = yield this._options.authProvider.getAuthRequest();
let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, `custom-domains/${core.url.encodePathParam(id)}`),
method: "GET",
headers: _headers,
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return {
data: _response.body,
rawResponse: _response.rawResponse,
};
}
if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Management.BadRequestError(_response.error.body, _response.rawResponse);
case 401:
throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse);
case 403:
throw new Management.ForbiddenError(_response.error.body, _response.rawResponse);
case 404:
throw new Management.NotFoundError(_response.error.body, _response.rawResponse);
case 429:
throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse);
default:
throw new errors.ManagementError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
}
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/custom-domains/{id}");
});
}
/**
* Delete a custom domain and stop serving requests for it.
*
* @param {string} id - ID of the custom domain to delete.
* @param {CustomDomainsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Management.BadRequestError}
* @throws {@link Management.UnauthorizedError}
* @throws {@link Management.ForbiddenError}
* @throws {@link Management.TooManyRequestsError}
*
* @example
* await client.customDomains.delete("id")
*/
delete(id, requestOptions) {
return core.HttpResponsePromise.fromPromise(this.__delete(id, requestOptions));
}
__delete(id, requestOptions) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
const _authRequest = yield this._options.authProvider.getAuthRequest();
let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, `custom-domains/${core.url.encodePathParam(id)}`),
method: "DELETE",
headers: _headers,
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return { data: undefined, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Management.BadRequestError(_response.error.body, _response.rawResponse);
case 401:
throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse);
case 403:
throw new Management.ForbiddenError(_response.error.body, _response.rawResponse);
case 429:
throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse);
default:
throw new errors.ManagementError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
}
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/custom-domains/{id}");
});
}
/**
* Update a custom domain.
*
* These are the attributes that can be updated:
*
* - custom_client_ip_header
* - tls_policy
*
* <h5>Updating CUSTOM_CLIENT_IP_HEADER for a custom domain</h5>To update the <code>custom_client_ip_header</code> for a domain, the body to
* send should be:
* <pre><code>{ "custom_client_ip_header": "cf-connecting-ip" }</code></pre>
*
* <h5>Updating TLS_POLICY for a custom domain</h5>To update the <code>tls_policy</code> for a domain, the body to send should be:
* <pre><code>{ "tls_policy": "recommended" }</code></pre>
*
*
* TLS Policies:
*
* - recommended - for modern usage this includes TLS 1.2 only
*
*
* Some considerations:
*
* - The TLS ciphers and protocols available in each TLS policy follow industry recommendations, and may be updated occasionally.
* - The <code>compatible</code> TLS policy is no longer supported.
*
* @param {string} id - The id of the custom domain to update
* @param {Management.UpdateCustomDomainRequestContent} request
* @param {CustomDomainsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Management.BadRequestError}
* @throws {@link Management.UnauthorizedError}
* @throws {@link Management.ForbiddenError}
* @throws {@link Management.TooManyRequestsError}
*
* @example
* await client.customDomains.update("id")
*/
update(id, request = {}, requestOptions) {
return core.HttpResponsePromise.fromPromise(this.__update(id, request, requestOptions));
}
__update(id_1) {
return __awaiter(this, arguments, void 0, function* (id, request = {}, requestOptions) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
const _authRequest = yield this._options.authProvider.getAuthRequest();
let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, `custom-domains/${core.url.encodePathParam(id)}`),
method: "PATCH",
headers: _headers,
contentType: "application/json",
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
requestType: "json",
body: request,
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return {
data: _response.body,
rawResponse: _response.rawResponse,
};
}
if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Management.BadRequestError(_response.error.body, _response.rawResponse);
case 401:
throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse);
case 403:
throw new Management.ForbiddenError(_response.error.body, _response.rawResponse);
case 429:
throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse);
default:
throw new errors.ManagementError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
}
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PATCH", "/custom-domains/{id}");
});
}
/**
* Run the test process on a custom domain.
*
* @param {string} id - ID of the custom domain to test.
* @param {CustomDomainsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Management.BadRequestError}
* @throws {@link Management.UnauthorizedError}
* @throws {@link Management.ForbiddenError}
* @throws {@link Management.NotFoundError}
* @throws {@link Management.ConflictError}
*
* @example
* await client.customDomains.test("id")
*/
test(id, requestOptions) {
return core.HttpResponsePromise.fromPromise(this.__test(id, requestOptions));
}
__test(id, requestOptions) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
const _authRequest = yield this._options.authProvider.getAuthRequest();
let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, `custom-domains/${core.url.encodePathParam(id)}/test`),
method: "POST",
headers: _headers,
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return {
data: _response.body,
rawResponse: _response.rawResponse,
};
}
if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Management.BadRequestError(_response.error.body, _response.rawResponse);
case 401:
throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse);
case 403:
throw new Management.ForbiddenError(_response.error.body, _response.rawResponse);
case 404:
throw new Management.NotFoundError(_response.error.body, _response.rawResponse);
case 409:
throw new Management.ConflictError(_response.error.body, _response.rawResponse);
default:
throw new errors.ManagementError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
}
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/custom-domains/{id}/test");
});
}
/**
* Run the verification process on a custom domain.
*
* Note: Check the <code>status</code> field to see its verification status. Once verification is complete, it may take up to 10 minutes before the custom domain can start accepting requests.
*
* For <code>self_managed_certs</code>, when the custom domain is verified for the first time, the response will also include the <code>cname_api_key</code> which you will need to configure your proxy. This key must be kept secret, and is used to validate the proxy requests.
*
* <a href="https://auth0.com/docs/custom-domains#step-2-verify-ownership">Learn more</a> about verifying custom domains that use Auth0 Managed certificates.
* <a href="https://auth0.com/docs/custom-domains/self-managed-certificates#step-2-verify-ownership">Learn more</a> about verifying custom domains that use Self Managed certificates.
*
* @param {string} id - ID of the custom domain to verify.
* @param {CustomDomainsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Management.BadRequestError}
* @throws {@link Management.UnauthorizedError}
* @throws {@link Management.ForbiddenError}
* @throws {@link Management.NotFoundError}
* @throws {@link Management.TooManyRequestsError}
*
* @example
* await client.customDomains.verify("id")
*/
verify(id, requestOptions) {
return core.HttpResponsePromise.fromPromise(this.__verify(id, requestOptions));
}
__verify(id, requestOptions) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
const _authRequest = yield this._options.authProvider.getAuthRequest();
let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, `custom-domains/${core.url.encodePathParam(id)}/verify`),
method: "POST",
headers: _headers,
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
logging: this._options.logging,
});
if (_response.ok) {
return {
data: _response.body,
rawResponse: _response.rawResponse,
};
}
if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Management.BadRequestError(_response.error.body, _response.rawResponse);
case 401:
throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse);
case 403:
throw new Management.ForbiddenError(_response.error.body, _response.rawResponse);
case 404:
throw new Management.NotFoundError(_response.error.body, _response.rawResponse);
case 429:
throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse);
default:
throw new errors.ManagementError({
statusCode: _response.error.statusCode,
body: _response.error.body,
rawResponse: _response.rawResponse,
});
}
}
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/custom-domains/{id}/verify");
});
}
}
exports.CustomDomainsClient = CustomDomainsClient;