1
1
import { CustomDomain } from 'auth0' ;
2
2
import DefaultAPIHandler , { order } from './default' ;
3
3
import { Asset , Assets } from '../../../types' ;
4
+ import log from '../../../logger' ;
4
5
5
6
export const schema = {
6
7
type : 'array' ,
@@ -18,6 +19,22 @@ export const schema = {
18
19
status : { type : 'string' , enum : [ 'pending_verification' , 'ready' , 'disabled' , 'pending' ] } ,
19
20
type : { type : 'string' , enum : [ 'auth0_managed_certs' , 'self_managed_certs' ] } ,
20
21
verification : { type : 'object' } ,
22
+ tls_policy : {
23
+ type : 'string' ,
24
+ description : 'Custom domain TLS policy. Must be `recommended`, includes TLS 1.2.' ,
25
+ defaultValue : 'recommended' ,
26
+ } ,
27
+ domain_metadata : {
28
+ type : 'object' ,
29
+ description : 'Domain metadata associated with the custom domain.' ,
30
+ defaultValue : undefined ,
31
+ maxProperties : 10 ,
32
+ } ,
33
+ verification_method : {
34
+ type : 'string' ,
35
+ description : 'Custom domain verification method. Must be `txt`.' ,
36
+ defaultValue : 'txt' ,
37
+ } ,
21
38
} ,
22
39
required : [ 'domain' , 'type' ] ,
23
40
} ,
@@ -31,10 +48,21 @@ export default class CustomDomainsHadnler extends DefaultAPIHandler {
31
48
...config ,
32
49
type : 'customDomains' ,
33
50
id : 'custom_domain_id' ,
34
- identifiers : [ 'domain' ] ,
35
- stripCreateFields : [ 'status' , 'primary' , 'verification' ] ,
51
+ identifiers : [ 'custom_domain_id' , 'domain' ] ,
52
+ stripCreateFields : [ 'status' , 'primary' , 'verification' , 'certificate' ] ,
53
+ stripUpdateFields : [
54
+ 'status' ,
55
+ 'primary' ,
56
+ 'verification' ,
57
+ 'type' ,
58
+ 'domain' ,
59
+ 'verification_method' ,
60
+ 'certificate' ,
61
+ ] ,
36
62
functions : {
37
63
delete : ( args ) => this . client . customDomains . delete ( { id : args . custom_domain_id } ) ,
64
+ update : ( args , data ) =>
65
+ this . client . customDomains . update ( { id : args . custom_domain_id } , data ) ,
38
66
} ,
39
67
} ) ;
40
68
}
@@ -71,29 +99,21 @@ export default class CustomDomainsHadnler extends DefaultAPIHandler {
71
99
const { customDomains } = assets ;
72
100
73
101
if ( ! customDomains ) return ;
74
- const changes = await this . calcChanges ( assets ) . then ( ( changes ) => {
75
- const changesWithoutUpdates = {
76
- ...changes ,
77
- create : changes . create . map ( ( customDomainToCreate ) => {
78
- const newCustomDomain = { ...customDomainToCreate } ;
79
- if ( customDomainToCreate . custom_client_ip_header === null ) {
80
- delete newCustomDomain . custom_client_ip_header ;
81
- }
82
102
83
- return newCustomDomain ;
84
- } ) ,
85
- delete : changes . del . map ( ( deleteToMake ) => {
86
- const deleteWithSDKCompatibleID = {
87
- ... deleteToMake ,
88
- id : deleteToMake . custom_domain_id ,
89
- } ;
90
- delete deleteWithSDKCompatibleID [ 'custom_domain_id' ] ;
91
- return deleteWithSDKCompatibleID ;
92
- } ) ,
93
- update : [ ] , //Do not perform custom domain updates because not supported by SDK
94
- } ;
95
- return changesWithoutUpdates ;
96
- } ) ;
103
+ // Deprecation warnings for custom domains
104
+ if ( customDomains . some ( ( customDomain ) => customDomain . primary != null ) ) {
105
+ log . warn (
106
+ 'The "primary" field is deprecated and may be removed in future versions for "customDomains"'
107
+ ) ;
108
+ }
109
+
110
+ if ( customDomains . some ( ( customDomain ) => 'verification_method' in customDomain ) ) {
111
+ log . warn (
112
+ 'The "verification_method" field is deprecated and may be removed in future versions for "customDomains"'
113
+ ) ;
114
+ }
115
+
116
+ const changes = await this . calcChanges ( assets ) ;
97
117
98
118
await super . processChanges ( assets , changes ) ;
99
119
}
0 commit comments