@cloud-copilot/iam-collect 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/cjs/aws/ClientPool.d.ts +27 -0
- package/dist/cjs/aws/ClientPool.d.ts.map +1 -0
- package/dist/cjs/aws/ClientPool.js +52 -0
- package/dist/cjs/aws/ClientPool.js.map +1 -0
- package/dist/cjs/aws/auth.d.ts +16 -0
- package/dist/cjs/aws/auth.d.ts.map +1 -0
- package/dist/cjs/aws/auth.js +76 -0
- package/dist/cjs/aws/auth.js.map +1 -0
- package/dist/cjs/cli.js +46 -8
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/config/config.d.ts +22 -11
- package/dist/cjs/config/config.d.ts.map +1 -1
- package/dist/cjs/config/config.js +52 -7
- package/dist/cjs/config/config.js.map +1 -1
- package/dist/cjs/config/configFile.d.ts +16 -0
- package/dist/cjs/config/configFile.d.ts.map +1 -0
- package/dist/cjs/config/configFile.js +49 -0
- package/dist/cjs/config/configFile.js.map +1 -0
- package/dist/cjs/config/defaultConfig.d.ts.map +1 -1
- package/dist/cjs/config/defaultConfig.js +38 -1
- package/dist/cjs/config/defaultConfig.js.map +1 -1
- package/dist/cjs/download/download.d.ts +3 -0
- package/dist/cjs/download/download.d.ts.map +1 -0
- package/dist/cjs/download/download.js +67 -0
- package/dist/cjs/download/download.js.map +1 -0
- package/dist/cjs/persistence/AwsIamStore.d.ts +95 -0
- package/dist/cjs/persistence/AwsIamStore.d.ts.map +1 -0
- package/dist/cjs/persistence/AwsIamStore.js +3 -0
- package/dist/cjs/persistence/AwsIamStore.js.map +1 -0
- package/dist/cjs/persistence/file/FileSystemAdapter.d.ts +20 -0
- package/dist/cjs/persistence/file/FileSystemAdapter.d.ts.map +1 -0
- package/dist/cjs/persistence/file/FileSystemAdapter.js +77 -0
- package/dist/cjs/persistence/file/FileSystemAdapter.js.map +1 -0
- package/dist/cjs/persistence/file/FileSystemAwsIamStore.d.ts +19 -0
- package/dist/cjs/persistence/file/FileSystemAwsIamStore.d.ts.map +1 -0
- package/dist/cjs/persistence/file/FileSystemAwsIamStore.js +96 -0
- package/dist/cjs/persistence/file/FileSystemAwsIamStore.js.map +1 -0
- package/dist/cjs/persistence/util.d.ts +28 -0
- package/dist/cjs/persistence/util.d.ts.map +1 -0
- package/dist/cjs/persistence/util.js +46 -0
- package/dist/cjs/persistence/util.js.map +1 -0
- package/dist/cjs/regions.d.ts +3 -0
- package/dist/cjs/regions.d.ts.map +1 -0
- package/dist/cjs/regions.js +15 -0
- package/dist/cjs/regions.js.map +1 -0
- package/dist/cjs/services.d.ts +3 -0
- package/dist/cjs/services.d.ts.map +1 -0
- package/dist/cjs/services.js +5 -0
- package/dist/cjs/services.js.map +1 -0
- package/dist/cjs/syncs/iam/authorizationDetails.d.ts +104 -0
- package/dist/cjs/syncs/iam/authorizationDetails.d.ts.map +1 -0
- package/dist/cjs/syncs/iam/authorizationDetails.js +490 -0
- package/dist/cjs/syncs/iam/authorizationDetails.js.map +1 -0
- package/dist/cjs/syncs/lambda/lambda.d.ts +3 -0
- package/dist/cjs/syncs/lambda/lambda.d.ts.map +1 -0
- package/dist/cjs/syncs/lambda/lambda.js +54 -0
- package/dist/cjs/syncs/lambda/lambda.js.map +1 -0
- package/dist/cjs/syncs/sync.d.ts +27 -0
- package/dist/cjs/syncs/sync.d.ts.map +1 -0
- package/dist/cjs/syncs/sync.js +16 -0
- package/dist/cjs/syncs/sync.js.map +1 -0
- package/dist/cjs/syncs/syncMap.d.ts +17 -0
- package/dist/cjs/syncs/syncMap.d.ts.map +1 -0
- package/dist/cjs/syncs/syncMap.js +51 -0
- package/dist/cjs/syncs/syncMap.js.map +1 -0
- package/dist/cjs/utils/arn.d.ts +26 -0
- package/dist/cjs/utils/arn.d.ts.map +1 -0
- package/dist/cjs/utils/arn.js +60 -0
- package/dist/cjs/utils/arn.js.map +1 -0
- package/dist/cjs/utils/client-tools.d.ts +15 -0
- package/dist/cjs/utils/client-tools.d.ts.map +1 -0
- package/dist/cjs/utils/client-tools.js +42 -0
- package/dist/cjs/utils/client-tools.js.map +1 -0
- package/dist/cjs/utils/strings.d.ts +8 -0
- package/dist/cjs/utils/strings.d.ts.map +1 -0
- package/dist/cjs/utils/strings.js +19 -0
- package/dist/cjs/utils/strings.js.map +1 -0
- package/dist/cjs/utils/types.d.ts +2 -0
- package/dist/cjs/utils/types.d.ts.map +1 -0
- package/dist/cjs/utils/types.js +7 -0
- package/dist/cjs/utils/types.js.map +1 -0
- package/dist/esm/aws/ClientPool.d.ts +27 -0
- package/dist/esm/aws/ClientPool.d.ts.map +1 -0
- package/dist/esm/aws/ClientPool.js +50 -0
- package/dist/esm/aws/ClientPool.js.map +1 -0
- package/dist/esm/aws/auth.d.ts +16 -0
- package/dist/esm/aws/auth.d.ts.map +1 -0
- package/dist/esm/aws/auth.js +71 -0
- package/dist/esm/aws/auth.js.map +1 -0
- package/dist/esm/cli.js +46 -8
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/config/config.d.ts +22 -11
- package/dist/esm/config/config.d.ts.map +1 -1
- package/dist/esm/config/config.js +50 -7
- package/dist/esm/config/config.js.map +1 -1
- package/dist/esm/config/configFile.d.ts +16 -0
- package/dist/esm/config/configFile.d.ts.map +1 -0
- package/dist/esm/config/configFile.js +45 -0
- package/dist/esm/config/configFile.js.map +1 -0
- package/dist/esm/config/defaultConfig.d.ts.map +1 -1
- package/dist/esm/config/defaultConfig.js +38 -1
- package/dist/esm/config/defaultConfig.js.map +1 -1
- package/dist/esm/download/download.d.ts +3 -0
- package/dist/esm/download/download.d.ts.map +1 -0
- package/dist/esm/download/download.js +64 -0
- package/dist/esm/download/download.js.map +1 -0
- package/dist/esm/persistence/AwsIamStore.d.ts +95 -0
- package/dist/esm/persistence/AwsIamStore.d.ts.map +1 -0
- package/dist/esm/persistence/AwsIamStore.js +2 -0
- package/dist/esm/persistence/AwsIamStore.js.map +1 -0
- package/dist/esm/persistence/file/FileSystemAdapter.d.ts +20 -0
- package/dist/esm/persistence/file/FileSystemAdapter.d.ts.map +1 -0
- package/dist/esm/persistence/file/FileSystemAdapter.js +73 -0
- package/dist/esm/persistence/file/FileSystemAdapter.js.map +1 -0
- package/dist/esm/persistence/file/FileSystemAwsIamStore.d.ts +19 -0
- package/dist/esm/persistence/file/FileSystemAwsIamStore.d.ts.map +1 -0
- package/dist/esm/persistence/file/FileSystemAwsIamStore.js +89 -0
- package/dist/esm/persistence/file/FileSystemAwsIamStore.js.map +1 -0
- package/dist/esm/persistence/util.d.ts +28 -0
- package/dist/esm/persistence/util.d.ts.map +1 -0
- package/dist/esm/persistence/util.js +41 -0
- package/dist/esm/persistence/util.js.map +1 -0
- package/dist/esm/regions.d.ts +3 -0
- package/dist/esm/regions.d.ts.map +1 -0
- package/dist/esm/regions.js +12 -0
- package/dist/esm/regions.js.map +1 -0
- package/dist/esm/services.d.ts +3 -0
- package/dist/esm/services.d.ts.map +1 -0
- package/dist/esm/services.js +2 -0
- package/dist/esm/services.js.map +1 -0
- package/dist/esm/syncs/iam/authorizationDetails.d.ts +104 -0
- package/dist/esm/syncs/iam/authorizationDetails.d.ts.map +1 -0
- package/dist/esm/syncs/iam/authorizationDetails.js +478 -0
- package/dist/esm/syncs/iam/authorizationDetails.js.map +1 -0
- package/dist/esm/syncs/lambda/lambda.d.ts +3 -0
- package/dist/esm/syncs/lambda/lambda.d.ts.map +1 -0
- package/dist/esm/syncs/lambda/lambda.js +51 -0
- package/dist/esm/syncs/lambda/lambda.js.map +1 -0
- package/dist/esm/syncs/sync.d.ts +27 -0
- package/dist/esm/syncs/sync.d.ts.map +1 -0
- package/dist/esm/syncs/sync.js +13 -0
- package/dist/esm/syncs/sync.js.map +1 -0
- package/dist/esm/syncs/syncMap.d.ts +17 -0
- package/dist/esm/syncs/syncMap.d.ts.map +1 -0
- package/dist/esm/syncs/syncMap.js +47 -0
- package/dist/esm/syncs/syncMap.js.map +1 -0
- package/dist/esm/utils/arn.d.ts +26 -0
- package/dist/esm/utils/arn.d.ts.map +1 -0
- package/dist/esm/utils/arn.js +56 -0
- package/dist/esm/utils/arn.js.map +1 -0
- package/dist/esm/utils/client-tools.d.ts +15 -0
- package/dist/esm/utils/client-tools.d.ts.map +1 -0
- package/dist/esm/utils/client-tools.js +38 -0
- package/dist/esm/utils/client-tools.js.map +1 -0
- package/dist/esm/utils/strings.d.ts +8 -0
- package/dist/esm/utils/strings.d.ts.map +1 -0
- package/dist/esm/utils/strings.js +16 -0
- package/dist/esm/utils/strings.js.map +1 -0
- package/dist/esm/utils/types.d.ts +2 -0
- package/dist/esm/utils/types.d.ts.map +1 -0
- package/dist/esm/utils/types.js +4 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/package.json +13 -1
- package/dist/cjs/cliUtils.d.ts +0 -13
- package/dist/cjs/cliUtils.d.ts.map +0 -1
- package/dist/cjs/cliUtils.js +0 -43
- package/dist/cjs/cliUtils.js.map +0 -1
- package/dist/esm/cliUtils.d.ts +0 -13
- package/dist/esm/cliUtils.d.ts.map +0 -1
- package/dist/esm/cliUtils.js +0 -40
- package/dist/esm/cliUtils.js.map +0 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { access, mkdir, readdir, readFile, rm, unlink, writeFile } from 'fs/promises';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
export class FileSystemAdapter {
|
|
4
|
+
async writeFile(filePath, data) {
|
|
5
|
+
// Ensure the directory exists
|
|
6
|
+
const dir = dirname(filePath);
|
|
7
|
+
await mkdir(dir, { recursive: true });
|
|
8
|
+
await writeFile(filePath, data);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Read the contents of a file. If the file does not exist, return undefined.
|
|
12
|
+
*
|
|
13
|
+
* @param filePath The path to the file to read
|
|
14
|
+
* @returns The contents of the file as a string, or undefined if the file does not exist.
|
|
15
|
+
*/
|
|
16
|
+
async readFile(filePath) {
|
|
17
|
+
try {
|
|
18
|
+
await access(filePath);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
// If the file does not exist, return undefined
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return await readFile(filePath, { encoding: 'utf8' });
|
|
25
|
+
}
|
|
26
|
+
async deleteFile(filePath) {
|
|
27
|
+
try {
|
|
28
|
+
await unlink(filePath);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
if (err.code !== 'ENOENT') {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async deleteDirectory(dirPath) {
|
|
37
|
+
try {
|
|
38
|
+
await rm(dirPath, { recursive: true, force: true });
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err.code !== 'ENOENT') {
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* List the contents of a directory. Will return the names of the subdirectories and files without the full path.
|
|
48
|
+
*
|
|
49
|
+
* @param dirPath The path to the directory to list
|
|
50
|
+
* @returns An array of strings representing the names of the subdirectories or files in the specified directory.
|
|
51
|
+
*/
|
|
52
|
+
async listDirectory(dirPath) {
|
|
53
|
+
try {
|
|
54
|
+
await access(dirPath);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// If the directory does not exist, return an empty array
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
62
|
+
// return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name)
|
|
63
|
+
return entries.map((e) => e.name);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
if (err.code === 'ENOENT') {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=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,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACrD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC1B,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CAAC,OAAe;QACjC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;QACvB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,yDAAyD;YACzD,OAAO,EAAE,CAAA;QACX,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;YAC/D,mFAAmF;YACnF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACnC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC1B,OAAO,EAAE,CAAA;YACX,CAAC;YACD,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AwsIamStore, ResourceTypeParts } from '../AwsIamStore.js';
|
|
2
|
+
import { FileSystemAdapter } from './FileSystemAdapter.js';
|
|
3
|
+
export declare class FileSystemAwsIamStore implements AwsIamStore {
|
|
4
|
+
private readonly baseFolder;
|
|
5
|
+
private readonly partition;
|
|
6
|
+
private fsAdapter;
|
|
7
|
+
constructor(baseFolder: string, partition: string, fsAdapter?: FileSystemAdapter);
|
|
8
|
+
private accountPath;
|
|
9
|
+
private buildResourcePath;
|
|
10
|
+
private buildMetadataPath;
|
|
11
|
+
saveResourceMetadata(accountId: string, arn: string, metadataType: string, data: string | any): Promise<void>;
|
|
12
|
+
listResourceMetadata(accountId: string, arn: string): Promise<string[]>;
|
|
13
|
+
getResourceMetadata<T, D extends T>(accountId: string, arn: string, metadataType: string, defaultValue?: D): Promise<D extends undefined ? T | undefined : T>;
|
|
14
|
+
deleteResourceMetadata(accountId: string, arn: string, metadataType: string): Promise<void>;
|
|
15
|
+
deleteResource(accountId: string, arn: string): Promise<void>;
|
|
16
|
+
listResources(accountId: string, options: ResourceTypeParts): Promise<string[]>;
|
|
17
|
+
syncResourceList(accountId: string, options: ResourceTypeParts, desiredResources: string[]): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=FileSystemAwsIamStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileSystemAwsIamStore.d.ts","sourceRoot":"","sources":["../../../../src/persistence/file/FileSystemAwsIamStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,qBAAa,qBAAsB,YAAW,WAAW;IAIrD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAJ5B,OAAO,CAAC,SAAS,CAAmB;gBAGjB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EAClC,SAAS,CAAC,EAAE,iBAAiB;IAS/B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,iBAAiB;IAKnB,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,GAAG,GAAG,GACjB,OAAO,CAAC,IAAI,CAAC;IAsBV,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAcvE,mBAAmB,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EACtC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,CAAC,GACf,OAAO,CAAC,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;IAS7C,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAKV,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAS/E,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,iBAAiB,EAC1B,gBAAgB,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,IAAI,CAAC;CA4BjB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { join, sep } from 'path';
|
|
2
|
+
import { resourcePrefix, resourceTypePrefix } from '../util.js';
|
|
3
|
+
import { FileSystemAdapter } from './FileSystemAdapter.js';
|
|
4
|
+
export class FileSystemAwsIamStore {
|
|
5
|
+
constructor(baseFolder, partition, fsAdapter) {
|
|
6
|
+
this.baseFolder = baseFolder;
|
|
7
|
+
this.partition = partition;
|
|
8
|
+
console.log(`Initializing FileSystemAwsIamStore with baseFolder: ${baseFolder}, partition: ${partition}`);
|
|
9
|
+
this.baseFolder = join(baseFolder, 'aws', partition);
|
|
10
|
+
this.fsAdapter = fsAdapter || new FileSystemAdapter();
|
|
11
|
+
}
|
|
12
|
+
accountPath(accountId) {
|
|
13
|
+
return join(this.baseFolder, 'accounts', accountId).toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
buildResourcePath(accountId, arn) {
|
|
16
|
+
return resourcePrefix(this.accountPath(accountId), arn, sep).toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
buildMetadataPath(accountId, arn, metadataType) {
|
|
19
|
+
const prefix = this.buildResourcePath(accountId, arn);
|
|
20
|
+
return join(prefix, `${metadataType}.json`).toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
async saveResourceMetadata(accountId, arn, metadataType, data) {
|
|
23
|
+
if (typeof data === 'string') {
|
|
24
|
+
data = data.trim();
|
|
25
|
+
}
|
|
26
|
+
if (data === undefined ||
|
|
27
|
+
data === null ||
|
|
28
|
+
data === '' ||
|
|
29
|
+
data === '{}' ||
|
|
30
|
+
data === '[]' ||
|
|
31
|
+
(Array.isArray(data) && data.length === 0) ||
|
|
32
|
+
(typeof data === 'object' && Object.keys(data).length === 0)) {
|
|
33
|
+
await this.deleteResourceMetadata(accountId, arn, metadataType);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const content = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
37
|
+
const filePath = this.buildMetadataPath(accountId, arn, metadataType);
|
|
38
|
+
await this.fsAdapter.writeFile(filePath, content);
|
|
39
|
+
}
|
|
40
|
+
async listResourceMetadata(accountId, arn) {
|
|
41
|
+
// List all files in the resource directory to find metadata types
|
|
42
|
+
const dirPath = this.buildResourcePath(accountId, arn);
|
|
43
|
+
// console.log(dirPath)
|
|
44
|
+
const files = await this.fsAdapter.listDirectory(dirPath);
|
|
45
|
+
// console.log(files)
|
|
46
|
+
// Filter for files that match the pattern of *.json
|
|
47
|
+
const metadataTypes = files
|
|
48
|
+
.filter((file) => file.endsWith('.json'))
|
|
49
|
+
.map((file) => file.replace('.json', '')); // Remove the .json extension
|
|
50
|
+
return metadataTypes;
|
|
51
|
+
}
|
|
52
|
+
async getResourceMetadata(accountId, arn, metadataType, defaultValue) {
|
|
53
|
+
const filePath = this.buildMetadataPath(accountId, arn, metadataType);
|
|
54
|
+
const contents = await this.fsAdapter.readFile(filePath);
|
|
55
|
+
if (!contents) {
|
|
56
|
+
return defaultValue;
|
|
57
|
+
}
|
|
58
|
+
return JSON.parse(contents);
|
|
59
|
+
}
|
|
60
|
+
async deleteResourceMetadata(accountId, arn, metadataType) {
|
|
61
|
+
const filePath = this.buildMetadataPath(accountId, arn, metadataType);
|
|
62
|
+
await this.fsAdapter.deleteFile(filePath);
|
|
63
|
+
}
|
|
64
|
+
async deleteResource(accountId, arn) {
|
|
65
|
+
const dirPath = this.buildResourcePath(accountId, arn);
|
|
66
|
+
await this.fsAdapter.deleteDirectory(dirPath);
|
|
67
|
+
}
|
|
68
|
+
async listResources(accountId, options) {
|
|
69
|
+
const dirPath = resourceTypePrefix(this.accountPath(accountId), { ...options, partition: this.partition }, sep);
|
|
70
|
+
return await this.fsAdapter.listDirectory(dirPath);
|
|
71
|
+
}
|
|
72
|
+
async syncResourceList(accountId, options, desiredResources) {
|
|
73
|
+
const dirPath = resourceTypePrefix(this.accountPath(accountId), { ...options, partition: this.partition }, sep);
|
|
74
|
+
const existingSubDirs = (await this.fsAdapter.listDirectory(dirPath)).map((subDir) => join(dirPath, subDir));
|
|
75
|
+
const desiredDirs = new Set(desiredResources.map((desiredArn) => {
|
|
76
|
+
const resourceDir = this.buildResourcePath(accountId, desiredArn);
|
|
77
|
+
return resourceDir;
|
|
78
|
+
}));
|
|
79
|
+
// console.log(desiredDirs)
|
|
80
|
+
// Identify resources that exist in storage but not in desiredResources.
|
|
81
|
+
const resourcesToDelete = existingSubDirs.filter((s) => !desiredDirs.has(s));
|
|
82
|
+
for (const resource of resourcesToDelete) {
|
|
83
|
+
// const resourceDir = join(dirPath, resource)
|
|
84
|
+
// console.log('Deleting resource directory:', resource)
|
|
85
|
+
await this.fsAdapter.deleteDirectory(resource);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=FileSystemAwsIamStore.js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
|
+
* Generate a resource prefix given a starting path, a resource ARN, and a separator.
|
|
3
|
+
* The function uses splitArnParts to get the parts of the ARN and then joins each non-empty part
|
|
4
|
+
* with the provided separator. The last segment (resourcePath) is URL encoded.
|
|
5
|
+
*
|
|
6
|
+
* @param startingPath - The starting path (e.g. a base folder)
|
|
7
|
+
* @param resourceArn - The full resource ARN.
|
|
8
|
+
* @param separator - The separator to use (e.g. '/' or '-').
|
|
9
|
+
* @returns A string that represents the resource prefix.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resourcePrefix(startingPath: string, resourceArn: string, separator: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Generate a resource type prefix based on the provided starting path and resource type parts.
|
|
14
|
+
*
|
|
15
|
+
* @param startingPath - The starting path (e.g. a base folder)
|
|
16
|
+
* @param parts - An object containing the components of the resource type
|
|
17
|
+
* @param separator - the separator to use for joining the parts. This could be '/' or any other string.
|
|
18
|
+
* @returns A string that represents the resource type prefix.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resourceTypePrefix(startingPath: string, parts: {
|
|
21
|
+
partition: string;
|
|
22
|
+
account?: string;
|
|
23
|
+
service: string;
|
|
24
|
+
region?: string;
|
|
25
|
+
resourceType?: string;
|
|
26
|
+
}, separator: string): string;
|
|
27
|
+
export declare function joinPathParts(parts: (string | undefined)[], separator: string): string;
|
|
28
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/persistence/util.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,MAAM,CAeR;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE;IACL,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,EACD,SAAS,EAAE,MAAM,GAChB,MAAM,CAKR;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKtF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { splitArnParts } from '../utils/arn.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a resource prefix given a starting path, a resource ARN, and a separator.
|
|
4
|
+
* The function uses splitArnParts to get the parts of the ARN and then joins each non-empty part
|
|
5
|
+
* with the provided separator. The last segment (resourcePath) is URL encoded.
|
|
6
|
+
*
|
|
7
|
+
* @param startingPath - The starting path (e.g. a base folder)
|
|
8
|
+
* @param resourceArn - The full resource ARN.
|
|
9
|
+
* @param separator - The separator to use (e.g. '/' or '-').
|
|
10
|
+
* @returns A string that represents the resource prefix.
|
|
11
|
+
*/
|
|
12
|
+
export function resourcePrefix(startingPath, resourceArn, separator) {
|
|
13
|
+
const parts = splitArnParts(resourceArn);
|
|
14
|
+
return joinPathParts([
|
|
15
|
+
startingPath,
|
|
16
|
+
parts.partition,
|
|
17
|
+
parts.service,
|
|
18
|
+
parts.region,
|
|
19
|
+
parts.accountId,
|
|
20
|
+
parts.resourceType,
|
|
21
|
+
parts.resourcePath ? encodeURIComponent(parts.resourcePath.trim()) : undefined
|
|
22
|
+
], separator);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generate a resource type prefix based on the provided starting path and resource type parts.
|
|
26
|
+
*
|
|
27
|
+
* @param startingPath - The starting path (e.g. a base folder)
|
|
28
|
+
* @param parts - An object containing the components of the resource type
|
|
29
|
+
* @param separator - the separator to use for joining the parts. This could be '/' or any other string.
|
|
30
|
+
* @returns A string that represents the resource type prefix.
|
|
31
|
+
*/
|
|
32
|
+
export function resourceTypePrefix(startingPath, parts, separator) {
|
|
33
|
+
return joinPathParts([startingPath, parts.partition, parts.service, parts.region, parts.account, parts.resourceType], separator);
|
|
34
|
+
}
|
|
35
|
+
export function joinPathParts(parts, separator) {
|
|
36
|
+
// Filter out undefined or empty strings
|
|
37
|
+
const filteredParts = parts.filter((part) => part !== undefined && part.trim() !== '');
|
|
38
|
+
// Join the remaining parts with a '/'
|
|
39
|
+
return filteredParts.join(separator);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/persistence/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAoB,EACpB,WAAmB,EACnB,SAAiB;IAEjB,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;IAExC,OAAO,aAAa,CAClB;QACE,YAAY;QACZ,KAAK,CAAC,SAAS;QACf,KAAK,CAAC,OAAO;QACb,KAAK,CAAC,MAAM;QACZ,KAAK,CAAC,SAAS;QACf,KAAK,CAAC,YAAY;QAClB,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;KAC/E,EACD,SAAS,CACV,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,YAAoB,EACpB,KAMC,EACD,SAAiB;IAEjB,OAAO,aAAa,CAClB,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC/F,SAAS,CACV,CAAA;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAA6B,EAAE,SAAiB;IAC5E,wCAAwC;IACxC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACtF,sCAAsC;IACtC,OAAO,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regions.d.ts","sourceRoot":"","sources":["../../src/regions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAA;AAGjE,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,iCAAiC,GAC7C,OAAO,CAAC,MAAM,EAAE,CAAC,CAUnB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AccountClient, ListRegionsCommand, RegionOptStatus } from '@aws-sdk/client-account';
|
|
2
|
+
import { isDefined } from './utils/types.js';
|
|
3
|
+
export async function getEnabledRegions(credentials) {
|
|
4
|
+
const accountClient = new AccountClient({ credentials });
|
|
5
|
+
const getRegionsCommand = new ListRegionsCommand({
|
|
6
|
+
RegionOptStatusContains: [RegionOptStatus.ENABLED, RegionOptStatus.ENABLED_BY_DEFAULT]
|
|
7
|
+
});
|
|
8
|
+
const result = await accountClient.send(getRegionsCommand);
|
|
9
|
+
const regions = result.Regions?.map((r) => r.RegionName).filter(isDefined) || [];
|
|
10
|
+
return regions;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=regions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regions.js","sourceRoot":"","sources":["../../src/regions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE5F,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,WAA8C;IAE9C,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,CAAA;IACxD,MAAM,iBAAiB,GAAG,IAAI,kBAAkB,CAAC;QAC/C,uBAAuB,EAAE,CAAC,eAAe,CAAC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC;KACvF,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAW,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;IAEjF,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAA;AAEzC,eAAO,MAAM,WAAW,EAAE,UAAU,EAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/services.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { AccessKeyLastUsed, AccessKeyMetadata, GroupDetail, IAMClient, LoginProfile, MFADevice, ManagedPolicyDetail, RoleDetail, Tag, User, UserDetail } from '@aws-sdk/client-iam';
|
|
2
|
+
import { Sync } from '../sync.js';
|
|
3
|
+
interface AccessKeyWithLastUsed extends AccessKeyMetadata {
|
|
4
|
+
lastUsed?: AccessKeyLastUsed;
|
|
5
|
+
}
|
|
6
|
+
export declare const AuthorizationDetailsSync: Sync;
|
|
7
|
+
/**
|
|
8
|
+
* Get the access keys for an IAM user.
|
|
9
|
+
*
|
|
10
|
+
* @param region The region to use for the API call
|
|
11
|
+
* @param credentials The credentials to use for the API call
|
|
12
|
+
* @param userName The name of the user to lookup the access keys for
|
|
13
|
+
* @returns Returns a list of access keys for the user. Will return an empty array if there are no access keys
|
|
14
|
+
*/
|
|
15
|
+
export declare function getAccessKeysForUser(client: IAMClient, userName: string): Promise<AccessKeyWithLastUsed[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Get the login profile for an IAM user if it exists.
|
|
18
|
+
*
|
|
19
|
+
* @param region The region to use for the API call
|
|
20
|
+
* @param credentials The credentials to use for the API call
|
|
21
|
+
* @param userName The name of the user to lookup the login profile for
|
|
22
|
+
* @returns Returns the login profile for the user if it exists. Otherwise returns undefined
|
|
23
|
+
*/
|
|
24
|
+
export declare function getLoginProfileForUser(client: IAMClient, userName: string): Promise<LoginProfile | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the MFA devices for an IAM user.
|
|
27
|
+
*
|
|
28
|
+
* @param region The region to use for the API call
|
|
29
|
+
* @param credentials The credentials to use for the API call
|
|
30
|
+
* @param userName The name of the user to lookup the MFA devices for
|
|
31
|
+
* @returns Returns a list of MFA devices for the user. Will return an empty array if there are no MFA devices.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getMfaDevicesForUser(client: IAMClient, userName: string): Promise<MFADevice[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Parses a username out of an ARN. Does not validate the ARN is a valid IAM user ARN.
|
|
36
|
+
*
|
|
37
|
+
* @param arn The arn to parse the username out of
|
|
38
|
+
* @returns Returns the username from the ARN
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseUsernameFromArn(arn: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Get all IAM users in an account.
|
|
43
|
+
*
|
|
44
|
+
* @param region The region to use for the API call
|
|
45
|
+
* @param credentials The credentials to use for the API call
|
|
46
|
+
* @returns Returns a list of all IAM users in the account
|
|
47
|
+
*/
|
|
48
|
+
export declare function getAllUsers(client: IAMClient): Promise<User[]>;
|
|
49
|
+
export interface UserWithMetadata extends User {
|
|
50
|
+
metadata: {
|
|
51
|
+
hasConsoleAccess: boolean;
|
|
52
|
+
createdAt: Date;
|
|
53
|
+
passwordChanged?: Date;
|
|
54
|
+
passwordLastUsed?: Date;
|
|
55
|
+
mfaEnabled: boolean;
|
|
56
|
+
numberAccessKeys: number;
|
|
57
|
+
oldestAccessKey?: Date;
|
|
58
|
+
accessKeyLastUsed?: Date;
|
|
59
|
+
accessKeys?: AccessKeyWithLastUsed[];
|
|
60
|
+
managedPolicies: string[];
|
|
61
|
+
inlinePolicies: any[];
|
|
62
|
+
groups: string[];
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get all IAM users in an account with metadata about each user.
|
|
67
|
+
*
|
|
68
|
+
* @param region The region to use for the API call
|
|
69
|
+
* @param credentials The credentials to use for the API call
|
|
70
|
+
* @returns Returns all users for the account with metadata about each user
|
|
71
|
+
*/
|
|
72
|
+
export declare function getAllUsersWithMetadata(client: IAMClient): Promise<UserWithMetadata[]>;
|
|
73
|
+
interface ManagedPolicyDetailWithExtraData extends ManagedPolicyDetail {
|
|
74
|
+
Tags?: Tag[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Return the results of the Authorization Details call for this account.
|
|
78
|
+
* Excludes users and AWS managed policies.
|
|
79
|
+
*
|
|
80
|
+
* @param credentials The credentials to use for the API call
|
|
81
|
+
* @returns Returns the results of the Authorization Details call for this account
|
|
82
|
+
*/
|
|
83
|
+
export declare function getAuthorizationDetails(client: IAMClient): Promise<{
|
|
84
|
+
groups: GroupDetail[];
|
|
85
|
+
roles: RoleDetail[];
|
|
86
|
+
policies: ManagedPolicyDetailWithExtraData[];
|
|
87
|
+
awsManagedPolicies: ManagedPolicyDetail[];
|
|
88
|
+
users: UserDetail[];
|
|
89
|
+
}>;
|
|
90
|
+
interface AttachedPolicy {
|
|
91
|
+
name: string;
|
|
92
|
+
document: any;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets the policies that are attached directly to a role. Does not include managed policies.
|
|
96
|
+
*
|
|
97
|
+
* @param credentials The credentials to use for the API call
|
|
98
|
+
* @param roleName The name of the role to get the policies for
|
|
99
|
+
* @returns Returns the policies that are attached directly to the role
|
|
100
|
+
*/
|
|
101
|
+
export declare function getPoliciesAttachedDirectlyToRole(client: IAMClient, roleName: string): Promise<AttachedPolicy[]>;
|
|
102
|
+
export declare function getManagedPoliciesAttachedToRole(client: IAMClient, roleName: string): Promise<import("@aws-sdk/client-iam").AttachedPolicy[]>;
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=authorizationDetails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorizationDetails.d.ts","sourceRoot":"","sources":["../../../../src/syncs/iam/authorizationDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EAOjB,WAAW,EACX,SAAS,EAUT,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,GAAG,EACH,IAAI,EACJ,UAAU,EACX,MAAM,qBAAqB,CAAA;AAM5B,OAAO,EAAE,IAAI,EAAY,MAAM,YAAY,CAAA;AAE3C,UAAU,qBAAsB,SAAQ,iBAAiB;IACvD,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC7B;AAED,eAAO,MAAM,wBAAwB,EAAE,IAwJtC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAsBlC;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY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