@cloud-copilot/iam-simulate 0.1.9 → 0.1.11
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/{ConditionKeys.d.ts → context_keys/contextKeyTypes.d.ts} +1 -1
- package/dist/cjs/context_keys/contextKeyTypes.d.ts.map +1 -0
- package/dist/cjs/{ConditionKeys.js → context_keys/contextKeyTypes.js} +1 -1
- package/dist/cjs/context_keys/contextKeyTypes.js.map +1 -0
- package/dist/cjs/context_keys/contextKeys.d.ts +33 -0
- package/dist/cjs/context_keys/contextKeys.d.ts.map +1 -0
- package/dist/cjs/context_keys/contextKeys.js +137 -0
- package/dist/cjs/context_keys/contextKeys.js.map +1 -0
- package/dist/cjs/context_keys/findContextKeys.d.ts.map +1 -1
- package/dist/cjs/context_keys/findContextKeys.js +3 -2
- package/dist/cjs/context_keys/findContextKeys.js.map +1 -1
- package/dist/cjs/global_conditions/globalConditionKeys.d.ts +10 -1
- package/dist/cjs/global_conditions/globalConditionKeys.d.ts.map +1 -1
- package/dist/cjs/global_conditions/globalConditionKeys.js +25 -0
- package/dist/cjs/global_conditions/globalConditionKeys.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +7 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/simulation_engine/simulationEngine.d.ts.map +1 -1
- package/dist/cjs/simulation_engine/simulationEngine.js +7 -6
- package/dist/cjs/simulation_engine/simulationEngine.js.map +1 -1
- package/dist/cjs/util.d.ts +0 -23
- package/dist/cjs/util.d.ts.map +1 -1
- package/dist/cjs/util.js +0 -68
- package/dist/cjs/util.js.map +1 -1
- package/dist/esm/{ConditionKeys.d.ts → context_keys/contextKeyTypes.d.ts} +1 -1
- package/dist/esm/context_keys/contextKeyTypes.d.ts.map +1 -0
- package/dist/esm/{ConditionKeys.js → context_keys/contextKeyTypes.js} +1 -1
- package/dist/esm/context_keys/contextKeyTypes.js.map +1 -0
- package/dist/esm/context_keys/contextKeys.d.ts +33 -0
- package/dist/esm/context_keys/contextKeys.d.ts.map +1 -0
- package/dist/esm/context_keys/contextKeys.js +131 -0
- package/dist/esm/context_keys/contextKeys.js.map +1 -0
- package/dist/esm/context_keys/findContextKeys.d.ts.map +1 -1
- package/dist/esm/context_keys/findContextKeys.js +2 -1
- package/dist/esm/context_keys/findContextKeys.js.map +1 -1
- package/dist/esm/global_conditions/globalConditionKeys.d.ts +10 -1
- package/dist/esm/global_conditions/globalConditionKeys.d.ts.map +1 -1
- package/dist/esm/global_conditions/globalConditionKeys.js +23 -0
- package/dist/esm/global_conditions/globalConditionKeys.js.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/simulation_engine/simulationEngine.d.ts.map +1 -1
- package/dist/esm/simulation_engine/simulationEngine.js +3 -2
- package/dist/esm/simulation_engine/simulationEngine.js.map +1 -1
- package/dist/esm/util.d.ts +0 -23
- package/dist/esm/util.d.ts.map +1 -1
- package/dist/esm/util.js +1 -66
- package/dist/esm/util.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/ConditionKeys.d.ts.map +0 -1
- package/dist/cjs/ConditionKeys.js.map +0 -1
- package/dist/esm/ConditionKeys.d.ts.map +0 -1
- package/dist/esm/ConditionKeys.js.map +0 -1
|
@@ -16,4 +16,4 @@ export declare function isConditionKeyArray(key: ConditionKeyType): key is Array
|
|
|
16
16
|
* @throws if the key is not an array type
|
|
17
17
|
*/
|
|
18
18
|
export declare function getBaseConditionKeyType(key: ArrayConditionKeyType): BaseConditionKeyType;
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=contextKeyTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextKeyTypes.d.ts","sourceRoot":"","sources":["../../../src/context_keys/contextKeyTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;AAC1G,MAAM,MAAM,qBAAqB,GAAG,UAAU,oBAAoB,EAAE,CAAA;AACpE,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,qBAAqB,CAAA;AAE3E;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,GAAG,GAAG,IAAI,qBAAqB,CAEvF;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,qBAAqB,GAAG,oBAAoB,CAKxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextKeyTypes.js","sourceRoot":"","sources":["../../../src/context_keys/contextKeyTypes.ts"],"names":[],"mappings":";;AAUA,kDAEC;AASD,0DAKC;AAtBD;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,GAAqB;IACvD,OAAO,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CAAC,GAA0B;IAChE,IAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,EAAE,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAyB,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ConditionKeyType } from "./contextKeyTypes.js";
|
|
2
|
+
/**
|
|
3
|
+
* Check if a context key actually exists
|
|
4
|
+
*
|
|
5
|
+
* @param key The context key to check
|
|
6
|
+
* @returns true if the context key is valid, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function isActualContextKey(key: string): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Split a context key into the service and the rest of the key. This has to be a special
|
|
11
|
+
* method because context keys with variables may have a colon in the variable section,
|
|
12
|
+
* because of course they can.
|
|
13
|
+
*
|
|
14
|
+
* @param contextKey The context key to split
|
|
15
|
+
* @returns A tuple with the service and the rest of the key
|
|
16
|
+
*/
|
|
17
|
+
export declare function contextKeyParts(contextKey: string): [string, string];
|
|
18
|
+
/**
|
|
19
|
+
* Check the capitalization of a context key and return the correct capitalization
|
|
20
|
+
*
|
|
21
|
+
* @param contextKey the condition key to check
|
|
22
|
+
* @returns if the condition key is an array type
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeContextKeyCase(contextKey: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the type of a context key
|
|
27
|
+
*
|
|
28
|
+
* @param contextKey - The string condition key to get the type for
|
|
29
|
+
* @returns The type of the condition key
|
|
30
|
+
* @throws an error if the condition key is not found
|
|
31
|
+
*/
|
|
32
|
+
export declare function typeForContextKey(contextKey: string): Promise<ConditionKeyType>;
|
|
33
|
+
//# sourceMappingURL=contextKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextKeys.d.ts","sourceRoot":"","sources":["../../../src/context_keys/contextKeys.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBtE;AAiDD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAGpE;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYjF;AAmBD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAYrF"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isActualContextKey = isActualContextKey;
|
|
4
|
+
exports.contextKeyParts = contextKeyParts;
|
|
5
|
+
exports.normalizeContextKeyCase = normalizeContextKeyCase;
|
|
6
|
+
exports.typeForContextKey = typeForContextKey;
|
|
7
|
+
const iam_data_1 = require("@cloud-copilot/iam-data");
|
|
8
|
+
const globalConditionKeys_js_1 = require("../global_conditions/globalConditionKeys.js");
|
|
9
|
+
/**
|
|
10
|
+
* Check if a context key actually exists
|
|
11
|
+
*
|
|
12
|
+
* @param key The context key to check
|
|
13
|
+
* @returns true if the context key is valid, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
async function isActualContextKey(key) {
|
|
16
|
+
if (key.includes("/")) {
|
|
17
|
+
return isActualContextKeyWithVariable(key);
|
|
18
|
+
}
|
|
19
|
+
if ((0, globalConditionKeys_js_1.globalConditionKeyExists)(key)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const parts = key.split(":");
|
|
23
|
+
if (parts.length !== 2) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const [service, action] = parts;
|
|
27
|
+
const serviceExists = await (0, iam_data_1.iamServiceExists)(service);
|
|
28
|
+
if (!serviceExists) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const actionExists = await (0, iam_data_1.iamConditionKeyExists)(service, key);
|
|
32
|
+
return actionExists;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a context key with a variable in it is a valid context key
|
|
36
|
+
*/
|
|
37
|
+
async function isActualContextKeyWithVariable(key) {
|
|
38
|
+
const slashLocation = key.indexOf("/");
|
|
39
|
+
const prefix = key.slice(0, slashLocation);
|
|
40
|
+
const globalKey = (0, globalConditionKeys_js_1.getVariableGlobalConditionKeyByPrefix)(prefix);
|
|
41
|
+
if (globalKey) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
const serviceKey = await serviceContextKeyDetails(key);
|
|
45
|
+
return !!serviceKey;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Takes context key and returns the details for it, accounting for any variables in the key
|
|
49
|
+
*
|
|
50
|
+
* @param contextKey The context key to get the details for
|
|
51
|
+
* @returns The details for the context key if it exists. if the key has variables in it it will return the details for the variable key
|
|
52
|
+
*/
|
|
53
|
+
async function serviceContextKeyDetails(contextKey) {
|
|
54
|
+
const [service, key] = contextKeyParts(contextKey.toLowerCase());
|
|
55
|
+
const serviceExists = await (0, iam_data_1.iamServiceExists)(service);
|
|
56
|
+
if (!serviceExists) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
if (key.includes("/")) {
|
|
60
|
+
const prefix = service + ":" + key.slice(0, key.indexOf("/") + 1);
|
|
61
|
+
const allConditionsKeys = await (0, iam_data_1.iamConditionKeysForService)(service);
|
|
62
|
+
const matchingKey = allConditionsKeys.find(k => k.toLowerCase().startsWith(prefix));
|
|
63
|
+
if (matchingKey) {
|
|
64
|
+
return await (0, iam_data_1.iamConditionKeyDetails)(service, matchingKey);
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const exists = await (0, iam_data_1.iamConditionKeyExists)(service, contextKey);
|
|
69
|
+
if (!exists) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return (0, iam_data_1.iamConditionKeyDetails)(service, contextKey);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Split a context key into the service and the rest of the key. This has to be a special
|
|
76
|
+
* method because context keys with variables may have a colon in the variable section,
|
|
77
|
+
* because of course they can.
|
|
78
|
+
*
|
|
79
|
+
* @param contextKey The context key to split
|
|
80
|
+
* @returns A tuple with the service and the rest of the key
|
|
81
|
+
*/
|
|
82
|
+
function contextKeyParts(contextKey) {
|
|
83
|
+
const colonIndex = contextKey.indexOf(":");
|
|
84
|
+
return [contextKey.slice(0, colonIndex), contextKey.slice(colonIndex + 1)];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check the capitalization of a context key and return the correct capitalization
|
|
88
|
+
*
|
|
89
|
+
* @param contextKey the condition key to check
|
|
90
|
+
* @returns if the condition key is an array type
|
|
91
|
+
*/
|
|
92
|
+
async function normalizeContextKeyCase(contextKey) {
|
|
93
|
+
const serviceKey = await serviceContextKeyDetails(contextKey);
|
|
94
|
+
if (serviceKey) {
|
|
95
|
+
return replaceVariableInContextKey(serviceKey.key, contextKey);
|
|
96
|
+
}
|
|
97
|
+
const globalConditionKey = (0, globalConditionKeys_js_1.getGlobalConditionKeyWithOrWithoutPrefix)(contextKey);
|
|
98
|
+
if (globalConditionKey) {
|
|
99
|
+
return replaceVariableInContextKey(globalConditionKey.key, contextKey);
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`Context key ${contextKey} not found`);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Replaces a variable in a context key with the actual value from a policy
|
|
105
|
+
*
|
|
106
|
+
* @param specKey the string value of the condition key spec
|
|
107
|
+
* @param actualKey the string value of the condition key in the policy
|
|
108
|
+
* @returns the spec condition key with the variable portion replaced with the actual value
|
|
109
|
+
*/
|
|
110
|
+
function replaceVariableInContextKey(specKey, actualKey) {
|
|
111
|
+
const slashIndex = specKey.indexOf("/");
|
|
112
|
+
if (slashIndex === -1) {
|
|
113
|
+
return specKey;
|
|
114
|
+
}
|
|
115
|
+
const prefix = specKey.slice(0, slashIndex);
|
|
116
|
+
const suffix = actualKey.slice(slashIndex);
|
|
117
|
+
return prefix + suffix;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get the type of a context key
|
|
121
|
+
*
|
|
122
|
+
* @param contextKey - The string condition key to get the type for
|
|
123
|
+
* @returns The type of the condition key
|
|
124
|
+
* @throws an error if the condition key is not found
|
|
125
|
+
*/
|
|
126
|
+
async function typeForContextKey(contextKey) {
|
|
127
|
+
const globalConditionKey = (0, globalConditionKeys_js_1.getGlobalConditionKeyWithOrWithoutPrefix)(contextKey);
|
|
128
|
+
if (globalConditionKey) {
|
|
129
|
+
return globalConditionKey.dataType;
|
|
130
|
+
}
|
|
131
|
+
const keyDetails = await serviceContextKeyDetails(contextKey);
|
|
132
|
+
if (keyDetails) {
|
|
133
|
+
return keyDetails.type;
|
|
134
|
+
}
|
|
135
|
+
throw new Error(`Condition key ${contextKey} not found`);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=contextKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextKeys.js","sourceRoot":"","sources":["../../../src/context_keys/contextKeys.ts"],"names":[],"mappings":";;AAUA,gDAoBC;AAyDD,0CAGC;AAQD,0DAYC;AA0BD,8CAYC;AApJD,sDAAoJ;AACpJ,wFAAwK;AAGxK;;;;;GAKG;AACI,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAClD,IAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,8BAA8B,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,IAAG,IAAA,iDAAwB,EAAC,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAG,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;IAChC,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAgB,EAAC,OAAO,CAAC,CAAC;IAEtD,IAAG,CAAC,aAAa,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,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,IAAG,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;IAC3C,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAC1C,OAAO,MAAM,GAAG,MAAM,CAAA;AACxB,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,iBAAiB,CAAC,UAAkB;IACxD,MAAM,kBAAkB,GAAG,IAAA,iEAAwC,EAAC,UAAU,CAAC,CAAC;IAChF,IAAG,kBAAkB,EAAE,CAAC;QACtB,OAAO,kBAAkB,CAAC,QAA4B,CAAC;IACzD,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,wBAAwB,CAAC,UAAU,CAAC,CAAA;IAC7D,IAAG,UAAU,EAAE,CAAC;QACd,OAAO,UAAU,CAAC,IAAwB,CAAC;IAC7C,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iBAAiB,UAAU,YAAY,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findContextKeys.d.ts","sourceRoot":"","sources":["../../../src/context_keys/findContextKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"findContextKeys.d.ts","sourceRoot":"","sources":["../../../src/context_keys/findContextKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAInD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAqBjH;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBjE"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.findContextKeys = findContextKeys;
|
|
4
4
|
exports.getContextKeysFromPolicy = getContextKeysFromPolicy;
|
|
5
5
|
const util_js_1 = require("../util.js");
|
|
6
|
+
const contextKeys_js_1 = require("./contextKeys.js");
|
|
6
7
|
/**
|
|
7
8
|
* Find all the context keys in a list of policies
|
|
8
9
|
*
|
|
@@ -17,9 +18,9 @@ async function findContextKeys(policies) {
|
|
|
17
18
|
const validKeys = new Set();
|
|
18
19
|
const invalidKeys = new Set();
|
|
19
20
|
for (const key of rawKeys) {
|
|
20
|
-
const valid = await (0,
|
|
21
|
+
const valid = await (0, contextKeys_js_1.isActualContextKey)(key);
|
|
21
22
|
if (valid) {
|
|
22
|
-
const normalizedKey = await (0,
|
|
23
|
+
const normalizedKey = await (0, contextKeys_js_1.normalizeContextKeyCase)(key);
|
|
23
24
|
validKeys.add(normalizedKey);
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findContextKeys.js","sourceRoot":"","sources":["../../../src/context_keys/findContextKeys.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"findContextKeys.js","sourceRoot":"","sources":["../../../src/context_keys/findContextKeys.ts"],"names":[],"mappings":";;AAUA,0CAqBC;AAQD,4DAiBC;AAvDD,wCAAoD;AACpD,qDAA+E;AAE/E;;;;;GAKG;AACI,KAAK,UAAU,eAAe,CAAC,QAAkB;IACtD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAI,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC7B,wBAAwB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,MAAM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AAC,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { ConditionKeyType } from "../
|
|
1
|
+
import { ConditionKeyType } from "../context_keys/contextKeyTypes.js";
|
|
2
2
|
interface GlobalConditionKey {
|
|
3
3
|
key: string;
|
|
4
4
|
category: string;
|
|
5
5
|
dataType: ConditionKeyType;
|
|
6
6
|
}
|
|
7
|
+
export declare function getGlobalConditionKeyWithOrWithoutPrefix(key: string): GlobalConditionKey | undefined;
|
|
7
8
|
export declare function getGlobalConditionKey(key: string): GlobalConditionKey | undefined;
|
|
8
9
|
export declare function globalConditionKeyExists(key: string): boolean;
|
|
9
10
|
export declare function getGlobalConditionKeysByCategory(category: string): GlobalConditionKey[];
|
|
11
|
+
/**
|
|
12
|
+
* Get the details for a global condition key that has a variable by it's prefix
|
|
13
|
+
* for example, it will find aws:ResourceTag/tag-key if you pass in aws:ResourceTag
|
|
14
|
+
*
|
|
15
|
+
* @param prefix - The prefix of the global condition key, case insensitive
|
|
16
|
+
* @returns The global condition key details if found
|
|
17
|
+
*/
|
|
18
|
+
export declare function getVariableGlobalConditionKeyByPrefix(prefix: string): GlobalConditionKey | undefined;
|
|
10
19
|
/**
|
|
11
20
|
* Get all the global condition keys as lower case strings
|
|
12
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalConditionKeys.d.ts","sourceRoot":"","sources":["../../../src/global_conditions/globalConditionKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"globalConditionKeys.d.ts","sourceRoot":"","sources":["../../../src/global_conditions/globalConditionKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,UAAU,kBAAkB;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,gBAAgB,CAAA;CAC3B;AAgSD,wBAAgB,wCAAwC,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAMpG;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAEjF;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAEvF;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAEpG;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGlobalConditionKeyWithOrWithoutPrefix = getGlobalConditionKeyWithOrWithoutPrefix;
|
|
3
4
|
exports.getGlobalConditionKey = getGlobalConditionKey;
|
|
4
5
|
exports.globalConditionKeyExists = globalConditionKeyExists;
|
|
5
6
|
exports.getGlobalConditionKeysByCategory = getGlobalConditionKeysByCategory;
|
|
7
|
+
exports.getVariableGlobalConditionKeyByPrefix = getVariableGlobalConditionKeyByPrefix;
|
|
6
8
|
exports.allGlobalConditionKeys = allGlobalConditionKeys;
|
|
7
9
|
const globalConditionKeys = [
|
|
8
10
|
{
|
|
@@ -270,12 +272,25 @@ const keysByName = globalConditionKeys.reduce((acc, key) => {
|
|
|
270
272
|
acc[key.key.toLowerCase()] = key;
|
|
271
273
|
return acc;
|
|
272
274
|
}, {});
|
|
275
|
+
const variableKeysByName = globalConditionKeys.reduce((acc, key) => {
|
|
276
|
+
if (key.key.includes("/")) {
|
|
277
|
+
acc[key.key.split("/")[0].toLowerCase()] = key;
|
|
278
|
+
}
|
|
279
|
+
return acc;
|
|
280
|
+
}, {});
|
|
273
281
|
const keysByCategory = globalConditionKeys.reduce((acc, key) => {
|
|
274
282
|
const lowerCategory = key.category.toLowerCase();
|
|
275
283
|
acc[lowerCategory] = acc[lowerCategory] || [];
|
|
276
284
|
acc[lowerCategory].push(key);
|
|
277
285
|
return acc;
|
|
278
286
|
}, {});
|
|
287
|
+
function getGlobalConditionKeyWithOrWithoutPrefix(key) {
|
|
288
|
+
const slashIndex = key.indexOf("/");
|
|
289
|
+
if (slashIndex !== -1) {
|
|
290
|
+
return getVariableGlobalConditionKeyByPrefix(key.slice(0, slashIndex));
|
|
291
|
+
}
|
|
292
|
+
return getGlobalConditionKey(key);
|
|
293
|
+
}
|
|
279
294
|
function getGlobalConditionKey(key) {
|
|
280
295
|
return keysByName[key.toLowerCase()];
|
|
281
296
|
}
|
|
@@ -285,6 +300,16 @@ function globalConditionKeyExists(key) {
|
|
|
285
300
|
function getGlobalConditionKeysByCategory(category) {
|
|
286
301
|
return keysByCategory[category.toLowerCase()] || [];
|
|
287
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Get the details for a global condition key that has a variable by it's prefix
|
|
305
|
+
* for example, it will find aws:ResourceTag/tag-key if you pass in aws:ResourceTag
|
|
306
|
+
*
|
|
307
|
+
* @param prefix - The prefix of the global condition key, case insensitive
|
|
308
|
+
* @returns The global condition key details if found
|
|
309
|
+
*/
|
|
310
|
+
function getVariableGlobalConditionKeyByPrefix(prefix) {
|
|
311
|
+
return variableKeysByName[prefix.toLowerCase()];
|
|
312
|
+
}
|
|
288
313
|
/**
|
|
289
314
|
* Get all the global condition keys as lower case strings
|
|
290
315
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalConditionKeys.js","sourceRoot":"","sources":["../../../src/global_conditions/globalConditionKeys.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"globalConditionKeys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AAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,SAAgB,gCAAgC,CAAC,QAAgB;IAC/D,OAAO,cAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,qCAAqC,CAAC,MAAc;IAClE,OAAO,kBAAkB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { typeForContextKey } from './context_keys/contextKeys.js';
|
|
2
|
+
export { BaseConditionKeyType, isConditionKeyArray, type ConditionKeyType } from './context_keys/contextKeyTypes.js';
|
|
2
3
|
export { findContextKeys } from './context_keys/findContextKeys.js';
|
|
3
4
|
export { type EvaluationResult } from './evaluate.js';
|
|
4
5
|
export { allowedContextKeysForRequest } from './simulation_engine/contextKeys.js';
|
|
@@ -6,5 +7,5 @@ export { type Simulation } from './simulation_engine/simulation.js';
|
|
|
6
7
|
export { runSimulation } from './simulation_engine/simulationEngine.js';
|
|
7
8
|
export { type SimulationOptions } from './simulation_engine/simulationOptions.js';
|
|
8
9
|
export { runUnsafeSimulation } from './simulation_engine/unsafeSimulationEngine.js';
|
|
9
|
-
export { isWildcardOnlyAction
|
|
10
|
+
export { isWildcardOnlyAction } from './util.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
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,oBAAoB,EAAE,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.isWildcardOnlyAction = exports.runUnsafeSimulation = exports.runSimulation = exports.allowedContextKeysForRequest = exports.findContextKeys = exports.isConditionKeyArray = exports.typeForContextKey = void 0;
|
|
4
|
+
var contextKeys_js_1 = require("./context_keys/contextKeys.js");
|
|
5
|
+
Object.defineProperty(exports, "typeForContextKey", { enumerable: true, get: function () { return contextKeys_js_1.typeForContextKey; } });
|
|
6
|
+
var contextKeyTypes_js_1 = require("./context_keys/contextKeyTypes.js");
|
|
7
|
+
Object.defineProperty(exports, "isConditionKeyArray", { enumerable: true, get: function () { return contextKeyTypes_js_1.isConditionKeyArray; } });
|
|
6
8
|
var findContextKeys_js_1 = require("./context_keys/findContextKeys.js");
|
|
7
9
|
Object.defineProperty(exports, "findContextKeys", { enumerable: true, get: function () { return findContextKeys_js_1.findContextKeys; } });
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "allowedContextKeysForRequest", { enumerable: true, get: function () { return
|
|
10
|
+
var contextKeys_js_2 = require("./simulation_engine/contextKeys.js");
|
|
11
|
+
Object.defineProperty(exports, "allowedContextKeysForRequest", { enumerable: true, get: function () { return contextKeys_js_2.allowedContextKeysForRequest; } });
|
|
10
12
|
var simulationEngine_js_1 = require("./simulation_engine/simulationEngine.js");
|
|
11
13
|
Object.defineProperty(exports, "runSimulation", { enumerable: true, get: function () { return simulationEngine_js_1.runSimulation; } });
|
|
12
14
|
var unsafeSimulationEngine_js_1 = require("./simulation_engine/unsafeSimulationEngine.js");
|
|
13
15
|
Object.defineProperty(exports, "runUnsafeSimulation", { enumerable: true, get: function () { return unsafeSimulationEngine_js_1.runUnsafeSimulation; } });
|
|
14
16
|
var util_js_1 = require("./util.js");
|
|
15
17
|
Object.defineProperty(exports, "isWildcardOnlyAction", { enumerable: true, get: function () { return util_js_1.isWildcardOnlyAction; } });
|
|
16
|
-
Object.defineProperty(exports, "typeForContextKey", { enumerable: true, get: function () { return util_js_1.typeForContextKey; } });
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,gEAAkE;AAAzD,mHAAA,iBAAiB,OAAA;AAC1B,wEAAqH;AAAtF,yHAAA,mBAAmB,OAAA;AAClD,wEAAoE;AAA3D,qHAAA,eAAe,OAAA;AAExB,qEAAkF;AAAzE,8HAAA,4BAA4B,OAAA;AAErC,+EAAwE;AAA/D,oHAAA,aAAa,OAAA;AAEtB,2FAAoF;AAA3E,gIAAA,mBAAmB,OAAA;AAC5B,qCAAiD;AAAxC,+GAAA,oBAAoB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulationEngine.d.ts","sourceRoot":"","sources":["../../../src/simulation_engine/simulationEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAoG,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"simulationEngine.d.ts","sourceRoot":"","sources":["../../../src/simulation_engine/simulationEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAoG,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAI9J,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKlD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IACzD,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC9D,oBAAoB,CAAC,EAAE,eAAe,EAAE,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE;QACP,gBAAgB,EAAE,gBAAgB,CAAA;KACnC,CAAA;CACF;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA+HpI;AAED,wBAAsB,6BAA6B,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CA0BtH"}
|
|
@@ -4,12 +4,13 @@ exports.runSimulation = runSimulation;
|
|
|
4
4
|
exports.normalizeSimulationParameters = normalizeSimulationParameters;
|
|
5
5
|
const iam_data_1 = require("@cloud-copilot/iam-data");
|
|
6
6
|
const iam_policy_1 = require("@cloud-copilot/iam-policy");
|
|
7
|
-
const
|
|
7
|
+
const contextKeyTypes_js_1 = require("../context_keys/contextKeyTypes.js");
|
|
8
|
+
const contextKeys_js_1 = require("../context_keys/contextKeys.js");
|
|
8
9
|
const coreSimulatorEngine_js_1 = require("../core_engine/coreSimulatorEngine.js");
|
|
9
10
|
const request_js_1 = require("../request/request.js");
|
|
10
11
|
const requestContext_js_1 = require("../requestContext.js");
|
|
11
12
|
const util_js_1 = require("../util.js");
|
|
12
|
-
const
|
|
13
|
+
const contextKeys_js_2 = require("./contextKeys.js");
|
|
13
14
|
/**
|
|
14
15
|
* Run a simulation with validation
|
|
15
16
|
*
|
|
@@ -134,16 +135,16 @@ async function runSimulation(simulation, simulationOptions) {
|
|
|
134
135
|
async function normalizeSimulationParameters(simulation) {
|
|
135
136
|
const [service, action] = simulation.request.action.split(":");
|
|
136
137
|
const resourceArn = simulation.request.resource.resource;
|
|
137
|
-
const contextVariablesForAction = new Set(await (0,
|
|
138
|
+
const contextVariablesForAction = new Set(await (0, contextKeys_js_2.allowedContextKeysForRequest)(service, action, resourceArn));
|
|
138
139
|
//Get the types of the context variables and set a string or array of strings based on that.
|
|
139
140
|
const allowedContextKeys = {};
|
|
140
141
|
for (const key of Object.keys(simulation.request.contextVariables)) {
|
|
141
142
|
const value = simulation.request.contextVariables[key];
|
|
142
143
|
const lowerCaseKey = key.toLowerCase();
|
|
143
144
|
if (contextVariablesForAction.has(lowerCaseKey)) {
|
|
144
|
-
const conditionType = await (0,
|
|
145
|
-
const normalizedKey = await (0,
|
|
146
|
-
if ((0,
|
|
145
|
+
const conditionType = await (0, contextKeys_js_1.typeForContextKey)(lowerCaseKey);
|
|
146
|
+
const normalizedKey = await (0, contextKeys_js_1.normalizeContextKeyCase)(lowerCaseKey);
|
|
147
|
+
if ((0, contextKeyTypes_js_1.isConditionKeyArray)(conditionType)) {
|
|
147
148
|
allowedContextKeys[normalizedKey] = [value].flat();
|
|
148
149
|
}
|
|
149
150
|
else if (Array.isArray(value)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulationEngine.js","sourceRoot":"","sources":["../../../src/simulation_engine/simulationEngine.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"simulationEngine.js","sourceRoot":"","sources":["../../../src/simulation_engine/simulationEngine.ts"],"names":[],"mappings":";;AAkCA,sCA+HC;AAED,sEA0BC;AA7LD,sDAA4E;AAC5E,0DAA8J;AAC9J,2EAAyE;AACzE,mEAA4F;AAC5F,kFAA0F;AAE1F,sDAAuD;AACvD,4DAA0D;AAC1D,wCAA6E;AAC7E,qDAAgE;AAkBhE;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CAAC,UAAsB,EAAE,iBAA6C;IACvG,MAAM,oBAAoB,GAAsC,EAAE,CAAC;IACnE,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5C,MAAM,EAAC,IAAI,EAAE,MAAM,EAAC,GAAG,KAAK,CAAC;QAC7B,MAAM,gBAAgB,GAAG,IAAA,mCAAsB,EAAC,MAAM,CAAC,CAAC;QACxD,IAAG,gBAAgB,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAChC,gBAAgB,CAAC,IAAI,CAAC,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,oBAAoB,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;QAChD,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,yBAAyB,GAAsC,EAAE,CAAC;IACxE,MAAM,sBAAsB,GAA6B,UAAU,CAAC,sBAAsB,CAAC,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gB,CAAC,EAAE,CAAC;QACnE,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACvD,MAAM,YAAY,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,yBAAyB,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YAEhD,MAAM,aAAa,GAAG,MAAM,IAAA,kCAAiB,EAAC,YAAY,CAAC,CAAC;YAC5D,MAAM,aAAa,GAAG,MAAM,IAAA,wCAAuB,EAAC,YAAY,CAAC,CAAC;YAElE,IAAG,IAAA,wCAAmB,EAAC,aAAa,CAAC,EAAE,CAAC;gBACtC,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;YACrD,CAAC;iBAAM,IAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,kBAAkB,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,kBAAkB,CAAA;AAC3B,CAAC"}
|
package/dist/cjs/util.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ResourceType } from '@cloud-copilot/iam-data';
|
|
2
|
-
import { ConditionKeyType } from './ConditionKeys.js';
|
|
3
2
|
import { AwsRequest } from './request/request.js';
|
|
4
3
|
interface StringReplaceOptions {
|
|
5
4
|
replaceWildcards: boolean;
|
|
@@ -83,21 +82,6 @@ export declare function convertResourcePatternToRegex(pattern: string): string;
|
|
|
83
82
|
* @returns the lowercased strings
|
|
84
83
|
*/
|
|
85
84
|
export declare function lowerCaseAll(strings: string[]): string[];
|
|
86
|
-
/**
|
|
87
|
-
* Check the capitalization of a context key and return the correct capitalization
|
|
88
|
-
*
|
|
89
|
-
* @param contextKey the condition key to check
|
|
90
|
-
* @returns if the condition key is an array type
|
|
91
|
-
*/
|
|
92
|
-
export declare function normalizeContextKeyCase(contextKey: string): Promise<string>;
|
|
93
|
-
/**
|
|
94
|
-
* Get the type of a context key
|
|
95
|
-
*
|
|
96
|
-
* @param contextKey - The string condition key to get the type for
|
|
97
|
-
* @returns The type of the condition key
|
|
98
|
-
* @throws an error if the condition key is not found
|
|
99
|
-
*/
|
|
100
|
-
export declare function typeForContextKey(contextKey: string): Promise<ConditionKeyType>;
|
|
101
85
|
/**
|
|
102
86
|
* Gets the IAM variables from a string
|
|
103
87
|
*
|
|
@@ -105,12 +89,5 @@ export declare function typeForContextKey(contextKey: string): Promise<Condition
|
|
|
105
89
|
* @returns the variables in the string, if any
|
|
106
90
|
*/
|
|
107
91
|
export declare function getVariablesFromString(value: string): string[];
|
|
108
|
-
/**
|
|
109
|
-
* Check if a context key actually exists
|
|
110
|
-
*
|
|
111
|
-
* @param key The context key to check
|
|
112
|
-
* @returns true if the context key is valid, false otherwise
|
|
113
|
-
*/
|
|
114
|
-
export declare function isActualContextKey(key: string): Promise<boolean>;
|
|
115
92
|
export {};
|
|
116
93
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/cjs/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAIjD,UAAU,oBAAoB;IAC5B,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAMD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,c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AAM,EAAE,GAAG,MAAM,EAAE,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAY9D"}
|
package/dist/cjs/util.js
CHANGED
|
@@ -9,12 +9,8 @@ exports.isWildcardOnlyAction = isWildcardOnlyAction;
|
|
|
9
9
|
exports.getResourceTypesForAction = getResourceTypesForAction;
|
|
10
10
|
exports.convertResourcePatternToRegex = convertResourcePatternToRegex;
|
|
11
11
|
exports.lowerCaseAll = lowerCaseAll;
|
|
12
|
-
exports.normalizeContextKeyCase = normalizeContextKeyCase;
|
|
13
|
-
exports.typeForContextKey = typeForContextKey;
|
|
14
12
|
exports.getVariablesFromString = getVariablesFromString;
|
|
15
|
-
exports.isActualContextKey = isActualContextKey;
|
|
16
13
|
const iam_data_1 = require("@cloud-copilot/iam-data");
|
|
17
|
-
const globalConditionKeys_js_1 = require("./global_conditions/globalConditionKeys.js");
|
|
18
14
|
const matchesNothing = new RegExp('a^');
|
|
19
15
|
const defaultStringReplaceOptions = {
|
|
20
16
|
replaceWildcards: true
|
|
@@ -260,48 +256,6 @@ function convertResourcePatternToRegex(pattern) {
|
|
|
260
256
|
function lowerCaseAll(strings) {
|
|
261
257
|
return strings.map(s => s.toLowerCase());
|
|
262
258
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Check the capitalization of a context key and return the correct capitalization
|
|
265
|
-
*
|
|
266
|
-
* @param contextKey the condition key to check
|
|
267
|
-
* @returns if the condition key is an array type
|
|
268
|
-
*/
|
|
269
|
-
async function normalizeContextKeyCase(contextKey) {
|
|
270
|
-
const [service, key] = contextKey.split(":");
|
|
271
|
-
const serviceExists = await (0, iam_data_1.iamServiceExists)(service);
|
|
272
|
-
if (serviceExists) {
|
|
273
|
-
const serviceKeyExists = await (0, iam_data_1.iamConditionKeyExists)(service, contextKey);
|
|
274
|
-
if (serviceKeyExists) {
|
|
275
|
-
const keyDetails = await (0, iam_data_1.iamConditionKeyDetails)(service, contextKey);
|
|
276
|
-
return keyDetails.key;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
const globalConditionKey = (0, globalConditionKeys_js_1.getGlobalConditionKey)(contextKey);
|
|
280
|
-
if (globalConditionKey) {
|
|
281
|
-
return globalConditionKey.key;
|
|
282
|
-
}
|
|
283
|
-
throw new Error(`Context key ${contextKey} not found`);
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Get the type of a context key
|
|
287
|
-
*
|
|
288
|
-
* @param contextKey - The string condition key to get the type for
|
|
289
|
-
* @returns The type of the condition key
|
|
290
|
-
* @throws an error if the condition key is not found
|
|
291
|
-
*/
|
|
292
|
-
async function typeForContextKey(contextKey) {
|
|
293
|
-
const globalConditionKey = (0, globalConditionKeys_js_1.getGlobalConditionKey)(contextKey);
|
|
294
|
-
if (globalConditionKey) {
|
|
295
|
-
return globalConditionKey.dataType;
|
|
296
|
-
}
|
|
297
|
-
const [service, key] = contextKey.split(":");
|
|
298
|
-
const serviceKeyExists = await (0, iam_data_1.iamConditionKeyExists)(service, contextKey);
|
|
299
|
-
if (serviceKeyExists) {
|
|
300
|
-
const keyDetails = await (0, iam_data_1.iamConditionKeyDetails)(service, contextKey);
|
|
301
|
-
return keyDetails.type;
|
|
302
|
-
}
|
|
303
|
-
throw new Error(`Condition key ${contextKey} not found`);
|
|
304
|
-
}
|
|
305
259
|
/**
|
|
306
260
|
* Gets the IAM variables from a string
|
|
307
261
|
*
|
|
@@ -321,26 +275,4 @@ function getVariablesFromString(value) {
|
|
|
321
275
|
}
|
|
322
276
|
return [];
|
|
323
277
|
}
|
|
324
|
-
/**
|
|
325
|
-
* Check if a context key actually exists
|
|
326
|
-
*
|
|
327
|
-
* @param key The context key to check
|
|
328
|
-
* @returns true if the context key is valid, false otherwise
|
|
329
|
-
*/
|
|
330
|
-
async function isActualContextKey(key) {
|
|
331
|
-
if ((0, globalConditionKeys_js_1.globalConditionKeyExists)(key)) {
|
|
332
|
-
return true;
|
|
333
|
-
}
|
|
334
|
-
const parts = key.split(":");
|
|
335
|
-
if (parts.length !== 2) {
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
const [service, action] = parts;
|
|
339
|
-
const serviceExists = await (0, iam_data_1.iamServiceExists)(service);
|
|
340
|
-
if (!serviceExists) {
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
const actionExists = await (0, iam_data_1.iamConditionKeyExists)(service, key);
|
|
344
|
-
return actionExists;
|
|
345
|
-
}
|
|
346
278
|
//# sourceMappingURL=util.js.map
|