auth0-deploy-cli 7.11.1 → 7.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.12.0] - 2022-05-10
11
+
12
+ ### Added
13
+
14
+ - Prompts support (both prompts settings and custom text for prompts) [#530]
15
+ - Custom domains support [#527]
16
+
10
17
  ## [7.11.1] - 2022-05-04
11
18
 
12
19
  ### Fixed
@@ -723,7 +730,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
723
730
  [#517]: https://github.com/auth0/auth0-deploy-cli/issues/517
724
731
  [#524]: https://github.com/auth0/auth0-deploy-cli/issues/524
725
732
  [#526]: https://github.com/auth0/auth0-deploy-cli/issues/526
726
- [unreleased]: https://github.com/auth0/auth0-deploy-cli/compare/v7.11.1...HEAD
733
+ [#527]: https://github.com/auth0/auth0-deploy-cli/issues/527
734
+ [#530]: https://github.com/auth0/auth0-deploy-cli/issues/530
735
+ [unreleased]: https://github.com/auth0/auth0-deploy-cli/compare/v7.12.0...HEAD
736
+ [7.12.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.11.1...v7.12.0
727
737
  [7.11.1]: https://github.com/auth0/auth0-deploy-cli/compare/v7.11.0...v7.11.1
728
738
  [7.11.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.10.0...v7.11.0
729
739
  [7.10.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.9.0...v7.10.0
@@ -0,0 +1,5 @@
1
+ import { DirectoryHandler } from '.';
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedCustomDomains = ParsedAsset<'customDomains', Asset[]>;
4
+ declare const customDomainsHandler: DirectoryHandler<ParsedCustomDomains>;
5
+ export default customDomainsHandler;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const fs_extra_1 = __importDefault(require("fs-extra"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const tools_1 = require("../../../tools");
18
+ const utils_1 = require("../../../utils");
19
+ const getCustomDomainsDirectory = (filePath) => path_1.default.join(filePath, tools_1.constants.CUSTOM_DOMAINS_DIRECTORY);
20
+ const getCustomDomainsFile = (filePath) => path_1.default.join(getCustomDomainsDirectory(filePath), 'custom-domains.json');
21
+ function parse(context) {
22
+ const customDomainsDirectory = getCustomDomainsDirectory(context.filePath);
23
+ if (!(0, utils_1.existsMustBeDir)(customDomainsDirectory))
24
+ return { customDomains: null }; // Skip
25
+ const customDomainsFile = getCustomDomainsFile(context.filePath);
26
+ return {
27
+ customDomains: (0, utils_1.loadJSON)(customDomainsFile, context.mappings),
28
+ };
29
+ }
30
+ function dump(context) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const { customDomains } = context.assets;
33
+ if (!customDomains)
34
+ return; // Skip, nothing to dump
35
+ // Create Rules folder
36
+ const customDomainsDirectory = getCustomDomainsDirectory(context.filePath);
37
+ fs_extra_1.default.ensureDirSync(customDomainsDirectory);
38
+ const customDomainsFile = getCustomDomainsFile(context.filePath);
39
+ (0, utils_1.dumpJSON)(customDomainsFile, customDomains);
40
+ });
41
+ }
42
+ const customDomainsHandler = {
43
+ parse,
44
+ dump,
45
+ };
46
+ exports.default = customDomainsHandler;
@@ -29,6 +29,8 @@ const triggers_1 = __importDefault(require("./triggers"));
29
29
  const attackProtection_1 = __importDefault(require("./attackProtection"));
30
30
  const branding_1 = __importDefault(require("./branding"));
31
31
  const logStreams_1 = __importDefault(require("./logStreams"));
32
+ const prompts_1 = __importDefault(require("./prompts"));
33
+ const customDomains_1 = __importDefault(require("./customDomains"));
32
34
  const directoryHandlers = {
33
35
  rules: rules_1.default,
34
36
  rulesConfigs: rulesConfigs_1.default,
@@ -56,5 +58,7 @@ const directoryHandlers = {
56
58
  attackProtection: attackProtection_1.default,
57
59
  branding: branding_1.default,
58
60
  logStreams: logStreams_1.default,
61
+ prompts: prompts_1.default,
62
+ customDomains: customDomains_1.default,
59
63
  };
60
64
  exports.default = directoryHandlers;
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ import { ParsedAsset } from '../../../types';
3
+ import { Prompts } from '../../../tools/auth0/handlers/prompts';
4
+ declare type ParsedPrompts = ParsedAsset<'prompts', Prompts>;
5
+ declare const promptsHandler: DirectoryHandler<ParsedPrompts>;
6
+ export default promptsHandler;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const path_1 = __importDefault(require("path"));
27
+ const fs_extra_1 = require("fs-extra");
28
+ const tools_1 = require("../../../tools");
29
+ const utils_1 = require("../../../utils");
30
+ const getPromptsDirectory = (filePath) => {
31
+ return path_1.default.join(filePath, tools_1.constants.PROMPTS_DIRECTORY);
32
+ };
33
+ const getPromptsSettingsFile = (promptsDirectory) => {
34
+ return path_1.default.join(promptsDirectory, 'prompts.json');
35
+ };
36
+ const getCustomTextFile = (promptsDirectory) => {
37
+ return path_1.default.join(promptsDirectory, 'custom-text.json');
38
+ };
39
+ function parse(context) {
40
+ const promptsDirectory = getPromptsDirectory(context.filePath);
41
+ if (!(0, utils_1.existsMustBeDir)(promptsDirectory))
42
+ return { prompts: null }; // Skip
43
+ const promptsSettings = (() => {
44
+ const promptsSettingsFile = getPromptsSettingsFile(promptsDirectory);
45
+ if (!(0, utils_1.isFile)(promptsSettingsFile))
46
+ return {};
47
+ return (0, utils_1.loadJSON)(promptsSettingsFile, context.mappings);
48
+ })();
49
+ const customText = (() => {
50
+ const customTextFile = getCustomTextFile(promptsDirectory);
51
+ if (!(0, utils_1.isFile)(customTextFile))
52
+ return {};
53
+ return (0, utils_1.loadJSON)(customTextFile, context.mappings);
54
+ })();
55
+ return {
56
+ prompts: Object.assign(Object.assign({}, promptsSettings), { customText }),
57
+ };
58
+ }
59
+ function dump(context) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const { prompts } = context.assets;
62
+ if (!prompts)
63
+ return;
64
+ const { customText } = prompts, promptsSettings = __rest(prompts, ["customText"]);
65
+ const promptsDirectory = getPromptsDirectory(context.filePath);
66
+ (0, fs_extra_1.ensureDirSync)(promptsDirectory);
67
+ if (!promptsSettings)
68
+ return;
69
+ const promptsSettingsFile = getPromptsSettingsFile(promptsDirectory);
70
+ (0, utils_1.dumpJSON)(promptsSettingsFile, promptsSettings);
71
+ if (!customText)
72
+ return;
73
+ const customTextFile = getCustomTextFile(promptsDirectory);
74
+ (0, utils_1.dumpJSON)(customTextFile, customText);
75
+ });
76
+ }
77
+ const promptsHandler = {
78
+ parse,
79
+ dump,
80
+ };
81
+ exports.default = promptsHandler;
@@ -0,0 +1,5 @@
1
+ import { YAMLHandler } from '.';
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedCustomDomains = ParsedAsset<'customDomains', Asset[]>;
4
+ declare const customDomainsHandler: YAMLHandler<ParsedCustomDomains>;
5
+ export default customDomainsHandler;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ function parseAndDump(context) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ const { customDomains } = context.assets;
15
+ if (!customDomains)
16
+ return { customDomains: null };
17
+ return {
18
+ customDomains,
19
+ };
20
+ });
21
+ }
22
+ const customDomainsHandler = {
23
+ parse: parseAndDump,
24
+ dump: parseAndDump,
25
+ };
26
+ exports.default = customDomainsHandler;
@@ -29,6 +29,8 @@ const triggers_1 = __importDefault(require("./triggers"));
29
29
  const attackProtection_1 = __importDefault(require("./attackProtection"));
30
30
  const branding_1 = __importDefault(require("./branding"));
31
31
  const logStreams_1 = __importDefault(require("./logStreams"));
32
+ const prompts_1 = __importDefault(require("./prompts"));
33
+ const customDomains_1 = __importDefault(require("./customDomains"));
32
34
  const yamlHandlers = {
33
35
  rules: rules_1.default,
34
36
  hooks: hooks_1.default,
@@ -56,5 +58,7 @@ const yamlHandlers = {
56
58
  attackProtection: attackProtection_1.default,
57
59
  branding: branding_1.default,
58
60
  logStreams: logStreams_1.default,
61
+ prompts: prompts_1.default,
62
+ customDomains: customDomains_1.default,
59
63
  };
60
64
  exports.default = yamlHandlers;
@@ -0,0 +1,6 @@
1
+ import { YAMLHandler } from '.';
2
+ import { ParsedAsset } from '../../../types';
3
+ import { Prompts } from '../../../tools/auth0/handlers/prompts';
4
+ declare type ParsedPrompts = ParsedAsset<'prompts', Prompts>;
5
+ declare const promptsHandler: YAMLHandler<ParsedPrompts>;
6
+ export default promptsHandler;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ function parseAndDump(context) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ const { prompts } = context.assets;
15
+ if (!prompts)
16
+ return { prompts: null };
17
+ return {
18
+ prompts,
19
+ };
20
+ });
21
+ }
22
+ const promptsHandler = {
23
+ parse: parseAndDump,
24
+ dump: parseAndDump,
25
+ };
26
+ exports.default = promptsHandler;
package/lib/index.d.ts CHANGED
@@ -77,6 +77,8 @@ declare const _default: {
77
77
  EMAIL_TEMPLATES_NAMES: string[];
78
78
  SUPPORTED_BRANDING_TEMPLATES: string[];
79
79
  LOG_STREAMS_DIRECTORY: string;
80
+ PROMPTS_DIRECTORY: string;
81
+ CUSTOM_DOMAINS_DIRECTORY: string;
80
82
  };
81
83
  deploy: typeof import("./tools").deploy;
82
84
  keywordReplace: typeof import("./tools").keywordReplace;
@@ -0,0 +1,43 @@
1
+ import DefaultAPIHandler from './default';
2
+ import { Asset, Assets } from '../../../types';
3
+ export declare const schema: {
4
+ type: string;
5
+ items: {
6
+ type: string;
7
+ properties: {
8
+ custom_domain_id: {
9
+ type: string;
10
+ };
11
+ custom_client_ip_header: {
12
+ type: string;
13
+ nullable: boolean;
14
+ enum: (string | null)[];
15
+ };
16
+ domain: {
17
+ type: string;
18
+ };
19
+ primary: {
20
+ type: string;
21
+ };
22
+ status: {
23
+ type: string;
24
+ enum: string[];
25
+ };
26
+ type: {
27
+ type: string;
28
+ enum: string[];
29
+ };
30
+ verification: {
31
+ type: string;
32
+ };
33
+ };
34
+ required: string[];
35
+ };
36
+ };
37
+ export default class CustomDomainsHadnler extends DefaultAPIHandler {
38
+ existing: Asset[] | null;
39
+ constructor(config: DefaultAPIHandler);
40
+ objString(item: Asset): string;
41
+ getType(): Promise<Asset>;
42
+ processChanges(assets: Assets): Promise<void>;
43
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.schema = void 0;
16
+ const default_1 = __importDefault(require("./default"));
17
+ exports.schema = {
18
+ type: 'array',
19
+ items: {
20
+ type: 'object',
21
+ properties: {
22
+ custom_domain_id: { type: 'string' },
23
+ custom_client_ip_header: {
24
+ type: 'string',
25
+ nullable: true,
26
+ enum: ['true-client-ip', 'cf-connecting-ip', 'x-forwarded-for', null],
27
+ },
28
+ domain: { type: 'string' },
29
+ primary: { type: 'boolean' },
30
+ status: { type: 'string', enum: ['pending_verification', 'ready', 'disabled', 'pending'] },
31
+ type: { type: 'string', enum: ['auth0_managed_certs', 'self_managed_certs'] },
32
+ verification: { type: 'object' },
33
+ },
34
+ required: ['domain', 'type'],
35
+ },
36
+ };
37
+ class CustomDomainsHadnler extends default_1.default {
38
+ constructor(config) {
39
+ super(Object.assign(Object.assign({}, config), { type: 'customDomains', id: 'custom_domain_id', identifiers: ['domain'], stripCreateFields: ['status', 'primary', 'verification'], functions: {
40
+ //@ts-ignore
41
+ delete: (args) => {
42
+ return this.client.customDomains.delete({ id: args.custom_domain_id });
43
+ },
44
+ } }));
45
+ }
46
+ objString(item) {
47
+ return super.objString(item.domain);
48
+ }
49
+ getType() {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ if (this.existing) {
52
+ return this.existing;
53
+ }
54
+ const customDomains = yield this.client.customDomains.getAll({ paginate: false });
55
+ this.existing = customDomains;
56
+ return customDomains;
57
+ });
58
+ }
59
+ processChanges(assets) {
60
+ const _super = Object.create(null, {
61
+ processChanges: { get: () => super.processChanges }
62
+ });
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const { customDomains } = assets;
65
+ if (!customDomains)
66
+ return;
67
+ const changes = yield this.calcChanges(assets).then((changes) => {
68
+ const changesWithoutUpdates = Object.assign(Object.assign({}, changes), { create: changes.create.map((customDomainToCreate) => {
69
+ const newCustomDomain = Object.assign({}, customDomainToCreate);
70
+ if (customDomainToCreate.custom_client_ip_header === null) {
71
+ delete newCustomDomain.custom_client_ip_header;
72
+ }
73
+ return newCustomDomain;
74
+ }), delete: changes.del.map((deleteToMake) => {
75
+ const deleteWithSDKCompatibleID = Object.assign(Object.assign({}, deleteToMake), { id: deleteToMake.custom_domain_id });
76
+ delete deleteWithSDKCompatibleID['custom_domain_id'];
77
+ return deleteWithSDKCompatibleID;
78
+ }), update: [] });
79
+ return changesWithoutUpdates;
80
+ });
81
+ yield _super.processChanges.call(this, assets, changes);
82
+ });
83
+ }
84
+ }
85
+ exports.default = CustomDomainsHadnler;
@@ -5,37 +5,37 @@ declare const _default: {
5
5
  excludeSchema?: any;
6
6
  schema: any;
7
7
  };
8
- rulesConfigs: {
8
+ hooks: {
9
9
  default: typeof APIHandler;
10
10
  excludeSchema?: any;
11
11
  schema: any;
12
12
  };
13
- hooks: {
13
+ actions: {
14
14
  default: typeof APIHandler;
15
15
  excludeSchema?: any;
16
16
  schema: any;
17
17
  };
18
- pages: {
18
+ triggers: {
19
19
  default: typeof APIHandler;
20
20
  excludeSchema?: any;
21
21
  schema: any;
22
22
  };
23
- databases: {
23
+ pages: {
24
24
  default: typeof APIHandler;
25
25
  excludeSchema?: any;
26
26
  schema: any;
27
27
  };
28
- clientGrants: {
28
+ resourceServers: {
29
29
  default: typeof APIHandler;
30
30
  excludeSchema?: any;
31
31
  schema: any;
32
32
  };
33
- resourceServers: {
33
+ clients: {
34
34
  default: typeof APIHandler;
35
35
  excludeSchema?: any;
36
36
  schema: any;
37
37
  };
38
- clients: {
38
+ branding: {
39
39
  default: typeof APIHandler;
40
40
  excludeSchema?: any;
41
41
  schema: any;
@@ -45,87 +45,97 @@ declare const _default: {
45
45
  excludeSchema?: any;
46
46
  schema: any;
47
47
  };
48
- tenant: {
48
+ roles: {
49
49
  default: typeof APIHandler;
50
50
  excludeSchema?: any;
51
51
  schema: any;
52
52
  };
53
- emailProvider: {
53
+ prompts: {
54
54
  default: typeof APIHandler;
55
55
  excludeSchema?: any;
56
56
  schema: any;
57
57
  };
58
- emailTemplates: {
58
+ attackProtection: {
59
59
  default: typeof APIHandler;
60
60
  excludeSchema?: any;
61
61
  schema: any;
62
62
  };
63
- guardianFactors: {
63
+ clientGrants: {
64
64
  default: typeof APIHandler;
65
65
  excludeSchema?: any;
66
66
  schema: any;
67
67
  };
68
- guardianFactorProviders: {
68
+ customDomains: {
69
69
  default: typeof APIHandler;
70
70
  excludeSchema?: any;
71
71
  schema: any;
72
72
  };
73
- guardianFactorTemplates: {
73
+ databases: {
74
74
  default: typeof APIHandler;
75
75
  excludeSchema?: any;
76
76
  schema: any;
77
77
  };
78
- migrations: {
78
+ emailProvider: {
79
79
  default: typeof APIHandler;
80
80
  excludeSchema?: any;
81
81
  schema: any;
82
82
  };
83
- guardianPhoneFactorMessageTypes: {
83
+ emailTemplates: {
84
84
  default: typeof APIHandler;
85
85
  excludeSchema?: any;
86
86
  schema: any;
87
87
  };
88
- guardianPhoneFactorSelectedProvider: {
88
+ guardianFactorProviders: {
89
89
  default: typeof APIHandler;
90
90
  excludeSchema?: any;
91
91
  schema: any;
92
92
  };
93
- guardianPolicies: {
93
+ guardianFactors: {
94
94
  default: typeof APIHandler;
95
95
  excludeSchema?: any;
96
96
  schema: any;
97
97
  };
98
- roles: {
98
+ guardianFactorTemplates: {
99
99
  default: typeof APIHandler;
100
100
  excludeSchema?: any;
101
101
  schema: any;
102
102
  };
103
- actions: {
103
+ guardianPhoneFactorMessageTypes: {
104
104
  default: typeof APIHandler;
105
105
  excludeSchema?: any;
106
106
  schema: any;
107
107
  };
108
- organizations: {
108
+ guardianPhoneFactorSelectedProvider: {
109
109
  default: typeof APIHandler;
110
110
  excludeSchema?: any;
111
111
  schema: any;
112
112
  };
113
- triggers: {
113
+ guardianPolicies: {
114
114
  default: typeof APIHandler;
115
115
  excludeSchema?: any;
116
116
  schema: any;
117
117
  };
118
- attackProtection: {
118
+ logStreams: {
119
119
  default: typeof APIHandler;
120
120
  excludeSchema?: any;
121
121
  schema: any;
122
122
  };
123
- branding: {
123
+ migrations: {
124
124
  default: typeof APIHandler;
125
125
  excludeSchema?: any;
126
126
  schema: any;
127
127
  };
128
- logStreams: {
128
+ organizations: {
129
+ default: typeof APIHandler;
130
+ excludeSchema?: any;
131
+ schema: any;
132
+ };
133
+ rulesConfigs: {
134
+ default: typeof APIHandler;
135
+ excludeSchema?: any;
136
+ schema: any;
137
+ };
138
+ tenant: {
129
139
  default: typeof APIHandler;
130
140
  excludeSchema?: any;
131
141
  schema: any;
@@ -51,6 +51,7 @@ const triggers = __importStar(require("./triggers"));
51
51
  const organizations = __importStar(require("./organizations"));
52
52
  const attackProtection = __importStar(require("./attackProtection"));
53
53
  const logStreams = __importStar(require("./logStreams"));
54
+ const customDomains = __importStar(require("./customDomains"));
54
55
  const auth0ApiHandlers = {
55
56
  rules,
56
57
  rulesConfigs,
@@ -80,5 +81,6 @@ const auth0ApiHandlers = {
80
81
  organizations,
81
82
  attackProtection,
82
83
  logStreams,
84
+ customDomains,
83
85
  };
84
86
  exports.default = auth0ApiHandlers; // TODO: apply stronger types to schema properties
@@ -1,11 +1,49 @@
1
1
  import DefaultHandler from './default';
2
- import { Asset, Assets } from '../../../types';
2
+ import { Assets, Language } from '../../../types';
3
+ declare const promptScreenTypes: readonly ["login", "login-id", "login-password", "login-email-verification", "signup", "signup-id", "signup-password", "reset-password", "consent", "mfa-push", "mfa-otp", "mfa-voice", "mfa-phone", "mfa-webauthn", "mfa-sms", "mfa-email", "mfa-recovery-code", "mfa", "status", "device-flow", "email-verification", "email-otp-challenge", "organizations", "invitation", "common"];
3
4
  export declare const schema: {
4
5
  type: string;
6
+ properties: {
7
+ universal_login_experience: {
8
+ type: string;
9
+ enum: string[];
10
+ };
11
+ webauthn_platform_first_factor: {
12
+ type: string;
13
+ };
14
+ identifier_first: {
15
+ type: string;
16
+ };
17
+ customText: {
18
+ type: string;
19
+ properties: {};
20
+ };
21
+ };
5
22
  };
23
+ export declare type PromptScreenTypes = typeof promptScreenTypes[number];
24
+ export declare type PromptSettings = {
25
+ universal_login_experience?: 'new' | 'classic';
26
+ webauthn_platform_first_factor?: boolean;
27
+ identifier_first?: boolean;
28
+ };
29
+ export declare type PromptsCustomText = {
30
+ [key in PromptScreenTypes]: {
31
+ [key: string]: string;
32
+ };
33
+ };
34
+ export declare type Prompts = Partial<PromptSettings & {
35
+ customText: AllPromptsByLanguage;
36
+ }>;
37
+ export declare type AllPromptsByLanguage = Partial<{
38
+ [key in Language]: Partial<PromptsCustomText>;
39
+ }>;
6
40
  export default class PromptsHandler extends DefaultHandler {
7
- existing: Asset[];
41
+ existing: Prompts;
8
42
  constructor(options: DefaultHandler);
9
- getType(): Promise<Asset[]>;
43
+ objString({ customText }: Prompts): string;
44
+ getType(): Promise<Prompts | null>;
45
+ getCustomTextSettings(): Promise<AllPromptsByLanguage>;
10
46
  processChanges(assets: Assets): Promise<void>;
47
+ updateCustomTextSettings(customText: Prompts['customText']): Promise<void>;
11
48
  }
49
+ export {};
@@ -8,46 +8,166 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
14
25
  Object.defineProperty(exports, "__esModule", { value: true });
15
26
  exports.schema = void 0;
16
- //@ts-nocheck because prompts haven't been fully implemented in this codebase yet
17
27
  const default_1 = __importDefault(require("./default"));
18
- exports.schema = { type: 'object' };
28
+ const types_1 = require("../../../types");
29
+ const lodash_1 = require("lodash");
30
+ const promptScreenTypes = [
31
+ 'login',
32
+ 'login-id',
33
+ 'login-password',
34
+ 'login-email-verification',
35
+ 'signup',
36
+ 'signup-id',
37
+ 'signup-password',
38
+ 'reset-password',
39
+ 'consent',
40
+ 'mfa-push',
41
+ 'mfa-otp',
42
+ 'mfa-voice',
43
+ 'mfa-phone',
44
+ 'mfa-webauthn',
45
+ 'mfa-sms',
46
+ 'mfa-email',
47
+ 'mfa-recovery-code',
48
+ 'mfa',
49
+ 'status',
50
+ 'device-flow',
51
+ 'email-verification',
52
+ 'email-otp-challenge',
53
+ 'organizations',
54
+ 'invitation',
55
+ 'common',
56
+ ];
57
+ exports.schema = {
58
+ type: 'object',
59
+ properties: {
60
+ universal_login_experience: {
61
+ type: 'string',
62
+ enum: ['new', 'classic'],
63
+ },
64
+ webauthn_platform_first_factor: {
65
+ type: 'boolean',
66
+ },
67
+ identifier_first: {
68
+ type: 'boolean',
69
+ },
70
+ customText: {
71
+ type: 'object',
72
+ properties: types_1.languages.reduce((acc, language) => {
73
+ return Object.assign(Object.assign({}, acc), { [language]: {
74
+ type: 'object',
75
+ properties: promptScreenTypes.reduce((acc, screenType) => {
76
+ return Object.assign(Object.assign({}, acc), { [screenType]: {
77
+ type: 'object',
78
+ } });
79
+ }, {}),
80
+ } });
81
+ }, {}),
82
+ },
83
+ },
84
+ };
19
85
  class PromptsHandler extends default_1.default {
20
86
  constructor(options) {
21
87
  super(Object.assign(Object.assign({}, options), { type: 'prompts' }));
22
88
  }
89
+ objString({ customText }) {
90
+ return `Prompts settings${!!customText ? ' and prompts custom text' : ''}`;
91
+ }
23
92
  getType() {
24
93
  return __awaiter(this, void 0, void 0, function* () {
25
- // in case client version does not support branding
26
- if (!this.client.prompts || typeof this.client.prompts.getSettings !== 'function') {
27
- return {};
28
- }
29
- try {
30
- return yield this.client.prompts.getSettings();
31
- }
32
- catch (err) {
33
- if (err.statusCode === 404)
34
- return {};
35
- if (err.statusCode === 501)
36
- return {};
37
- throw err;
38
- }
94
+ const promptsSettings = yield this.client.prompts.getSettings();
95
+ const customText = yield this.getCustomTextSettings();
96
+ return Object.assign(Object.assign({}, promptsSettings), { customText });
97
+ });
98
+ }
99
+ getCustomTextSettings() {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ const supportedLanguages = yield this.client.tenant
102
+ .getSettings()
103
+ .then(({ enabled_locales }) => enabled_locales);
104
+ const data = yield Promise.all(supportedLanguages.flatMap((language) => {
105
+ return promptScreenTypes.map((screenType) => {
106
+ return this.client.prompts
107
+ .getCustomTextByLanguage({
108
+ prompt: screenType,
109
+ language,
110
+ })
111
+ .then((customTextData) => {
112
+ if ((0, lodash_1.isEmpty)(customTextData))
113
+ return null;
114
+ return Object.assign({ language }, customTextData);
115
+ });
116
+ });
117
+ })).then((customTextData) => {
118
+ return customTextData
119
+ .filter((customTextData) => {
120
+ return customTextData !== null;
121
+ })
122
+ .reduce((acc, customTextItem) => {
123
+ if ((customTextItem === null || customTextItem === void 0 ? void 0 : customTextItem.language) === undefined)
124
+ return acc;
125
+ const { language } = customTextItem, customTextSettings = __rest(customTextItem, ["language"]);
126
+ return Object.assign(Object.assign({}, acc), { [language]: !!acc[language]
127
+ ? Object.assign(Object.assign({}, acc[language]), customTextSettings) : Object.assign({}, customTextSettings) });
128
+ }, {});
129
+ });
130
+ return data;
39
131
  });
40
132
  }
41
133
  processChanges(assets) {
42
134
  return __awaiter(this, void 0, void 0, function* () {
43
135
  const { prompts } = assets;
44
- // Do nothing if not set
45
- if (!prompts || !Object.keys(prompts).length)
136
+ if (!prompts)
46
137
  return;
47
- yield this.client.prompts.updateSettings({}, prompts);
138
+ const { customText } = prompts, promptSettings = __rest(prompts, ["customText"]);
139
+ if (!(0, lodash_1.isEmpty)(promptSettings)) {
140
+ yield this.client.prompts.updateSettings({}, promptSettings);
141
+ }
142
+ yield this.updateCustomTextSettings(customText);
48
143
  this.updated += 1;
49
144
  this.didUpdate(prompts);
50
145
  });
51
146
  }
147
+ updateCustomTextSettings(customText) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ /*
150
+ Note: deletes are not currently supported
151
+ */
152
+ if (!customText)
153
+ return;
154
+ yield Promise.all(Object.keys(customText).flatMap((language) => {
155
+ const languageScreenTypes = customText[language];
156
+ if (!languageScreenTypes)
157
+ return [];
158
+ return Object.keys(languageScreenTypes).map((prompt) => {
159
+ const body = languageScreenTypes[prompt];
160
+ return this.client.prompts.updateCustomTextByLanguage({
161
+ prompt,
162
+ language,
163
+ //@ts-ignore
164
+ body: {
165
+ [prompt]: languageScreenTypes[prompt],
166
+ } || {},
167
+ });
168
+ });
169
+ }));
170
+ });
171
+ }
52
172
  }
53
173
  exports.default = PromptsHandler;
@@ -68,5 +68,7 @@ declare const constants: {
68
68
  EMAIL_TEMPLATES_NAMES: string[];
69
69
  SUPPORTED_BRANDING_TEMPLATES: string[];
70
70
  LOG_STREAMS_DIRECTORY: string;
71
+ PROMPTS_DIRECTORY: string;
72
+ CUSTOM_DOMAINS_DIRECTORY: string;
71
73
  };
72
74
  export default constants;
@@ -165,5 +165,7 @@ const constants = {
165
165
  ],
166
166
  SUPPORTED_BRANDING_TEMPLATES: [UNIVERSAL_LOGIN_TEMPLATE],
167
167
  LOG_STREAMS_DIRECTORY: 'log-streams',
168
+ PROMPTS_DIRECTORY: 'prompts',
169
+ CUSTOM_DOMAINS_DIRECTORY: 'custom-domains',
168
170
  };
169
171
  exports.default = constants;
@@ -73,6 +73,8 @@ declare const _default: {
73
73
  EMAIL_TEMPLATES_NAMES: string[];
74
74
  SUPPORTED_BRANDING_TEMPLATES: string[];
75
75
  LOG_STREAMS_DIRECTORY: string;
76
+ PROMPTS_DIRECTORY: string;
77
+ CUSTOM_DOMAINS_DIRECTORY: string;
76
78
  };
77
79
  deploy: typeof deploy;
78
80
  keywordReplace: typeof keywordReplace;
package/lib/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { PromptScreenTypes, Prompts, PromptsCustomText, PromptSettings } from './tools/auth0/handlers/prompts';
1
2
  declare type SharedPaginationParams = {
2
3
  checkpoint?: boolean;
3
4
  paginate?: boolean;
@@ -126,9 +127,20 @@ export declare type BaseAuth0APIClient = {
126
127
  get: (arg0: Asset) => Promise<Asset>;
127
128
  };
128
129
  };
129
- prompts: APIClientBaseFunctions & {
130
- getSettings: () => Promise<Asset[]>;
131
- updateSettings: (arg0: {}, arg1: Asset) => Promise<void>;
130
+ prompts: {
131
+ updateCustomTextByLanguage: (arg0: {
132
+ prompt: PromptScreenTypes;
133
+ language: Language;
134
+ body: {
135
+ [key: string]: string;
136
+ };
137
+ }) => Promise<void>;
138
+ getCustomTextByLanguage: (arg0: {
139
+ prompt: PromptScreenTypes;
140
+ language: Language;
141
+ }) => Promise<Partial<PromptsCustomText>>;
142
+ getSettings: () => Promise<PromptSettings>;
143
+ updateSettings: (arg0: {}, arg1: Partial<PromptSettings>) => Promise<void>;
132
144
  };
133
145
  resourceServers: APIClientBaseFunctions;
134
146
  roles: APIClientBaseFunctions & {
@@ -150,7 +162,9 @@ export declare type BaseAuth0APIClient = {
150
162
  getAll: () => Promise<Asset[]>;
151
163
  };
152
164
  tenant: APIClientBaseFunctions & {
153
- getSettings: () => Promise<Asset>;
165
+ getSettings: () => Promise<Asset & {
166
+ enabled_locales: Language[];
167
+ }>;
154
168
  updateSettings: (arg0: Asset) => Promise<void>;
155
169
  };
156
170
  triggers: APIClientBaseFunctions & {
@@ -217,6 +231,7 @@ export declare type Assets = Partial<{
217
231
  clients: Asset[] | null;
218
232
  clientGrants: Asset[] | null;
219
233
  connections: Asset[] | null;
234
+ customDomains: Asset[] | null;
220
235
  databases: Asset[] | null;
221
236
  emailProvider: Asset | null;
222
237
  emailTemplates: Asset[] | null;
@@ -235,6 +250,7 @@ export declare type Assets = Partial<{
235
250
  migrations: Asset[] | null;
236
251
  organizations: Asset[] | null;
237
252
  pages: Asset[] | null;
253
+ prompts: Prompts | null;
238
254
  resourceServers: Asset[] | null;
239
255
  roles: Asset[] | null;
240
256
  rules: Asset[] | null;
@@ -252,11 +268,13 @@ export declare type CalculatedChanges = {
252
268
  conflicts: Asset[];
253
269
  create: Asset[];
254
270
  };
255
- export declare type AssetTypes = 'rules' | 'rulesConfigs' | 'hooks' | 'pages' | 'databases' | 'clientGrants' | 'resourceServers' | 'clients' | 'connections' | 'tenant' | 'emailProvider' | 'emailTemplates' | 'guardianFactors' | 'guardianFactorProviders' | 'guardianFactorTemplates' | 'migrations' | 'guardianPhoneFactorMessageTypes' | 'guardianPhoneFactorSelectedProvider' | 'guardianPolicies' | 'roles' | 'actions' | 'organizations' | 'triggers' | 'attackProtection' | 'branding' | 'logStreams';
271
+ export declare type AssetTypes = 'rules' | 'rulesConfigs' | 'hooks' | 'pages' | 'databases' | 'clientGrants' | 'resourceServers' | 'clients' | 'connections' | 'tenant' | 'emailProvider' | 'emailTemplates' | 'guardianFactors' | 'guardianFactorProviders' | 'guardianFactorTemplates' | 'migrations' | 'guardianPhoneFactorMessageTypes' | 'guardianPhoneFactorSelectedProvider' | 'guardianPolicies' | 'roles' | 'actions' | 'organizations' | 'triggers' | 'attackProtection' | 'branding' | 'logStreams' | 'prompts' | 'customDomains';
256
272
  export declare type KeywordMappings = {
257
273
  [key: string]: (string | number)[] | string | number;
258
274
  };
259
275
  export declare type ParsedAsset<Key extends AssetTypes, T> = {
260
276
  [key in Key]: T | null;
261
277
  };
278
+ export declare const languages: readonly ["ar", "bg", "bs", "cs", "da", "de", "el", "en", "es", "et", "fi", "fr", "fr-CA", "fr-FR", "he", "hi", "hr", "hu", "id", "is", "it", "ja", "ko", "lt", "lv", "nb", "nl", "pl", "pt", "pt-BR", "pt-PT", "ro", "ru", "sk", "sl", "sr", "sv", "th", "tr", "uk", "vi", "zh-CN", "zh-TW"];
279
+ export declare type Language = typeof languages[number];
262
280
  export {};
package/lib/types.js CHANGED
@@ -1,2 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.languages = void 0;
4
+ exports.languages = [
5
+ 'ar',
6
+ 'bg',
7
+ 'bs',
8
+ 'cs',
9
+ 'da',
10
+ 'de',
11
+ 'el',
12
+ 'en',
13
+ 'es',
14
+ 'et',
15
+ 'fi',
16
+ 'fr',
17
+ 'fr-CA',
18
+ 'fr-FR',
19
+ 'he',
20
+ 'hi',
21
+ 'hr',
22
+ 'hu',
23
+ 'id',
24
+ 'is',
25
+ 'it',
26
+ 'ja',
27
+ 'ko',
28
+ 'lt',
29
+ 'lv',
30
+ 'nb',
31
+ 'nl',
32
+ 'pl',
33
+ 'pt',
34
+ 'pt-BR',
35
+ 'pt-PT',
36
+ 'ro',
37
+ 'ru',
38
+ 'sk',
39
+ 'sl',
40
+ 'sr',
41
+ 'sv',
42
+ 'th',
43
+ 'tr',
44
+ 'uk',
45
+ 'vi',
46
+ 'zh-CN',
47
+ 'zh-TW',
48
+ ];
package/lib/utils.d.ts CHANGED
@@ -21,6 +21,7 @@ export declare function stripIdentifiers(auth0: Auth0, assets: Assets): {
21
21
  clients?: Asset[] | null | undefined;
22
22
  clientGrants?: Asset[] | null | undefined;
23
23
  connections?: Asset[] | null | undefined;
24
+ customDomains?: Asset[] | null | undefined;
24
25
  databases?: Asset[] | null | undefined;
25
26
  emailProvider?: Asset | null | undefined;
26
27
  emailTemplates?: Asset[] | null | undefined;
@@ -39,6 +40,53 @@ export declare function stripIdentifiers(auth0: Auth0, assets: Assets): {
39
40
  migrations?: Asset[] | null | undefined;
40
41
  organizations?: Asset[] | null | undefined;
41
42
  pages?: Asset[] | null | undefined;
43
+ prompts?: Partial<import("./tools/auth0/handlers/prompts").PromptSettings & {
44
+ customText: Partial<{
45
+ id: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
46
+ ar: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
47
+ bg: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
48
+ bs: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
49
+ cs: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
50
+ da: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
51
+ de: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
52
+ el: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
53
+ en: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
54
+ es: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
55
+ et: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
56
+ fi: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
57
+ fr: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
58
+ "fr-CA": Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
59
+ "fr-FR": Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
60
+ he: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
61
+ hi: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
62
+ hr: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
63
+ hu: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
64
+ is: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
65
+ it: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
66
+ ja: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
67
+ ko: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
68
+ lt: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
69
+ lv: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
70
+ nb: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
71
+ nl: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
72
+ pl: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
73
+ pt: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
74
+ "pt-BR": Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
75
+ "pt-PT": Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
76
+ ro: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
77
+ ru: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
78
+ sk: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
79
+ sl: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
80
+ sr: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
81
+ sv: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
82
+ th: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
83
+ tr: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
84
+ uk: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
85
+ vi: Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
86
+ "zh-CN": Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
87
+ "zh-TW": Partial<import("./tools/auth0/handlers/prompts").PromptsCustomText>;
88
+ }>;
89
+ }> | null | undefined;
42
90
  resourceServers?: Asset[] | null | undefined;
43
91
  roles?: Asset[] | null | undefined;
44
92
  rules?: Asset[] | null | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0-deploy-cli",
3
- "version": "7.11.1",
3
+ "version": "7.12.0",
4
4
  "description": "A command line tool for deploying updates to your Auth0 tenant",
5
5
  "main": "lib/index.js",
6
6
  "bin": {