@kensio/yulin 1.20.11 → 1.20.13

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.
Files changed (150) hide show
  1. package/dist/service/acm/command/delete-certificate/delete-certificate-authorizer.js +1 -0
  2. package/dist/service/acm/command/describe-certificate/describe-certificate-authorizer.js +1 -0
  3. package/dist/service/acm/command/list-certificates/list-certificates-authorizer.js +1 -0
  4. package/dist/service/acm/command/request-certificate/request-certificate-authorizer.js +1 -0
  5. package/dist/service/apigateway/serve/auth/sim-rest-api-authorizer-policy.js +3 -0
  6. package/dist/service/apigatewayv2/serve/auth/sim-http-api-authorizer-policy.js +3 -0
  7. package/dist/service/athena/engine/sim-athena-regexp-flags.d.ts +22 -0
  8. package/dist/service/athena/engine/sim-athena-regexp-flags.js +34 -0
  9. package/dist/service/athena/engine/sim-athena-regexp-shims.js +3 -1
  10. package/dist/service/athena/engine/sim-athena-url-parts.d.ts +24 -0
  11. package/dist/service/athena/engine/sim-athena-url-parts.js +76 -0
  12. package/dist/service/athena/engine/sim-athena-url-shims.d.ts +3 -2
  13. package/dist/service/athena/engine/sim-athena-url-shims.js +57 -25
  14. package/dist/service/athena/table/sim-athena-negated-columns.d.ts +17 -0
  15. package/dist/service/athena/table/sim-athena-negated-columns.js +80 -0
  16. package/dist/service/athena/table/sim-athena-partition-filters.d.ts +7 -4
  17. package/dist/service/athena/table/sim-athena-partition-filters.js +12 -5
  18. package/dist/service/aws/factory/sim-aws-account-service-cache.d.ts +3 -0
  19. package/dist/service/aws/factory/sim-aws-account-service-cache.js +5 -0
  20. package/dist/service/aws/factory/sim-aws-service-factory.d.ts +9 -0
  21. package/dist/service/aws/factory/sim-aws-service-factory.js +10 -0
  22. package/dist/service/aws/sim-aws.d.ts +18 -0
  23. package/dist/service/aws/sim-aws.js +19 -0
  24. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn-value-adapter.d.ts +6 -0
  25. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn-value-adapter.js +23 -0
  26. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn.d.ts +66 -0
  27. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn.js +136 -0
  28. package/dist/service/cloudformation/resource/cfn/sim-cfn-service-value-adapters.js +2 -0
  29. package/dist/service/cloudformation/resource/resolve/service/sim-cfn-service-factories.js +7 -0
  30. package/dist/service/cloudfront/command/create-distribution/create-distribution-authorizer.js +1 -0
  31. package/dist/service/cloudfront/command/create-function/create-function-authorizer.js +1 -0
  32. package/dist/service/cloudfront/command/delete-distribution/delete-distribution-authorizer.js +1 -0
  33. package/dist/service/cloudfront/command/delete-function/delete-function-authorizer.js +1 -0
  34. package/dist/service/cloudfront/command/get-distribution/get-distribution-authorizer.js +1 -0
  35. package/dist/service/cloudfront/command/update-distribution/update-distribution-authorizer.js +1 -0
  36. package/dist/service/cloudfront/edge/sim-cf-edge-association-auth-z.js +1 -0
  37. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.js +1 -0
  38. package/dist/service/cloudwatch/command/authorize/sim-cloudwatch-decide.js +1 -0
  39. package/dist/service/cognito/command/authorize/sim-cognito-authorizer.js +1 -0
  40. package/dist/service/dynamodb/command/authorize/sim-dynamodb-authorizer.js +1 -0
  41. package/dist/service/firehose/command/authorize/sim-firehose-authorizer.js +1 -0
  42. package/dist/service/glue/command/authorize/sim-glue-authorize-resources.js +1 -0
  43. package/dist/service/iam/authorize/allow/sim-iam-policy-evaluation.d.ts +45 -0
  44. package/dist/service/iam/authorize/allow/sim-iam-policy-evaluation.js +59 -0
  45. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +15 -4
  46. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +15 -4
  47. package/dist/service/iam/authorize/context/sim-iam-auth-z-context.d.ts +31 -1
  48. package/dist/service/iam/authorize/context/sim-iam-auth-z-context.factory.js +1 -0
  49. package/dist/service/iam/authorize/context/sim-iam-auth-z-scp-source-builder.d.ts +46 -0
  50. package/dist/service/iam/authorize/context/sim-iam-auth-z-scp-source-builder.js +71 -0
  51. package/dist/service/iam/authorize/scp/sim-iam-scp-gate.d.ts +96 -0
  52. package/dist/service/iam/authorize/scp/sim-iam-scp-gate.js +148 -0
  53. package/dist/service/iam/authorize/scp/sim-iam-scp-resolver.d.ts +53 -0
  54. package/dist/service/iam/authorize/scp/sim-iam-scp-resolver.js +1 -0
  55. package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +8 -0
  56. package/dist/service/iam/authorize/sim-iam-account-auth-z.js +1 -0
  57. package/dist/service/iam/authorize/sim-iam-action-authorizer.js +1 -0
  58. package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +2 -0
  59. package/dist/service/iam/authorize/sim-iam-authorizer.js +1 -0
  60. package/dist/service/iam/authorize/sim-iam-decision-value.d.ts +13 -0
  61. package/dist/service/iam/authorize/sim-iam-decision-value.js +12 -0
  62. package/dist/service/iam/authorize/sim-iam-decision.d.ts +33 -16
  63. package/dist/service/iam/authorize/sim-iam-decision.js +64 -49
  64. package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.d.ts +8 -0
  65. package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.js +1 -0
  66. package/dist/service/iam/error/sim-iam.error.d.ts +8 -0
  67. package/dist/service/iam/error/sim-iam.error.js +2 -1
  68. package/dist/service/iam/sim-iam-account-parts.d.ts +9 -0
  69. package/dist/service/iam/sim-iam-account-parts.js +1 -0
  70. package/dist/service/kinesis/command/authorize/sim-kinesis-authorizer.js +1 -0
  71. package/dist/service/kms/command/authorize/sim-kms-authorizer.js +2 -0
  72. package/dist/service/lambda/command/create-function/create-function-authorizer.js +1 -0
  73. package/dist/service/lambda/command/delete-function/delete-function-authorizer.js +1 -0
  74. package/dist/service/lambda/command/event-invoke-config/event-invoke-config-authorizer.js +1 -0
  75. package/dist/service/lambda/command/function-url/function-url-authorizer.js +1 -0
  76. package/dist/service/lambda/command/get-function/get-function-authorizer.js +1 -0
  77. package/dist/service/lambda/command/invoke/invoke-authorizer.js +1 -0
  78. package/dist/service/lambda/command/list-functions/list-functions-authorizer.js +1 -0
  79. package/dist/service/lambda/command/update-function-code/update-function-code-authorizer.js +1 -0
  80. package/dist/service/lambda/command/update-function-configuration/update-function-configuration-authorizer.js +1 -0
  81. package/dist/service/lambda/command/version/version-authorizer.js +1 -0
  82. package/dist/service/logs/command/authorize/sim-logs-authorizer.js +1 -0
  83. package/dist/service/organizations/cfn/sim-cfn-organization-creator.d.ts +19 -0
  84. package/dist/service/organizations/cfn/sim-cfn-organization-creator.js +25 -0
  85. package/dist/service/organizations/cfn/sim-cfn-organizational-unit-creator.d.ts +16 -0
  86. package/dist/service/organizations/cfn/sim-cfn-organizational-unit-creator.js +21 -0
  87. package/dist/service/organizations/cfn/sim-cfn-organizations-account-creator.d.ts +20 -0
  88. package/dist/service/organizations/cfn/sim-cfn-organizations-account-creator.js +34 -0
  89. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-creator.d.ts +21 -0
  90. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-creator.js +40 -0
  91. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-input.d.ts +20 -0
  92. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-input.js +33 -0
  93. package/dist/service/organizations/cfn/sim-cfn-organizations-properties.d.ts +36 -0
  94. package/dist/service/organizations/cfn/sim-cfn-organizations-properties.js +78 -0
  95. package/dist/service/organizations/cfn/sim-cfn-organizations-record.d.ts +40 -0
  96. package/dist/service/organizations/cfn/sim-cfn-organizations-record.js +54 -0
  97. package/dist/service/organizations/cfn/sim-cfn-organizations-remover.d.ts +17 -0
  98. package/dist/service/organizations/cfn/sim-cfn-organizations-remover.js +40 -0
  99. package/dist/service/organizations/cfn/sim-organizations-cfn-resource-factory.d.ts +24 -0
  100. package/dist/service/organizations/cfn/sim-organizations-cfn-resource-factory.js +50 -0
  101. package/dist/service/organizations/index.d.ts +6 -0
  102. package/dist/service/organizations/index.js +6 -0
  103. package/dist/service/organizations/policy/sim-organizations-effective-policies.d.ts +43 -0
  104. package/dist/service/organizations/policy/sim-organizations-effective-policies.js +58 -0
  105. package/dist/service/organizations/policy/sim-organizations-scp-store.d.ts +61 -0
  106. package/dist/service/organizations/policy/sim-organizations-scp-store.js +103 -0
  107. package/dist/service/organizations/sim-organizations-structure.d.ts +94 -0
  108. package/dist/service/organizations/sim-organizations-structure.js +140 -0
  109. package/dist/service/organizations/sim-organizations.d.ts +95 -0
  110. package/dist/service/organizations/sim-organizations.js +99 -0
  111. package/dist/service/organizations/tree/sim-organizations-node.d.ts +57 -0
  112. package/dist/service/organizations/tree/sim-organizations-node.js +58 -0
  113. package/dist/service/organizations/tree/sim-organizations-tree.d.ts +91 -0
  114. package/dist/service/organizations/tree/sim-organizations-tree.js +154 -0
  115. package/dist/service/route53/command/change-resource-record-sets/change-resource-record-sets-authorizer.js +1 -0
  116. package/dist/service/route53/command/create-hosted-zone/create-hosted-zone-authorizer.js +1 -0
  117. package/dist/service/route53/command/delete-hosted-zone/delete-hosted-zone-authorizer.js +1 -0
  118. package/dist/service/route53/command/dnssec/sim-route53-dnssec-authorizer.js +1 -0
  119. package/dist/service/route53/command/get-hosted-zone/get-hosted-zone-authorizer.js +1 -0
  120. package/dist/service/route53/command/list-hosted-zones-by-name/list-hosted-zones-by-name-authorizer.js +1 -0
  121. package/dist/service/route53/command/list-resource-record-sets/list-resource-record-sets-authorizer.js +1 -0
  122. package/dist/service/s3/command/create-bucket/create-bucket.handler.js +1 -0
  123. package/dist/service/s3/command/delete-bucket/delete-bucket-authorizer.js +1 -0
  124. package/dist/service/s3/command/delete-bucket-policy/delete-bucket-policy-authorizer.js +1 -0
  125. package/dist/service/s3/command/delete-object/delete-object-authorizer.js +1 -0
  126. package/dist/service/s3/command/get-bucket-policy/get-bucket-policy-authorizer.js +1 -0
  127. package/dist/service/s3/command/get-object/get-object-authorizer.js +1 -0
  128. package/dist/service/s3/command/head-bucket/head-bucket-authorizer.js +1 -0
  129. package/dist/service/s3/command/lifecycle/sim-s3-lifecycle-authorizer.js +1 -0
  130. package/dist/service/s3/command/list-buckets/list-buckets-authorizer.js +1 -0
  131. package/dist/service/s3/command/list-objects/list-objects-authorizer.js +1 -0
  132. package/dist/service/s3/command/multipart/sim-s3-multipart-authorizer.js +1 -0
  133. package/dist/service/s3/command/notification/sim-s3-notification-authorizer.js +1 -0
  134. package/dist/service/s3/command/public-access-block/sim-s3-public-access-block-authorizer.js +1 -0
  135. package/dist/service/s3/command/put-bucket-policy/put-bucket-policy-authorizer.js +1 -0
  136. package/dist/service/s3/command/put-bucket-website/put-bucket-website-authorizer.js +1 -0
  137. package/dist/service/s3/command/put-object/put-object-authorizer.js +1 -0
  138. package/dist/service/secretsmanager/command/authorize/sim-secrets-manager-authorizer.js +1 -0
  139. package/dist/service/ses/command/authorize/sim-ses-authorizer.js +1 -0
  140. package/dist/service/sqs/command/authorize/sim-sqs-authorizer.js +1 -0
  141. package/dist/service/ssm/command/authorize/sim-ssm-authorizer.js +1 -0
  142. package/dist/service/wafv2/command/authorize/sim-wafv2-authorizer.js +1 -0
  143. package/dist/service/wafv2/command/ip-set/sim-wafv2-ip-set-commands.js +4 -3
  144. package/dist/service/wafv2/command/regex-pattern-set/sim-wafv2-regex-pattern-set-commands.js +4 -3
  145. package/dist/service/wafv2/command/sim-wafv2-input.d.ts +15 -0
  146. package/dist/service/wafv2/command/sim-wafv2-input.js +66 -1
  147. package/dist/service/wafv2/command/web-acl/sim-wafv2-web-acl-commands.js +7 -5
  148. package/dist/service/wafv2/error/sim-wafv2.error.d.ts +11 -0
  149. package/dist/service/wafv2/error/sim-wafv2.error.js +13 -0
  150. package/package.json +5 -1
@@ -0,0 +1,33 @@
1
+ import { SimCfnOrganizationsProperties } from "./sim-cfn-organizations-properties.js";
2
+ const SERVICE_CONTROL_POLICY = "SERVICE_CONTROL_POLICY";
3
+ /**
4
+ * What an `AWS::Organizations::Policy` Resource asks for.
5
+ *
6
+ * Every property is read here before the creator changes anything, so a
7
+ * Resource that cannot be satisfied fails with the organization untouched.
8
+ */
9
+ export class SimCfnOrganizationsPolicyInput {
10
+ name;
11
+ document;
12
+ targetIds;
13
+ constructor(resource, properties) {
14
+ const values = new SimCfnOrganizationsProperties(resource, "AWS::Organizations::Policy");
15
+ const policyType = values.requiredString(properties["Type"], "Type");
16
+ if (policyType !== SERVICE_CONTROL_POLICY) {
17
+ throw new Error(`Unsupported sim Organizations CloudFormation Resource Policy of ` +
18
+ `type ${policyType}`);
19
+ }
20
+ values.ignore(properties["Tags"], "Tags", "Simulated Organizations reads no policy tags");
21
+ values.ignore(properties["Description"], "Description", "A policy description decides nothing");
22
+ this.name = values.requiredString(properties["Name"], "Name");
23
+ this.document = values.documentValue(properties["Content"], "Content");
24
+ this.targetIds = values.stringList(properties["TargetIds"]);
25
+ }
26
+ /**
27
+ * The policy type this Resource carries, which is the only one simulated
28
+ * Organizations evaluates.
29
+ */
30
+ get policyType() {
31
+ return SERVICE_CONTROL_POLICY;
32
+ }
33
+ }
@@ -0,0 +1,36 @@
1
+ import type { SimCfnResource } from "../../cloudformation/resource/sim-cfn-resource.js";
2
+ import type { SimCfnTemplateValue } from "../../cloudformation/template/value/sim-cfn-template-value.js";
3
+ /**
4
+ * Reading the properties of an `AWS::Organizations::*` Resource.
5
+ *
6
+ * Each property is passed in by the caller under its own literal name, the way
7
+ * the other services read a template. A required one that is absent or of the
8
+ * wrong shape fails the Resource rather than quietly creating something else.
9
+ */
10
+ export declare class SimCfnOrganizationsProperties {
11
+ #private;
12
+ constructor(resource: SimCfnResource, resourceType: string);
13
+ /**
14
+ * A property that has to be a string for the Resource to mean anything.
15
+ */
16
+ requiredString(value: SimCfnTemplateValue | undefined, name: string): string;
17
+ /**
18
+ * A property that is a string where a template gives one.
19
+ */
20
+ optionalString(value: SimCfnTemplateValue | undefined): string | undefined;
21
+ /**
22
+ * A list-valued property, read as the strings in it.
23
+ *
24
+ * A template may give one value where a list is allowed, which
25
+ * CloudFormation accepts, so a bare string reads as a list of one.
26
+ */
27
+ stringList(value: SimCfnTemplateValue | undefined): readonly string[];
28
+ /**
29
+ * A property holding an IAM policy document, given inline or as JSON text.
30
+ */
31
+ documentValue(value: SimCfnTemplateValue | undefined, name: string): Readonly<Record<string, unknown>>;
32
+ /**
33
+ * Record a property the simulation creates the Resource without acting on.
34
+ */
35
+ ignore(value: SimCfnTemplateValue | undefined, name: string, reason: string): void;
36
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Reading the properties of an `AWS::Organizations::*` Resource.
3
+ *
4
+ * Each property is passed in by the caller under its own literal name, the way
5
+ * the other services read a template. A required one that is absent or of the
6
+ * wrong shape fails the Resource rather than quietly creating something else.
7
+ */
8
+ export class SimCfnOrganizationsProperties {
9
+ #resource;
10
+ #resourceType;
11
+ constructor(resource, resourceType) {
12
+ this.#resource = resource;
13
+ this.#resourceType = resourceType;
14
+ }
15
+ /**
16
+ * A property that has to be a string for the Resource to mean anything.
17
+ */
18
+ requiredString(value, name) {
19
+ if (typeof value !== "string" || value.length === 0) {
20
+ throw new Error(`${this.#resourceType} ${this.#resource.logicalId} requires ${name}`);
21
+ }
22
+ return value;
23
+ }
24
+ /**
25
+ * A property that is a string where a template gives one.
26
+ */
27
+ optionalString(value) {
28
+ return typeof value === "string" ? value : undefined;
29
+ }
30
+ /**
31
+ * A list-valued property, read as the strings in it.
32
+ *
33
+ * A template may give one value where a list is allowed, which
34
+ * CloudFormation accepts, so a bare string reads as a list of one.
35
+ */
36
+ stringList(value) {
37
+ if (typeof value === "string") {
38
+ return [value];
39
+ }
40
+ if (!Array.isArray(value)) {
41
+ return [];
42
+ }
43
+ return value.filter((item) => typeof item === "string");
44
+ }
45
+ /**
46
+ * A property holding an IAM policy document, given inline or as JSON text.
47
+ */
48
+ documentValue(value, name) {
49
+ const document = typeof value === "string" ? this.#parse(value, name) : value;
50
+ if (typeof document !== "object" ||
51
+ document === null ||
52
+ Array.isArray(document)) {
53
+ throw new Error(`${this.#resourceType} ${this.#resource.logicalId} requires ${name} ` +
54
+ `to be a policy document`);
55
+ }
56
+ return document;
57
+ }
58
+ /**
59
+ * Record a property the simulation creates the Resource without acting on.
60
+ */
61
+ ignore(value, name, reason) {
62
+ if (value !== undefined) {
63
+ this.#resource.ignoreProperty(name, reason);
64
+ }
65
+ }
66
+ /**
67
+ * Read a document a template gave as JSON text.
68
+ */
69
+ #parse(value, name) {
70
+ try {
71
+ return JSON.parse(value);
72
+ }
73
+ catch {
74
+ throw new Error(`${this.#resourceType} ${this.#resource.logicalId} ${name} is not ` +
75
+ `valid JSON`);
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,40 @@
1
+ import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
2
+ import type { SimOrganizationsNodeId, SimOrganizationsRootId } from "../tree/sim-organizations-node.js";
3
+ /**
4
+ * What a template's `AWS::Organizations::Organization` produced.
5
+ *
6
+ * A simulated organization exists as soon as a SimAws does, so this records
7
+ * the one already there rather than making another. What the Resource is for
8
+ * is the values a template reads back off it, `RootId` above all, since that
9
+ * is how an organizational unit says where it hangs.
10
+ */
11
+ export declare class SimCfnOrganization {
12
+ readonly rootId: SimOrganizationsRootId;
13
+ readonly featureSet: string;
14
+ readonly managementAccountId: SimAwsAccountId;
15
+ constructor(rootId: SimOrganizationsRootId, featureSet: string, managementAccountId: SimAwsAccountId);
16
+ /**
17
+ * AWS gives an organization an `o-` id of its own, apart from its root's.
18
+ */
19
+ get id(): string;
20
+ }
21
+ /**
22
+ * What a template's `AWS::Organizations::Account` produced.
23
+ */
24
+ export declare class SimCfnOrganizationsAccount {
25
+ readonly accountId: SimAwsAccountId;
26
+ readonly accountName: string;
27
+ readonly email: string;
28
+ readonly joinedTimestamp: Date;
29
+ constructor(accountId: SimAwsAccountId, accountName: string, email: string, joinedTimestamp: Date);
30
+ }
31
+ /**
32
+ * What a template's `AWS::Organizations::Policy` produced.
33
+ */
34
+ export declare class SimCfnOrganizationsPolicy {
35
+ readonly id: string;
36
+ readonly name: string;
37
+ readonly policyType: string;
38
+ readonly targetIds: readonly SimOrganizationsNodeId[];
39
+ constructor(id: string, name: string, policyType: string, targetIds: readonly SimOrganizationsNodeId[]);
40
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * What a template's `AWS::Organizations::Organization` produced.
3
+ *
4
+ * A simulated organization exists as soon as a SimAws does, so this records
5
+ * the one already there rather than making another. What the Resource is for
6
+ * is the values a template reads back off it, `RootId` above all, since that
7
+ * is how an organizational unit says where it hangs.
8
+ */
9
+ export class SimCfnOrganization {
10
+ rootId;
11
+ featureSet;
12
+ managementAccountId;
13
+ constructor(rootId, featureSet, managementAccountId) {
14
+ this.rootId = rootId;
15
+ this.featureSet = featureSet;
16
+ this.managementAccountId = managementAccountId;
17
+ }
18
+ /**
19
+ * AWS gives an organization an `o-` id of its own, apart from its root's.
20
+ */
21
+ get id() {
22
+ return `o-${this.rootId.slice(2)}`;
23
+ }
24
+ }
25
+ /**
26
+ * What a template's `AWS::Organizations::Account` produced.
27
+ */
28
+ export class SimCfnOrganizationsAccount {
29
+ accountId;
30
+ accountName;
31
+ email;
32
+ joinedTimestamp;
33
+ constructor(accountId, accountName, email, joinedTimestamp) {
34
+ this.accountId = accountId;
35
+ this.accountName = accountName;
36
+ this.email = email;
37
+ this.joinedTimestamp = joinedTimestamp;
38
+ }
39
+ }
40
+ /**
41
+ * What a template's `AWS::Organizations::Policy` produced.
42
+ */
43
+ export class SimCfnOrganizationsPolicy {
44
+ id;
45
+ name;
46
+ policyType;
47
+ targetIds;
48
+ constructor(id, name, policyType, targetIds) {
49
+ this.id = id;
50
+ this.name = name;
51
+ this.policyType = policyType;
52
+ this.targetIds = targetIds;
53
+ }
54
+ }
@@ -0,0 +1,17 @@
1
+ import type { SimAws } from "../../aws/sim-aws.js";
2
+ import type { SimCfnResource } from "../../cloudformation/resource/sim-cfn-resource.js";
3
+ /**
4
+ * Takes back what an `AWS::Organizations::*` Resource did.
5
+ *
6
+ * A Stack tears down in reverse dependency order, so a policy comes off before
7
+ * the unit it was attached to goes, and a unit goes before the root it hung
8
+ * on. Each Resource here undoes its own step and nothing else.
9
+ */
10
+ export declare class SimCfnOrganizationsRemover {
11
+ #private;
12
+ constructor(simAws: SimAws);
13
+ /**
14
+ * Undo one Resource.
15
+ */
16
+ remove(resourceTypeName: string, resource: SimCfnResource): void;
17
+ }
@@ -0,0 +1,40 @@
1
+ import { SimCfnOrganizationsAccount, SimCfnOrganizationsPolicy, } from "./sim-cfn-organizations-record.js";
2
+ import { SimOrganizationsOrganizationalUnit } from "../tree/sim-organizations-node.js";
3
+ /**
4
+ * Takes back what an `AWS::Organizations::*` Resource did.
5
+ *
6
+ * A Stack tears down in reverse dependency order, so a policy comes off before
7
+ * the unit it was attached to goes, and a unit goes before the root it hung
8
+ * on. Each Resource here undoes its own step and nothing else.
9
+ */
10
+ export class SimCfnOrganizationsRemover {
11
+ #simAws;
12
+ constructor(simAws) {
13
+ this.#simAws = simAws;
14
+ }
15
+ /**
16
+ * Undo one Resource.
17
+ */
18
+ remove(resourceTypeName, resource) {
19
+ const simResource = resource.simResource;
20
+ const organizations = this.#simAws.organizations();
21
+ if (simResource instanceof SimCfnOrganizationsPolicy) {
22
+ for (const targetId of simResource.targetIds) {
23
+ organizations.detachServiceControlPolicy(targetId, simResource.id);
24
+ }
25
+ return;
26
+ }
27
+ if (simResource instanceof SimCfnOrganizationsAccount) {
28
+ organizations.removeAccount(simResource.accountId);
29
+ return;
30
+ }
31
+ if (simResource instanceof SimOrganizationsOrganizationalUnit) {
32
+ organizations.removeOrganizationalUnit(simResource);
33
+ return;
34
+ }
35
+ if (resourceTypeName !== "Organization") {
36
+ throw new Error(`Unsupported sim Organizations CloudFormation Resource ` +
37
+ `${resourceTypeName} deletion`);
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,24 @@
1
+ import type { SimCfnServiceResourceFactory } from "../../cloudformation/resource/factory/sim-cfn-resource-factory.type.js";
2
+ import type { SimCfnResource, SimCloudFormationResourceCreateContext, SimCloudFormationResourceDeleteContext } from "../../cloudformation/resource/sim-cfn-resource.js";
3
+ /**
4
+ * CloudFormation Resource factory for simulated Organizations resources.
5
+ *
6
+ * An organization belongs to a whole SimAws rather than to the Account and
7
+ * Region scope a Stack deploys into, so this reads the organization off the
8
+ * creation context instead of being handed one. That leaves the factory with
9
+ * no state and lets one serve every scope.
10
+ *
11
+ * `AWS::Organizations::ResourcePolicy` is left out, along with every policy
12
+ * type but `SERVICE_CONTROL_POLICY`, and a template declaring either is
13
+ * recorded as a skipped Resource.
14
+ */
15
+ export declare class SimOrganizationsCfnResourceFactory implements SimCfnServiceResourceFactory {
16
+ /**
17
+ * Create a simulated Organizations resource from a CloudFormation Resource.
18
+ */
19
+ create(resourceTypeName: string, resource: SimCfnResource, context: SimCloudFormationResourceCreateContext): Promise<object | undefined>;
20
+ /**
21
+ * Remove a simulated Organizations resource a Stack created.
22
+ */
23
+ delete(resourceTypeName: string, resource: SimCfnResource, context: SimCloudFormationResourceDeleteContext): Promise<void>;
24
+ }
@@ -0,0 +1,50 @@
1
+ import { SimCfnOrganizationCreator } from "./sim-cfn-organization-creator.js";
2
+ import { SimCfnOrganizationalUnitCreator } from "./sim-cfn-organizational-unit-creator.js";
3
+ import { SimCfnOrganizationsAccountCreator } from "./sim-cfn-organizations-account-creator.js";
4
+ import { SimCfnOrganizationsPolicyCreator } from "./sim-cfn-organizations-policy-creator.js";
5
+ import { SimCfnOrganizationsRemover } from "./sim-cfn-organizations-remover.js";
6
+ /**
7
+ * CloudFormation Resource factory for simulated Organizations resources.
8
+ *
9
+ * An organization belongs to a whole SimAws rather than to the Account and
10
+ * Region scope a Stack deploys into, so this reads the organization off the
11
+ * creation context instead of being handed one. That leaves the factory with
12
+ * no state and lets one serve every scope.
13
+ *
14
+ * `AWS::Organizations::ResourcePolicy` is left out, along with every policy
15
+ * type but `SERVICE_CONTROL_POLICY`, and a template declaring either is
16
+ * recorded as a skipped Resource.
17
+ */
18
+ export class SimOrganizationsCfnResourceFactory {
19
+ /**
20
+ * Create a simulated Organizations resource from a CloudFormation Resource.
21
+ */
22
+ create(resourceTypeName, resource, context) {
23
+ const properties = context.resolvedProperties ?? resource.properties;
24
+ const { simAws } = context;
25
+ switch (resourceTypeName) {
26
+ case "Organization": {
27
+ return Promise.resolve(new SimCfnOrganizationCreator(simAws).create(resource, properties));
28
+ }
29
+ case "OrganizationalUnit": {
30
+ return Promise.resolve(new SimCfnOrganizationalUnitCreator(simAws).create(resource, properties));
31
+ }
32
+ case "Account": {
33
+ return Promise.resolve(new SimCfnOrganizationsAccountCreator(simAws).create(resource, properties));
34
+ }
35
+ case "Policy": {
36
+ return Promise.resolve(new SimCfnOrganizationsPolicyCreator(simAws).create(resource, properties));
37
+ }
38
+ default: {
39
+ throw new Error(`Unsupported sim Organizations CloudFormation Resource ${resourceTypeName}`);
40
+ }
41
+ }
42
+ }
43
+ /**
44
+ * Remove a simulated Organizations resource a Stack created.
45
+ */
46
+ delete(resourceTypeName, resource, context) {
47
+ new SimCfnOrganizationsRemover(context.simAws).remove(resourceTypeName, resource);
48
+ return Promise.resolve();
49
+ }
50
+ }
@@ -0,0 +1,6 @@
1
+ export { SimOrganizations, type SimOrganizationsAttachOptions, } from "./sim-organizations.js";
2
+ export { SimOrganizationsStructure } from "./sim-organizations-structure.js";
3
+ export { SIM_ORGANIZATIONS_FULL_AWS_ACCESS, SimOrganizationsScpStore, } from "./policy/sim-organizations-scp-store.js";
4
+ export { SimOrganizationsEffectivePolicies } from "./policy/sim-organizations-effective-policies.js";
5
+ export { makeSimOrganizationsOrganizationalUnitId, makeSimOrganizationsRootId, SimOrganizationsOrganizationalUnit, type SimOrganizationsNodeId, type SimOrganizationsOrganizationalUnitId, SimOrganizationsRoot, type SimOrganizationsRootId, type SimOrganizationsTarget, } from "./tree/sim-organizations-node.js";
6
+ export { SimOrganizationsTree, SimOrganizationsUnknownNode, } from "./tree/sim-organizations-tree.js";
@@ -0,0 +1,6 @@
1
+ export { SimOrganizations, } from "./sim-organizations.js";
2
+ export { SimOrganizationsStructure } from "./sim-organizations-structure.js";
3
+ export { SIM_ORGANIZATIONS_FULL_AWS_ACCESS, SimOrganizationsScpStore, } from "./policy/sim-organizations-scp-store.js";
4
+ export { SimOrganizationsEffectivePolicies } from "./policy/sim-organizations-effective-policies.js";
5
+ export { makeSimOrganizationsOrganizationalUnitId, makeSimOrganizationsRootId, SimOrganizationsOrganizationalUnit, SimOrganizationsRoot, } from "./tree/sim-organizations-node.js";
6
+ export { SimOrganizationsTree, SimOrganizationsUnknownNode, } from "./tree/sim-organizations-tree.js";
@@ -0,0 +1,43 @@
1
+ import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
2
+ import type { SimIamServiceControlPolicySet } from "../../iam/authorize/scp/sim-iam-scp-resolver.js";
3
+ import type { SimOrganizationsTree } from "../tree/sim-organizations-tree.js";
4
+ import type { SimOrganizationsScpStore } from "./sim-organizations-scp-store.js";
5
+ interface SimOrganizationsEffectivePoliciesProperties {
6
+ readonly tree: SimOrganizationsTree;
7
+ readonly scpStore: SimOrganizationsScpStore;
8
+ }
9
+ /**
10
+ * Works out which service control policies an Account is actually subject to.
11
+ *
12
+ * The tree says which nodes lie above an Account and the store says what hangs
13
+ * on each of them. Putting the two together is the whole of what sim IAM asks
14
+ * an organization, so it lives here rather than in the facade.
15
+ */
16
+ export declare class SimOrganizationsEffectivePolicies {
17
+ private readonly tree;
18
+ private readonly scpStore;
19
+ private managementAccountId?;
20
+ constructor(properties: SimOrganizationsEffectivePoliciesProperties);
21
+ /**
22
+ * Name the Account AWS exempts from every service control policy.
23
+ */
24
+ setManagementAccount(accountId: SimAwsAccountId): void;
25
+ /**
26
+ * The policies in force for an Account, level by level, root first.
27
+ */
28
+ setFor(accountId: SimAwsAccountId): SimIamServiceControlPolicySet;
29
+ /**
30
+ * The nodes filtering an Account's requests.
31
+ *
32
+ * An Account placed in the organization is filtered by the path down to it.
33
+ * An Account only ever named by having a policy attached to it is filtered
34
+ * by that policy alone, which is what attaching to an Account meant before
35
+ * the organization had a shape.
36
+ */
37
+ private pathFor;
38
+ /**
39
+ * What one node contributes to an Account's decision.
40
+ */
41
+ private levelAt;
42
+ }
43
+ export {};
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Works out which service control policies an Account is actually subject to.
3
+ *
4
+ * The tree says which nodes lie above an Account and the store says what hangs
5
+ * on each of them. Putting the two together is the whole of what sim IAM asks
6
+ * an organization, so it lives here rather than in the facade.
7
+ */
8
+ export class SimOrganizationsEffectivePolicies {
9
+ tree;
10
+ scpStore;
11
+ managementAccountId;
12
+ constructor(properties) {
13
+ this.tree = properties.tree;
14
+ this.scpStore = properties.scpStore;
15
+ }
16
+ /**
17
+ * Name the Account AWS exempts from every service control policy.
18
+ */
19
+ setManagementAccount(accountId) {
20
+ this.managementAccountId = accountId;
21
+ }
22
+ /**
23
+ * The policies in force for an Account, level by level, root first.
24
+ */
25
+ setFor(accountId) {
26
+ if (accountId === this.managementAccountId) {
27
+ return { applies: false, levels: [] };
28
+ }
29
+ const path = this.pathFor(accountId);
30
+ if (path.length === 0) {
31
+ return { applies: false, levels: [] };
32
+ }
33
+ return { applies: true, levels: path.map((node) => this.levelAt(node)) };
34
+ }
35
+ /**
36
+ * The nodes filtering an Account's requests.
37
+ *
38
+ * An Account placed in the organization is filtered by the path down to it.
39
+ * An Account only ever named by having a policy attached to it is filtered
40
+ * by that policy alone, which is what attaching to an Account meant before
41
+ * the organization had a shape.
42
+ */
43
+ pathFor(accountId) {
44
+ if (this.tree.holds(accountId)) {
45
+ return this.tree.pathTo(accountId);
46
+ }
47
+ return this.scpStore.holds(accountId) ? [accountId] : [];
48
+ }
49
+ /**
50
+ * What one node contributes to an Account's decision.
51
+ */
52
+ levelAt(nodeId) {
53
+ return {
54
+ nodeName: this.tree.nameOf(nodeId),
55
+ policies: this.scpStore.policiesAt(nodeId),
56
+ };
57
+ }
58
+ }
@@ -0,0 +1,61 @@
1
+ import type { SimIamServiceControlPolicy } from "../../iam/authorize/scp/sim-iam-scp-resolver.js";
2
+ import type { SimIamPolicyDocument } from "../../iam/policy/sim-iam-policy.js";
3
+ import type { SimOrganizationsNodeId } from "../tree/sim-organizations-node.js";
4
+ /**
5
+ * The AWS-managed policy attached to every organization node by default.
6
+ *
7
+ * Turning service control policies on in an organization leaves every
8
+ * account's permissions as they were, because this policy comes with them. A
9
+ * simulated node gets the same treatment, so attaching one Deny statement
10
+ * denies that one action and leaves the rest working.
11
+ */
12
+ export declare const SIM_ORGANIZATIONS_FULL_AWS_ACCESS: SimIamServiceControlPolicy;
13
+ /**
14
+ * The service control policies attached to each node of an organization.
15
+ *
16
+ * A node holds FullAWSAccess along with whatever was attached to it, until a
17
+ * test detaches FullAWSAccess to write an allow list at that node. A node
18
+ * nothing was attached to still holds FullAWSAccess, so an organizational unit
19
+ * a test never mentions allows everything through it.
20
+ */
21
+ export declare class SimOrganizationsScpStore {
22
+ private readonly byNodeId;
23
+ /**
24
+ * Attach a service control policy to a node under an id of its own.
25
+ *
26
+ * The id is what takes the policy off again. One policy attached to several
27
+ * nodes carries the same id at each of them, the way an AWS policy attached
28
+ * to several targets is one policy.
29
+ */
30
+ attach(nodeId: SimOrganizationsNodeId, policyId: string, document: SimIamPolicyDocument, policyName?: string): void;
31
+ /**
32
+ * Take one service control policy off a node, leaving the rest.
33
+ *
34
+ * A node can hold policies from more than one source, so taking the wrong
35
+ * ones off would change what an Account may do behind the caller's back.
36
+ */
37
+ detach(nodeId: SimOrganizationsNodeId, policyId: string): void;
38
+ /**
39
+ * Take the AWS-managed FullAWSAccess policy off a node.
40
+ *
41
+ * What remains at that node has to allow an action for a request through it
42
+ * to go ahead, which is how a level is turned into an allow list.
43
+ */
44
+ detachFullAwsAccess(nodeId: SimOrganizationsNodeId): void;
45
+ /**
46
+ * Put a node back to holding FullAWSAccess and nothing else.
47
+ */
48
+ detachAll(nodeId: SimOrganizationsNodeId): void;
49
+ /**
50
+ * The policies in force at one node, FullAWSAccess first.
51
+ */
52
+ policiesAt(nodeId: SimOrganizationsNodeId): readonly SimIamServiceControlPolicy[];
53
+ /**
54
+ * Whether anything has been attached to or detached from a node.
55
+ */
56
+ holds(nodeId: SimOrganizationsNodeId): boolean;
57
+ /**
58
+ * The record for a node, created on first use.
59
+ */
60
+ private nodePolicies;
61
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The AWS-managed policy attached to every organization node by default.
3
+ *
4
+ * Turning service control policies on in an organization leaves every
5
+ * account's permissions as they were, because this policy comes with them. A
6
+ * simulated node gets the same treatment, so attaching one Deny statement
7
+ * denies that one action and leaves the rest working.
8
+ */
9
+ export const SIM_ORGANIZATIONS_FULL_AWS_ACCESS = {
10
+ policyName: "FullAWSAccess",
11
+ document: {
12
+ Version: "2012-10-17",
13
+ Statement: { Effect: "Allow", Action: "*", Resource: "*" },
14
+ },
15
+ };
16
+ /**
17
+ * The service control policies attached to each node of an organization.
18
+ *
19
+ * A node holds FullAWSAccess along with whatever was attached to it, until a
20
+ * test detaches FullAWSAccess to write an allow list at that node. A node
21
+ * nothing was attached to still holds FullAWSAccess, so an organizational unit
22
+ * a test never mentions allows everything through it.
23
+ */
24
+ export class SimOrganizationsScpStore {
25
+ byNodeId = new Map();
26
+ /**
27
+ * Attach a service control policy to a node under an id of its own.
28
+ *
29
+ * The id is what takes the policy off again. One policy attached to several
30
+ * nodes carries the same id at each of them, the way an AWS policy attached
31
+ * to several targets is one policy.
32
+ */
33
+ attach(nodeId, policyId, document, policyName) {
34
+ this.nodePolicies(nodeId).attached.push({
35
+ policyId,
36
+ policy: { document, policyName },
37
+ });
38
+ }
39
+ /**
40
+ * Take one service control policy off a node, leaving the rest.
41
+ *
42
+ * A node can hold policies from more than one source, so taking the wrong
43
+ * ones off would change what an Account may do behind the caller's back.
44
+ */
45
+ detach(nodeId, policyId) {
46
+ const node = this.byNodeId.get(nodeId);
47
+ if (node === undefined) {
48
+ return;
49
+ }
50
+ const remaining = node.attached.filter((attached) => attached.policyId !== policyId);
51
+ node.attached.length = 0;
52
+ node.attached.push(...remaining);
53
+ }
54
+ /**
55
+ * Take the AWS-managed FullAWSAccess policy off a node.
56
+ *
57
+ * What remains at that node has to allow an action for a request through it
58
+ * to go ahead, which is how a level is turned into an allow list.
59
+ */
60
+ detachFullAwsAccess(nodeId) {
61
+ this.nodePolicies(nodeId).fullAwsAccess = false;
62
+ }
63
+ /**
64
+ * Put a node back to holding FullAWSAccess and nothing else.
65
+ */
66
+ detachAll(nodeId) {
67
+ this.byNodeId.delete(nodeId);
68
+ }
69
+ /**
70
+ * The policies in force at one node, FullAWSAccess first.
71
+ */
72
+ policiesAt(nodeId) {
73
+ const node = this.byNodeId.get(nodeId);
74
+ if (node === undefined) {
75
+ return [SIM_ORGANIZATIONS_FULL_AWS_ACCESS];
76
+ }
77
+ const attached = node.attached.map((entry) => entry.policy);
78
+ return node.fullAwsAccess
79
+ ? [SIM_ORGANIZATIONS_FULL_AWS_ACCESS, ...attached]
80
+ : attached;
81
+ }
82
+ /**
83
+ * Whether anything has been attached to or detached from a node.
84
+ */
85
+ holds(nodeId) {
86
+ return this.byNodeId.has(nodeId);
87
+ }
88
+ /**
89
+ * The record for a node, created on first use.
90
+ */
91
+ nodePolicies(nodeId) {
92
+ const existing = this.byNodeId.get(nodeId);
93
+ if (existing !== undefined) {
94
+ return existing;
95
+ }
96
+ const created = {
97
+ attached: [],
98
+ fullAwsAccess: true,
99
+ };
100
+ this.byNodeId.set(nodeId, created);
101
+ return created;
102
+ }
103
+ }