auth0-deploy-cli 7.4.0 → 7.5.2
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 +2 -0
- package/CHANGELOG.md +27 -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 +255 -282
- package/lib/utils.js +167 -190
- package/package.json +10 -16
- package/tsconfig.json +17 -0
- package/typescript-migration-progress.sh +22 -0
- package/.babelrc +0 -17
- package/.nyc_output/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
- package/.nyc_output/processinfo/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
|
@@ -1,85 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _default2 = _interopRequireDefault(_default);
|
|
11
|
-
|
|
12
|
-
var _constants = require("../../constants");
|
|
13
|
-
|
|
14
|
-
var _constants2 = _interopRequireDefault(_constants);
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const schema = exports.schema = {
|
|
19
|
-
type: 'object',
|
|
20
|
-
properties: {
|
|
21
|
-
message_types: {
|
|
22
|
-
type: 'array',
|
|
23
|
-
items: {
|
|
24
|
-
type: 'string',
|
|
25
|
-
enum: _constants2.default.GUARDIAN_PHONE_MESSAGE_TYPES
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
additionalProperties: false
|
|
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
|
+
});
|
|
30
10
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (err.statusCode === 404) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (err.statusCode === 403 && err.originalError && err.originalError.response && err.originalError.response.body && err.originalError.response.body.errorCode === 'voice_mfa_not_allowed') {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return false;
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
13
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.schema = void 0;
|
|
16
|
+
const default_1 = __importDefault(require("./default"));
|
|
17
|
+
const constants_1 = __importDefault(require("../../constants"));
|
|
18
|
+
exports.schema = {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
message_types: {
|
|
22
|
+
type: 'array',
|
|
23
|
+
items: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
enum: constants_1.default.GUARDIAN_PHONE_MESSAGE_TYPES
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
additionalProperties: false
|
|
30
|
+
};
|
|
31
|
+
const isFeatureUnavailableError = (err) => {
|
|
32
|
+
if (err.statusCode === 404) {
|
|
33
|
+
// Older Management API version where the endpoint is not available.
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (err.statusCode === 403
|
|
37
|
+
&& err.originalError
|
|
38
|
+
&& err.originalError.response
|
|
39
|
+
&& err.originalError.response.body
|
|
40
|
+
&& err.originalError.response.body.errorCode === 'voice_mfa_not_allowed') {
|
|
41
|
+
// Recent Management API version, but with feature explicitly disabled.
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
};
|
|
46
|
+
class GuardianPhoneMessageTypesHandler extends default_1.default {
|
|
47
|
+
constructor(options) {
|
|
48
|
+
super(Object.assign(Object.assign({}, options), { type: 'guardianPhoneFactorMessageTypes' }));
|
|
49
|
+
}
|
|
50
|
+
getType() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
// in case client version does not support the operation
|
|
53
|
+
if (!this.client.guardian || typeof this.client.guardian.getPhoneFactorMessageTypes !== 'function') {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
if (this.existing)
|
|
57
|
+
return this.existing;
|
|
58
|
+
try {
|
|
59
|
+
this.existing = yield this.client.guardian.getPhoneFactorMessageTypes();
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
if (isFeatureUnavailableError(e)) {
|
|
63
|
+
// Gracefully skip processing this configuration value.
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
throw e;
|
|
67
|
+
}
|
|
68
|
+
return this.existing;
|
|
69
|
+
});
|
|
54
70
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
processChanges(assets) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
// No API to delete or create guardianPhoneFactorMessageTypes, we can only update.
|
|
74
|
+
const { guardianPhoneFactorMessageTypes } = assets;
|
|
75
|
+
// Do nothing if not set
|
|
76
|
+
if (!guardianPhoneFactorMessageTypes || !guardianPhoneFactorMessageTypes.message_types)
|
|
77
|
+
return;
|
|
78
|
+
const params = {};
|
|
79
|
+
const data = guardianPhoneFactorMessageTypes;
|
|
80
|
+
yield this.client.guardian.updatePhoneFactorMessageTypes(params, data);
|
|
81
|
+
this.updated += 1;
|
|
82
|
+
this.didUpdate(guardianPhoneFactorMessageTypes);
|
|
83
|
+
});
|
|
66
84
|
}
|
|
67
|
-
|
|
68
|
-
return this.existing;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async processChanges(assets) {
|
|
72
|
-
const {
|
|
73
|
-
guardianPhoneFactorMessageTypes
|
|
74
|
-
} = assets;
|
|
75
|
-
if (!guardianPhoneFactorMessageTypes || !guardianPhoneFactorMessageTypes.message_types) return;
|
|
76
|
-
const params = {};
|
|
77
|
-
const data = guardianPhoneFactorMessageTypes;
|
|
78
|
-
await this.client.guardian.updatePhoneFactorMessageTypes(params, data);
|
|
79
|
-
this.updated += 1;
|
|
80
|
-
this.didUpdate(guardianPhoneFactorMessageTypes);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
exports.default = GuardianPhoneMessageTypesHandler;
|
|
86
|
+
exports.default = GuardianPhoneMessageTypesHandler;
|
|
@@ -1,82 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _default2 = _interopRequireDefault(_default);
|
|
11
|
-
|
|
12
|
-
var _constants = require("../../constants");
|
|
13
|
-
|
|
14
|
-
var _constants2 = _interopRequireDefault(_constants);
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const schema = exports.schema = {
|
|
19
|
-
type: 'object',
|
|
20
|
-
properties: {
|
|
21
|
-
provider: {
|
|
22
|
-
type: 'string',
|
|
23
|
-
enum: _constants2.default.GUARDIAN_PHONE_PROVIDERS
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
additionalProperties: false
|
|
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
|
+
});
|
|
27
10
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (err.statusCode === 404) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (err.statusCode === 403 && err.originalError && err.originalError.response && err.originalError.response.body && err.originalError.response.body.errorCode === 'hooks_not_allowed') {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return false;
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
13
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.schema = void 0;
|
|
16
|
+
const default_1 = __importDefault(require("./default"));
|
|
17
|
+
const constants_1 = __importDefault(require("../../constants"));
|
|
18
|
+
exports.schema = {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
provider: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
enum: constants_1.default.GUARDIAN_PHONE_PROVIDERS
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
additionalProperties: false
|
|
27
|
+
};
|
|
28
|
+
const isFeatureUnavailableError = (err) => {
|
|
29
|
+
if (err.statusCode === 404) {
|
|
30
|
+
// Older Management API version where the endpoint is not available.
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (err.statusCode === 403
|
|
34
|
+
&& err.originalError
|
|
35
|
+
&& err.originalError.response
|
|
36
|
+
&& err.originalError.response.body
|
|
37
|
+
&& err.originalError.response.body.errorCode === 'hooks_not_allowed') {
|
|
38
|
+
// Recent Management API version, but with feature explicitly disabled.
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
};
|
|
43
|
+
class GuardianPhoneSelectedProviderHandler extends default_1.default {
|
|
44
|
+
constructor(options) {
|
|
45
|
+
super(Object.assign(Object.assign({}, options), { type: 'guardianPhoneFactorSelectedProvider' }));
|
|
46
|
+
}
|
|
47
|
+
getType() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
// in case client version does not support the operation
|
|
50
|
+
if (!this.client.guardian || typeof this.client.guardian.getPhoneFactorSelectedProvider !== 'function') {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
if (this.existing)
|
|
54
|
+
return this.existing;
|
|
55
|
+
try {
|
|
56
|
+
this.existing = yield this.client.guardian.getPhoneFactorSelectedProvider();
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
if (isFeatureUnavailableError(e)) {
|
|
60
|
+
// Gracefully skip processing this configuration value.
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
throw e;
|
|
64
|
+
}
|
|
65
|
+
return this.existing;
|
|
66
|
+
});
|
|
51
67
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
processChanges(assets) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
// No API to delete or create guardianPhoneFactorSelectedProvider, we can only update.
|
|
71
|
+
const { guardianPhoneFactorSelectedProvider } = assets;
|
|
72
|
+
// Do nothing if not set
|
|
73
|
+
if (!guardianPhoneFactorSelectedProvider || !guardianPhoneFactorSelectedProvider.provider)
|
|
74
|
+
return;
|
|
75
|
+
const params = {};
|
|
76
|
+
const data = guardianPhoneFactorSelectedProvider;
|
|
77
|
+
yield this.client.guardian.updatePhoneFactorSelectedProvider(params, data);
|
|
78
|
+
this.updated += 1;
|
|
79
|
+
this.didUpdate(guardianPhoneFactorSelectedProvider);
|
|
80
|
+
});
|
|
63
81
|
}
|
|
64
|
-
|
|
65
|
-
return this.existing;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async processChanges(assets) {
|
|
69
|
-
const {
|
|
70
|
-
guardianPhoneFactorSelectedProvider
|
|
71
|
-
} = assets;
|
|
72
|
-
if (!guardianPhoneFactorSelectedProvider || !guardianPhoneFactorSelectedProvider.provider) return;
|
|
73
|
-
const params = {};
|
|
74
|
-
const data = guardianPhoneFactorSelectedProvider;
|
|
75
|
-
await this.client.guardian.updatePhoneFactorSelectedProvider(params, data);
|
|
76
|
-
this.updated += 1;
|
|
77
|
-
this.didUpdate(guardianPhoneFactorSelectedProvider);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
82
|
}
|
|
81
|
-
|
|
82
|
-
exports.default = GuardianPhoneSelectedProviderHandler;
|
|
83
|
+
exports.default = GuardianPhoneSelectedProviderHandler;
|
|
@@ -1,66 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _default2 = _interopRequireDefault(_default);
|
|
11
|
-
|
|
12
|
-
var _constants = require("../../constants");
|
|
13
|
-
|
|
14
|
-
var _constants2 = _interopRequireDefault(_constants);
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const schema = exports.schema = {
|
|
19
|
-
type: 'object',
|
|
20
|
-
properties: {
|
|
21
|
-
policies: {
|
|
22
|
-
type: 'array',
|
|
23
|
-
items: {
|
|
24
|
-
type: 'string',
|
|
25
|
-
enum: _constants2.default.GUARDIAN_POLICIES
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
additionalProperties: false
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
class GuardianPoliciesHandler extends _default2.default {
|
|
33
|
-
constructor(options) {
|
|
34
|
-
super({ ...options,
|
|
35
|
-
type: 'guardianPolicies'
|
|
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());
|
|
36
9
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
const constants_1 = __importDefault(require("../../constants"));
|
|
18
|
+
exports.schema = {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
policies: {
|
|
22
|
+
type: 'array',
|
|
23
|
+
items: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
enum: constants_1.default.GUARDIAN_POLICIES
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
additionalProperties: false
|
|
30
|
+
};
|
|
31
|
+
class GuardianPoliciesHandler extends default_1.default {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
super(Object.assign(Object.assign({}, options), { type: 'guardianPolicies' }));
|
|
34
|
+
}
|
|
35
|
+
getType() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
// in case client version does not support the operation
|
|
38
|
+
if (!this.client.guardian || typeof this.client.guardian.getPolicies !== 'function') {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
if (this.existing)
|
|
42
|
+
return this.existing;
|
|
43
|
+
const policies = yield this.client.guardian.getPolicies();
|
|
44
|
+
this.existing = { policies };
|
|
45
|
+
return this.existing;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
processChanges(assets) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
// No API to delete or create guardianPolicies, we can only update.
|
|
51
|
+
const { guardianPolicies } = assets;
|
|
52
|
+
// Do nothing if not set
|
|
53
|
+
if (!guardianPolicies || !guardianPolicies.policies)
|
|
54
|
+
return;
|
|
55
|
+
const params = {};
|
|
56
|
+
const data = guardianPolicies.policies;
|
|
57
|
+
yield this.client.guardian.updatePolicies(params, data);
|
|
58
|
+
this.updated += 1;
|
|
59
|
+
this.didUpdate(guardianPolicies);
|
|
60
|
+
});
|
|
42
61
|
}
|
|
43
|
-
|
|
44
|
-
if (this.existing) return this.existing;
|
|
45
|
-
const policies = await this.client.guardian.getPolicies();
|
|
46
|
-
this.existing = {
|
|
47
|
-
policies
|
|
48
|
-
};
|
|
49
|
-
return this.existing;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async processChanges(assets) {
|
|
53
|
-
const {
|
|
54
|
-
guardianPolicies
|
|
55
|
-
} = assets;
|
|
56
|
-
if (!guardianPolicies || !guardianPolicies.policies) return;
|
|
57
|
-
const params = {};
|
|
58
|
-
const data = guardianPolicies.policies;
|
|
59
|
-
await this.client.guardian.updatePolicies(params, data);
|
|
60
|
-
this.updated += 1;
|
|
61
|
-
this.didUpdate(guardianPolicies);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
exports.default = GuardianPoliciesHandler;
|
|
63
|
+
exports.default = GuardianPoliciesHandler;
|