aws-iam-managed-policies 0.0.656 → 0.0.685
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/dist/index.js +29 -28
- package/dist/managedPolicies.json +2 -2
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -4,26 +4,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getPolicyDiffByVersions = exports.getPolicyDocumentByVersion = exports.getLatestPolicyDocument = exports.getPolicyByName = exports.getPolicyCount = exports.listPolicies = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const deep_object_diff_1 = require("deep-object-diff");
|
|
8
|
+
const managedPolicies_json_1 = __importDefault(require("./managedPolicies.json"));
|
|
9
|
+
const managedPolicies = managedPolicies_json_1.default;
|
|
10
|
+
const sortObjectByPropertyNames = (obj) => Object.keys(obj).sort().reduce((objEntries, key) => {
|
|
10
11
|
objEntries[key] = obj[key];
|
|
11
12
|
return objEntries;
|
|
12
|
-
}, {});
|
|
13
|
+
}, {});
|
|
13
14
|
/**
|
|
14
15
|
* Retrieve a list of all included IAM Managed Polcies.
|
|
15
16
|
* @returns {Array} An array of IAM Managed Policy names.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
-
return Object.keys(sortObjectByPropertyNames(
|
|
18
|
+
const listPolicies = () => {
|
|
19
|
+
return Object.keys(sortObjectByPropertyNames(managedPolicies));
|
|
19
20
|
};
|
|
20
21
|
exports.listPolicies = listPolicies;
|
|
21
22
|
/**
|
|
22
23
|
* Get the number of included IAM Managed Polcies.
|
|
23
24
|
* @returns {number} The count of IAM Managed Policies.
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
return Object.keys(
|
|
26
|
+
const getPolicyCount = () => {
|
|
27
|
+
return Object.keys(managedPolicies).length;
|
|
27
28
|
};
|
|
28
29
|
exports.getPolicyCount = getPolicyCount;
|
|
29
30
|
/**
|
|
@@ -32,13 +33,13 @@ exports.getPolicyCount = getPolicyCount;
|
|
|
32
33
|
* @returns {object} The IAM Managed Policy if found.
|
|
33
34
|
* @throws Will throw an error if not found by the name.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const getPolicyByName = (policyName) => {
|
|
37
|
+
const policy = managedPolicies[policyName];
|
|
37
38
|
if (policy) {
|
|
38
39
|
return policy;
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
|
-
throw new Error(
|
|
42
|
+
throw new Error(`IAM Managed Policy '${policyName}' wasn't found!`);
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
exports.getPolicyByName = getPolicyByName;
|
|
@@ -48,14 +49,14 @@ exports.getPolicyByName = getPolicyByName;
|
|
|
48
49
|
* @returns {object} The IAM Managed Policy document if found.
|
|
49
50
|
* @throws Will throw an error if not found by the name.
|
|
50
51
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
const getLatestPolicyDocument = (policyName) => {
|
|
53
|
+
const policy = managedPolicies[policyName];
|
|
53
54
|
if (policy) {
|
|
54
|
-
|
|
55
|
+
const latestVersionId = policy.latestVersionId;
|
|
55
56
|
return policy.versions[latestVersionId].document;
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
|
-
throw new Error(
|
|
59
|
+
throw new Error(`IAM Managed Policy '${policyName}' wasn't found!`);
|
|
59
60
|
}
|
|
60
61
|
};
|
|
61
62
|
exports.getLatestPolicyDocument = getLatestPolicyDocument;
|
|
@@ -66,13 +67,13 @@ exports.getLatestPolicyDocument = getLatestPolicyDocument;
|
|
|
66
67
|
* @returns {object} The IAM Managed Policy document if found.
|
|
67
68
|
* @throws Will throw an error if not found by the name.
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (policy && policy.versions[
|
|
72
|
-
return policy.versions[
|
|
70
|
+
const getPolicyDocumentByVersion = (policyName, policyVersion) => {
|
|
71
|
+
const policy = managedPolicies[policyName];
|
|
72
|
+
if (policy && policy.versions[`v${policyVersion}`]) {
|
|
73
|
+
return policy.versions[`v${policyVersion}`].document;
|
|
73
74
|
}
|
|
74
75
|
else {
|
|
75
|
-
throw new Error(
|
|
76
|
+
throw new Error(`IAM Managed Policy '${policyName}' wasn't found in version '${policyVersion}'!`);
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
79
|
exports.getPolicyDocumentByVersion = getPolicyDocumentByVersion;
|
|
@@ -84,19 +85,19 @@ exports.getPolicyDocumentByVersion = getPolicyDocumentByVersion;
|
|
|
84
85
|
* @returns {object} The diff of the IAM Managed Policy document versions if found.
|
|
85
86
|
* @throws Will throw an error if not found by the name or the respective policy document versions.
|
|
86
87
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
const getPolicyDiffByVersions = (policyName, oldPolicyVersion, newPolicyVersion) => {
|
|
89
|
+
const policy = managedPolicies[policyName];
|
|
89
90
|
if (policy) {
|
|
90
|
-
if (!policy.versions[
|
|
91
|
-
throw new Error(
|
|
91
|
+
if (!policy.versions[`v${oldPolicyVersion}`]) {
|
|
92
|
+
throw new Error(`IAM Managed Policy '${policyName}' wasn't found in version '${oldPolicyVersion}'!`);
|
|
92
93
|
}
|
|
93
|
-
if (!policy.versions[
|
|
94
|
-
throw new Error(
|
|
94
|
+
if (!policy.versions[`v${newPolicyVersion}`]) {
|
|
95
|
+
throw new Error(`IAM Managed Policy '${policyName}' wasn't found in version '${newPolicyVersion}'!`);
|
|
95
96
|
}
|
|
96
|
-
return (0, deep_object_diff_1.detailedDiff)(policy.versions[
|
|
97
|
+
return (0, deep_object_diff_1.detailedDiff)(policy.versions[`v${oldPolicyVersion}`].document, policy.versions[`v${newPolicyVersion}`].document);
|
|
97
98
|
}
|
|
98
99
|
else {
|
|
99
|
-
throw new Error(
|
|
100
|
+
throw new Error(`IAM Managed Policy '${policyName}' wasn't found!`);
|
|
100
101
|
}
|
|
101
102
|
};
|
|
102
103
|
exports.getPolicyDiffByVersions = getPolicyDiffByVersions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/managedPolicies.json
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 81019938 bytes
|
|
4
|
+
sha256: 0c87f88bccbd7f625f6c7454a401510d92302733dc9faa40c6dfc76d77d7373a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-iam-managed-policies",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.685",
|
|
4
4
|
"description": "Provides AWS IAM Managed Policies historical data as a convenient npm package that can be used in other OSS projects.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
".": "./dist/index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"gather-managed-policies": "
|
|
12
|
-
"backfill-managed-policies": "
|
|
11
|
+
"gather-managed-policies": "tsx process/gatherManagedPolicies.ts",
|
|
12
|
+
"backfill-managed-policies": "tsx process/backfillManagedPoliciesHistory.ts",
|
|
13
|
+
"typecheck": "tsc --project tsconfig.json",
|
|
13
14
|
"build": "rm -rf dist/ && tsc --build src/",
|
|
14
15
|
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
|
|
15
16
|
},
|
|
@@ -33,14 +34,14 @@
|
|
|
33
34
|
},
|
|
34
35
|
"homepage": "https://github.com/tobilg/aws-iam-managed-policies#readme",
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^
|
|
37
|
-
"aws-sdk": "^2.
|
|
38
|
-
"jsdoc": "^4.0.
|
|
39
|
-
"jsdoc-fresh": "^
|
|
37
|
+
"@types/node": "^22",
|
|
38
|
+
"aws-sdk": "^2.1693.0",
|
|
39
|
+
"jsdoc": "^4.0.5",
|
|
40
|
+
"jsdoc-fresh": "^6.0.0",
|
|
40
41
|
"mkdirp": "^3.0.1",
|
|
41
|
-
"p-limit": "3.
|
|
42
|
-
"
|
|
43
|
-
"typescript": "^
|
|
42
|
+
"p-limit": "7.3.3",
|
|
43
|
+
"tsx": "^4.23.15",
|
|
44
|
+
"typescript": "^6.0.3"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"deep-object-diff": "^1.1.9"
|