/
custom-domains-manager.ts
230 lines (209 loc) · 6.9 KB
/
custom-domains-manager.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import * as runtime from '../../../lib/runtime.js';
import type { InitOverride, ApiResponse } from '../../../lib/runtime.js';
import type {
CustomDomain,
PatchCustomDomainsByIdRequest,
PostCustomDomains201Response,
PostCustomDomainsRequest,
PostVerify200Response,
DeleteCustomDomainsByIdRequest,
GetCustomDomainsByIdRequest,
PatchCustomDomainsByIdOperationRequest,
PostVerifyRequest,
} from '../models/index.js';
const { BaseAPI } = runtime;
/**
*
*/
export class CustomDomainsManager extends BaseAPI {
/**
* Delete a custom domain and stop serving requests for it.
* Delete custom domain configuration
*
* @throws {RequiredError}
*/
async delete(
requestParameters: DeleteCustomDomainsByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const response = await this.request(
{
path: `/custom-domains/{id}`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'DELETE',
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Retrieve details on <a href="https://auth0.com/docs/custom-domains">custom domains</a>.
* Get custom domains configurations
*
* @throws {RequiredError}
*/
async getAll(initOverrides?: InitOverride): Promise<ApiResponse<Array<CustomDomain>>> {
const response = await this.request(
{
path: `/custom-domains`,
method: 'GET',
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Retrieve a custom domain configuration and status.
* Get custom domain configuration
*
* @throws {RequiredError}
*/
async get(
requestParameters: GetCustomDomainsByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<CustomDomain>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const response = await this.request(
{
path: `/custom-domains/{id}`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'GET',
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* 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": "compatible" }</code></pre>
*
*
* TLS Policies:
*
* - recommended - for modern usage this includes TLS 1.2 only
* - compatible - compatible with older browsers this policy includes TLS 1.0, 1.1, 1.2
*
*
* Some considerations:
*
* - The TLS ciphers and protocols available in each TLS policy follow industry recommendations, and may be updated occasionally.
* - Do not use the <code>compatible</code> TLS policy unless you have clients that require TLS 1.0.
*
* Update custom domain configuration
*
* @throws {RequiredError}
*/
async update(
requestParameters: PatchCustomDomainsByIdOperationRequest,
bodyParameters: PatchCustomDomainsByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<PostCustomDomains201Response>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/custom-domains/{id}`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'PATCH',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* 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
* - compatible - compatible with older browsers this policy includes TLS 1.0, 1.1, 1.2
*
*
* Some considerations:
*
* - The TLS ciphers and protocols available in each TLS policy follow industry recommendations, and may be updated occasionally.
* - Do not use the <code>compatible</code> TLS policy unless you have clients that require TLS 1.0.
*
* Configure a new custom domain
*
* @throws {RequiredError}
*/
async create(
bodyParameters: PostCustomDomainsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<PostCustomDomains201Response>> {
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/custom-domains`,
method: 'POST',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* 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.
*
* Verify a custom domain
*
* @throws {RequiredError}
*/
async verify(
requestParameters: PostVerifyRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<PostVerify200Response>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const response = await this.request(
{
path: `/custom-domains/{id}/verify`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'POST',
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
}