aws-iam-managed-policies 0.0.6 → 0.0.7
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.d.ts +10 -1
- package/dist/index.js +29 -4
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const listPolicies: () => string[];
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const getPolicyCount: () => number;
|
|
12
12
|
/**
|
|
13
|
-
* Get the IAM Managed Policy by name
|
|
13
|
+
* Get the IAM Managed Policy by name with the full version history
|
|
14
14
|
* @param {string} policyName The IAM Managed Policy name.
|
|
15
15
|
* @returns {object} The IAM Managed Policy if found.
|
|
16
16
|
* @throws Will throw an error if not found by the name.
|
|
@@ -31,4 +31,13 @@ export declare const getLatestPolicyDocument: (policyName: string) => object;
|
|
|
31
31
|
* @throws Will throw an error if not found by the name.
|
|
32
32
|
*/
|
|
33
33
|
export declare const getPolicyDocumentByVersion: (policyName: string, policyVersion: number) => object;
|
|
34
|
+
/**
|
|
35
|
+
* Get a diff of the policy documents for two versions of a IAM Managed Policy
|
|
36
|
+
* @param {string} policyName The IAM Managed Policy name.
|
|
37
|
+
* @param {number} oldPolicyVersion The old version id of the IAM Managed Policy.
|
|
38
|
+
* @param {number} newPolicyVersion The new version id of the IAM Managed Policy.
|
|
39
|
+
* @returns {object} The diff of the IAM Managed Policy document versions if found.
|
|
40
|
+
* @throws Will throw an error if not found by the name or the respective policy document versions.
|
|
41
|
+
*/
|
|
42
|
+
export declare const getPolicyDiffByVersions: (policyName: string, oldPolicyVersion: number, newPolicyVersion: number) => object;
|
|
34
43
|
export { ManagedPolicies, };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPolicyDocumentByVersion = exports.getLatestPolicyDocument = exports.getPolicyByName = exports.getPolicyCount = exports.listPolicies = void 0;
|
|
6
|
+
exports.getPolicyDiffByVersions = exports.getPolicyDocumentByVersion = exports.getLatestPolicyDocument = exports.getPolicyByName = exports.getPolicyCount = exports.listPolicies = void 0;
|
|
7
|
+
var deep_object_diff_1 = require("deep-object-diff");
|
|
7
8
|
var managedPolicies_json_1 = __importDefault(require("./managedPolicies.json"));
|
|
8
9
|
var sortObjectByPropertyNames = function (obj) { return Object.keys(obj).sort().reduce(function (objEntries, key) {
|
|
9
10
|
objEntries[key] = obj[key];
|
|
@@ -26,7 +27,7 @@ var getPolicyCount = function () {
|
|
|
26
27
|
};
|
|
27
28
|
exports.getPolicyCount = getPolicyCount;
|
|
28
29
|
/**
|
|
29
|
-
* Get the IAM Managed Policy by name
|
|
30
|
+
* Get the IAM Managed Policy by name with the full version history
|
|
30
31
|
* @param {string} policyName The IAM Managed Policy name.
|
|
31
32
|
* @returns {object} The IAM Managed Policy if found.
|
|
32
33
|
* @throws Will throw an error if not found by the name.
|
|
@@ -67,11 +68,35 @@ exports.getLatestPolicyDocument = getLatestPolicyDocument;
|
|
|
67
68
|
*/
|
|
68
69
|
var getPolicyDocumentByVersion = function (policyName, policyVersion) {
|
|
69
70
|
var policy = managedPolicies_json_1.default[policyName];
|
|
70
|
-
if (policy && policy.versions[policyVersion]) {
|
|
71
|
-
return policy.versions[policyVersion].document;
|
|
71
|
+
if (policy && policy.versions["v".concat(policyVersion)]) {
|
|
72
|
+
return policy.versions["v".concat(policyVersion)].document;
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
74
75
|
throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found in version '").concat(policyVersion, "'!"));
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
78
|
exports.getPolicyDocumentByVersion = getPolicyDocumentByVersion;
|
|
79
|
+
/**
|
|
80
|
+
* Get a diff of the policy documents for two versions of a IAM Managed Policy
|
|
81
|
+
* @param {string} policyName The IAM Managed Policy name.
|
|
82
|
+
* @param {number} oldPolicyVersion The old version id of the IAM Managed Policy.
|
|
83
|
+
* @param {number} newPolicyVersion The new version id of the IAM Managed Policy.
|
|
84
|
+
* @returns {object} The diff of the IAM Managed Policy document versions if found.
|
|
85
|
+
* @throws Will throw an error if not found by the name or the respective policy document versions.
|
|
86
|
+
*/
|
|
87
|
+
var getPolicyDiffByVersions = function (policyName, oldPolicyVersion, newPolicyVersion) {
|
|
88
|
+
var policy = managedPolicies_json_1.default[policyName];
|
|
89
|
+
if (policy) {
|
|
90
|
+
if (!policy.versions["v".concat(oldPolicyVersion)]) {
|
|
91
|
+
throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found in version '").concat(oldPolicyVersion, "'!"));
|
|
92
|
+
}
|
|
93
|
+
if (!policy.versions["v".concat(newPolicyVersion)]) {
|
|
94
|
+
throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found in version '").concat(newPolicyVersion, "'!"));
|
|
95
|
+
}
|
|
96
|
+
return (0, deep_object_diff_1.detailedDiff)(policy.versions["v".concat(oldPolicyVersion)].document, policy.versions["v".concat(newPolicyVersion)].document);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found!"));
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.getPolicyDiffByVersions = getPolicyDiffByVersions;
|
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.7",
|
|
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",
|
|
@@ -41,5 +41,8 @@
|
|
|
41
41
|
"p-limit": "3.1.0",
|
|
42
42
|
"ts-node": "^10.9.1",
|
|
43
43
|
"typescript": "^5.1.6"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"deep-object-diff": "^1.1.9"
|
|
44
47
|
}
|
|
45
48
|
}
|