auth0-deploy-cli 8.38.0 → 8.40.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/lib/context/defaults.d.ts +1 -0
  3. package/lib/context/defaults.js +47 -0
  4. package/lib/context/directory/handlers/clientAuthCredentials.d.ts +5 -0
  5. package/lib/context/directory/handlers/clientAuthCredentials.js +13 -0
  6. package/lib/context/directory/handlers/clients.js +15 -0
  7. package/lib/context/directory/handlers/eventStreams.d.ts +5 -0
  8. package/lib/context/directory/handlers/eventStreams.js +52 -0
  9. package/lib/context/directory/handlers/index.js +6 -0
  10. package/lib/context/directory/handlers/rateLimitPolicies.d.ts +6 -0
  11. package/lib/context/directory/handlers/rateLimitPolicies.js +53 -0
  12. package/lib/context/yaml/handlers/clientAuthCredentials.d.ts +5 -0
  13. package/lib/context/yaml/handlers/clientAuthCredentials.js +13 -0
  14. package/lib/context/yaml/handlers/clients.js +15 -0
  15. package/lib/context/yaml/handlers/eventStreams.d.ts +5 -0
  16. package/lib/context/yaml/handlers/eventStreams.js +24 -0
  17. package/lib/context/yaml/handlers/index.js +6 -0
  18. package/lib/context/yaml/handlers/rateLimitPolicies.d.ts +6 -0
  19. package/lib/context/yaml/handlers/rateLimitPolicies.js +27 -0
  20. package/lib/tools/auth0/handlers/clientAuthCredentials.d.ts +26 -0
  21. package/lib/tools/auth0/handlers/clientAuthCredentials.js +216 -0
  22. package/lib/tools/auth0/handlers/clientAuthCredentialsPre.d.ts +37 -0
  23. package/lib/tools/auth0/handlers/clientAuthCredentialsPre.js +118 -0
  24. package/lib/tools/auth0/handlers/clients.js +38 -1
  25. package/lib/tools/auth0/handlers/connections.js +1 -0
  26. package/lib/tools/auth0/handlers/eventStreams.d.ts +58 -0
  27. package/lib/tools/auth0/handlers/eventStreams.js +186 -0
  28. package/lib/tools/auth0/handlers/index.js +10 -0
  29. package/lib/tools/auth0/handlers/prompts.js +1 -1
  30. package/lib/tools/auth0/handlers/rateLimitPolicies.d.ts +81 -0
  31. package/lib/tools/auth0/handlers/rateLimitPolicies.js +203 -0
  32. package/lib/tools/constants.d.ts +2 -0
  33. package/lib/tools/constants.js +2 -0
  34. package/lib/types.d.ts +5 -1
  35. package/package.json +1 -1
@@ -74,6 +74,10 @@ const userAttributeProfiles = __importStar(require("./userAttributeProfiles"));
74
74
  const connectionProfiles = __importStar(require("./connectionProfiles"));
75
75
  const tokenExchangeProfiles = __importStar(require("./tokenExchangeProfiles"));
76
76
  const supplementalSignals = __importStar(require("./supplementalSignals"));
77
+ const rateLimitPolicies = __importStar(require("./rateLimitPolicies"));
78
+ const eventStreams = __importStar(require("./eventStreams"));
79
+ const clientAuthCredentials = __importStar(require("./clientAuthCredentials"));
80
+ const clientAuthCredentialsPre = __importStar(require("./clientAuthCredentialsPre"));
77
81
  const auth0ApiHandlers = {
78
82
  rules,
79
83
  rulesConfigs,
@@ -117,5 +121,11 @@ const auth0ApiHandlers = {
117
121
  connectionProfiles,
118
122
  tokenExchangeProfiles,
119
123
  supplementalSignals,
124
+ rateLimitPolicies,
125
+ eventStreams,
126
+ clientAuthCredentials,
127
+ // clientAuthCredentialsPre is a deploy-only pre-pass handler (order 40) — not a user-facing
128
+ // asset type so it is not in AssetTypes, but must be registered here to run during deploy.
129
+ ...{ clientAuthCredentialsPre },
120
130
  };
121
131
  exports.default = auth0ApiHandlers; // TODO: apply stronger types to schema properties
@@ -496,7 +496,7 @@ class PromptsHandler extends default_1.default {
496
496
  updatePayload = {
497
497
  ...updatePrams,
498
498
  rendering_mode: auth0_1.Management.AculRenderingModeEnum.Advanced,
499
- default_head_tags_disabled: screenRenderer.default_head_tags_disabled || undefined,
499
+ default_head_tags_disabled: screenRenderer.default_head_tags_disabled ?? undefined,
500
500
  head_tags: screenRenderer.head_tags,
501
501
  };
502
502
  }
@@ -0,0 +1,81 @@
1
+ import { Management } from 'auth0';
2
+ import DefaultAPIHandler from './default';
3
+ import { Asset, Assets, CalculatedChanges } from '../../../types';
4
+ export type RateLimitPolicyConfiguration = Management.RateLimitPolicyConfiguration;
5
+ export type RateLimitPolicy = Management.RateLimitPolicy;
6
+ export declare const schema: {
7
+ type: string;
8
+ items: {
9
+ type: string;
10
+ properties: {
11
+ resource: {
12
+ type: string;
13
+ enum: "oauth_authentication_api"[];
14
+ };
15
+ consumer: {
16
+ type: string;
17
+ enum: "client"[];
18
+ };
19
+ consumer_selector: {
20
+ type: string;
21
+ };
22
+ configuration: {
23
+ type: string;
24
+ oneOf: ({
25
+ required: string[];
26
+ properties: {
27
+ action: {
28
+ type: string;
29
+ enum: string[];
30
+ };
31
+ limit?: undefined;
32
+ redirect_uri?: undefined;
33
+ };
34
+ additionalProperties: boolean;
35
+ } | {
36
+ required: string[];
37
+ properties: {
38
+ action: {
39
+ type: string;
40
+ enum: string[];
41
+ };
42
+ limit: {
43
+ type: string;
44
+ };
45
+ redirect_uri?: undefined;
46
+ };
47
+ additionalProperties: boolean;
48
+ } | {
49
+ required: string[];
50
+ properties: {
51
+ action: {
52
+ type: string;
53
+ enum: string[];
54
+ };
55
+ limit: {
56
+ type: string;
57
+ };
58
+ redirect_uri: {
59
+ type: string;
60
+ };
61
+ };
62
+ additionalProperties: boolean;
63
+ })[];
64
+ };
65
+ };
66
+ required: string[];
67
+ };
68
+ };
69
+ export default class RateLimitPoliciesHandler extends DefaultAPIHandler {
70
+ existing: RateLimitPolicy[] | null;
71
+ constructor(config: DefaultAPIHandler);
72
+ objString(policy: RateLimitPolicy): string;
73
+ getType(): Promise<Asset | null>;
74
+ processChanges(assets: Assets): Promise<void>;
75
+ createRateLimitPolicy(policy: RateLimitPolicy): Promise<RateLimitPolicy>;
76
+ createRateLimitPolicies(creates: CalculatedChanges['create']): Promise<void>;
77
+ updateRateLimitPolicy(policy: RateLimitPolicy): Promise<void>;
78
+ updateRateLimitPolicies(updates: CalculatedChanges['update']): Promise<void>;
79
+ deleteRateLimitPolicy(policy: RateLimitPolicy): Promise<void>;
80
+ deleteRateLimitPolicies(data: Asset[]): Promise<void>;
81
+ }
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.schema = void 0;
7
+ const auth0_1 = require("auth0");
8
+ const default_1 = __importDefault(require("./default"));
9
+ const client_1 = require("../client");
10
+ const utils_1 = require("../../utils");
11
+ const logger_1 = __importDefault(require("../../../logger"));
12
+ exports.schema = {
13
+ type: 'array',
14
+ items: {
15
+ type: 'object',
16
+ properties: {
17
+ resource: {
18
+ type: 'string',
19
+ enum: Object.values(auth0_1.Management.RateLimitPolicyResourceEnum),
20
+ },
21
+ consumer: {
22
+ type: 'string',
23
+ enum: Object.values(auth0_1.Management.RateLimitPolicyConsumerEnum),
24
+ },
25
+ consumer_selector: {
26
+ type: 'string',
27
+ },
28
+ configuration: {
29
+ type: 'object',
30
+ oneOf: [
31
+ {
32
+ required: ['action'],
33
+ properties: {
34
+ action: { type: 'string', enum: ['allow'] },
35
+ },
36
+ additionalProperties: false,
37
+ },
38
+ {
39
+ required: ['action', 'limit'],
40
+ properties: {
41
+ action: { type: 'string', enum: ['block', 'log'] },
42
+ limit: { type: 'number' },
43
+ },
44
+ additionalProperties: false,
45
+ },
46
+ {
47
+ required: ['action', 'limit', 'redirect_uri'],
48
+ properties: {
49
+ action: { type: 'string', enum: ['redirect'] },
50
+ limit: { type: 'number' },
51
+ redirect_uri: { type: 'string' },
52
+ },
53
+ additionalProperties: false,
54
+ },
55
+ ],
56
+ },
57
+ },
58
+ required: ['resource', 'consumer', 'consumer_selector', 'configuration'],
59
+ },
60
+ };
61
+ class RateLimitPoliciesHandler extends default_1.default {
62
+ constructor(config) {
63
+ super({
64
+ ...config,
65
+ type: 'rateLimitPolicies',
66
+ id: 'id',
67
+ identifiers: ['id', 'consumer_selector'],
68
+ stripCreateFields: ['id', 'created_at', 'updated_at'],
69
+ stripUpdateFields: [
70
+ 'id',
71
+ 'resource',
72
+ 'consumer',
73
+ 'consumer_selector',
74
+ 'created_at',
75
+ 'updated_at',
76
+ ],
77
+ });
78
+ }
79
+ objString(policy) {
80
+ return super.objString({
81
+ consumer_selector: policy.consumer_selector,
82
+ resource: policy.resource,
83
+ });
84
+ }
85
+ async getType() {
86
+ if (this.existing)
87
+ return this.existing;
88
+ try {
89
+ const rateLimitPolicies = await (0, client_1.paginate)(this.client.rateLimitPolicies.list, { checkpoint: true });
90
+ this.existing = rateLimitPolicies;
91
+ return this.existing;
92
+ }
93
+ catch (err) {
94
+ if (err.statusCode === 404 || err.statusCode === 501) {
95
+ return null;
96
+ }
97
+ if (err.statusCode === 403) {
98
+ logger_1.default.debug('Rate Limit Policies feature is not enabled for this tenant. Please contact Auth0 support to enable this feature.');
99
+ return null;
100
+ }
101
+ throw err;
102
+ }
103
+ }
104
+ async processChanges(assets) {
105
+ const { rateLimitPolicies } = assets;
106
+ if (!rateLimitPolicies)
107
+ return;
108
+ const { del, update, create } = await this.calcChanges(assets);
109
+ if ((0, utils_1.isDryRun)(this.config)) {
110
+ if (create.length === 0 && update.length === 0 && del.length === 0) {
111
+ return;
112
+ }
113
+ }
114
+ logger_1.default.debug(`Start processChanges for rateLimitPolicies [delete:${del.length}] [update:${update.length}], [create:${create.length}]`);
115
+ const changes = [{ del }, { create }, { update }];
116
+ await Promise.all(changes.map(async (change) => {
117
+ switch (true) {
118
+ case change.del && change.del.length > 0:
119
+ await this.deleteRateLimitPolicies(change.del);
120
+ break;
121
+ case change.create && change.create.length > 0:
122
+ await this.createRateLimitPolicies(change.create);
123
+ break;
124
+ case change.update && change.update.length > 0:
125
+ await this.updateRateLimitPolicies(change.update);
126
+ break;
127
+ default:
128
+ break;
129
+ }
130
+ }));
131
+ }
132
+ async createRateLimitPolicy(policy) {
133
+ const created = await this.client.rateLimitPolicies.create(policy);
134
+ return created;
135
+ }
136
+ async createRateLimitPolicies(creates) {
137
+ await this.client.pool
138
+ .addEachTask({
139
+ data: creates || [],
140
+ generator: (item) => this.createRateLimitPolicy(item)
141
+ .then((data) => {
142
+ this.didCreate(data);
143
+ this.created += 1;
144
+ })
145
+ .catch((err) => {
146
+ throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
147
+ }),
148
+ })
149
+ .promise();
150
+ }
151
+ async updateRateLimitPolicy(policy) {
152
+ const { id, configuration } = policy;
153
+ if (!id) {
154
+ throw new Error(`Missing id for ${this.type} ${this.objString(policy)}`);
155
+ }
156
+ await this.client.rateLimitPolicies.update(id, { configuration });
157
+ }
158
+ async updateRateLimitPolicies(updates) {
159
+ await this.client.pool
160
+ .addEachTask({
161
+ data: updates || [],
162
+ generator: (item) => this.updateRateLimitPolicy(item)
163
+ .then(() => {
164
+ this.didUpdate(item);
165
+ this.updated += 1;
166
+ })
167
+ .catch((err) => {
168
+ throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
169
+ }),
170
+ })
171
+ .promise();
172
+ }
173
+ async deleteRateLimitPolicy(policy) {
174
+ if (!policy.id) {
175
+ throw new Error(`Missing id for ${this.type} ${this.objString(policy)}`);
176
+ }
177
+ await this.client.rateLimitPolicies.delete(policy.id);
178
+ }
179
+ async deleteRateLimitPolicies(data) {
180
+ if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
181
+ this.config('AUTH0_ALLOW_DELETE') === true) {
182
+ await this.client.pool
183
+ .addEachTask({
184
+ data: data || [],
185
+ generator: (item) => this.deleteRateLimitPolicy(item)
186
+ .then(() => {
187
+ this.didDelete(item);
188
+ this.deleted += 1;
189
+ })
190
+ .catch((err) => {
191
+ throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
192
+ }),
193
+ })
194
+ .promise();
195
+ }
196
+ else {
197
+ logger_1.default.warn(`Detected the following ${this.type} should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config\n${data
198
+ .map((i) => this.objString(i))
199
+ .join('\n')}`);
200
+ }
201
+ }
202
+ }
203
+ exports.default = RateLimitPoliciesHandler;
@@ -90,5 +90,7 @@ declare const constants: {
90
90
  CONNECTION_PROFILES_DIRECTORY: string;
91
91
  TOKEN_EXCHANGE_PROFILES_DIRECTORY: string;
92
92
  SUPPLEMENTAL_SIGNALS_DIRECTORY: string;
93
+ RATE_LIMIT_POLICIES_DIRECTORY: string;
94
+ EVENT_STREAMS_DIRECTORY: string;
93
95
  };
94
96
  export default constants;
@@ -220,5 +220,7 @@ const constants = {
220
220
  CONNECTION_PROFILES_DIRECTORY: 'connection-profiles',
221
221
  TOKEN_EXCHANGE_PROFILES_DIRECTORY: 'token-exchange-profiles',
222
222
  SUPPLEMENTAL_SIGNALS_DIRECTORY: 'supplemental-signals',
223
+ RATE_LIMIT_POLICIES_DIRECTORY: 'rate-limit-policies',
224
+ EVENT_STREAMS_DIRECTORY: 'event-streams',
223
225
  };
224
226
  exports.default = constants;
package/lib/types.d.ts CHANGED
@@ -21,6 +21,8 @@ import { AttackProtection } from './tools/auth0/handlers/attackProtection';
21
21
  import { TokenExchangeProfile } from './tools/auth0/handlers/tokenExchangeProfiles';
22
22
  import { RiskAssessment } from './tools/auth0/handlers/riskAssessment';
23
23
  import { SupplementalSignals } from './tools/auth0/handlers/supplementalSignals';
24
+ import { RateLimitPolicy } from './tools/auth0/handlers/rateLimitPolicies';
25
+ import { EventStream } from './tools/auth0/handlers/eventStreams';
24
26
  type SharedPaginationParams = {
25
27
  checkpoint?: boolean;
26
28
  paginate?: boolean;
@@ -158,6 +160,8 @@ export type Assets = Partial<{
158
160
  userAttributeProfilesWithId: UserAttributeProfile[] | null;
159
161
  connectionProfiles: Asset[] | null;
160
162
  tokenExchangeProfiles: TokenExchangeProfile[] | null;
163
+ rateLimitPolicies: RateLimitPolicy[] | null;
164
+ eventStreams: EventStream[] | null;
161
165
  }>;
162
166
  export type CalculatedChanges = {
163
167
  del: Asset[];
@@ -178,7 +182,7 @@ export type DetailedDryRunChanges = {
178
182
  changes: DetailedDryRunChange[];
179
183
  };
180
184
  };
181
- export type AssetTypes = 'rules' | 'rulesConfigs' | 'hooks' | 'pages' | 'databases' | 'clientGrants' | 'resourceServers' | 'clients' | 'connections' | 'tenant' | 'emailProvider' | 'emailTemplates' | 'guardianFactors' | 'guardianFactorProviders' | 'guardianFactorTemplates' | 'guardianPhoneFactorMessageTypes' | 'guardianPhoneFactorSelectedProvider' | 'guardianPolicies' | 'roles' | 'actions' | 'actionModules' | 'organizations' | 'triggers' | 'attackProtection' | 'riskAssessment' | 'branding' | 'phoneProviders' | 'phoneTemplates' | 'logStreams' | 'prompts' | 'customDomains' | 'themes' | 'forms' | 'flows' | 'flowVaultConnections' | 'selfServiceProfiles' | 'networkACLs' | 'userAttributeProfiles' | 'connectionProfiles' | 'tokenExchangeProfiles' | 'supplementalSignals';
185
+ export type AssetTypes = 'rules' | 'rulesConfigs' | 'hooks' | 'pages' | 'databases' | 'clientGrants' | 'resourceServers' | 'clients' | 'connections' | 'tenant' | 'emailProvider' | 'emailTemplates' | 'guardianFactors' | 'guardianFactorProviders' | 'guardianFactorTemplates' | 'guardianPhoneFactorMessageTypes' | 'guardianPhoneFactorSelectedProvider' | 'guardianPolicies' | 'roles' | 'actions' | 'actionModules' | 'organizations' | 'triggers' | 'attackProtection' | 'riskAssessment' | 'branding' | 'phoneProviders' | 'phoneTemplates' | 'logStreams' | 'prompts' | 'customDomains' | 'themes' | 'forms' | 'flows' | 'flowVaultConnections' | 'selfServiceProfiles' | 'networkACLs' | 'userAttributeProfiles' | 'connectionProfiles' | 'tokenExchangeProfiles' | 'supplementalSignals' | 'rateLimitPolicies' | 'eventStreams' | 'clientAuthCredentials';
182
186
  export type KeywordMappings = {
183
187
  [key: string]: (string | number)[] | string | number;
184
188
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0-deploy-cli",
3
- "version": "8.38.0",
3
+ "version": "8.40.0",
4
4
  "description": "A command line tool for deploying updates to your Auth0 tenant",
5
5
  "main": "lib/index.js",
6
6
  "bin": {