@cloud-copilot/iam-policy 0.0.1
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/LICENSE.txt +674 -0
- package/README.md +135 -0
- package/dist/cjs/actions/action.d.ts +51 -0
- package/dist/cjs/actions/action.d.ts.map +1 -0
- package/dist/cjs/actions/action.js +33 -0
- package/dist/cjs/actions/action.js.map +1 -0
- package/dist/cjs/conditions/condition.d.ts +15 -0
- package/dist/cjs/conditions/condition.d.ts.map +1 -0
- package/dist/cjs/conditions/condition.js +24 -0
- package/dist/cjs/conditions/condition.js.map +1 -0
- package/dist/cjs/conditions/conditions.d.ts +15 -0
- package/dist/cjs/conditions/conditions.d.ts.map +1 -0
- package/dist/cjs/conditions/conditions.js +24 -0
- package/dist/cjs/conditions/conditions.js.map +1 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/parser.d.ts +9 -0
- package/dist/cjs/parser.d.ts.map +1 -0
- package/dist/cjs/parser.js +14 -0
- package/dist/cjs/parser.js.map +1 -0
- package/dist/cjs/policies/policy.d.ts +14 -0
- package/dist/cjs/policies/policy.d.ts.map +1 -0
- package/dist/cjs/policies/policy.js +21 -0
- package/dist/cjs/policies/policy.js.map +1 -0
- package/dist/cjs/principals/principal.d.ts +21 -0
- package/dist/cjs/principals/principal.d.ts.map +1 -0
- package/dist/cjs/principals/principal.js +35 -0
- package/dist/cjs/principals/principal.js.map +1 -0
- package/dist/cjs/principals/principals.d.ts +21 -0
- package/dist/cjs/principals/principals.d.ts.map +1 -0
- package/dist/cjs/principals/principals.js +35 -0
- package/dist/cjs/principals/principals.js.map +1 -0
- package/dist/cjs/resources/resource.d.ts +20 -0
- package/dist/cjs/resources/resource.d.ts.map +1 -0
- package/dist/cjs/resources/resource.js +18 -0
- package/dist/cjs/resources/resource.js.map +1 -0
- package/dist/cjs/statements/statement.d.ts +146 -0
- package/dist/cjs/statements/statement.d.ts.map +1 -0
- package/dist/cjs/statements/statement.js +121 -0
- package/dist/cjs/statements/statement.js.map +1 -0
- package/dist/cjs/utils.d.ts +8 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +13 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/actions/action.d.ts +51 -0
- package/dist/esm/actions/action.d.ts.map +1 -0
- package/dist/esm/actions/action.js +28 -0
- package/dist/esm/actions/action.js.map +1 -0
- package/dist/esm/conditions/condition.d.ts +15 -0
- package/dist/esm/conditions/condition.d.ts.map +1 -0
- package/dist/esm/conditions/condition.js +17 -0
- package/dist/esm/conditions/condition.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parser.d.ts +9 -0
- package/dist/esm/parser.d.ts.map +1 -0
- package/dist/esm/parser.js +11 -0
- package/dist/esm/parser.js.map +1 -0
- package/dist/esm/policies/policy.d.ts +14 -0
- package/dist/esm/policies/policy.d.ts.map +1 -0
- package/dist/esm/policies/policy.js +16 -0
- package/dist/esm/policies/policy.js.map +1 -0
- package/dist/esm/principals/principal.d.ts +21 -0
- package/dist/esm/principals/principal.d.ts.map +1 -0
- package/dist/esm/principals/principal.js +25 -0
- package/dist/esm/principals/principal.js.map +1 -0
- package/dist/esm/resources/resource.d.ts +20 -0
- package/dist/esm/resources/resource.d.ts.map +1 -0
- package/dist/esm/resources/resource.js +13 -0
- package/dist/esm/resources/resource.js.map +1 -0
- package/dist/esm/statements/statement.d.ts +146 -0
- package/dist/esm/statements/statement.d.ts.map +1 -0
- package/dist/esm/statements/statement.js +116 -0
- package/dist/esm/statements/statement.js.map +1 -0
- package/dist/esm/utils.d.ts +8 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +10 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +40 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
import { Action } from "../actions/action.js";
|
2
|
+
import { Condition } from "../conditions/condition.js";
|
3
|
+
import { Principal } from "../principals/principal.js";
|
4
|
+
import { Resource } from "../resources/resource.js";
|
5
|
+
/**
|
6
|
+
* Represents a statement in an IAM policy
|
7
|
+
*/
|
8
|
+
export interface Statement {
|
9
|
+
/**
|
10
|
+
* The optional Sid (Statement ID) for a statement
|
11
|
+
*/
|
12
|
+
sid(): string | undefined;
|
13
|
+
/**
|
14
|
+
* The effect of the statement, either 'Allow' or 'Deny'
|
15
|
+
*/
|
16
|
+
effect(): string;
|
17
|
+
/**
|
18
|
+
* Is the statement an Allow statement
|
19
|
+
*/
|
20
|
+
isAllow(): boolean;
|
21
|
+
/**
|
22
|
+
* Is the statement a Deny statement
|
23
|
+
*/
|
24
|
+
isDeny(): boolean;
|
25
|
+
/**
|
26
|
+
* The conditions for the statement
|
27
|
+
*/
|
28
|
+
conditions(): Condition[];
|
29
|
+
/**
|
30
|
+
* Does the statement have a Principal
|
31
|
+
*/
|
32
|
+
isPrincipalStatement(): this is PrincipalStatement;
|
33
|
+
/**
|
34
|
+
* Does the statement have a NotPrincipal
|
35
|
+
*/
|
36
|
+
isNotPrincipalStatement(): this is NotPrincipalStatement;
|
37
|
+
/**
|
38
|
+
* Does the statement have an Action
|
39
|
+
*/
|
40
|
+
isActionStatement(): this is ActionStatement;
|
41
|
+
/**
|
42
|
+
* Does the statement have a NotAction
|
43
|
+
*/
|
44
|
+
isNotActionStatement(): this is NotActionStatement;
|
45
|
+
/**
|
46
|
+
* Does the statement have a Resource
|
47
|
+
*/
|
48
|
+
isResourceStatement(): this is ResourceStatement;
|
49
|
+
/**
|
50
|
+
* Does the statement have a NotResource
|
51
|
+
*/
|
52
|
+
isNotResourceStatement(): this is NotResourceStatement;
|
53
|
+
}
|
54
|
+
/**
|
55
|
+
* Represents a statement in an IAM policy that has Action
|
56
|
+
*/
|
57
|
+
export interface ActionStatement extends Statement {
|
58
|
+
/**
|
59
|
+
* The actions for the statement
|
60
|
+
*/
|
61
|
+
actions(): Action[];
|
62
|
+
}
|
63
|
+
/**
|
64
|
+
* Represents a statement in an IAM policy that has NotAction
|
65
|
+
*/
|
66
|
+
export interface NotActionStatement extends Statement {
|
67
|
+
/**
|
68
|
+
* The not actions for the statement
|
69
|
+
*/
|
70
|
+
notActions(): Action[];
|
71
|
+
}
|
72
|
+
/**
|
73
|
+
* Represents a statement in an IAM policy that has Resource
|
74
|
+
*/
|
75
|
+
export interface ResourceStatement extends Statement {
|
76
|
+
/**
|
77
|
+
* The resources for the statement
|
78
|
+
*/
|
79
|
+
resources(): Resource[];
|
80
|
+
/**
|
81
|
+
* Is the resource element exactly a single wildcard: `"*"`
|
82
|
+
*/
|
83
|
+
hasSingleResourceWildcard(): boolean;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Represents a statement in an IAM policy that has NotResource
|
87
|
+
*/
|
88
|
+
export interface NotResourceStatement extends Statement {
|
89
|
+
/**
|
90
|
+
* The not resources for the statement
|
91
|
+
*/
|
92
|
+
notResources(): Resource[];
|
93
|
+
}
|
94
|
+
/**
|
95
|
+
* Represents a statement in an IAM policy that has Principal
|
96
|
+
*/
|
97
|
+
export interface PrincipalStatement extends Statement {
|
98
|
+
/**
|
99
|
+
* The principals for the statement
|
100
|
+
*/
|
101
|
+
principals(): Principal[];
|
102
|
+
}
|
103
|
+
/**
|
104
|
+
* Represents a statement in an IAM policy that has NotPrincipal
|
105
|
+
*/
|
106
|
+
export interface NotPrincipalStatement extends Statement {
|
107
|
+
/**
|
108
|
+
* The not principals for the statement
|
109
|
+
*/
|
110
|
+
notPrincipals(): Principal[];
|
111
|
+
}
|
112
|
+
/**
|
113
|
+
* Implementation of the Statement interface and all its sub-interfaces
|
114
|
+
*/
|
115
|
+
export declare class StatementImpl implements Statement, ActionStatement, NotActionStatement, ResourceStatement, NotResourceStatement, PrincipalStatement {
|
116
|
+
private readonly statementObject;
|
117
|
+
constructor(statementObject: any);
|
118
|
+
sid(): string | undefined;
|
119
|
+
effect(): string;
|
120
|
+
isAllow(): boolean;
|
121
|
+
isDeny(): boolean;
|
122
|
+
isPrincipalStatement(): this is PrincipalStatement;
|
123
|
+
isNotPrincipalStatement(): this is NotPrincipalStatement;
|
124
|
+
principals(): Principal[];
|
125
|
+
notPrincipals(): Principal[];
|
126
|
+
/**
|
127
|
+
* Parse the principal object into PrincipalImpl objects.
|
128
|
+
*
|
129
|
+
* This is non trivial and we don't want to implement this in each function.
|
130
|
+
*
|
131
|
+
* @param principals the Principal or NotPrincipal object ot parse
|
132
|
+
* @returns the backing principals for a Principal or NotPrincipal object
|
133
|
+
*/
|
134
|
+
private parsePrincipalObject;
|
135
|
+
isActionStatement(): this is ActionStatement;
|
136
|
+
isNotActionStatement(): this is NotActionStatement;
|
137
|
+
actions(): Action[];
|
138
|
+
notActions(): Action[];
|
139
|
+
isResourceStatement(): this is ResourceStatement;
|
140
|
+
isNotResourceStatement(): this is NotResourceStatement;
|
141
|
+
resources(): Resource[];
|
142
|
+
notResources(): Resource[];
|
143
|
+
hasSingleResourceWildcard(): boolean;
|
144
|
+
conditions(): Condition[];
|
145
|
+
}
|
146
|
+
//# sourceMappingURL=statement.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"statement.d.ts","sourceRoot":"","sources":["../../../src/statements/statement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAiB,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,SAAS,EAAgC,MAAM,4BAA4B,CAAA;AACpF,OAAO,EAAE,QAAQ,EAAgB,MAAM,0BAA0B,CAAA;AAEjE;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,GAAG,IAAI,MAAM,GAAG,SAAS,CAAA;IAE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,qBAAa,aAAc,YAAW,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,kBAAkB;IACnI,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,GAAG;IAE1C,GAAG,IAAI,MAAM,GAAG,SAAS;IAIzB,MAAM,IAAI,MAAM;IAIhB,OAAO,IAAI,OAAO;IAIlB,MAAM,IAAI,OAAO;IAIjB,oBAAoB,IAAI,IAAI,IAAI,kBAAkB;IAIlD,uBAAuB,IAAI,IAAI,IAAI,qBAAqB;IAIxD,UAAU,IAAI,SAAS,EAAE;IAOzB,aAAa,IAAI,SAAS,EAAE;IAOnC;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAcrB,iBAAiB,IAAI,IAAI,IAAI,eAAe;IAI5C,oBAAoB,IAAI,IAAI,IAAI,kBAAkB;IAIlD,OAAO,IAAI,MAAM,EAAE;IAOnB,UAAU,IAAI,MAAM,EAAE;IAOtB,mBAAmB,IAAI,IAAI,IAAI,iBAAiB;IAIhD,sBAAsB,IAAI,IAAI,IAAI,oBAAoB;IAItD,SAAS,IAAI,QAAQ,EAAE;IAOvB,YAAY,IAAI,QAAQ,EAAE;IAO1B,yBAAyB,IAAI,OAAO;IAOpC,UAAU,IAAI,SAAS,EAAE;CAWjC"}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { ActionImpl } from "../actions/action.js";
|
2
|
+
import { ConditionImpl } from "../conditions/condition.js";
|
3
|
+
import { PrincipalImpl } from "../principals/principal.js";
|
4
|
+
import { ResourceImpl } from "../resources/resource.js";
|
5
|
+
/**
|
6
|
+
* Implementation of the Statement interface and all its sub-interfaces
|
7
|
+
*/
|
8
|
+
export class StatementImpl {
|
9
|
+
constructor(statementObject) {
|
10
|
+
this.statementObject = statementObject;
|
11
|
+
}
|
12
|
+
sid() {
|
13
|
+
return this.statementObject.Sid;
|
14
|
+
}
|
15
|
+
effect() {
|
16
|
+
return this.statementObject.Effect;
|
17
|
+
}
|
18
|
+
isAllow() {
|
19
|
+
return this.effect() === 'Allow';
|
20
|
+
}
|
21
|
+
isDeny() {
|
22
|
+
return this.effect() === 'Deny';
|
23
|
+
}
|
24
|
+
isPrincipalStatement() {
|
25
|
+
return this.statementObject.Principal !== undefined;
|
26
|
+
}
|
27
|
+
isNotPrincipalStatement() {
|
28
|
+
return this.statementObject.NotPrincipal !== undefined;
|
29
|
+
}
|
30
|
+
principals() {
|
31
|
+
if (!this.isPrincipalStatement()) {
|
32
|
+
throw new Error('Called principals on a statement without Principal, use isPrincipalStatement before calling principals');
|
33
|
+
}
|
34
|
+
return this.parsePrincipalObject(this.statementObject.Principal);
|
35
|
+
}
|
36
|
+
notPrincipals() {
|
37
|
+
if (!this.isNotPrincipalStatement()) {
|
38
|
+
throw new Error('Called notPrincipals on a statement without NotPrincipal, use isNotPrincipalStatement before calling notPrincipals');
|
39
|
+
}
|
40
|
+
return this.parsePrincipalObject(this.statementObject.NotPrincipal);
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Parse the principal object into PrincipalImpl objects.
|
44
|
+
*
|
45
|
+
* This is non trivial and we don't want to implement this in each function.
|
46
|
+
*
|
47
|
+
* @param principals the Principal or NotPrincipal object ot parse
|
48
|
+
* @returns the backing principals for a Principal or NotPrincipal object
|
49
|
+
*/
|
50
|
+
parsePrincipalObject(principals) {
|
51
|
+
if (typeof principals === 'string') {
|
52
|
+
return [new PrincipalImpl('AWS', principals)];
|
53
|
+
}
|
54
|
+
return Object.entries(principals).map(([principalType, principalValue]) => {
|
55
|
+
if (typeof principalValue === 'string') {
|
56
|
+
return new PrincipalImpl(principalType, principalValue);
|
57
|
+
}
|
58
|
+
return Object.entries(principalValue).map(([key, value]) => {
|
59
|
+
return new PrincipalImpl(principalType, value);
|
60
|
+
});
|
61
|
+
}).flat();
|
62
|
+
}
|
63
|
+
isActionStatement() {
|
64
|
+
return this.statementObject.Action !== undefined;
|
65
|
+
}
|
66
|
+
isNotActionStatement() {
|
67
|
+
return this.statementObject.NotAction !== undefined;
|
68
|
+
}
|
69
|
+
actions() {
|
70
|
+
if (!this.isActionStatement()) {
|
71
|
+
throw new Error('Called actions on a statement without Action, use isActionStatement before calling actions');
|
72
|
+
}
|
73
|
+
return [this.statementObject.Action].flat().map((action) => new ActionImpl(action));
|
74
|
+
}
|
75
|
+
notActions() {
|
76
|
+
if (!this.isNotActionStatement()) {
|
77
|
+
throw new Error('Called notActions on a statement without NotAction, use isNotActionStatement before calling notActions');
|
78
|
+
}
|
79
|
+
return [this.statementObject.NotAction].flat().map((action) => new ActionImpl(action));
|
80
|
+
}
|
81
|
+
isResourceStatement() {
|
82
|
+
return this.statementObject.Resource !== undefined;
|
83
|
+
}
|
84
|
+
isNotResourceStatement() {
|
85
|
+
return this.statementObject.NotResource !== undefined;
|
86
|
+
}
|
87
|
+
resources() {
|
88
|
+
if (!this.isResourceStatement()) {
|
89
|
+
throw new Error('Called resources on a statement without Resource, use isResourceStatement before calling resources');
|
90
|
+
}
|
91
|
+
return [this.statementObject.Resource].flat().map((resource) => new ResourceImpl(resource));
|
92
|
+
}
|
93
|
+
notResources() {
|
94
|
+
if (!this.isNotResourceStatement()) {
|
95
|
+
throw new Error('Called notResources on a statement without NotResource, use isNotResourceStatement before calling notResources');
|
96
|
+
}
|
97
|
+
return [this.statementObject.NotResource].flat().map((resource) => new ResourceImpl(resource));
|
98
|
+
}
|
99
|
+
hasSingleResourceWildcard() {
|
100
|
+
if (!this.isResourceStatement()) {
|
101
|
+
throw new Error('Called hasSingleResourceWildcard on a statement without Resource, use isResourceStatement before calling hasSingleResourceWildcard');
|
102
|
+
}
|
103
|
+
return this.isResourceStatement() && this.statementObject.Resource === '*';
|
104
|
+
}
|
105
|
+
conditions() {
|
106
|
+
if (!this.statementObject.Condition) {
|
107
|
+
return [];
|
108
|
+
}
|
109
|
+
return Object.entries(this.statementObject.Condition).map(([opKey, opValue]) => {
|
110
|
+
return Object.entries(opValue).map(([condKey, condValue]) => {
|
111
|
+
return new ConditionImpl(opKey, condKey, condValue);
|
112
|
+
});
|
113
|
+
}).flat();
|
114
|
+
}
|
115
|
+
}
|
116
|
+
//# sourceMappingURL=statement.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"statement.js","sourceRoot":"","sources":["../../../src/statements/statement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAa,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAa,aAAa,EAAiB,MAAM,4BAA4B,CAAA;AACpF,OAAO,EAAY,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAiIjE;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB,YAA6B,eAAoB;QAApB,oBAAe,GAAf,eAAe,CAAK;IAAG,CAAC;IAE9C,GAAG;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAA;IACjC,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAA;IACpC,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK,OAAO,CAAA;IAClC,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK,MAAM,CAAA;IACjC,CAAC;IAEM,oBAAoB;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC,SAAS,KAAK,SAAS,CAAC;IACtD,CAAC;IAEM,uBAAuB;QAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,YAAY,KAAK,SAAS,CAAC;IACzD,CAAC;IAEM,UAAU;QACf,IAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,wGAAwG,CAAC,CAAA;QAC3H,CAAC;QACD,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;IAClE,CAAC;IAEM,aAAa;QACl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AyB;QAC9B,IAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,oIAAoI,CAAC,CAAA;QACvJ,CAAC;QACD,OAAO,IAAI,CAAC,mBAAmB,EAAE,IAAI,IAAI,CAAC,eAAe,CAAC,QAAQ,KAAK,GAAG,CAAA;IAC5E,CAAC;IAEM,UAAU;QACf,IAAG,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;YACnC,OAAO,EAAE,CAAA;QACX,CAAC;QAED,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE;YAC7E,OAAO,MAAM,CAAC,OAAO,CAAC,OAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE;gBACjE,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,SAA8B,CAAC,CAAA;YAC1E,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IACX,CAAC;CACF"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* Checks if a string is all wildcards(*)
|
3
|
+
*
|
4
|
+
* @param value The value to check if it is a wildcard
|
5
|
+
* @returns True if the value is all wildcards, false otherwise
|
6
|
+
*/
|
7
|
+
export declare function isAllWildcards(value: string): boolean;
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* Checks if a string is all wildcards(*)
|
3
|
+
*
|
4
|
+
* @param value The value to check if it is a wildcard
|
5
|
+
* @returns True if the value is all wildcards, false otherwise
|
6
|
+
*/
|
7
|
+
export function isAllWildcards(value) {
|
8
|
+
return value.match(/^\**$/) !== null;
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;AACtC,CAAC"}
|
package/package.json
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"name": "@cloud-copilot/iam-policy",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "An ORM for AWS IAM policies",
|
5
|
+
"repository": {
|
6
|
+
"type": "git",
|
7
|
+
"url": "git+https://github.com/cloud-copilot/iam-policy.git"
|
8
|
+
},
|
9
|
+
"exports": {
|
10
|
+
".": {
|
11
|
+
"import": "./dist/esm/index.js",
|
12
|
+
"require": "./dist/cjs/index.js"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"files": [
|
16
|
+
"dist/**/*"
|
17
|
+
],
|
18
|
+
"types": "dist/cjs/index.d.ts",
|
19
|
+
"scripts": {
|
20
|
+
"build": "npx tsc -p tsconfig.cjs.json && npx tsc -p tsconfig.esm.json && ./postbuild.sh",
|
21
|
+
"test": "npx vitest --run --coverage",
|
22
|
+
"prepare": "npm run build"
|
23
|
+
},
|
24
|
+
"keywords": [
|
25
|
+
"AWS",
|
26
|
+
"IAM"
|
27
|
+
],
|
28
|
+
"author": "David Kerber <dave@cloudcopilot.io>",
|
29
|
+
"license": "GPL-3.0-or-later",
|
30
|
+
"bugs": {
|
31
|
+
"url": "https://github.com/cloud-copilot/iam-policy/issues"
|
32
|
+
},
|
33
|
+
"homepage": "https://github.com/cloud-copilot/iam-policy#readme",
|
34
|
+
"devDependencies": {
|
35
|
+
"@types/node": "^22.5.0",
|
36
|
+
"@vitest/coverage-v8": "^2.0.5",
|
37
|
+
"typescript": "^5.5.4",
|
38
|
+
"vitest": "^2.0.5"
|
39
|
+
}
|
40
|
+
}
|