@cloud-copilot/iam-lens 0.1.0 → 0.1.2

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 (57) hide show
  1. package/dist/cjs/accounts.d.ts +3 -0
  2. package/dist/cjs/accounts.d.ts.map +1 -0
  3. package/dist/cjs/accounts.js +8 -0
  4. package/dist/cjs/accounts.js.map +1 -0
  5. package/dist/cjs/collect/client.d.ts +238 -0
  6. package/dist/cjs/collect/client.d.ts.map +1 -0
  7. package/dist/cjs/collect/client.js +459 -0
  8. package/dist/cjs/collect/client.js.map +1 -0
  9. package/dist/cjs/collect/collect.d.ts +18 -0
  10. package/dist/cjs/collect/collect.d.ts.map +1 -0
  11. package/dist/cjs/collect/collect.js +26 -0
  12. package/dist/cjs/collect/collect.js.map +1 -0
  13. package/dist/cjs/principals.d.ts +40 -0
  14. package/dist/cjs/principals.d.ts.map +1 -0
  15. package/dist/cjs/principals.js +71 -0
  16. package/dist/cjs/principals.js.map +1 -0
  17. package/dist/cjs/resources.d.ts +19 -0
  18. package/dist/cjs/resources.d.ts.map +1 -0
  19. package/dist/cjs/resources.js +43 -0
  20. package/dist/cjs/resources.js.map +1 -0
  21. package/dist/cjs/util/arn.d.ts +26 -0
  22. package/dist/cjs/util/arn.d.ts.map +1 -0
  23. package/dist/cjs/util/arn.js +68 -0
  24. package/dist/cjs/util/arn.js.map +1 -0
  25. package/dist/esm/accounts.d.ts +3 -0
  26. package/dist/esm/accounts.d.ts.map +1 -0
  27. package/dist/esm/accounts.js +5 -0
  28. package/dist/esm/accounts.js.map +1 -0
  29. package/dist/esm/collect/client.d.ts +238 -0
  30. package/dist/esm/collect/client.d.ts.map +1 -0
  31. package/dist/esm/collect/client.js +454 -0
  32. package/dist/esm/collect/client.js.map +1 -0
  33. package/dist/esm/collect/collect.d.ts +18 -0
  34. package/dist/esm/collect/collect.d.ts.map +1 -0
  35. package/dist/esm/collect/collect.js +22 -0
  36. package/dist/esm/collect/collect.js.map +1 -0
  37. package/dist/esm/principals.d.ts +40 -0
  38. package/dist/esm/principals.d.ts.map +1 -0
  39. package/dist/esm/principals.js +66 -0
  40. package/dist/esm/principals.js.map +1 -0
  41. package/dist/esm/resources.d.ts +19 -0
  42. package/dist/esm/resources.d.ts.map +1 -0
  43. package/dist/esm/resources.js +39 -0
  44. package/dist/esm/resources.js.map +1 -0
  45. package/dist/esm/util/arn.d.ts +26 -0
  46. package/dist/esm/util/arn.d.ts.map +1 -0
  47. package/dist/esm/util/arn.js +64 -0
  48. package/dist/esm/util/arn.js.map +1 -0
  49. package/package.json +85 -17
  50. package/.github/workflows/guarddog.yml +0 -31
  51. package/.github/workflows/pr-checks.yml +0 -101
  52. package/.github/workflows/update-dependencies.yml +0 -16
  53. package/postbuild.sh +0 -12
  54. package/src/index.ts +0 -1
  55. package/tsconfig.cjs.json +0 -11
  56. package/tsconfig.esm.json +0 -14
  57. package/tsconfig.json +0 -22
@@ -0,0 +1,19 @@
1
+ import { Simulation } from '@cloud-copilot/iam-simulate';
2
+ import { IamCollectClient } from './collect/client.js';
3
+ /**
4
+ * Get the account ID for a given resource ARN. Lookup index if necessary to find the account ID.
5
+ *
6
+ * @param collectClient the IAM collect client to use for retrieving the account ID
7
+ * @param resourceArn the ARN of the resource to get the account ID for
8
+ * @returns the account ID for the specified resource, or undefined if not found
9
+ */
10
+ export declare function getAccountIdForResource(collectClient: IamCollectClient, resourceArn: string): Promise<string | undefined>;
11
+ /**
12
+ * Get the resource control policies (RCPs) for a given resource ARN.
13
+ *
14
+ * @param collectClient the IAM collect client to use for retrieving RCPs
15
+ * @param resourceArn the ARN of the resource to get RCPs for
16
+ * @returns an array of resource control policies for the specified resource
17
+ */
18
+ export declare function getRcpsForResource(collectClient: IamCollectClient, resourceArn: string): Promise<Simulation['resourceControlPolicies']>;
19
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAGtD;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,gBAAgB,EAC/B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAc7B;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,gBAAgB,EAC/B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAMhD"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAccountIdForResource = getAccountIdForResource;
4
+ exports.getRcpsForResource = getRcpsForResource;
5
+ const arn_js_1 = require("./util/arn.js");
6
+ /**
7
+ * Get the account ID for a given resource ARN. Lookup index if necessary to find the account ID.
8
+ *
9
+ * @param collectClient the IAM collect client to use for retrieving the account ID
10
+ * @param resourceArn the ARN of the resource to get the account ID for
11
+ * @returns the account ID for the specified resource, or undefined if not found
12
+ */
13
+ async function getAccountIdForResource(collectClient, resourceArn) {
14
+ const arnParts = (0, arn_js_1.splitArnParts)(resourceArn);
15
+ let accountId = arnParts.accountId;
16
+ if (accountId) {
17
+ return accountId;
18
+ }
19
+ if (arnParts.service === 's3' && arnParts.resourceType === '') {
20
+ const bucketName = arnParts.resourcePath;
21
+ return collectClient.getAccountIdForBucket(bucketName);
22
+ }
23
+ else if (arnParts.service === 'apigateway' && arnParts.resourceType === 'restapis') {
24
+ const apiId = arnParts.resourcePath;
25
+ return collectClient.getAccountIdForRestApi(apiId);
26
+ }
27
+ return undefined;
28
+ }
29
+ /**
30
+ * Get the resource control policies (RCPs) for a given resource ARN.
31
+ *
32
+ * @param collectClient the IAM collect client to use for retrieving RCPs
33
+ * @param resourceArn the ARN of the resource to get RCPs for
34
+ * @returns an array of resource control policies for the specified resource
35
+ */
36
+ async function getRcpsForResource(collectClient, resourceArn) {
37
+ const accountId = await getAccountIdForResource(collectClient, resourceArn);
38
+ if (!accountId) {
39
+ throw new Error(`Unable to determine account ID for resource ARN: ${resourceArn}`);
40
+ }
41
+ return collectClient.getRcpHierarchyForAccount(accountId);
42
+ }
43
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/resources.ts"],"names":[],"mappings":";;AAWA,0DAiBC;AASD,gDASC;AA5CD,0CAA6C;AAE7C;;;;;;GAMG;AACI,KAAK,UAAU,uBAAuB,CAC3C,aAA+B,EAC/B,WAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAA,sBAAa,EAAC,WAAW,CAAC,CAAA;IAC3C,IAAI,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;IAClC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,IAAI,QAAQ,CAAC,YAAY,KAAK,EAAE,EAAE,CAAC;QAC9D,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAa,CAAA;QACzC,OAAO,aAAa,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;SAAM,IAAI,QAAQ,CAAC,OAAO,KAAK,YAAY,IAAI,QAAQ,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;QACrF,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAa,CAAA;QACpC,OAAO,aAAa,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,kBAAkB,CACtC,aAA+B,EAC/B,WAAmB;IAEnB,MAAM,SAAS,GAAG,MAAM,uBAAuB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;IAC3E,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,oDAAoD,WAAW,EAAE,CAAC,CAAA;IACpF,CAAC;IACD,OAAO,aAAa,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAA;AAC3D,CAAC"}
@@ -0,0 +1,26 @@
1
+ export interface ArnParts {
2
+ partition: string | undefined;
3
+ service: string | undefined;
4
+ region: string | undefined;
5
+ accountId: string | undefined;
6
+ resource: string | undefined;
7
+ resourceType: string | undefined;
8
+ resourcePath: string | undefined;
9
+ }
10
+ /**
11
+ * Split an ARN into its parts
12
+ *
13
+ * @param arn the arn to split
14
+ * @returns the parts of the ARN
15
+ */
16
+ export declare function splitArnParts(arn: string): ArnParts;
17
+ /**
18
+ * Get the product/id segments of the resource portion of an ARN.
19
+ * The first segment is the product segment and the second segment is the resource id segment.
20
+ * This could be split by a colon or a slash, so it checks for both. It also checks for S3 buckets/objects.
21
+ *
22
+ * @param resource The resource to get the resource segments. Must be an ARN resource.
23
+ * @returns a tuple with the first segment being the product segment (without the separator) and the second segment being the resource id.
24
+ */
25
+ export declare function getResourceSegments(service: string, accountId: string, region: string, resourceString: string): [string, string];
26
+ //# sourceMappingURL=arn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arn.d.ts","sourceRoot":"","sources":["../../../src/util/arn.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAkBnD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GACrB,CAAC,MAAM,EAAE,MAAM,CAAC,CA+BlB"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ // Copied from https://github.com/cloud-copilot/iam-simulate/blob/main/src/util.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.splitArnParts = splitArnParts;
5
+ exports.getResourceSegments = getResourceSegments;
6
+ /**
7
+ * Split an ARN into its parts
8
+ *
9
+ * @param arn the arn to split
10
+ * @returns the parts of the ARN
11
+ */
12
+ function splitArnParts(arn) {
13
+ const parts = arn.split(':');
14
+ const partition = parts.at(1);
15
+ const service = parts.at(2);
16
+ const region = parts.at(3);
17
+ const accountId = parts.at(4);
18
+ const resource = parts.slice(5).join(':');
19
+ const [resourceType, resourcePath] = getResourceSegments(service, accountId, region, resource);
20
+ return {
21
+ partition,
22
+ service,
23
+ region,
24
+ accountId,
25
+ resource,
26
+ resourceType,
27
+ resourcePath
28
+ };
29
+ }
30
+ /**
31
+ * Get the product/id segments of the resource portion of an ARN.
32
+ * The first segment is the product segment and the second segment is the resource id segment.
33
+ * This could be split by a colon or a slash, so it checks for both. It also checks for S3 buckets/objects.
34
+ *
35
+ * @param resource The resource to get the resource segments. Must be an ARN resource.
36
+ * @returns a tuple with the first segment being the product segment (without the separator) and the second segment being the resource id.
37
+ */
38
+ function getResourceSegments(service, accountId, region, resourceString) {
39
+ // This is terrible, and I hate it
40
+ if ((service === 's3' && accountId === '' && region === '') ||
41
+ service === 'sns' ||
42
+ service === 'sqs') {
43
+ return ['', resourceString];
44
+ }
45
+ if (resourceString.startsWith('/')) {
46
+ resourceString = resourceString.slice(1);
47
+ }
48
+ const slashIndex = resourceString.indexOf('/');
49
+ const colonIndex = resourceString.indexOf(':');
50
+ let splitIndex = slashIndex;
51
+ if (slashIndex != -1 && colonIndex != -1) {
52
+ splitIndex = Math.min(slashIndex, colonIndex) + 1;
53
+ }
54
+ else if (slashIndex == -1 && colonIndex == -1) {
55
+ splitIndex = resourceString.length + 1;
56
+ }
57
+ else if (colonIndex == -1) {
58
+ splitIndex = slashIndex + 1;
59
+ }
60
+ else if (slashIndex == -1) {
61
+ splitIndex = colonIndex + 1;
62
+ }
63
+ else {
64
+ throw new Error(`Unable to split resource ${resourceString}`);
65
+ }
66
+ return [resourceString.slice(0, splitIndex - 1), resourceString.slice(splitIndex)];
67
+ }
68
+ //# sourceMappingURL=arn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arn.js","sourceRoot":"","sources":["../../../src/util/arn.ts"],"names":[],"mappings":";AAAA,kFAAkF;;AAkBlF,sCAkBC;AAUD,kDAoCC;AAtED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,MAAM,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAA;IAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAA;IAC3B,MAAM,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAA;IAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IAE9F,OAAO;QACL,SAAS;QACT,OAAO;QACP,MAAM;QACN,SAAS;QACT,QAAQ;QACR,YAAY;QACZ,YAAY;KACb,CAAA;AACH,C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C;IAED,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA;AACpF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { AwsIamStore } from '@cloud-copilot/iam-collect';
2
+ export declare function accountExists(storageClient: AwsIamStore, accountId: string): Promise<boolean>;
3
+ //# sourceMappingURL=accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,wBAAsB,aAAa,CACjC,aAAa,EAAE,WAAW,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC,CAGlB"}
@@ -0,0 +1,5 @@
1
+ export async function accountExists(storageClient, accountId) {
2
+ const accounts = await storageClient.listAccountIds();
3
+ return accounts.includes(accountId);
4
+ }
5
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/accounts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,aAA0B,EAC1B,SAAiB;IAEjB,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,cAAc,EAAE,CAAA;IACrD,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;AACrC,CAAC"}
@@ -0,0 +1,238 @@
1
+ import { AwsIamStore } from '@cloud-copilot/iam-collect';
2
+ export interface SimulationOrgPolicies {
3
+ orgIdentifier: string;
4
+ policies: {
5
+ name: string;
6
+ policy: any;
7
+ }[];
8
+ }
9
+ interface IamUserMetadata {
10
+ arn: string;
11
+ path: string;
12
+ permissionBoundary: string;
13
+ id: string;
14
+ name: string;
15
+ created: string;
16
+ }
17
+ export interface OrgPolicy {
18
+ arn: string;
19
+ name: string;
20
+ policy: any;
21
+ }
22
+ export interface ManagedPolicy {
23
+ arn: string;
24
+ name: string;
25
+ policy: any;
26
+ }
27
+ export interface InlinePolicy {
28
+ name: string;
29
+ policy: any;
30
+ }
31
+ interface OrgAccount {
32
+ ou: string;
33
+ rcps: string[];
34
+ scps: string[];
35
+ }
36
+ type OrgAccounts = Record<string, OrgAccount>;
37
+ interface OrgUnitDetails {
38
+ parent: string | undefined;
39
+ scps: string[];
40
+ rcps: string[];
41
+ }
42
+ type OrgUnits = Record<string, OrgUnitDetails>;
43
+ type OrgPolicyType = 'scps' | 'rcps';
44
+ interface OrganizationMetadata {
45
+ id: string;
46
+ arn: string;
47
+ rootOu: string;
48
+ rootAccountArn: string;
49
+ rootAccountId: string;
50
+ features: {
51
+ AISERVICES_OPT_OUT_POLICY?: boolean;
52
+ BACKUP_POLICY?: boolean;
53
+ RESOURCE_CONTROL_POLICY?: boolean;
54
+ SERVICE_CONTROL_POLICY?: boolean;
55
+ TAG_POLICY?: boolean;
56
+ };
57
+ }
58
+ export declare class IamCollectClient {
59
+ private storageClient;
60
+ constructor(storageClient: AwsIamStore);
61
+ /**
62
+ * Checks if an account exists in the store.
63
+ * @param accountId The ID of the account to check.
64
+ * @returns True if the account exists, false otherwise.
65
+ */
66
+ accountExists(accountId: string): Promise<boolean>;
67
+ /**
68
+ * Checks if a principal exists in the store.
69
+ * @param principalArn The ARN of the principal to check.
70
+ * @returns True if the principal exists, false otherwise.
71
+ */
72
+ principalExists(principalArn: string): Promise<boolean>;
73
+ /**
74
+ * Gets the SCP Hierarchy for an account. The first element is the root, the last element is the account itself.
75
+ * @param accountId The ID of the account to get the SCP Hierarchy for.
76
+ * @returns The SCP Hierarchy for the account.
77
+ */
78
+ getScpHierarchyForAccount(accountId: string): Promise<SimulationOrgPolicies[]>;
79
+ /**
80
+ * Gets the policy hierarchy for an account for a given policy type.
81
+ * @param accountId The ID of the account.
82
+ * @param policyType The type of policy ('scps' or 'rcps').
83
+ * @returns The policy hierarchy for the account.
84
+ */
85
+ getOrgPolicyHierarchyForAccount(accountId: string, policyType: OrgPolicyType): Promise<SimulationOrgPolicies[]>;
86
+ /**
87
+ * Gets the OUs for an account. The first element is the root,
88
+ * the last element is the parent OU of the account.
89
+ * @param accountId The ID of the account to get the OUs for.
90
+ * @returns The OUs for the account.
91
+ */
92
+ getOrgUnitHierarchyForAccount(accountId: string): Promise<string[]>;
93
+ /**
94
+ * Gets the org unit ID for an account.
95
+ * @param accountId The ID of the account.
96
+ * @returns The org unit ID for the account, or undefined if not found.
97
+ */
98
+ getOrgUnitIdForAccount(accountId: string): Promise<string | undefined>;
99
+ /**
100
+ * Gets the parent org unit ID for a given org unit.
101
+ * @param orgId The ID of the organization.
102
+ * @param ouId The ID of the org unit.
103
+ * @returns The parent org unit ID, or undefined if not found.
104
+ */
105
+ getParentOrgUnitIdForOrgUnit(orgId: string, ouId: string): Promise<string | undefined>;
106
+ /**
107
+ * Gets the SCPs for an account.
108
+ * @param accountId The ID of the account.
109
+ * @returns The SCPs for the account.
110
+ */
111
+ getScpsForAccount(accountId: string): Promise<OrgPolicy[]>;
112
+ /**
113
+ * Gets the org policies for an account for a given policy type.
114
+ * @param accountId The ID of the account.
115
+ * @param policyType The type of policy ('scps' or 'rcps').
116
+ * @returns The org policies for the account.
117
+ */
118
+ getOrgPoliciesForAccount(accountId: string, policyType: OrgPolicyType): Promise<OrgPolicy[]>;
119
+ /**
120
+ * Gets the account data for an organization.
121
+ * @param orgId The ID of the organization.
122
+ * @returns The account data for the organization.
123
+ */
124
+ getAccountDataForOrg(orgId: string): Promise<OrgAccounts>;
125
+ /**
126
+ * Gets the org units data for an organization.
127
+ * @param orgId The ID of the organization.
128
+ * @returns The org units data for the organization.
129
+ */
130
+ getOrgUnitsDataForOrg(orgId: string): Promise<OrgUnits>;
131
+ /**
132
+ * Gets a specific org policy.
133
+ * @param orgId The ID of the organization.
134
+ * @param policyType The type of policy ('scps' or 'rcps').
135
+ * @param policyArn The ARN of the policy.
136
+ * @returns The org policy.
137
+ */
138
+ getOrgPolicy(orgId: string, policyType: OrgPolicyType, policyArn: string): Promise<OrgPolicy>;
139
+ /**
140
+ * Gets the RCPs for an account.
141
+ * @param accountId The ID of the account.
142
+ * @returns The RCPs for the account.
143
+ */
144
+ getRcpsForAccount(accountId: string): Promise<OrgPolicy[]>;
145
+ /**
146
+ * Gets the RCP hierarchy for an account.
147
+ * @param accountId The ID of the account.
148
+ * @returns The RCP hierarchy for the account.
149
+ */
150
+ getRcpHierarchyForAccount(accountId: string): Promise<SimulationOrgPolicies[]>;
151
+ /**
152
+ * Gets the SCPs for an org unit.
153
+ * @param orgId The ID of the organization.
154
+ * @param orgUnitId The ID of the org unit.
155
+ * @returns The SCPs for the org unit.
156
+ */
157
+ getScpsForOrgUnit(orgId: string, orgUnitId: string): Promise<OrgPolicy[]>;
158
+ /**
159
+ * Gets the org policies for an org unit for a given policy type.
160
+ * @param orgId The ID of the organization.
161
+ * @param orgUnitId The ID of the org unit.
162
+ * @param policyType The type of policy ('scps' or 'rcps').
163
+ * @returns The org policies for the org unit.
164
+ */
165
+ getOrgPoliciesForOrgUnit(orgId: string, orgUnitId: string, policyType: OrgPolicyType): Promise<OrgPolicy[]>;
166
+ /**
167
+ * Gets the RCPs for an org unit.
168
+ * @param orgId The ID of the organization.
169
+ * @param orgUnitId The ID of the org unit.
170
+ * @returns The RCPs for the org unit.
171
+ */
172
+ getRcpsForOrgUnit(orgId: string, orgUnitId: string): Promise<OrgPolicy[]>;
173
+ /**
174
+ * Gets the org ID for an account.
175
+ * @param accountId The ID of the account.
176
+ * @returns The org ID for the account, or undefined if not found.
177
+ */
178
+ getOrgIdForAccount(accountId: string): Promise<string | undefined>;
179
+ /**
180
+ * Gets the account ID for a given S3 bucket name.
181
+ * @param bucketName The name of the bucket.
182
+ * @returns The account ID for the bucket, or undefined if not found.
183
+ */
184
+ getAccountIdForBucket(bucketName: string): Promise<string | undefined>;
185
+ /**
186
+ * Gets the account ID for a given API Gateway ARN.
187
+ * @param apiArn The ARN of the API Gateway.
188
+ * @returns The account ID for the API Gateway, or undefined if not found.
189
+ */
190
+ getAccountIdForRestApi(apiArn: string): Promise<string | undefined>;
191
+ /**
192
+ * Gets the managed policies attached to a user.
193
+ * @param userArn The ARN of the user.
194
+ * @returns The managed policies for the user.
195
+ */
196
+ getManagedPoliciesForUser(userArn: string): Promise<ManagedPolicy[]>;
197
+ getManagedPolicy(accountId: string, policyArn: string): Promise<ManagedPolicy>;
198
+ /**
199
+ * Gets the inline policies attached to a user.
200
+ * @param userArn The ARN of the user.
201
+ * @returns The inline policies for the user.
202
+ */
203
+ getInlinePoliciesForUser(userArn: string): Promise<InlinePolicy[]>;
204
+ getIamUserMetadata(userArn: string): Promise<IamUserMetadata | undefined>;
205
+ /**
206
+ * Gets the permissions boundary policy attached to a user, if any.
207
+ *
208
+ * @param userArn The ARN of the user.
209
+ * @returns The permissions boundary policy as an OrgPolicy, or undefined if none is set.
210
+ */
211
+ getPermissionsBoundaryForUser(userArn: string): Promise<ManagedPolicy | undefined>;
212
+ /**
213
+ * Gets the group ARNs that the user is a member of.
214
+ * @param userArn The ARN of the user.
215
+ * @returns An array of group ARNs the user belongs to.
216
+ */
217
+ getGroupsForUser(userArn: string): Promise<string[]>;
218
+ /**
219
+ * Gets the managed policies attached to a group.
220
+ *
221
+ * @param groupArn The ARN of the group.
222
+ * @returns The managed policies for the group.
223
+ */
224
+ getManagedPoliciesForGroup(groupArn: string): Promise<ManagedPolicy[]>;
225
+ getInlinePoliciesForGroup(groupArn: string): Promise<InlinePolicy[]>;
226
+ getManagedPoliciesForRole(roleArn: string): Promise<ManagedPolicy[]>;
227
+ getInlinePoliciesForRole(roleArn: string): Promise<InlinePolicy[]>;
228
+ getPermissionsBoundaryForRole(roleArn: string): Promise<ManagedPolicy | undefined>;
229
+ /**
230
+ * Get the metadata for an organization.
231
+ *
232
+ * @param organizationId the id of the organization
233
+ * @returns the metadata for the organization
234
+ */
235
+ getOrganizationMetadata(organizationId: string): Promise<OrganizationMetadata>;
236
+ }
237
+ export {};
238
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/collect/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAIxD,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,EAAE,CAAA;CAC1C;AAED,UAAU,eAAe;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,kBAAkB,EAAE,MAAM,CAAA;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAOD,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,GAAG,CAAA;CACZ;AAOD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,GAAG,CAAA;CACZ;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,GAAG,CAAA;CACZ;AAED,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAc7C,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;C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