@kensio/yulin 1.20.12 → 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 (132) 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/aws/factory/sim-aws-account-service-cache.d.ts +3 -0
  8. package/dist/service/aws/factory/sim-aws-account-service-cache.js +5 -0
  9. package/dist/service/aws/factory/sim-aws-service-factory.d.ts +9 -0
  10. package/dist/service/aws/factory/sim-aws-service-factory.js +10 -0
  11. package/dist/service/aws/sim-aws.d.ts +18 -0
  12. package/dist/service/aws/sim-aws.js +19 -0
  13. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn-value-adapter.d.ts +6 -0
  14. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn-value-adapter.js +23 -0
  15. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn.d.ts +66 -0
  16. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn.js +136 -0
  17. package/dist/service/cloudformation/resource/cfn/sim-cfn-service-value-adapters.js +2 -0
  18. package/dist/service/cloudformation/resource/resolve/service/sim-cfn-service-factories.js +7 -0
  19. package/dist/service/cloudfront/command/create-distribution/create-distribution-authorizer.js +1 -0
  20. package/dist/service/cloudfront/command/create-function/create-function-authorizer.js +1 -0
  21. package/dist/service/cloudfront/command/delete-distribution/delete-distribution-authorizer.js +1 -0
  22. package/dist/service/cloudfront/command/delete-function/delete-function-authorizer.js +1 -0
  23. package/dist/service/cloudfront/command/get-distribution/get-distribution-authorizer.js +1 -0
  24. package/dist/service/cloudfront/command/update-distribution/update-distribution-authorizer.js +1 -0
  25. package/dist/service/cloudfront/edge/sim-cf-edge-association-auth-z.js +1 -0
  26. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.js +1 -0
  27. package/dist/service/cloudwatch/command/authorize/sim-cloudwatch-decide.js +1 -0
  28. package/dist/service/cognito/command/authorize/sim-cognito-authorizer.js +1 -0
  29. package/dist/service/dynamodb/command/authorize/sim-dynamodb-authorizer.js +1 -0
  30. package/dist/service/firehose/command/authorize/sim-firehose-authorizer.js +1 -0
  31. package/dist/service/glue/command/authorize/sim-glue-authorize-resources.js +1 -0
  32. package/dist/service/iam/authorize/allow/sim-iam-policy-evaluation.d.ts +45 -0
  33. package/dist/service/iam/authorize/allow/sim-iam-policy-evaluation.js +59 -0
  34. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +15 -4
  35. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +15 -4
  36. package/dist/service/iam/authorize/context/sim-iam-auth-z-context.d.ts +31 -1
  37. package/dist/service/iam/authorize/context/sim-iam-auth-z-context.factory.js +1 -0
  38. package/dist/service/iam/authorize/context/sim-iam-auth-z-scp-source-builder.d.ts +46 -0
  39. package/dist/service/iam/authorize/context/sim-iam-auth-z-scp-source-builder.js +71 -0
  40. package/dist/service/iam/authorize/scp/sim-iam-scp-gate.d.ts +96 -0
  41. package/dist/service/iam/authorize/scp/sim-iam-scp-gate.js +148 -0
  42. package/dist/service/iam/authorize/scp/sim-iam-scp-resolver.d.ts +53 -0
  43. package/dist/service/iam/authorize/scp/sim-iam-scp-resolver.js +1 -0
  44. package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +8 -0
  45. package/dist/service/iam/authorize/sim-iam-account-auth-z.js +1 -0
  46. package/dist/service/iam/authorize/sim-iam-action-authorizer.js +1 -0
  47. package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +2 -0
  48. package/dist/service/iam/authorize/sim-iam-authorizer.js +1 -0
  49. package/dist/service/iam/authorize/sim-iam-decision-value.d.ts +13 -0
  50. package/dist/service/iam/authorize/sim-iam-decision-value.js +12 -0
  51. package/dist/service/iam/authorize/sim-iam-decision.d.ts +33 -16
  52. package/dist/service/iam/authorize/sim-iam-decision.js +64 -49
  53. package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.d.ts +8 -0
  54. package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.js +1 -0
  55. package/dist/service/iam/error/sim-iam.error.d.ts +8 -0
  56. package/dist/service/iam/error/sim-iam.error.js +2 -1
  57. package/dist/service/iam/sim-iam-account-parts.d.ts +9 -0
  58. package/dist/service/iam/sim-iam-account-parts.js +1 -0
  59. package/dist/service/kinesis/command/authorize/sim-kinesis-authorizer.js +1 -0
  60. package/dist/service/kms/command/authorize/sim-kms-authorizer.js +2 -0
  61. package/dist/service/lambda/command/create-function/create-function-authorizer.js +1 -0
  62. package/dist/service/lambda/command/delete-function/delete-function-authorizer.js +1 -0
  63. package/dist/service/lambda/command/event-invoke-config/event-invoke-config-authorizer.js +1 -0
  64. package/dist/service/lambda/command/function-url/function-url-authorizer.js +1 -0
  65. package/dist/service/lambda/command/get-function/get-function-authorizer.js +1 -0
  66. package/dist/service/lambda/command/invoke/invoke-authorizer.js +1 -0
  67. package/dist/service/lambda/command/list-functions/list-functions-authorizer.js +1 -0
  68. package/dist/service/lambda/command/update-function-code/update-function-code-authorizer.js +1 -0
  69. package/dist/service/lambda/command/update-function-configuration/update-function-configuration-authorizer.js +1 -0
  70. package/dist/service/lambda/command/version/version-authorizer.js +1 -0
  71. package/dist/service/logs/command/authorize/sim-logs-authorizer.js +1 -0
  72. package/dist/service/organizations/cfn/sim-cfn-organization-creator.d.ts +19 -0
  73. package/dist/service/organizations/cfn/sim-cfn-organization-creator.js +25 -0
  74. package/dist/service/organizations/cfn/sim-cfn-organizational-unit-creator.d.ts +16 -0
  75. package/dist/service/organizations/cfn/sim-cfn-organizational-unit-creator.js +21 -0
  76. package/dist/service/organizations/cfn/sim-cfn-organizations-account-creator.d.ts +20 -0
  77. package/dist/service/organizations/cfn/sim-cfn-organizations-account-creator.js +34 -0
  78. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-creator.d.ts +21 -0
  79. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-creator.js +40 -0
  80. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-input.d.ts +20 -0
  81. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-input.js +33 -0
  82. package/dist/service/organizations/cfn/sim-cfn-organizations-properties.d.ts +36 -0
  83. package/dist/service/organizations/cfn/sim-cfn-organizations-properties.js +78 -0
  84. package/dist/service/organizations/cfn/sim-cfn-organizations-record.d.ts +40 -0
  85. package/dist/service/organizations/cfn/sim-cfn-organizations-record.js +54 -0
  86. package/dist/service/organizations/cfn/sim-cfn-organizations-remover.d.ts +17 -0
  87. package/dist/service/organizations/cfn/sim-cfn-organizations-remover.js +40 -0
  88. package/dist/service/organizations/cfn/sim-organizations-cfn-resource-factory.d.ts +24 -0
  89. package/dist/service/organizations/cfn/sim-organizations-cfn-resource-factory.js +50 -0
  90. package/dist/service/organizations/index.d.ts +6 -0
  91. package/dist/service/organizations/index.js +6 -0
  92. package/dist/service/organizations/policy/sim-organizations-effective-policies.d.ts +43 -0
  93. package/dist/service/organizations/policy/sim-organizations-effective-policies.js +58 -0
  94. package/dist/service/organizations/policy/sim-organizations-scp-store.d.ts +61 -0
  95. package/dist/service/organizations/policy/sim-organizations-scp-store.js +103 -0
  96. package/dist/service/organizations/sim-organizations-structure.d.ts +94 -0
  97. package/dist/service/organizations/sim-organizations-structure.js +140 -0
  98. package/dist/service/organizations/sim-organizations.d.ts +95 -0
  99. package/dist/service/organizations/sim-organizations.js +99 -0
  100. package/dist/service/organizations/tree/sim-organizations-node.d.ts +57 -0
  101. package/dist/service/organizations/tree/sim-organizations-node.js +58 -0
  102. package/dist/service/organizations/tree/sim-organizations-tree.d.ts +91 -0
  103. package/dist/service/organizations/tree/sim-organizations-tree.js +154 -0
  104. package/dist/service/route53/command/change-resource-record-sets/change-resource-record-sets-authorizer.js +1 -0
  105. package/dist/service/route53/command/create-hosted-zone/create-hosted-zone-authorizer.js +1 -0
  106. package/dist/service/route53/command/delete-hosted-zone/delete-hosted-zone-authorizer.js +1 -0
  107. package/dist/service/route53/command/dnssec/sim-route53-dnssec-authorizer.js +1 -0
  108. package/dist/service/route53/command/get-hosted-zone/get-hosted-zone-authorizer.js +1 -0
  109. package/dist/service/route53/command/list-hosted-zones-by-name/list-hosted-zones-by-name-authorizer.js +1 -0
  110. package/dist/service/route53/command/list-resource-record-sets/list-resource-record-sets-authorizer.js +1 -0
  111. package/dist/service/s3/command/create-bucket/create-bucket.handler.js +1 -0
  112. package/dist/service/s3/command/delete-bucket/delete-bucket-authorizer.js +1 -0
  113. package/dist/service/s3/command/delete-bucket-policy/delete-bucket-policy-authorizer.js +1 -0
  114. package/dist/service/s3/command/delete-object/delete-object-authorizer.js +1 -0
  115. package/dist/service/s3/command/get-bucket-policy/get-bucket-policy-authorizer.js +1 -0
  116. package/dist/service/s3/command/get-object/get-object-authorizer.js +1 -0
  117. package/dist/service/s3/command/head-bucket/head-bucket-authorizer.js +1 -0
  118. package/dist/service/s3/command/lifecycle/sim-s3-lifecycle-authorizer.js +1 -0
  119. package/dist/service/s3/command/list-buckets/list-buckets-authorizer.js +1 -0
  120. package/dist/service/s3/command/list-objects/list-objects-authorizer.js +1 -0
  121. package/dist/service/s3/command/multipart/sim-s3-multipart-authorizer.js +1 -0
  122. package/dist/service/s3/command/notification/sim-s3-notification-authorizer.js +1 -0
  123. package/dist/service/s3/command/public-access-block/sim-s3-public-access-block-authorizer.js +1 -0
  124. package/dist/service/s3/command/put-bucket-policy/put-bucket-policy-authorizer.js +1 -0
  125. package/dist/service/s3/command/put-bucket-website/put-bucket-website-authorizer.js +1 -0
  126. package/dist/service/s3/command/put-object/put-object-authorizer.js +1 -0
  127. package/dist/service/secretsmanager/command/authorize/sim-secrets-manager-authorizer.js +1 -0
  128. package/dist/service/ses/command/authorize/sim-ses-authorizer.js +1 -0
  129. package/dist/service/sqs/command/authorize/sim-sqs-authorizer.js +1 -0
  130. package/dist/service/ssm/command/authorize/sim-ssm-authorizer.js +1 -0
  131. package/dist/service/wafv2/command/authorize/sim-wafv2-authorizer.js +1 -0
  132. package/package.json +5 -1
@@ -0,0 +1,57 @@
1
+ import type { Brand } from "../../../util/brand.type.js";
2
+ import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
3
+ export type SimOrganizationsRootId = Brand<string, "SimOrganizationsRootId">;
4
+ export type SimOrganizationsOrganizationalUnitId = Brand<string, "SimOrganizationsOrganizationalUnitId">;
5
+ /**
6
+ * Anything a service control policy can hang on.
7
+ *
8
+ * AWS attaches a policy to the root, to an organizational unit, or to one
9
+ * account, and an account inherits every policy on the path down to it.
10
+ */
11
+ export type SimOrganizationsNodeId = SimOrganizationsRootId | SimOrganizationsOrganizationalUnitId | SimAwsAccountId;
12
+ /**
13
+ * Generate an AWS-shaped organization root id.
14
+ */
15
+ export declare function makeSimOrganizationsRootId(): SimOrganizationsRootId;
16
+ /**
17
+ * Generate an AWS-shaped organizational unit id.
18
+ */
19
+ export declare function makeSimOrganizationsOrganizationalUnitId(rootId: SimOrganizationsRootId): SimOrganizationsOrganizationalUnitId;
20
+ /**
21
+ * Generate an AWS-shaped service control policy id.
22
+ */
23
+ export declare function makeSimOrganizationsPolicyId(): string;
24
+ /**
25
+ * An organizational unit in a simulated organization.
26
+ *
27
+ * This is the handle a test holds on to. Pass it where a policy is attached or
28
+ * an Account is moved, so neither reads back as a bare string.
29
+ */
30
+ export declare class SimOrganizationsOrganizationalUnit {
31
+ readonly id: SimOrganizationsOrganizationalUnitId;
32
+ readonly name: string;
33
+ readonly parentId: SimOrganizationsNodeId;
34
+ constructor(id: SimOrganizationsOrganizationalUnitId, name: string, parentId: SimOrganizationsNodeId);
35
+ }
36
+ /**
37
+ * The root of a simulated organization.
38
+ */
39
+ export declare class SimOrganizationsRoot {
40
+ readonly id: SimOrganizationsRootId;
41
+ readonly name = "Root";
42
+ constructor(id: SimOrganizationsRootId);
43
+ }
44
+ /**
45
+ * Somewhere a policy can be attached, given as a handle or as an id.
46
+ *
47
+ * An id is what a CloudFormation template carries, since a `Ref` to a unit
48
+ * resolves to the id AWS gave it rather than to anything holding a reference.
49
+ */
50
+ export type SimOrganizationsTarget = SimOrganizationsRoot | SimOrganizationsOrganizationalUnit | string;
51
+ /**
52
+ * Whether an id names the root or an organizational unit.
53
+ *
54
+ * AWS ids carry their own kind in a prefix, and an Account id is twelve
55
+ * digits, so nothing here has to guess which of the two a string is.
56
+ */
57
+ export declare function isSimOrganizationsUnitId(value: string): boolean;
@@ -0,0 +1,58 @@
1
+ import { faker } from "@faker-js/faker";
2
+ /**
3
+ * Generate an AWS-shaped organization root id.
4
+ */
5
+ export function makeSimOrganizationsRootId() {
6
+ return `r-${faker.string.alphanumeric({
7
+ length: 4,
8
+ casing: "lower",
9
+ })}`;
10
+ }
11
+ /**
12
+ * Generate an AWS-shaped organizational unit id.
13
+ */
14
+ export function makeSimOrganizationsOrganizationalUnitId(rootId) {
15
+ const suffix = faker.string.alphanumeric({ length: 8, casing: "lower" });
16
+ return `ou-${rootId.slice(2)}-${suffix}`;
17
+ }
18
+ /**
19
+ * Generate an AWS-shaped service control policy id.
20
+ */
21
+ export function makeSimOrganizationsPolicyId() {
22
+ return `p-${faker.string.alphanumeric({ length: 8, casing: "lower" })}`;
23
+ }
24
+ /**
25
+ * An organizational unit in a simulated organization.
26
+ *
27
+ * This is the handle a test holds on to. Pass it where a policy is attached or
28
+ * an Account is moved, so neither reads back as a bare string.
29
+ */
30
+ export class SimOrganizationsOrganizationalUnit {
31
+ id;
32
+ name;
33
+ parentId;
34
+ constructor(id, name, parentId) {
35
+ this.id = id;
36
+ this.name = name;
37
+ this.parentId = parentId;
38
+ }
39
+ }
40
+ /**
41
+ * The root of a simulated organization.
42
+ */
43
+ export class SimOrganizationsRoot {
44
+ id;
45
+ name = "Root";
46
+ constructor(id) {
47
+ this.id = id;
48
+ }
49
+ }
50
+ /**
51
+ * Whether an id names the root or an organizational unit.
52
+ *
53
+ * AWS ids carry their own kind in a prefix, and an Account id is twelve
54
+ * digits, so nothing here has to guess which of the two a string is.
55
+ */
56
+ export function isSimOrganizationsUnitId(value) {
57
+ return value.startsWith("r-") || value.startsWith("ou-");
58
+ }
@@ -0,0 +1,91 @@
1
+ import { SimOrganizationsOrganizationalUnit, type SimOrganizationsNodeId, SimOrganizationsRoot } from "./sim-organizations-node.js";
2
+ import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
3
+ /**
4
+ * Thrown for an organizational unit this organization has never seen.
5
+ */
6
+ export declare class SimOrganizationsUnknownNode extends Error {
7
+ constructor(nodeId: string);
8
+ }
9
+ /**
10
+ * Where the Accounts and organizational units of one simulated organization
11
+ * sit relative to each other.
12
+ *
13
+ * The tree answers one question for authorization: which nodes lie on the path
14
+ * from the root down to an Account. Every policy on that path applies to the
15
+ * Account, which is what makes an organizational unit worth modelling at all.
16
+ *
17
+ * An Account joins the organization the moment it is named, whether by being
18
+ * moved into a unit or by having a policy attached to it. An Account never
19
+ * named sits outside the organization and is unrestricted.
20
+ */
21
+ export declare class SimOrganizationsTree {
22
+ readonly root: SimOrganizationsRoot;
23
+ private readonly organizationalUnits;
24
+ private readonly accountParents;
25
+ /**
26
+ * Create an organizational unit, under the root unless another unit is
27
+ * named as its parent.
28
+ */
29
+ createOrganizationalUnit(name: string, parentId?: SimOrganizationsNodeId): SimOrganizationsOrganizationalUnit;
30
+ /**
31
+ * Place an Account under a node, joining the organization if it was outside
32
+ * it.
33
+ */
34
+ placeAccount(accountId: SimAwsAccountId, parentId?: SimOrganizationsNodeId): void;
35
+ /**
36
+ * Take an Account out of the organization.
37
+ */
38
+ removeAccount(accountId: SimAwsAccountId): void;
39
+ /**
40
+ * Take an organizational unit out of the organization.
41
+ *
42
+ * Whatever still sits under it moves up to its parent, which is the only
43
+ * answer that leaves every Account on a path back to the root. AWS refuses
44
+ * to delete a unit that still holds anything, and a Stack tears down in
45
+ * reverse dependency order, so nothing should still be there.
46
+ */
47
+ removeOrganizationalUnit(unitId: SimOrganizationsNodeId): void;
48
+ /**
49
+ * Every Account in the organization.
50
+ */
51
+ accountIds(): readonly SimAwsAccountId[];
52
+ /**
53
+ * Whether this Account is in the organization.
54
+ */
55
+ holds(accountId: SimAwsAccountId): boolean;
56
+ /**
57
+ * Refuse a root or organizational unit this organization never created.
58
+ *
59
+ * A handle from another simulated organization would otherwise be attached
60
+ * to and then never read, because no Account here has it on its path. A
61
+ * policy that silently applies to nothing is worse than a refusal.
62
+ */
63
+ requireNode(nodeId: SimOrganizationsNodeId): void;
64
+ /**
65
+ * Whether this organization has a root or unit under an id.
66
+ */
67
+ hasNode(nodeId: SimOrganizationsNodeId): boolean;
68
+ /**
69
+ * The nodes a request against an Account is filtered by, root first.
70
+ *
71
+ * The Account itself is the last of them, because a policy attached to an
72
+ * Account applies alongside the ones it inherits.
73
+ */
74
+ pathTo(accountId: SimAwsAccountId): readonly SimOrganizationsNodeId[];
75
+ /**
76
+ * What to call a node in a denial.
77
+ */
78
+ nameOf(nodeId: SimOrganizationsNodeId): string;
79
+ /**
80
+ * Move everything under one node up to another.
81
+ */
82
+ private reparent;
83
+ /**
84
+ * The nodes from the root down to one node, root first.
85
+ */
86
+ private ancestors;
87
+ /**
88
+ * Refuse a node this organization never created.
89
+ */
90
+ private requireKnown;
91
+ }
@@ -0,0 +1,154 @@
1
+ import { makeSimOrganizationsOrganizationalUnitId, makeSimOrganizationsRootId, SimOrganizationsOrganizationalUnit, SimOrganizationsRoot, } from "./sim-organizations-node.js";
2
+ /**
3
+ * Thrown for an organizational unit this organization has never seen.
4
+ */
5
+ export class SimOrganizationsUnknownNode extends Error {
6
+ constructor(nodeId) {
7
+ super(`Unknown simulated Organizations node "${nodeId}"`);
8
+ this.name = "SimOrganizationsUnknownNode";
9
+ }
10
+ }
11
+ /**
12
+ * Where the Accounts and organizational units of one simulated organization
13
+ * sit relative to each other.
14
+ *
15
+ * The tree answers one question for authorization: which nodes lie on the path
16
+ * from the root down to an Account. Every policy on that path applies to the
17
+ * Account, which is what makes an organizational unit worth modelling at all.
18
+ *
19
+ * An Account joins the organization the moment it is named, whether by being
20
+ * moved into a unit or by having a policy attached to it. An Account never
21
+ * named sits outside the organization and is unrestricted.
22
+ */
23
+ export class SimOrganizationsTree {
24
+ root = new SimOrganizationsRoot(makeSimOrganizationsRootId());
25
+ organizationalUnits = new Map();
26
+ accountParents = new Map();
27
+ /**
28
+ * Create an organizational unit, under the root unless another unit is
29
+ * named as its parent.
30
+ */
31
+ createOrganizationalUnit(name, parentId = this.root.id) {
32
+ this.requireKnown(parentId);
33
+ const unit = new SimOrganizationsOrganizationalUnit(makeSimOrganizationsOrganizationalUnitId(this.root.id), name, parentId);
34
+ this.organizationalUnits.set(unit.id, unit);
35
+ return unit;
36
+ }
37
+ /**
38
+ * Place an Account under a node, joining the organization if it was outside
39
+ * it.
40
+ */
41
+ placeAccount(accountId, parentId = this.root.id) {
42
+ this.requireKnown(parentId);
43
+ this.accountParents.set(accountId, parentId);
44
+ }
45
+ /**
46
+ * Take an Account out of the organization.
47
+ */
48
+ removeAccount(accountId) {
49
+ this.accountParents.delete(accountId);
50
+ }
51
+ /**
52
+ * Take an organizational unit out of the organization.
53
+ *
54
+ * Whatever still sits under it moves up to its parent, which is the only
55
+ * answer that leaves every Account on a path back to the root. AWS refuses
56
+ * to delete a unit that still holds anything, and a Stack tears down in
57
+ * reverse dependency order, so nothing should still be there.
58
+ */
59
+ removeOrganizationalUnit(unitId) {
60
+ const unit = this.organizationalUnits.get(unitId);
61
+ if (unit === undefined) {
62
+ return;
63
+ }
64
+ this.organizationalUnits.delete(unitId);
65
+ this.reparent(unitId, unit.parentId);
66
+ }
67
+ /**
68
+ * Every Account in the organization.
69
+ */
70
+ accountIds() {
71
+ return this.accountParents.keys().toArray();
72
+ }
73
+ /**
74
+ * Whether this Account is in the organization.
75
+ */
76
+ holds(accountId) {
77
+ return this.accountParents.has(accountId);
78
+ }
79
+ /**
80
+ * Refuse a root or organizational unit this organization never created.
81
+ *
82
+ * A handle from another simulated organization would otherwise be attached
83
+ * to and then never read, because no Account here has it on its path. A
84
+ * policy that silently applies to nothing is worse than a refusal.
85
+ */
86
+ requireNode(nodeId) {
87
+ this.requireKnown(nodeId);
88
+ }
89
+ /**
90
+ * Whether this organization has a root or unit under an id.
91
+ */
92
+ hasNode(nodeId) {
93
+ return nodeId === this.root.id || this.organizationalUnits.has(nodeId);
94
+ }
95
+ /**
96
+ * The nodes a request against an Account is filtered by, root first.
97
+ *
98
+ * The Account itself is the last of them, because a policy attached to an
99
+ * Account applies alongside the ones it inherits.
100
+ */
101
+ pathTo(accountId) {
102
+ const parentId = this.accountParents.get(accountId);
103
+ if (parentId === undefined) {
104
+ return [];
105
+ }
106
+ return [...this.ancestors(parentId), accountId];
107
+ }
108
+ /**
109
+ * What to call a node in a denial.
110
+ */
111
+ nameOf(nodeId) {
112
+ if (nodeId === this.root.id) {
113
+ return this.root.name;
114
+ }
115
+ return this.organizationalUnits.get(nodeId)?.name ?? String(nodeId);
116
+ }
117
+ /**
118
+ * Move everything under one node up to another.
119
+ */
120
+ reparent(fromId, toId) {
121
+ for (const [accountId, parentId] of this.accountParents) {
122
+ if (parentId === fromId) {
123
+ this.accountParents.set(accountId, toId);
124
+ }
125
+ }
126
+ const orphaned = this.organizationalUnits
127
+ .values()
128
+ .filter((unit) => unit.parentId === fromId)
129
+ .toArray();
130
+ for (const unit of orphaned) {
131
+ this.organizationalUnits.set(unit.id, new SimOrganizationsOrganizationalUnit(unit.id, unit.name, toId));
132
+ }
133
+ }
134
+ /**
135
+ * The nodes from the root down to one node, root first.
136
+ */
137
+ ancestors(nodeId) {
138
+ const path = [];
139
+ let currentId = nodeId;
140
+ while (currentId !== undefined && currentId !== this.root.id) {
141
+ path.unshift(currentId);
142
+ currentId = this.organizationalUnits.get(currentId)?.parentId;
143
+ }
144
+ return [this.root.id, ...path];
145
+ }
146
+ /**
147
+ * Refuse a node this organization never created.
148
+ */
149
+ requireKnown(nodeId) {
150
+ if (nodeId !== this.root.id && !this.organizationalUnits.has(nodeId)) {
151
+ throw new SimOrganizationsUnknownNode(nodeId);
152
+ }
153
+ }
154
+ }
@@ -33,6 +33,7 @@ export class ChangeResourceRecordSetsAuthorizer {
33
33
  if (decision.isDenied) {
34
34
  throw new SimIamAccessDenied({
35
35
  principal: decision.caller.principal,
36
+ reason: decision.denialReason,
36
37
  action: ChangeResourceRecordSetsAuthorizer.action,
37
38
  resource: hostedZoneArn,
38
39
  });
@@ -29,6 +29,7 @@ export class CreateHostedZoneAuthorizer {
29
29
  if (decision.isDenied) {
30
30
  throw new SimIamAccessDenied({
31
31
  principal: decision.caller.principal,
32
+ reason: decision.denialReason,
32
33
  action: CreateHostedZoneAuthorizer.action,
33
34
  resource: CreateHostedZoneAuthorizer.resource,
34
35
  });
@@ -27,6 +27,7 @@ export class DeleteHostedZoneAuthorizer {
27
27
  if (decision.isDenied) {
28
28
  throw new SimIamAccessDenied({
29
29
  principal: decision.caller.principal,
30
+ reason: decision.denialReason,
30
31
  action: DeleteHostedZoneAuthorizer.action,
31
32
  resource: hostedZoneArn,
32
33
  });
@@ -22,6 +22,7 @@ export class SimRoute53DnssecAuthorizer {
22
22
  if (decision.isDenied) {
23
23
  throw new SimIamAccessDenied({
24
24
  principal: decision.caller.principal,
25
+ reason: decision.denialReason,
25
26
  action,
26
27
  resource,
27
28
  });
@@ -31,6 +31,7 @@ export class GetHostedZoneAuthorizer {
31
31
  if (decision.isDenied) {
32
32
  throw new SimIamAccessDenied({
33
33
  principal: decision.caller.principal,
34
+ reason: decision.denialReason,
34
35
  action: GetHostedZoneAuthorizer.action,
35
36
  resource: hostedZoneArn,
36
37
  });
@@ -30,6 +30,7 @@ export class ListHostedZonesByNameAuthorizer {
30
30
  if (decision.isDenied) {
31
31
  throw new SimIamAccessDenied({
32
32
  principal: decision.caller.principal,
33
+ reason: decision.denialReason,
33
34
  action: ListHostedZonesByNameAuthorizer.action,
34
35
  resource: ListHostedZonesByNameAuthorizer.resource,
35
36
  });
@@ -33,6 +33,7 @@ export class ListResourceRecordSetsAuthorizer {
33
33
  if (decision.isDenied) {
34
34
  throw new SimIamAccessDenied({
35
35
  principal: decision.caller.principal,
36
+ reason: decision.denialReason,
36
37
  action: ListResourceRecordSetsAuthorizer.action,
37
38
  resource: hostedZoneArn,
38
39
  });
@@ -44,6 +44,7 @@ export class CreateBucketCommandHandler {
44
44
  if (decision.isDenied) {
45
45
  throw new SimIamAccessDenied({
46
46
  principal: decision.caller.principal,
47
+ reason: decision.denialReason,
47
48
  action: "s3:CreateBucket",
48
49
  resource,
49
50
  });
@@ -30,6 +30,7 @@ export class DeleteBucketAuthorizer {
30
30
  if (decision.isDenied) {
31
31
  throw new SimIamAccessDenied({
32
32
  principal: decision.caller.principal,
33
+ reason: decision.denialReason,
33
34
  action: DeleteBucketAuthorizer.action,
34
35
  resource,
35
36
  });
@@ -29,6 +29,7 @@ export class DeleteBucketPolicyAuthorizer {
29
29
  if (decision.isDenied) {
30
30
  throw new SimIamAccessDenied({
31
31
  principal: decision.caller.principal,
32
+ reason: decision.denialReason,
32
33
  action: DeleteBucketPolicyAuthorizer.action,
33
34
  resource,
34
35
  });
@@ -38,6 +38,7 @@ export class DeleteObjectAuthorizer {
38
38
  if (decision.isDenied) {
39
39
  throw new SimIamAccessDenied({
40
40
  principal: decision.caller.principal,
41
+ reason: decision.denialReason,
41
42
  action: DeleteObjectAuthorizer.action,
42
43
  resource,
43
44
  });
@@ -26,6 +26,7 @@ export class GetBucketPolicyAuthorizer {
26
26
  if (decision.isDenied) {
27
27
  throw new SimIamAccessDenied({
28
28
  principal: decision.caller.principal,
29
+ reason: decision.denialReason,
29
30
  action: GetBucketPolicyAuthorizer.action,
30
31
  resource,
31
32
  });
@@ -41,6 +41,7 @@ export class GetObjectAuthorizer {
41
41
  if (decision.isDenied) {
42
42
  throw new SimIamAccessDenied({
43
43
  principal: decision.caller.principal,
44
+ reason: decision.denialReason,
44
45
  action: GetObjectAuthorizer.action,
45
46
  resource,
46
47
  });
@@ -39,6 +39,7 @@ export class HeadBucketAuthorizer {
39
39
  if (decision.isDenied) {
40
40
  throw new SimIamAccessDenied({
41
41
  principal: decision.caller.principal,
42
+ reason: decision.denialReason,
42
43
  action: HeadBucketAuthorizer.action,
43
44
  resource,
44
45
  });
@@ -42,6 +42,7 @@ export class SimS3LifecycleAuthorizer {
42
42
  if (decision.isDenied) {
43
43
  throw new SimIamAccessDenied({
44
44
  principal: decision.caller.principal,
45
+ reason: decision.denialReason,
45
46
  action,
46
47
  resource,
47
48
  });
@@ -37,6 +37,7 @@ export class ListBucketsAuthorizer {
37
37
  if (decision.isDenied) {
38
38
  throw new SimIamAccessDenied({
39
39
  principal: decision.caller.principal,
40
+ reason: decision.denialReason,
40
41
  action: ListBucketsAuthorizer.action,
41
42
  resource: ListBucketsAuthorizer.resource,
42
43
  });
@@ -48,6 +48,7 @@ export class ListObjectsAuthorizer {
48
48
  if (decision.isDenied) {
49
49
  throw new SimIamAccessDenied({
50
50
  principal: decision.caller.principal,
51
+ reason: decision.denialReason,
51
52
  action: ListObjectsAuthorizer.action,
52
53
  resource,
53
54
  });
@@ -42,6 +42,7 @@ export class SimS3MultipartAuthorizer {
42
42
  if (decision.isDenied) {
43
43
  throw new SimIamAccessDenied({
44
44
  principal: decision.caller.principal,
45
+ reason: decision.denialReason,
45
46
  action: SimS3MultipartAuthorizer.action,
46
47
  resource,
47
48
  });
@@ -43,6 +43,7 @@ export class SimS3NotificationAuthorizer {
43
43
  if (decision.isDenied) {
44
44
  throw new SimIamAccessDenied({
45
45
  principal: decision.caller.principal,
46
+ reason: decision.denialReason,
46
47
  action,
47
48
  resource,
48
49
  });
@@ -41,6 +41,7 @@ export class SimS3PublicAccessBlockAuthorizer {
41
41
  if (decision.isDenied) {
42
42
  throw new SimIamAccessDenied({
43
43
  principal: decision.caller.principal,
44
+ reason: decision.denialReason,
44
45
  action,
45
46
  resource,
46
47
  });
@@ -23,6 +23,7 @@ export class PutBucketPolicyAuthorizer {
23
23
  if (decision.isDenied) {
24
24
  throw new SimIamAccessDenied({
25
25
  principal: decision.caller.principal,
26
+ reason: decision.denialReason,
26
27
  action: PutBucketPolicyAuthorizer.action,
27
28
  resource,
28
29
  });
@@ -40,6 +40,7 @@ export class PutBucketWebsiteAuthorizer {
40
40
  if (decision.isDenied) {
41
41
  throw new SimIamAccessDenied({
42
42
  principal: decision.caller.principal,
43
+ reason: decision.denialReason,
43
44
  action: PutBucketWebsiteAuthorizer.action,
44
45
  resource,
45
46
  });
@@ -41,6 +41,7 @@ export class PutObjectAuthorizer {
41
41
  if (decision.isDenied) {
42
42
  throw new SimIamAccessDenied({
43
43
  principal: decision.caller.principal,
44
+ reason: decision.denialReason,
44
45
  action: PutObjectAuthorizer.action,
45
46
  resource,
46
47
  });
@@ -38,6 +38,7 @@ export class SimSecretsManagerAuthorizer {
38
38
  if (decision.isDenied) {
39
39
  throw new SimIamAccessDenied({
40
40
  principal: decision.caller.principal,
41
+ reason: decision.denialReason,
41
42
  action,
42
43
  resource,
43
44
  });
@@ -78,6 +78,7 @@ export class SimSesAuthorizer {
78
78
  if (decision.isDenied) {
79
79
  throw new SimIamAccessDenied({
80
80
  principal: decision.caller.principal,
81
+ reason: decision.denialReason,
81
82
  action,
82
83
  resource,
83
84
  });
@@ -69,6 +69,7 @@ export class SimSqsAuthorizer {
69
69
  if (decision.isDenied) {
70
70
  throw new SimIamAccessDenied({
71
71
  principal: decision.caller.principal,
72
+ reason: decision.denialReason,
72
73
  action: input.action,
73
74
  resource: input.resource,
74
75
  });
@@ -55,6 +55,7 @@ export class SimSsmAuthorizer {
55
55
  if (decision.isDenied) {
56
56
  throw new SimIamAccessDenied({
57
57
  principal: decision.caller.principal,
58
+ reason: decision.denialReason,
58
59
  action,
59
60
  resource,
60
61
  });
@@ -34,6 +34,7 @@ export class SimWafAuthorizer {
34
34
  if (decision.isDenied) {
35
35
  throw new SimIamAccessDenied({
36
36
  principal: decision.caller.principal,
37
+ reason: decision.denialReason,
37
38
  action,
38
39
  resource,
39
40
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kensio/yulin",
3
- "version": "1.20.12",
3
+ "version": "1.20.13",
4
4
  "description": "AWS system behaviour simulation for isolated unit testing",
5
5
  "repository": "https://github.com/KensioSoftware/yulin",
6
6
  "homepage": "https://yulinsim.dev/",
@@ -142,6 +142,10 @@
142
142
  },
143
143
  "./oxlint/cffjs2.oxlintrc.json": "./dist/config/oxlint/cffjs2.oxlintrc.json",
144
144
  "./package.json": "./package.json",
145
+ "./organizations": {
146
+ "import": "./dist/service/organizations/index.js",
147
+ "types": "./dist/service/organizations/index.d.ts"
148
+ },
145
149
  "./personalize": {
146
150
  "import": "./dist/service/personalize/index.js",
147
151
  "types": "./dist/service/personalize/index.d.ts"