@beesolve/iam-policy-ts 0.1.0
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/README.md +144 -0
- package/dist/catalog.d.ts +472 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +21692 -0
- package/dist/helpers.d.ts +17 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +12 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/render.d.ts +20 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +102 -0
- package/dist/schema.d.ts +269 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +103 -0
- package/package.json +43 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { iamActionCatalog } from "./catalog.js";
|
|
2
|
+
export type IamActionCatalog = typeof iamActionCatalog;
|
|
3
|
+
export type IamPolicyServicePrefix = keyof IamActionCatalog;
|
|
4
|
+
export type IamPolicyActionNameByService<TService extends IamPolicyServicePrefix> = IamActionCatalog[TService][number];
|
|
5
|
+
export type IamPolicyActionForService<TService extends IamPolicyServicePrefix> = `${TService}:${IamPolicyActionNameByService<TService>}`;
|
|
6
|
+
export type IamHelperObject = {
|
|
7
|
+
[K in IamPolicyServicePrefix]: (action: IamPolicyActionNameByService<K>) => IamPolicyActionForService<K>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Builds a fully qualified IAM action string with service-scoped autocomplete.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* iamAction("s3", "GetObject") // "s3:GetObject"
|
|
14
|
+
* iamAction("kms", "Decrypt") // "kms:Decrypt"
|
|
15
|
+
*/
|
|
16
|
+
export declare function iamAction<TService extends IamPolicyServicePrefix>(service: TService, action: IamPolicyActionNameByService<TService>): IamPolicyActionForService<TService>;
|
|
17
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC;AACvD,MAAM,MAAM,sBAAsB,GAAG,MAAM,gBAAgB,CAAC;AAC5D,MAAM,MAAM,4BAA4B,CACtC,QAAQ,SAAS,sBAAsB,IACrC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AACvC,MAAM,MAAM,yBAAyB,CAAC,QAAQ,SAAS,sBAAsB,IAC3E,GAAG,QAAQ,IAAI,4BAA4B,CAAC,QAAQ,CAAC,EAAE,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;KAC3B,CAAC,IAAI,sBAAsB,GAAG,CAC7B,MAAM,EAAE,4BAA4B,CAAC,CAAC,CAAC,KACpC,yBAAyB,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,SAAS,sBAAsB,EAC/D,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAC7C,yBAAyB,CAAC,QAAQ,CAAC,CAErC"}
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { iamActionCatalog } from "./catalog.js";
|
|
2
|
+
/**
|
|
3
|
+
* Builds a fully qualified IAM action string with service-scoped autocomplete.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* iamAction("s3", "GetObject") // "s3:GetObject"
|
|
7
|
+
* iamAction("kms", "Decrypt") // "kms:Decrypt"
|
|
8
|
+
*/
|
|
9
|
+
export function iamAction(service, action) {
|
|
10
|
+
return `${service}:${action}`;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=helpers.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { iamActionCatalog, iamActionCatalogSourceUrl, iamActionCatalogSourceSha256, iamActionCatalogActionCount, iam, } from "./catalog.js";
|
|
2
|
+
export { iamAction, type IamActionCatalog, type IamPolicyServicePrefix, type IamPolicyActionNameByService, type IamPolicyActionForService, type IamHelperObject, } from "./helpers.js";
|
|
3
|
+
export { iamPolicyDocumentSchema, iamPolicyStatementSchema, iamPolicyDocumentStrictSchema, iamPolicyStatementStrictSchema, isIamPolicyDocument, isIamPolicyStatement, isIamPolicyDocumentStrict, assertIamPolicyDocument, assertIamPolicyDocumentStrict, type IamPolicyVersion, type IamPolicyScalar, type IamPolicyScalarList, type IamPolicyStringList, type IamPolicyPrincipalMap, type IamPolicyPrincipal, type IamPolicyConditionBlock, type IamPolicyStatement, type IamPolicyDocument, type IamPolicyStatementStrict, type IamPolicyDocumentStrict, } from "./schema.js";
|
|
4
|
+
export { policyToTypescript } from "./render.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,GAAG,GACJ,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,8BAA8B,EAC9B,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { iamActionCatalog, iamActionCatalogSourceUrl, iamActionCatalogSourceSha256, iamActionCatalogActionCount, iam, } from "./catalog.js";
|
|
2
|
+
export { iamAction, } from "./helpers.js";
|
|
3
|
+
export { iamPolicyDocumentSchema, iamPolicyStatementSchema, iamPolicyDocumentStrictSchema, iamPolicyStatementStrictSchema, isIamPolicyDocument, isIamPolicyStatement, isIamPolicyDocumentStrict, assertIamPolicyDocument, assertIamPolicyDocumentStrict, } from "./schema.js";
|
|
4
|
+
export { policyToTypescript } from "./render.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IamPolicyDocument } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Renders an IAM policy document as TypeScript source code using `iam.*` helpers
|
|
4
|
+
* for known actions. Unknown actions are rendered as plain string literals.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const ts = policyToTypescript({
|
|
8
|
+
* Version: "2012-10-17",
|
|
9
|
+
* Statement: [{
|
|
10
|
+
* Effect: "Allow",
|
|
11
|
+
* Action: ["s3:GetObject", "s3:ListBucket"],
|
|
12
|
+
* Resource: "*",
|
|
13
|
+
* }],
|
|
14
|
+
* });
|
|
15
|
+
* // Returns TypeScript source with iam.s3("GetObject"), iam.s3("ListBucket"), etc.
|
|
16
|
+
*/
|
|
17
|
+
export declare function policyToTypescript(policy: IamPolicyDocument, options?: {
|
|
18
|
+
indentLevel?: number;
|
|
19
|
+
}): string;
|
|
20
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACjC,MAAM,CAGR"}
|
package/dist/render.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { iamActionCatalog } from "./catalog.js";
|
|
2
|
+
/**
|
|
3
|
+
* Renders an IAM policy document as TypeScript source code using `iam.*` helpers
|
|
4
|
+
* for known actions. Unknown actions are rendered as plain string literals.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const ts = policyToTypescript({
|
|
8
|
+
* Version: "2012-10-17",
|
|
9
|
+
* Statement: [{
|
|
10
|
+
* Effect: "Allow",
|
|
11
|
+
* Action: ["s3:GetObject", "s3:ListBucket"],
|
|
12
|
+
* Resource: "*",
|
|
13
|
+
* }],
|
|
14
|
+
* });
|
|
15
|
+
* // Returns TypeScript source with iam.s3("GetObject"), iam.s3("ListBucket"), etc.
|
|
16
|
+
*/
|
|
17
|
+
export function policyToTypescript(policy, options) {
|
|
18
|
+
const indentLevel = options?.indentLevel ?? 0;
|
|
19
|
+
return renderValue(policy, { indentLevel, parentPropertyName: undefined });
|
|
20
|
+
}
|
|
21
|
+
function renderValue(value, props) {
|
|
22
|
+
if (value === null) {
|
|
23
|
+
return "null";
|
|
24
|
+
}
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
return "undefined";
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
return renderStringValue(value, props);
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
32
|
+
return JSON.stringify(value);
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(value)) {
|
|
35
|
+
return renderArray(value, props);
|
|
36
|
+
}
|
|
37
|
+
if (isRecord(value)) {
|
|
38
|
+
return renderObject(value, props);
|
|
39
|
+
}
|
|
40
|
+
return JSON.stringify(value);
|
|
41
|
+
}
|
|
42
|
+
function renderStringValue(value, props) {
|
|
43
|
+
if (props.parentPropertyName === "Action" ||
|
|
44
|
+
props.parentPropertyName === "NotAction") {
|
|
45
|
+
return renderActionString(value);
|
|
46
|
+
}
|
|
47
|
+
return JSON.stringify(value);
|
|
48
|
+
}
|
|
49
|
+
function renderActionString(value) {
|
|
50
|
+
const separatorIndex = value.indexOf(":");
|
|
51
|
+
if (separatorIndex <= 0 || separatorIndex === value.length - 1) {
|
|
52
|
+
return JSON.stringify(value);
|
|
53
|
+
}
|
|
54
|
+
const servicePrefix = value.slice(0, separatorIndex);
|
|
55
|
+
const actionName = value.slice(separatorIndex + 1);
|
|
56
|
+
const knownActions = iamActionCatalog[servicePrefix];
|
|
57
|
+
if (knownActions == null || !knownActions.includes(actionName)) {
|
|
58
|
+
return JSON.stringify(value);
|
|
59
|
+
}
|
|
60
|
+
if (isIdentifierSafe(servicePrefix)) {
|
|
61
|
+
return `iam.${servicePrefix}(${JSON.stringify(actionName)})`;
|
|
62
|
+
}
|
|
63
|
+
return `iam[${JSON.stringify(servicePrefix)}](${JSON.stringify(actionName)})`;
|
|
64
|
+
}
|
|
65
|
+
function renderArray(value, props) {
|
|
66
|
+
if (value.length === 0) {
|
|
67
|
+
return "[]";
|
|
68
|
+
}
|
|
69
|
+
const indent = " ".repeat(props.indentLevel);
|
|
70
|
+
const childIndent = " ".repeat(props.indentLevel + 1);
|
|
71
|
+
const renderedItems = value.map((item) => renderValue(item, {
|
|
72
|
+
indentLevel: props.indentLevel + 1,
|
|
73
|
+
parentPropertyName: props.parentPropertyName,
|
|
74
|
+
}));
|
|
75
|
+
return `[\n${renderedItems.map((item) => `${childIndent}${item}`).join(",\n")}\n${indent}]`;
|
|
76
|
+
}
|
|
77
|
+
function renderObject(value, props) {
|
|
78
|
+
const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== undefined);
|
|
79
|
+
if (entries.length === 0) {
|
|
80
|
+
return "{}";
|
|
81
|
+
}
|
|
82
|
+
const indent = " ".repeat(props.indentLevel);
|
|
83
|
+
const childIndent = " ".repeat(props.indentLevel + 1);
|
|
84
|
+
const renderedEntries = entries.map(([key, entryValue]) => {
|
|
85
|
+
const renderedValue = renderValue(entryValue, {
|
|
86
|
+
indentLevel: props.indentLevel + 1,
|
|
87
|
+
parentPropertyName: key,
|
|
88
|
+
});
|
|
89
|
+
return `${childIndent}${renderObjectKey(key)}: ${renderedValue}`;
|
|
90
|
+
});
|
|
91
|
+
return `{\n${renderedEntries.join(",\n")}\n${indent}}`;
|
|
92
|
+
}
|
|
93
|
+
function renderObjectKey(value) {
|
|
94
|
+
return isIdentifierSafe(value) ? value : JSON.stringify(value);
|
|
95
|
+
}
|
|
96
|
+
function isIdentifierSafe(value) {
|
|
97
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(value);
|
|
98
|
+
}
|
|
99
|
+
function isRecord(value) {
|
|
100
|
+
return (value != null && typeof value === "object" && Array.isArray(value) === false);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=render.js.map
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
declare const nonEmptyStringListSchema: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
3
|
+
declare const policyScalarSchema: v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>;
|
|
4
|
+
declare const policyScalarListSchema: v.UnionSchema<[v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, undefined>]>], undefined>;
|
|
5
|
+
declare const policyPrincipalMapSchema: v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
6
|
+
declare const policyPrincipalSchema: v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>;
|
|
7
|
+
declare const policyConditionBlockSchema: v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, undefined>]>], undefined>, undefined>, undefined>;
|
|
8
|
+
export declare const iamPolicyStatementSchema: v.StrictObjectSchema<{
|
|
9
|
+
readonly Sid: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
10
|
+
readonly Effect: v.PicklistSchema<["Allow", "Deny"], undefined>;
|
|
11
|
+
readonly Action: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
12
|
+
readonly NotAction: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
13
|
+
readonly Resource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
14
|
+
readonly NotResource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
15
|
+
readonly Principal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
16
|
+
readonly NotPrincipal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
17
|
+
readonly Condition: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, undefined>]>], undefined>, undefined>, undefined>, undefined>;
|
|
18
|
+
}, undefined>;
|
|
19
|
+
export declare const iamPolicyDocumentSchema: v.StrictObjectSchema<{
|
|
20
|
+
readonly Version: v.OptionalSchema<v.PicklistSchema<["2008-10-17", "2012-10-17"], undefined>, undefined>;
|
|
21
|
+
readonly Id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
22
|
+
readonly Statement: v.UnionSchema<[v.StrictObjectSchema<{
|
|
23
|
+
readonly Sid: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
24
|
+
readonly Effect: v.PicklistSchema<["Allow", "Deny"], undefined>;
|
|
25
|
+
readonly Action: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
26
|
+
readonly NotAction: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
27
|
+
readonly Resource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
28
|
+
readonly NotResource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
29
|
+
readonly Principal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
30
|
+
readonly NotPrincipal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
31
|
+
readonly Condition: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, undefined>]>], undefined>, undefined>, undefined>, undefined>;
|
|
32
|
+
}, undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StrictObjectSchema<{
|
|
33
|
+
readonly Sid: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
34
|
+
readonly Effect: v.PicklistSchema<["Allow", "Deny"], undefined>;
|
|
35
|
+
readonly Action: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
36
|
+
readonly NotAction: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
37
|
+
readonly Resource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
38
|
+
readonly NotResource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
39
|
+
readonly Principal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
40
|
+
readonly NotPrincipal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
41
|
+
readonly Condition: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, undefined>]>], undefined>, undefined>, undefined>, undefined>;
|
|
42
|
+
}, undefined>, undefined>, v.MinLengthAction<{
|
|
43
|
+
Sid?: string | undefined;
|
|
44
|
+
Effect: "Allow" | "Deny";
|
|
45
|
+
Action?: string | string[] | undefined;
|
|
46
|
+
NotAction?: string | string[] | undefined;
|
|
47
|
+
Resource?: string | string[] | undefined;
|
|
48
|
+
NotResource?: string | string[] | undefined;
|
|
49
|
+
Principal?: "*" | {
|
|
50
|
+
[x: string]: string | string[];
|
|
51
|
+
} | undefined;
|
|
52
|
+
NotPrincipal?: "*" | {
|
|
53
|
+
[x: string]: string | string[];
|
|
54
|
+
} | undefined;
|
|
55
|
+
Condition?: {
|
|
56
|
+
[x: string]: {
|
|
57
|
+
[x: string]: string | number | boolean | (string | number | boolean)[];
|
|
58
|
+
};
|
|
59
|
+
} | undefined;
|
|
60
|
+
}[], 1, undefined>]>], undefined>;
|
|
61
|
+
}, undefined>;
|
|
62
|
+
export type IamPolicyVersion = v.InferOutput<typeof iamPolicyDocumentSchema>["Version"];
|
|
63
|
+
export type IamPolicyScalar = v.InferOutput<typeof policyScalarSchema>;
|
|
64
|
+
export type IamPolicyScalarList = v.InferOutput<typeof policyScalarListSchema>;
|
|
65
|
+
export type IamPolicyStringList = v.InferOutput<typeof nonEmptyStringListSchema>;
|
|
66
|
+
export type IamPolicyPrincipalMap = v.InferOutput<typeof policyPrincipalMapSchema>;
|
|
67
|
+
export type IamPolicyPrincipal = v.InferOutput<typeof policyPrincipalSchema>;
|
|
68
|
+
export type IamPolicyConditionBlock = v.InferOutput<typeof policyConditionBlockSchema>;
|
|
69
|
+
export type IamPolicyStatement = v.InferOutput<typeof iamPolicyStatementSchema>;
|
|
70
|
+
export type IamPolicyDocument = v.InferOutput<typeof iamPolicyDocumentSchema>;
|
|
71
|
+
/**
|
|
72
|
+
* Type guard: checks if a value is a valid IAM policy document.
|
|
73
|
+
*/
|
|
74
|
+
export declare function isIamPolicyDocument(value: unknown): value is IamPolicyDocument;
|
|
75
|
+
/**
|
|
76
|
+
* Type guard: checks if a value is a valid IAM policy statement.
|
|
77
|
+
*/
|
|
78
|
+
export declare function isIamPolicyStatement(value: unknown): value is IamPolicyStatement;
|
|
79
|
+
/**
|
|
80
|
+
* Parses and validates a value as an IAM policy document.
|
|
81
|
+
* Throws a ValiError if validation fails.
|
|
82
|
+
*/
|
|
83
|
+
export declare function assertIamPolicyDocument(value: unknown): IamPolicyDocument;
|
|
84
|
+
/**
|
|
85
|
+
* Strict IAM policy statement schema that enforces grammar rules:
|
|
86
|
+
* - Must have exactly one of Action or NotAction
|
|
87
|
+
* - Must have exactly one of Resource or NotResource (for identity-based policies)
|
|
88
|
+
* - Cannot have both Action and NotAction
|
|
89
|
+
* - Cannot have both Resource and NotResource
|
|
90
|
+
*/
|
|
91
|
+
export declare const iamPolicyStatementStrictSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
92
|
+
readonly Sid: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
93
|
+
readonly Effect: v.PicklistSchema<["Allow", "Deny"], undefined>;
|
|
94
|
+
readonly Action: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
95
|
+
readonly NotAction: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
96
|
+
readonly Resource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
97
|
+
readonly NotResource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
98
|
+
readonly Principal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
99
|
+
readonly NotPrincipal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
100
|
+
readonly Condition: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, undefined>]>], undefined>, undefined>, undefined>, undefined>;
|
|
101
|
+
}, undefined>, v.CheckAction<{
|
|
102
|
+
Sid?: string | undefined;
|
|
103
|
+
Effect: "Allow" | "Deny";
|
|
104
|
+
Action?: string | string[] | undefined;
|
|
105
|
+
NotAction?: string | string[] | undefined;
|
|
106
|
+
Resource?: string | string[] | undefined;
|
|
107
|
+
NotResource?: string | string[] | undefined;
|
|
108
|
+
Principal?: "*" | {
|
|
109
|
+
[x: string]: string | string[];
|
|
110
|
+
} | undefined;
|
|
111
|
+
NotPrincipal?: "*" | {
|
|
112
|
+
[x: string]: string | string[];
|
|
113
|
+
} | undefined;
|
|
114
|
+
Condition?: {
|
|
115
|
+
[x: string]: {
|
|
116
|
+
[x: string]: string | number | boolean | (string | number | boolean)[];
|
|
117
|
+
};
|
|
118
|
+
} | undefined;
|
|
119
|
+
}, "Statement must have exactly one of Action or NotAction.">, v.CheckAction<{
|
|
120
|
+
Sid?: string | undefined;
|
|
121
|
+
Effect: "Allow" | "Deny";
|
|
122
|
+
Action?: string | string[] | undefined;
|
|
123
|
+
NotAction?: string | string[] | undefined;
|
|
124
|
+
Resource?: string | string[] | undefined;
|
|
125
|
+
NotResource?: string | string[] | undefined;
|
|
126
|
+
Principal?: "*" | {
|
|
127
|
+
[x: string]: string | string[];
|
|
128
|
+
} | undefined;
|
|
129
|
+
NotPrincipal?: "*" | {
|
|
130
|
+
[x: string]: string | string[];
|
|
131
|
+
} | undefined;
|
|
132
|
+
Condition?: {
|
|
133
|
+
[x: string]: {
|
|
134
|
+
[x: string]: string | number | boolean | (string | number | boolean)[];
|
|
135
|
+
};
|
|
136
|
+
} | undefined;
|
|
137
|
+
}, "Statement cannot have both Resource and NotResource.">]>;
|
|
138
|
+
/**
|
|
139
|
+
* Strict IAM policy document schema that enforces grammar rules on each statement.
|
|
140
|
+
*/
|
|
141
|
+
export declare const iamPolicyDocumentStrictSchema: v.StrictObjectSchema<{
|
|
142
|
+
readonly Version: v.OptionalSchema<v.PicklistSchema<["2008-10-17", "2012-10-17"], undefined>, undefined>;
|
|
143
|
+
readonly Id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
144
|
+
readonly Statement: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
145
|
+
readonly Sid: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
146
|
+
readonly Effect: v.PicklistSchema<["Allow", "Deny"], undefined>;
|
|
147
|
+
readonly Action: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
148
|
+
readonly NotAction: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
149
|
+
readonly Resource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
150
|
+
readonly NotResource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
151
|
+
readonly Principal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
152
|
+
readonly NotPrincipal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
153
|
+
readonly Condition: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, undefined>]>], undefined>, undefined>, undefined>, undefined>;
|
|
154
|
+
}, undefined>, v.CheckAction<{
|
|
155
|
+
Sid?: string | undefined;
|
|
156
|
+
Effect: "Allow" | "Deny";
|
|
157
|
+
Action?: string | string[] | undefined;
|
|
158
|
+
NotAction?: string | string[] | undefined;
|
|
159
|
+
Resource?: string | string[] | undefined;
|
|
160
|
+
NotResource?: string | string[] | undefined;
|
|
161
|
+
Principal?: "*" | {
|
|
162
|
+
[x: string]: string | string[];
|
|
163
|
+
} | undefined;
|
|
164
|
+
NotPrincipal?: "*" | {
|
|
165
|
+
[x: string]: string | string[];
|
|
166
|
+
} | undefined;
|
|
167
|
+
Condition?: {
|
|
168
|
+
[x: string]: {
|
|
169
|
+
[x: string]: string | number | boolean | (string | number | boolean)[];
|
|
170
|
+
};
|
|
171
|
+
} | undefined;
|
|
172
|
+
}, "Statement must have exactly one of Action or NotAction.">, v.CheckAction<{
|
|
173
|
+
Sid?: string | undefined;
|
|
174
|
+
Effect: "Allow" | "Deny";
|
|
175
|
+
Action?: string | string[] | undefined;
|
|
176
|
+
NotAction?: string | string[] | undefined;
|
|
177
|
+
Resource?: string | string[] | undefined;
|
|
178
|
+
NotResource?: string | string[] | undefined;
|
|
179
|
+
Principal?: "*" | {
|
|
180
|
+
[x: string]: string | string[];
|
|
181
|
+
} | undefined;
|
|
182
|
+
NotPrincipal?: "*" | {
|
|
183
|
+
[x: string]: string | string[];
|
|
184
|
+
} | undefined;
|
|
185
|
+
Condition?: {
|
|
186
|
+
[x: string]: {
|
|
187
|
+
[x: string]: string | number | boolean | (string | number | boolean)[];
|
|
188
|
+
};
|
|
189
|
+
} | undefined;
|
|
190
|
+
}, "Statement cannot have both Resource and NotResource.">]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
191
|
+
readonly Sid: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
192
|
+
readonly Effect: v.PicklistSchema<["Allow", "Deny"], undefined>;
|
|
193
|
+
readonly Action: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
194
|
+
readonly NotAction: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
195
|
+
readonly Resource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
196
|
+
readonly NotResource: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>;
|
|
197
|
+
readonly Principal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
198
|
+
readonly NotPrincipal: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"*", undefined>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>, undefined>], undefined>, undefined>;
|
|
199
|
+
readonly Condition: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.UnionSchema<[v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>, v.MinLengthAction<(string | number | boolean)[], 1, undefined>]>], undefined>, undefined>, undefined>, undefined>;
|
|
200
|
+
}, undefined>, v.CheckAction<{
|
|
201
|
+
Sid?: string | undefined;
|
|
202
|
+
Effect: "Allow" | "Deny";
|
|
203
|
+
Action?: string | string[] | undefined;
|
|
204
|
+
NotAction?: string | string[] | undefined;
|
|
205
|
+
Resource?: string | string[] | undefined;
|
|
206
|
+
NotResource?: string | string[] | undefined;
|
|
207
|
+
Principal?: "*" | {
|
|
208
|
+
[x: string]: string | string[];
|
|
209
|
+
} | undefined;
|
|
210
|
+
NotPrincipal?: "*" | {
|
|
211
|
+
[x: string]: string | string[];
|
|
212
|
+
} | undefined;
|
|
213
|
+
Condition?: {
|
|
214
|
+
[x: string]: {
|
|
215
|
+
[x: string]: string | number | boolean | (string | number | boolean)[];
|
|
216
|
+
};
|
|
217
|
+
} | undefined;
|
|
218
|
+
}, "Statement must have exactly one of Action or NotAction.">, v.CheckAction<{
|
|
219
|
+
Sid?: string | undefined;
|
|
220
|
+
Effect: "Allow" | "Deny";
|
|
221
|
+
Action?: string | string[] | undefined;
|
|
222
|
+
NotAction?: string | string[] | undefined;
|
|
223
|
+
Resource?: string | string[] | undefined;
|
|
224
|
+
NotResource?: string | string[] | undefined;
|
|
225
|
+
Principal?: "*" | {
|
|
226
|
+
[x: string]: string | string[];
|
|
227
|
+
} | undefined;
|
|
228
|
+
NotPrincipal?: "*" | {
|
|
229
|
+
[x: string]: string | string[];
|
|
230
|
+
} | undefined;
|
|
231
|
+
Condition?: {
|
|
232
|
+
[x: string]: {
|
|
233
|
+
[x: string]: string | number | boolean | (string | number | boolean)[];
|
|
234
|
+
};
|
|
235
|
+
} | undefined;
|
|
236
|
+
}, "Statement cannot have both Resource and NotResource.">]>, undefined>, v.MinLengthAction<{
|
|
237
|
+
Sid?: string | undefined;
|
|
238
|
+
Effect: "Allow" | "Deny";
|
|
239
|
+
Action?: string | string[] | undefined;
|
|
240
|
+
NotAction?: string | string[] | undefined;
|
|
241
|
+
Resource?: string | string[] | undefined;
|
|
242
|
+
NotResource?: string | string[] | undefined;
|
|
243
|
+
Principal?: "*" | {
|
|
244
|
+
[x: string]: string | string[];
|
|
245
|
+
} | undefined;
|
|
246
|
+
NotPrincipal?: "*" | {
|
|
247
|
+
[x: string]: string | string[];
|
|
248
|
+
} | undefined;
|
|
249
|
+
Condition?: {
|
|
250
|
+
[x: string]: {
|
|
251
|
+
[x: string]: string | number | boolean | (string | number | boolean)[];
|
|
252
|
+
};
|
|
253
|
+
} | undefined;
|
|
254
|
+
}[], 1, undefined>]>], undefined>;
|
|
255
|
+
}, undefined>;
|
|
256
|
+
export type IamPolicyStatementStrict = v.InferOutput<typeof iamPolicyStatementStrictSchema>;
|
|
257
|
+
export type IamPolicyDocumentStrict = v.InferOutput<typeof iamPolicyDocumentStrictSchema>;
|
|
258
|
+
/**
|
|
259
|
+
* Type guard: checks if a value is a valid IAM policy document
|
|
260
|
+
* with strict grammar enforcement.
|
|
261
|
+
*/
|
|
262
|
+
export declare function isIamPolicyDocumentStrict(value: unknown): value is IamPolicyDocumentStrict;
|
|
263
|
+
/**
|
|
264
|
+
* Parses and validates a value as an IAM policy document with strict grammar rules.
|
|
265
|
+
* Throws a ValiError if validation fails.
|
|
266
|
+
*/
|
|
267
|
+
export declare function assertIamPolicyDocumentStrict(value: unknown): IamPolicyDocumentStrict;
|
|
268
|
+
export {};
|
|
269
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,QAAA,MAAM,wBAAwB,wTAG5B,CAAC;AACH,QAAA,MAAM,kBAAkB,8GAAiD,CAAC;AAC1E,QAAA,MAAM,sBAAsB,+WAG1B,CAAC;AACH,QAAA,MAAM,wBAAwB,gbAG7B,CAAC;AACF,QAAA,MAAM,qBAAqB,6eAGzB,CAAC;AACH,QAAA,MAAM,0BAA0B,+lBAG/B,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;aAUnC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAOlC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAC1C,OAAO,uBAAuB,CAC/B,CAAC,SAAS,CAAC,CAAC;AACb,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACvE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AACjF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,wBAAwB,CAChC,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC7E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,WAAW,CACjD,OAAO,0BAA0B,CAClC,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAChF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,iBAAiB,CAE5B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,kBAAkB,CAE7B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAEzE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DAqB1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAOxC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,WAAW,CAClD,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,WAAW,CACjD,OAAO,6BAA6B,CACrC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,uBAAuB,CAElC;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,GACb,uBAAuB,CAEzB"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
const nonEmptyString = v.pipe(v.string(), v.nonEmpty());
|
|
3
|
+
const nonEmptyStringListSchema = v.union([
|
|
4
|
+
nonEmptyString,
|
|
5
|
+
v.pipe(v.array(nonEmptyString), v.minLength(1)),
|
|
6
|
+
]);
|
|
7
|
+
const policyScalarSchema = v.union([v.string(), v.number(), v.boolean()]);
|
|
8
|
+
const policyScalarListSchema = v.union([
|
|
9
|
+
policyScalarSchema,
|
|
10
|
+
v.pipe(v.array(policyScalarSchema), v.minLength(1)),
|
|
11
|
+
]);
|
|
12
|
+
const policyPrincipalMapSchema = v.record(nonEmptyString, nonEmptyStringListSchema);
|
|
13
|
+
const policyPrincipalSchema = v.union([
|
|
14
|
+
v.literal("*"),
|
|
15
|
+
policyPrincipalMapSchema,
|
|
16
|
+
]);
|
|
17
|
+
const policyConditionBlockSchema = v.record(nonEmptyString, v.record(nonEmptyString, policyScalarListSchema));
|
|
18
|
+
export const iamPolicyStatementSchema = v.strictObject({
|
|
19
|
+
Sid: v.optional(nonEmptyString),
|
|
20
|
+
Effect: v.picklist(["Allow", "Deny"]),
|
|
21
|
+
Action: v.optional(nonEmptyStringListSchema),
|
|
22
|
+
NotAction: v.optional(nonEmptyStringListSchema),
|
|
23
|
+
Resource: v.optional(nonEmptyStringListSchema),
|
|
24
|
+
NotResource: v.optional(nonEmptyStringListSchema),
|
|
25
|
+
Principal: v.optional(policyPrincipalSchema),
|
|
26
|
+
NotPrincipal: v.optional(policyPrincipalSchema),
|
|
27
|
+
Condition: v.optional(policyConditionBlockSchema),
|
|
28
|
+
});
|
|
29
|
+
export const iamPolicyDocumentSchema = v.strictObject({
|
|
30
|
+
Version: v.optional(v.picklist(["2008-10-17", "2012-10-17"])),
|
|
31
|
+
Id: v.optional(nonEmptyString),
|
|
32
|
+
Statement: v.union([
|
|
33
|
+
iamPolicyStatementSchema,
|
|
34
|
+
v.pipe(v.array(iamPolicyStatementSchema), v.minLength(1)),
|
|
35
|
+
]),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Type guard: checks if a value is a valid IAM policy document.
|
|
39
|
+
*/
|
|
40
|
+
export function isIamPolicyDocument(value) {
|
|
41
|
+
return v.safeParse(iamPolicyDocumentSchema, value).success;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Type guard: checks if a value is a valid IAM policy statement.
|
|
45
|
+
*/
|
|
46
|
+
export function isIamPolicyStatement(value) {
|
|
47
|
+
return v.safeParse(iamPolicyStatementSchema, value).success;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parses and validates a value as an IAM policy document.
|
|
51
|
+
* Throws a ValiError if validation fails.
|
|
52
|
+
*/
|
|
53
|
+
export function assertIamPolicyDocument(value) {
|
|
54
|
+
return v.parse(iamPolicyDocumentSchema, value);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Strict IAM policy statement schema that enforces grammar rules:
|
|
58
|
+
* - Must have exactly one of Action or NotAction
|
|
59
|
+
* - Must have exactly one of Resource or NotResource (for identity-based policies)
|
|
60
|
+
* - Cannot have both Action and NotAction
|
|
61
|
+
* - Cannot have both Resource and NotResource
|
|
62
|
+
*/
|
|
63
|
+
export const iamPolicyStatementStrictSchema = v.pipe(iamPolicyStatementSchema, v.check((statement) => {
|
|
64
|
+
const hasAction = statement.Action != null;
|
|
65
|
+
const hasNotAction = statement.NotAction != null;
|
|
66
|
+
if (hasAction && hasNotAction)
|
|
67
|
+
return false;
|
|
68
|
+
if (!hasAction && !hasNotAction)
|
|
69
|
+
return false;
|
|
70
|
+
return true;
|
|
71
|
+
}, "Statement must have exactly one of Action or NotAction."), v.check((statement) => {
|
|
72
|
+
const hasResource = statement.Resource != null;
|
|
73
|
+
const hasNotResource = statement.NotResource != null;
|
|
74
|
+
if (hasResource && hasNotResource)
|
|
75
|
+
return false;
|
|
76
|
+
return true;
|
|
77
|
+
}, "Statement cannot have both Resource and NotResource."));
|
|
78
|
+
/**
|
|
79
|
+
* Strict IAM policy document schema that enforces grammar rules on each statement.
|
|
80
|
+
*/
|
|
81
|
+
export const iamPolicyDocumentStrictSchema = v.strictObject({
|
|
82
|
+
Version: v.optional(v.picklist(["2008-10-17", "2012-10-17"])),
|
|
83
|
+
Id: v.optional(nonEmptyString),
|
|
84
|
+
Statement: v.union([
|
|
85
|
+
iamPolicyStatementStrictSchema,
|
|
86
|
+
v.pipe(v.array(iamPolicyStatementStrictSchema), v.minLength(1)),
|
|
87
|
+
]),
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Type guard: checks if a value is a valid IAM policy document
|
|
91
|
+
* with strict grammar enforcement.
|
|
92
|
+
*/
|
|
93
|
+
export function isIamPolicyDocumentStrict(value) {
|
|
94
|
+
return v.safeParse(iamPolicyDocumentStrictSchema, value).success;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parses and validates a value as an IAM policy document with strict grammar rules.
|
|
98
|
+
* Throws a ValiError if validation fails.
|
|
99
|
+
*/
|
|
100
|
+
export function assertIamPolicyDocumentStrict(value) {
|
|
101
|
+
return v.parse(iamPolicyDocumentStrictSchema, value);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=schema.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@beesolve/iam-policy-ts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Type-safe IAM policy helpers with auto-generated action catalog from AWS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"!dist/**/*.js.map"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rm -rf dist && tsc",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"test": "rm -rf dist-test && tsc -p tsconfig.test.json --outDir dist-test && node --test dist-test/**/*.test.js",
|
|
20
|
+
"generate": "node scripts/generate-catalog.mjs",
|
|
21
|
+
"prepack": "npm run generate && npm run build"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"aws",
|
|
25
|
+
"iam",
|
|
26
|
+
"policy",
|
|
27
|
+
"typescript",
|
|
28
|
+
"autocomplete",
|
|
29
|
+
"valibot"
|
|
30
|
+
],
|
|
31
|
+
"author": "BeeSlove",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"valibot": "^1.4.0"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=24"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^25.7.0",
|
|
41
|
+
"typescript": "^6.0.3"
|
|
42
|
+
}
|
|
43
|
+
}
|