auth0-deploy-cli 7.3.7 → 7.5.1
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/.circleci/config.yml +15 -0
- package/.eslintrc +66 -17
- package/.github/CODEOWNERS +1 -0
- package/.husky/pre-commit +6 -0
- package/.husky/pre-push +4 -0
- package/CHANGELOG.md +37 -2
- package/lib/args.js +94 -81
- package/lib/commands/export.js +54 -78
- package/lib/commands/import.js +46 -70
- package/lib/commands/index.js +11 -20
- package/lib/configFactory.js +19 -27
- package/lib/context/defaults.js +18 -41
- package/lib/context/directory/handlers/actions.js +77 -107
- package/lib/context/directory/handlers/attackProtection.js +59 -0
- package/lib/context/directory/handlers/clientGrants.js +45 -54
- package/lib/context/directory/handlers/clients.js +60 -79
- package/lib/context/directory/handlers/connections.js +65 -89
- package/lib/context/directory/handlers/databases.js +91 -123
- package/lib/context/directory/handlers/emailProvider.js +46 -57
- package/lib/context/directory/handlers/emailTemplates.js +67 -80
- package/lib/context/directory/handlers/guardianFactorProviders.js +41 -49
- package/lib/context/directory/handlers/guardianFactorTemplates.js +41 -49
- package/lib/context/directory/handlers/guardianFactors.js +41 -49
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +40 -50
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +40 -50
- package/lib/context/directory/handlers/guardianPolicies.js +40 -50
- package/lib/context/directory/handlers/hooks.js +55 -70
- package/lib/context/directory/handlers/index.js +53 -123
- package/lib/context/directory/handlers/migrations.js +36 -41
- package/lib/context/directory/handlers/organizations.js +54 -69
- package/lib/context/directory/handlers/pages.js +72 -86
- package/lib/context/directory/handlers/resourceServers.js +41 -49
- package/lib/context/directory/handlers/roles.js +49 -62
- package/lib/context/directory/handlers/rules.js +52 -68
- package/lib/context/directory/handlers/rulesConfigs.js +33 -32
- package/lib/context/directory/handlers/tenant.js +52 -47
- package/lib/context/directory/handlers/triggers.js +39 -54
- package/lib/context/directory/index.js +113 -101
- package/lib/context/index.js +96 -105
- package/lib/context/yaml/handlers/actions.js +71 -88
- package/lib/context/yaml/handlers/attackProtection.js +29 -0
- package/lib/context/yaml/handlers/clientGrants.js +36 -29
- package/lib/context/yaml/handlers/clients.js +61 -76
- package/lib/context/yaml/handlers/connections.js +76 -103
- package/lib/context/yaml/handlers/databases.js +64 -79
- package/lib/context/yaml/handlers/emailProvider.js +33 -30
- package/lib/context/yaml/handlers/emailTemplates.js +45 -54
- package/lib/context/yaml/handlers/guardianFactorProviders.js +27 -18
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +27 -18
- package/lib/context/yaml/handlers/guardianFactors.js +27 -18
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +27 -20
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +27 -20
- package/lib/context/yaml/handlers/guardianPolicies.js +27 -20
- package/lib/context/yaml/handlers/hooks.js +57 -67
- package/lib/context/yaml/handlers/index.js +53 -123
- package/lib/context/yaml/handlers/migrations.js +23 -24
- package/lib/context/yaml/handlers/organizations.js +40 -38
- package/lib/context/yaml/handlers/pages.js +49 -58
- package/lib/context/yaml/handlers/resourceServers.js +27 -18
- package/lib/context/yaml/handlers/roles.js +34 -24
- package/lib/context/yaml/handlers/rules.js +48 -58
- package/lib/context/yaml/handlers/rulesConfigs.js +27 -18
- package/lib/context/yaml/handlers/tenant.js +44 -30
- package/lib/context/yaml/handlers/triggers.js +32 -23
- package/lib/context/yaml/index.js +127 -142
- package/lib/index.js +73 -79
- package/lib/logger.js +18 -22
- package/lib/readonly.js +74 -66
- package/lib/tools/ValidationError.js +8 -13
- package/lib/tools/auth0/client.js +143 -133
- package/lib/tools/auth0/handlers/actions.js +231 -243
- package/lib/tools/auth0/handlers/attackProtection.js +86 -0
- package/lib/tools/auth0/handlers/branding.js +47 -46
- package/lib/tools/auth0/handlers/clientGrants.js +118 -116
- package/lib/tools/auth0/handlers/clients.js +72 -90
- package/lib/tools/auth0/handlers/connections.js +150 -118
- package/lib/tools/auth0/handlers/databases.js +127 -124
- package/lib/tools/auth0/handlers/default.js +186 -189
- package/lib/tools/auth0/handlers/emailProvider.js +67 -78
- package/lib/tools/auth0/handlers/emailTemplates.js +116 -92
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +66 -81
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +60 -71
- package/lib/tools/auth0/handlers/guardianFactors.js +56 -63
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +80 -79
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +77 -76
- package/lib/tools/auth0/handlers/guardianPolicies.js +59 -62
- package/lib/tools/auth0/handlers/hooks.js +201 -227
- package/lib/tools/auth0/handlers/index.js +53 -111
- package/lib/tools/auth0/handlers/migrations.js +99 -79
- package/lib/tools/auth0/handlers/organizations.js +225 -247
- package/lib/tools/auth0/handlers/pages.js +116 -154
- package/lib/tools/auth0/handlers/prompts.js +47 -46
- package/lib/tools/auth0/handlers/resourceServers.js +88 -112
- package/lib/tools/auth0/handlers/roles.js +203 -220
- package/lib/tools/auth0/handlers/rules.js +168 -189
- package/lib/tools/auth0/handlers/rulesConfigs.js +54 -63
- package/lib/tools/auth0/handlers/tenant.js +88 -64
- package/lib/tools/auth0/handlers/triggers.js +126 -126
- package/lib/tools/auth0/index.js +92 -85
- package/lib/tools/auth0/schema.js +39 -31
- package/lib/tools/constants.js +111 -21
- package/lib/tools/deploy.js +35 -32
- package/lib/tools/index.js +19 -32
- package/lib/tools/logger.js +11 -12
- package/lib/tools/utils.js +258 -254
- package/lib/utils.js +167 -190
- package/package.json +13 -17
- package/tsconfig.json +17 -0
- package/typescript-migration-progress.sh +22 -0
- package/.babelrc +0 -17
- package/.nyc_output/32e2bffd-d561-4814-9aa3-fe929a1e178a.json +0 -1
- package/.nyc_output/processinfo/32e2bffd-d561-4814-9aa3-fe929a1e178a.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
|
@@ -1,262 +1,250 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
32
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
35
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
36
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
37
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.schema = void 0;
|
|
45
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
46
|
+
const default_1 = __importStar(require("./default"));
|
|
47
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
48
|
+
const utils_1 = require("../../utils");
|
|
28
49
|
const MAX_ACTION_DEPLOY_RETRY = 60;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
type: 'string'
|
|
51
|
-
},
|
|
52
|
-
version: {
|
|
53
|
-
type: 'string'
|
|
54
|
-
},
|
|
55
|
-
registry_url: {
|
|
56
|
-
type: 'string'
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
secrets: {
|
|
62
|
-
type: 'array',
|
|
63
|
-
items: {
|
|
64
|
-
type: 'object',
|
|
65
|
-
properties: {
|
|
66
|
-
name: {
|
|
67
|
-
type: 'string'
|
|
50
|
+
// With this schema, we can only validate property types but not valid properties on per type basis
|
|
51
|
+
exports.schema = {
|
|
52
|
+
type: 'array',
|
|
53
|
+
items: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
required: ['name', 'supported_triggers', 'code'],
|
|
56
|
+
additionalProperties: false,
|
|
57
|
+
properties: {
|
|
58
|
+
code: { type: 'string', default: '' },
|
|
59
|
+
runtime: { type: 'string' },
|
|
60
|
+
dependencies: {
|
|
61
|
+
type: 'array',
|
|
62
|
+
items: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
additionalProperties: false,
|
|
65
|
+
properties: {
|
|
66
|
+
name: { type: 'string' },
|
|
67
|
+
version: { type: 'string' },
|
|
68
|
+
registry_url: { type: 'string' }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
68
71
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
name: {
|
|
80
|
-
type: 'string',
|
|
81
|
-
default: ''
|
|
82
|
-
},
|
|
83
|
-
supported_triggers: {
|
|
84
|
-
type: 'array',
|
|
85
|
-
items: {
|
|
86
|
-
type: 'object',
|
|
87
|
-
properties: {
|
|
88
|
-
id: {
|
|
89
|
-
type: 'string',
|
|
90
|
-
default: ''
|
|
72
|
+
secrets: {
|
|
73
|
+
type: 'array',
|
|
74
|
+
items: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
name: { type: 'string' },
|
|
78
|
+
value: { type: 'string' },
|
|
79
|
+
updated_at: { type: 'string', format: 'date-time' }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
91
82
|
},
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
name: { type: 'string', default: '' },
|
|
84
|
+
supported_triggers: {
|
|
85
|
+
type: 'array',
|
|
86
|
+
items: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
id: { type: 'string', default: '' },
|
|
90
|
+
version: { type: 'string' },
|
|
91
|
+
url: { type: 'string' }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
94
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
}
|
|
95
|
+
deployed: { type: 'boolean' },
|
|
96
|
+
status: { type: 'string' }
|
|
99
97
|
}
|
|
100
|
-
},
|
|
101
|
-
deployed: {
|
|
102
|
-
type: 'boolean'
|
|
103
|
-
},
|
|
104
|
-
status: {
|
|
105
|
-
type: 'string'
|
|
106
|
-
}
|
|
107
98
|
}
|
|
108
|
-
}
|
|
109
99
|
};
|
|
110
|
-
|
|
111
100
|
function sleep(ms) {
|
|
112
|
-
|
|
101
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
113
102
|
}
|
|
114
|
-
|
|
115
103
|
function isActionsDisabled(err) {
|
|
116
|
-
|
|
117
|
-
|
|
104
|
+
const errorBody = lodash_1.default.get(err, 'originalError.response.body') || {};
|
|
105
|
+
return (err.statusCode === 403 && errorBody.errorCode === 'feature_not_enabled');
|
|
118
106
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
stripUpdateFields: ['deployed', 'status']
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async createAction(action) {
|
|
133
|
-
const addAction = { ...action
|
|
134
|
-
};
|
|
135
|
-
delete addAction.deployed;
|
|
136
|
-
delete addAction.status;
|
|
137
|
-
const createdAction = await this.client.actions.create(addAction);
|
|
138
|
-
action.id = createdAction.id;
|
|
139
|
-
return createdAction;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async deleteAction(action) {
|
|
143
|
-
if (!this.client.actions || typeof this.client.actions.delete !== 'function') {
|
|
144
|
-
return [];
|
|
107
|
+
class ActionHandler extends default_1.default {
|
|
108
|
+
constructor(options) {
|
|
109
|
+
super(Object.assign(Object.assign({}, options), { type: 'actions', functions: {
|
|
110
|
+
create: (action) => this.createAction(action),
|
|
111
|
+
delete: (action) => this.deleteAction(action)
|
|
112
|
+
}, stripUpdateFields: [
|
|
113
|
+
'deployed',
|
|
114
|
+
'status'
|
|
115
|
+
] }));
|
|
145
116
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async deployActions(actions) {
|
|
161
|
-
await this.client.pool.addEachTask({
|
|
162
|
-
data: actions || [],
|
|
163
|
-
generator: action => this.deployAction(action).then(() => {
|
|
164
|
-
_logger2.default.info(`Deployed [${this.type}]: ${this.objString(action)}`);
|
|
165
|
-
}).catch(err => {
|
|
166
|
-
throw new Error(`Problem Deploying ${this.type} ${this.objString(action)}\n${err}`);
|
|
167
|
-
})
|
|
168
|
-
}).promise();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async deployAction(action) {
|
|
172
|
-
try {
|
|
173
|
-
await this.client.actions.deploy({
|
|
174
|
-
id: action.id
|
|
175
|
-
});
|
|
176
|
-
} catch (err) {
|
|
177
|
-
if (err.message && err.message.includes('must be in the \'built\' state')) {
|
|
178
|
-
if (!action.retry_count) {
|
|
179
|
-
_logger2.default.info(`[${this.type}]: Waiting for build to complete ${this.objString(action)}`);
|
|
180
|
-
|
|
181
|
-
action.retry_count = 1;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (action.retry_count > MAX_ACTION_DEPLOY_RETRY) {
|
|
185
|
-
throw err;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
await sleep(1000);
|
|
189
|
-
action.retry_count += 1;
|
|
190
|
-
await this.deployAction(action);
|
|
191
|
-
} else {
|
|
192
|
-
throw err;
|
|
193
|
-
}
|
|
117
|
+
createAction(action) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
// Strip the deployed flag
|
|
120
|
+
const addAction = Object.assign({}, action);
|
|
121
|
+
delete addAction.deployed;
|
|
122
|
+
delete addAction.status;
|
|
123
|
+
const createdAction = yield this.client.actions.create(addAction);
|
|
124
|
+
// Add the action id so we can deploy it later
|
|
125
|
+
action.id = createdAction.id;
|
|
126
|
+
return createdAction;
|
|
127
|
+
});
|
|
194
128
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
actionChanges.code = action.code;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (action.runtime !== found.runtime) {
|
|
206
|
-
actionChanges.runtime = action.runtime;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (!(0, _utils.areArraysEquals)(action.dependencies, found.dependencies)) {
|
|
210
|
-
actionChanges.dependencies = action.dependencies;
|
|
211
|
-
}
|
|
129
|
+
deleteAction(action) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
if (!this.client.actions || typeof this.client.actions.delete !== 'function') {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
return this.client.actions.delete({ id: action.id, force: true });
|
|
135
|
+
});
|
|
212
136
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
actionChanges.supported_triggers = action.supported_triggers;
|
|
137
|
+
objString(action) {
|
|
138
|
+
return super.objString({ id: action.id, name: action.name });
|
|
216
139
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
140
|
+
deployActions(actions) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
yield this.client.pool
|
|
143
|
+
.addEachTask({
|
|
144
|
+
data: actions || [],
|
|
145
|
+
generator: (action) => this.deployAction(action)
|
|
146
|
+
.then(() => {
|
|
147
|
+
logger_1.default.info(`Deployed [${this.type}]: ${this.objString(action)}`);
|
|
148
|
+
})
|
|
149
|
+
.catch((err) => {
|
|
150
|
+
throw new Error(`Problem Deploying ${this.type} ${this.objString(action)}\n${err}`);
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
.promise();
|
|
154
|
+
});
|
|
226
155
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
156
|
+
deployAction(action) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
try {
|
|
159
|
+
yield this.client.actions.deploy({ id: action.id });
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
// Retry if pending build.
|
|
163
|
+
if (err.message && err.message.includes('must be in the \'built\' state')) {
|
|
164
|
+
if (!action.retry_count) {
|
|
165
|
+
logger_1.default.info(`[${this.type}]: Waiting for build to complete ${this.objString(action)}`);
|
|
166
|
+
action.retry_count = 1;
|
|
167
|
+
}
|
|
168
|
+
if (action.retry_count > MAX_ACTION_DEPLOY_RETRY) {
|
|
169
|
+
throw err;
|
|
170
|
+
}
|
|
171
|
+
yield sleep(1000);
|
|
172
|
+
action.retry_count += 1;
|
|
173
|
+
yield this.deployAction(action);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
throw err;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
245
180
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
181
|
+
actionChanges(action, found) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
const actionChanges = {};
|
|
184
|
+
// if action is deployed, should compare against curren_version - calcDeployedVersionChanges method
|
|
185
|
+
if (!action.deployed) {
|
|
186
|
+
// name or secrets modifications are not supported yet
|
|
187
|
+
if (action.code !== found.code) {
|
|
188
|
+
actionChanges.code = action.code;
|
|
189
|
+
}
|
|
190
|
+
if (action.runtime !== found.runtime) {
|
|
191
|
+
actionChanges.runtime = action.runtime;
|
|
192
|
+
}
|
|
193
|
+
if (!(0, utils_1.areArraysEquals)(action.dependencies, found.dependencies)) {
|
|
194
|
+
actionChanges.dependencies = action.dependencies;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (!(0, utils_1.areArraysEquals)(action.supported_triggers, found.supported_triggers)) {
|
|
198
|
+
actionChanges.supported_triggers = action.supported_triggers;
|
|
199
|
+
}
|
|
200
|
+
return actionChanges;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
getType() {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
if (this.existing)
|
|
206
|
+
return this.existing;
|
|
207
|
+
if (!this.client.actions || typeof this.client.actions.getAll !== 'function') {
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
// Actions API does not support include_totals param like the other paginate API's.
|
|
211
|
+
// So we set it to false otherwise it will fail with "Additional properties not allowed: include_totals"
|
|
212
|
+
try {
|
|
213
|
+
this.existing = yield this.client.actions.getAll({ paginate: true });
|
|
214
|
+
return this.existing;
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
if (err.statusCode === 403 || err.statusCode === 404 || err.statusCode === 501) {
|
|
218
|
+
return [];
|
|
219
|
+
}
|
|
220
|
+
if (isActionsDisabled(err)) {
|
|
221
|
+
logger_1.default.info('Skipping actions because it is not enabled.');
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
throw err;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
processChanges(assets) {
|
|
229
|
+
const _super = Object.create(null, {
|
|
230
|
+
processChanges: { get: () => super.processChanges }
|
|
231
|
+
});
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
const { actions } = assets;
|
|
234
|
+
// Do nothing if not set
|
|
235
|
+
if (!actions)
|
|
236
|
+
return;
|
|
237
|
+
const changes = yield this.calcChanges(assets);
|
|
238
|
+
yield _super.processChanges.call(this, assets, changes);
|
|
239
|
+
// Deploy actions
|
|
240
|
+
const deployActions = [];
|
|
241
|
+
deployActions.push(...changes.create.filter((action) => action.deployed));
|
|
242
|
+
deployActions.push(...changes.update.filter((action) => action.deployed));
|
|
243
|
+
yield this.deployActions(deployActions);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
__decorate([
|
|
248
|
+
(0, default_1.order)('60')
|
|
249
|
+
], ActionHandler.prototype, "processChanges", null);
|
|
250
|
+
exports.default = ActionHandler;
|
|
@@ -0,0 +1,86 @@
|
|
|
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: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
breachedPasswordDetection: {
|
|
21
|
+
type: 'object'
|
|
22
|
+
},
|
|
23
|
+
bruteForceProtection: {
|
|
24
|
+
type: 'object'
|
|
25
|
+
},
|
|
26
|
+
suspiciousIpThrottling: {
|
|
27
|
+
type: 'object'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
additionalProperties: false
|
|
31
|
+
};
|
|
32
|
+
class AttackProtectionHandler extends default_1.default {
|
|
33
|
+
constructor(config) {
|
|
34
|
+
super(Object.assign(Object.assign({}, config), { type: 'attackProtection' }));
|
|
35
|
+
}
|
|
36
|
+
objString(item) {
|
|
37
|
+
return super.objString({
|
|
38
|
+
'breached-password-protection': {
|
|
39
|
+
enabled: item.breachedPasswordDetection.enabled
|
|
40
|
+
},
|
|
41
|
+
'brute-force-protection': {
|
|
42
|
+
enabled: item.bruteForceProtection.enabled
|
|
43
|
+
},
|
|
44
|
+
'suspicious-ip-throttling': {
|
|
45
|
+
enabled: item.suspiciousIpThrottling.enabled
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
getType() {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (this.existing) {
|
|
52
|
+
return this.existing;
|
|
53
|
+
}
|
|
54
|
+
const [breachedPasswordDetection, bruteForceProtection, suspiciousIpThrottling] = yield Promise.all([
|
|
55
|
+
this.client.attackProtection.getBreachedPasswordDetectionConfig(),
|
|
56
|
+
this.client.attackProtection.getBruteForceConfig(),
|
|
57
|
+
this.client.attackProtection.getSuspiciousIpThrottlingConfig()
|
|
58
|
+
]);
|
|
59
|
+
this.existing = {
|
|
60
|
+
breachedPasswordDetection,
|
|
61
|
+
bruteForceProtection,
|
|
62
|
+
suspiciousIpThrottling
|
|
63
|
+
};
|
|
64
|
+
return this.existing;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
processChanges(assets) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const { attackProtection } = assets;
|
|
70
|
+
if (!attackProtection || !Object.keys(attackProtection).length) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
Promise.all([
|
|
74
|
+
this.client.attackProtection
|
|
75
|
+
.updateBreachedPasswordDetectionConfig({}, attackProtection.breachedPasswordDetection),
|
|
76
|
+
this.client.attackProtection
|
|
77
|
+
.updateSuspiciousIpThrottlingConfig({}, attackProtection.suspiciousIpThrottling),
|
|
78
|
+
this.client.attackProtection
|
|
79
|
+
.updateBruteForceConfig({}, attackProtection.bruteForceProtection)
|
|
80
|
+
]);
|
|
81
|
+
this.updated += 1;
|
|
82
|
+
this.didUpdate(attackProtection);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.default = AttackProtectionHandler;
|