@cloud-copilot/iam-expand 0.11.5 → 0.11.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/cjs/actions.d.ts +15 -0
- package/dist/cjs/actions.d.ts.map +1 -0
- package/dist/cjs/actions.js +39 -0
- package/dist/cjs/actions.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/util.d.ts +1 -1
- package/dist/cjs/util.js +1 -1
- package/dist/esm/actions.d.ts +15 -0
- package/dist/esm/actions.d.ts.map +1 -0
- package/dist/esm/actions.js +35 -0
- package/dist/esm/actions.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/util.d.ts +1 -1
- package/dist/esm/util.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the action supplied matches any known IAM actions.
|
|
3
|
+
*
|
|
4
|
+
* @param action the "service:action" string to check if it matches any known IAM actions. Can include wildcards.
|
|
5
|
+
* @return true if the action matches at least one known IAM action, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function matchesAnyAction(action: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Checks to see if the action matches the provided pattern IAM action pattern.
|
|
10
|
+
*
|
|
11
|
+
* @param action the action to check, should not contain wildcards
|
|
12
|
+
* @param pattern the pattern to match against, may contain wildcards
|
|
13
|
+
*/
|
|
14
|
+
export declare function actionMatchesPattern(action: string, pattern: string): boolean;
|
|
15
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBvE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAG7E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchesAnyAction = matchesAnyAction;
|
|
4
|
+
exports.actionMatchesPattern = actionMatchesPattern;
|
|
5
|
+
const iam_data_1 = require("@cloud-copilot/iam-data");
|
|
6
|
+
const util_js_1 = require("./util.js");
|
|
7
|
+
/**
|
|
8
|
+
* Check if the action supplied matches any known IAM actions.
|
|
9
|
+
*
|
|
10
|
+
* @param action the "service:action" string to check if it matches any known IAM actions. Can include wildcards.
|
|
11
|
+
* @return true if the action matches at least one known IAM action, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
async function matchesAnyAction(action) {
|
|
14
|
+
const parts = action.split(':');
|
|
15
|
+
if (parts.length !== 2) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const [service, actionName] = parts;
|
|
19
|
+
const serviceExists = await (0, iam_data_1.iamServiceExists)(service);
|
|
20
|
+
if (!serviceExists) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (actionName.includes('*') || actionName.includes('?')) {
|
|
24
|
+
const allActions = await (0, iam_data_1.iamActionsForService)(service);
|
|
25
|
+
return allActions.some((knownAction) => actionMatchesPattern(knownAction, actionName));
|
|
26
|
+
}
|
|
27
|
+
return (0, iam_data_1.iamActionExists)(service, actionName);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Checks to see if the action matches the provided pattern IAM action pattern.
|
|
31
|
+
*
|
|
32
|
+
* @param action the action to check, should not contain wildcards
|
|
33
|
+
* @param pattern the pattern to match against, may contain wildcards
|
|
34
|
+
*/
|
|
35
|
+
function actionMatchesPattern(action, pattern) {
|
|
36
|
+
const regex = (0, util_js_1.convertStringToPattern)((0, util_js_1.unescapeUnicodeCharacters)(pattern));
|
|
37
|
+
return regex.test((0, util_js_1.unescapeUnicodeCharacters)(action));
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":";;AASA,4CAkBC;AAQD,oDAGC;AAtCD,sDAAiG;AACjG,uCAA6E;AAE7E;;;;;GAKG;AACI,KAAK,UAAU,gBAAgB,CAAC,MAAc;IACnD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAA;IAEnC,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAgB,EAAC,OAAO,CAAC,CAAA;IACrD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzD,MAAM,UAAU,GAAG,MAAM,IAAA,+BAAoB,EAAC,OAAO,CAAC,CAAA;QACtD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,oBAAoB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAA;IACxF,CAAC;IAED,OAAO,IAAA,0BAAe,EAAC,OAAO,EAAE,UAAU,CAAC,CAAA;AAC7C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,MAAc,EAAE,OAAe;IAClE,MAAM,KAAK,GAAG,IAAA,gCAAsB,EAAC,IAAA,mCAAyB,EAAC,OAAO,CAAC,CAAC,CAAA;IACxE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAA,mCAAyB,EAAC,MAAM,CAAC,CAAC,CAAA;AACtD,CAAC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { actionMatchesPattern, matchesAnyAction } from './actions.js';
|
|
1
2
|
export { extractActionsFromLineOfInput } from './cli_utils.js';
|
|
2
3
|
export { expandIamActions, type ExpandIamActionsOptions, type InvalidActionBehavior } from './expand.js';
|
|
3
4
|
export { expandJsonDocument, type ExpandJsonDocumentOptions } from './expand_file.js';
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invertIamActions = exports.expandJsonDocument = exports.expandIamActions = exports.extractActionsFromLineOfInput = void 0;
|
|
3
|
+
exports.invertIamActions = exports.expandJsonDocument = exports.expandIamActions = exports.extractActionsFromLineOfInput = exports.matchesAnyAction = exports.actionMatchesPattern = void 0;
|
|
4
|
+
var actions_js_1 = require("./actions.js");
|
|
5
|
+
Object.defineProperty(exports, "actionMatchesPattern", { enumerable: true, get: function () { return actions_js_1.actionMatchesPattern; } });
|
|
6
|
+
Object.defineProperty(exports, "matchesAnyAction", { enumerable: true, get: function () { return actions_js_1.matchesAnyAction; } });
|
|
4
7
|
var cli_utils_js_1 = require("./cli_utils.js");
|
|
5
8
|
Object.defineProperty(exports, "extractActionsFromLineOfInput", { enumerable: true, get: function () { return cli_utils_js_1.extractActionsFromLineOfInput; } });
|
|
6
9
|
var expand_js_1 = require("./expand.js");
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAArD,6HAAA,6BAA6B,OAAA;AACtC,yCAIoB;AAHlB,6GAAA,gBAAgB,OAAA;AAIlB,mDAAqF;AAA5E,oHAAA,kBAAkB,OAAA;AAC3B,yCAA8C;AAArC,6GAAA,gBAAgB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAAqE;AAA5D,kHAAA,oBAAoB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAC/C,+CAA8D;AAArD,6HAAA,6BAA6B,OAAA;AACtC,yCAIoB;AAHlB,6GAAA,gBAAgB,OAAA;AAIlB,mDAAqF;AAA5E,oHAAA,kBAAkB,OAAA;AAC3B,yCAA8C;AAArC,6GAAA,gBAAgB,OAAA"}
|
package/dist/cjs/util.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const allAsterisksPattern: RegExp;
|
|
2
2
|
export declare function convertStringToPattern(actionString: string): RegExp;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Unescapes unicode characters in a string
|
|
5
5
|
*
|
|
6
6
|
* @param str The string to unescape
|
|
7
7
|
* @returns The string with any escaped unicode characters replaced with their actual characters
|
package/dist/cjs/util.js
CHANGED
|
@@ -9,7 +9,7 @@ function convertStringToPattern(actionString) {
|
|
|
9
9
|
return new RegExp(pattern, 'i');
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Unescapes unicode characters in a string
|
|
13
13
|
*
|
|
14
14
|
* @param str The string to unescape
|
|
15
15
|
* @returns The string with any escaped unicode characters replaced with their actual characters
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the action supplied matches any known IAM actions.
|
|
3
|
+
*
|
|
4
|
+
* @param action the "service:action" string to check if it matches any known IAM actions. Can include wildcards.
|
|
5
|
+
* @return true if the action matches at least one known IAM action, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function matchesAnyAction(action: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Checks to see if the action matches the provided pattern IAM action pattern.
|
|
10
|
+
*
|
|
11
|
+
* @param action the action to check, should not contain wildcards
|
|
12
|
+
* @param pattern the pattern to match against, may contain wildcards
|
|
13
|
+
*/
|
|
14
|
+
export declare function actionMatchesPattern(action: string, pattern: string): boolean;
|
|
15
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBvE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAG7E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { iamActionExists, iamActionsForService, iamServiceExists } from '@cloud-copilot/iam-data';
|
|
2
|
+
import { convertStringToPattern, unescapeUnicodeCharacters } from './util.js';
|
|
3
|
+
/**
|
|
4
|
+
* Check if the action supplied matches any known IAM actions.
|
|
5
|
+
*
|
|
6
|
+
* @param action the "service:action" string to check if it matches any known IAM actions. Can include wildcards.
|
|
7
|
+
* @return true if the action matches at least one known IAM action, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export async function matchesAnyAction(action) {
|
|
10
|
+
const parts = action.split(':');
|
|
11
|
+
if (parts.length !== 2) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const [service, actionName] = parts;
|
|
15
|
+
const serviceExists = await iamServiceExists(service);
|
|
16
|
+
if (!serviceExists) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (actionName.includes('*') || actionName.includes('?')) {
|
|
20
|
+
const allActions = await iamActionsForService(service);
|
|
21
|
+
return allActions.some((knownAction) => actionMatchesPattern(knownAction, actionName));
|
|
22
|
+
}
|
|
23
|
+
return iamActionExists(service, actionName);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks to see if the action matches the provided pattern IAM action pattern.
|
|
27
|
+
*
|
|
28
|
+
* @param action the action to check, should not contain wildcards
|
|
29
|
+
* @param pattern the pattern to match against, may contain wildcards
|
|
30
|
+
*/
|
|
31
|
+
export function actionMatchesPattern(action, pattern) {
|
|
32
|
+
const regex = convertStringToPattern(unescapeUnicodeCharacters(pattern));
|
|
33
|
+
return regex.test(unescapeUnicodeCharacters(action));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -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CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { actionMatchesPattern, matchesAnyAction } from './actions.js';
|
|
1
2
|
export { extractActionsFromLineOfInput } from './cli_utils.js';
|
|
2
3
|
export { expandIamActions, type ExpandIamActionsOptions, type InvalidActionBehavior } from './expand.js';
|
|
3
4
|
export { expandJsonDocument, type ExpandJsonDocumentOptions } from './expand_file.js';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EACL,gBAAgB,EAGjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAkC,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EACL,gBAAgB,EAGjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAkC,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/esm/util.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const allAsterisksPattern: RegExp;
|
|
2
2
|
export declare function convertStringToPattern(actionString: string): RegExp;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Unescapes unicode characters in a string
|
|
5
5
|
*
|
|
6
6
|
* @param str The string to unescape
|
|
7
7
|
* @returns The string with any escaped unicode characters replaced with their actual characters
|
package/dist/esm/util.js
CHANGED
|
@@ -4,7 +4,7 @@ export function convertStringToPattern(actionString) {
|
|
|
4
4
|
return new RegExp(pattern, 'i');
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Unescapes unicode characters in a string
|
|
8
8
|
*
|
|
9
9
|
* @param str The string to unescape
|
|
10
10
|
* @returns The string with any escaped unicode characters replaced with their actual characters
|