@activepieces/piece-amazon-s3 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -3
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/lib/actions/decrypt-pgp-file.d.ts +12 -0
- package/src/lib/actions/decrypt-pgp-file.js +185 -0
- package/src/lib/actions/decrypt-pgp-file.js.map +1 -0
- package/src/lib/common.d.ts +6 -0
- package/src/lib/common.js +13 -0
- package/src/lib/common.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-amazon-s3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@aws-sdk/client-s3": "3.637.0",
|
|
6
|
+
"@aws-sdk/client-secrets-manager": "^3.0.0",
|
|
6
7
|
"@aws-sdk/s3-request-presigner": "3.658.1",
|
|
7
8
|
"@sinclair/typebox": "0.34.11",
|
|
9
|
+
"ai": "5.0.104",
|
|
8
10
|
"axios": "1.13.1",
|
|
9
11
|
"axios-retry": "4.4.1",
|
|
10
12
|
"dayjs": "1.11.9",
|
|
11
13
|
"deepmerge-ts": "7.1.0",
|
|
12
14
|
"form-data": "4.0.4",
|
|
15
|
+
"i18next": "23.13.0",
|
|
13
16
|
"mime-types": "2.1.35",
|
|
14
17
|
"nanoid": "3.3.8",
|
|
18
|
+
"openpgp": "^6.3.0",
|
|
15
19
|
"semver": "7.6.0",
|
|
16
20
|
"socket.io-client": "4.8.1",
|
|
17
21
|
"zod": "4.1.13",
|
|
18
|
-
"@activepieces/pieces-common": "0.11.
|
|
22
|
+
"@activepieces/pieces-common": "0.11.1",
|
|
19
23
|
"@activepieces/pieces-framework": "0.23.0",
|
|
20
|
-
"@activepieces/shared": "0.
|
|
24
|
+
"@activepieces/shared": "0.32.0",
|
|
21
25
|
"tslib": "2.6.2"
|
|
22
26
|
},
|
|
23
27
|
"resolutions": {
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const generate_signed_url_1 = require("./lib/actions/generate-signed-url");
|
|
|
12
12
|
const move_file_1 = require("./lib/actions/move-file");
|
|
13
13
|
const delete_file_1 = require("./lib/actions/delete-file");
|
|
14
14
|
const list_files_1 = require("./lib/actions/list-files");
|
|
15
|
+
const decrypt_pgp_file_1 = require("./lib/actions/decrypt-pgp-file");
|
|
15
16
|
const description = `
|
|
16
17
|
This piece allows you to upload files to Amazon S3 or other S3 compatible services.
|
|
17
18
|
|
|
@@ -195,7 +196,7 @@ exports.amazonS3 = (0, pieces_framework_1.createPiece)({
|
|
|
195
196
|
authors: ["Willianwg", "kishanprmr", "MoShizzle", "AbdulTheActivePiecer", "khaledmashaly", "abuaboud", "Kevinyu-alan"],
|
|
196
197
|
categories: [shared_1.PieceCategory.DEVELOPER_TOOLS],
|
|
197
198
|
auth: exports.amazonS3Auth,
|
|
198
|
-
actions: [upload_file_1.amazons3UploadFile, read_file_1.readFile, generate_signed_url_1.generateSignedUrl, move_file_1.moveFile, delete_file_1.deleteFile, list_files_1.listFiles],
|
|
199
|
+
actions: [upload_file_1.amazons3UploadFile, read_file_1.readFile, generate_signed_url_1.generateSignedUrl, move_file_1.moveFile, delete_file_1.deleteFile, list_files_1.listFiles, decrypt_pgp_file_1.decryptPgpFile],
|
|
199
200
|
triggers: [new_file_1.newFile],
|
|
200
201
|
});
|
|
201
202
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/amazon-s3/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,iDAAqD;AACrD,uDAAmD;AACnD,2DAA+D;AAC/D,yCAAwC;AACxC,sDAAkD;AAClD,2EAAsE;AACtE,uDAAmD;AACnD,2DAAuD;AACvD,yDAAqD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/amazon-s3/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,iDAAqD;AACrD,uDAAmD;AACnD,2DAA+D;AAC/D,yCAAwC;AACxC,sDAAkD;AAClD,2EAAsE;AACtE,uDAAmD;AACnD,2DAAuD;AACvD,yDAAqD;AACrD,qEAAgE;AAEhE,MAAM,WAAW,GAAG;;;;;;CAMnB,CAAC;AAEW,QAAA,YAAY,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,WAAW;IACxB,KAAK,EAAE;QACL,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,eAAe,EAAE,4BAAS,CAAC,UAAU,CAAC;YACpC,WAAW,EAAE,mBAAmB;YAChC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC9B,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,SAAS;wBAChB,KAAK,EAAE,WAAW;qBACnB;oBACD;wBACE,KAAK,EAAE,mCAAmC;wBAC1C,KAAK,EAAE,WAAW;qBACnB;oBACD;wBACE,KAAK,EAAE,4BAA4B;wBACnC,KAAK,EAAE,WAAW;qBACnB;oBACD;wBACE,KAAK,EAAE,qCAAqC;wBAC5C,KAAK,EAAE,WAAW;qBACnB;oBACD;wBACE,KAAK,EAAE,8BAA8B;wBACrC,KAAK,EA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,EAAC,eAAe,EAAC,UAAU,EAAE,cAAc,CAAC;IACjH,UAAU,EAAE,CAAC,sBAAa,CAAC,eAAe,CAAC;IAC3C,IAAI,EAAE,oBAAY;IAClB,OAAO,EAAE,CAAC,gCAAkB,EAAE,oBAAQ,EAAE,uCAAiB,EAAE,oBAAQ,EAAE,wBAAU,EAAE,sBAAS,EAAE,iCAAc,CAAC;IAC3G,QAAQ,EAAE,CAAC,kBAAO,CAAC;CACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const decryptPgpFile: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
accessKeyId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
secretAccessKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
endpoint: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
7
|
+
}>, {
|
|
8
|
+
key: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
secretArn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
passphraseArn: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
secretsManagerRegion: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decryptPgpFile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
7
|
+
const openpgp = tslib_1.__importStar(require("openpgp"));
|
|
8
|
+
const __1 = require("../..");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
exports.decryptPgpFile = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: __1.amazonS3Auth,
|
|
12
|
+
name: 'decrypt-pgp-file',
|
|
13
|
+
displayName: 'Decrypt PGP File',
|
|
14
|
+
description: 'Decrypt a PGP encrypted file from S3 using a private key stored in AWS Secrets Manager',
|
|
15
|
+
props: {
|
|
16
|
+
key: pieces_framework_1.Property.ShortText({
|
|
17
|
+
displayName: 'S3 File Key',
|
|
18
|
+
description: 'The key (path) of the encrypted file in S3',
|
|
19
|
+
required: true,
|
|
20
|
+
}),
|
|
21
|
+
secretArn: pieces_framework_1.Property.ShortText({
|
|
22
|
+
displayName: 'Secret ARN',
|
|
23
|
+
description: 'The ARN of the secret in AWS Secrets Manager containing the PGP private key',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
passphraseArn: pieces_framework_1.Property.ShortText({
|
|
27
|
+
displayName: 'Passphrase ARN',
|
|
28
|
+
description: 'Optional ARN of the secret in AWS Secrets Manager containing the passphrase for the private key (if the key is encrypted)',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
secretsManagerRegion: pieces_framework_1.Property.ShortText({
|
|
32
|
+
displayName: 'Secrets Manager Region',
|
|
33
|
+
description: 'The AWS region where the Secrets Manager secret is stored (defaults to S3 region if not provided)',
|
|
34
|
+
required: false,
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
run(context) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const { bucket } = context.auth.props;
|
|
41
|
+
const { key, secretArn, passphraseArn, secretsManagerRegion } = context.propsValue;
|
|
42
|
+
const { accessKeyId, secretAccessKey, region } = context.auth.props;
|
|
43
|
+
// Create S3 client
|
|
44
|
+
const s3 = (0, common_1.createS3)(context.auth.props);
|
|
45
|
+
// Download the encrypted file from S3
|
|
46
|
+
let encryptedData;
|
|
47
|
+
try {
|
|
48
|
+
const file = yield s3.getObject({
|
|
49
|
+
Bucket: bucket,
|
|
50
|
+
Key: key,
|
|
51
|
+
});
|
|
52
|
+
const base64 = yield ((_a = file.Body) === null || _a === void 0 ? void 0 : _a.transformToString('base64'));
|
|
53
|
+
if (!base64) {
|
|
54
|
+
throw new Error(`Could not read file ${key} from S3`);
|
|
55
|
+
}
|
|
56
|
+
encryptedData = Buffer.from(base64, 'base64');
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new Error(`Failed to download file from S3: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
60
|
+
}
|
|
61
|
+
// Create AWS Secrets Manager client
|
|
62
|
+
const secretsClient = (0, common_1.createSecretsManagerClient)({
|
|
63
|
+
accessKeyId: accessKeyId,
|
|
64
|
+
secretAccessKey: secretAccessKey,
|
|
65
|
+
region: secretsManagerRegion || region,
|
|
66
|
+
});
|
|
67
|
+
// Fetch the secret key from AWS Secrets Manager
|
|
68
|
+
let privateKeyArmored;
|
|
69
|
+
try {
|
|
70
|
+
const command = new client_secrets_manager_1.GetSecretValueCommand({
|
|
71
|
+
SecretId: secretArn,
|
|
72
|
+
});
|
|
73
|
+
const response = yield secretsClient.send(command);
|
|
74
|
+
if (!response.SecretString) {
|
|
75
|
+
throw new Error(`Secret ${secretArn} does not contain a string value`);
|
|
76
|
+
}
|
|
77
|
+
// Trim whitespace from the key (AWS Secrets Manager might add extra whitespace)
|
|
78
|
+
privateKeyArmored = response.SecretString.trim();
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
// Provide more specific error messages for common issues
|
|
82
|
+
if (error.name === 'AccessDeniedException') {
|
|
83
|
+
throw new Error(`Access denied when retrieving secret ${secretArn}. ` +
|
|
84
|
+
`Please ensure your AWS credentials have the secretsmanager:GetSecretValue permission for this secret.`);
|
|
85
|
+
}
|
|
86
|
+
if (error.name === 'ResourceNotFoundException') {
|
|
87
|
+
throw new Error(`Secret ${secretArn} not found. Please verify the secret ARN is correct and exists in region ${secretsManagerRegion || region}.`);
|
|
88
|
+
}
|
|
89
|
+
if (error.name === 'InvalidParameterException') {
|
|
90
|
+
throw new Error(`Invalid secret ARN: ${secretArn}. Please verify the ARN format is correct.`);
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Failed to retrieve secret from AWS Secrets Manager: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
93
|
+
}
|
|
94
|
+
// Fetch the passphrase from AWS Secrets Manager if provided
|
|
95
|
+
let passphrase;
|
|
96
|
+
if (passphraseArn) {
|
|
97
|
+
try {
|
|
98
|
+
const passphraseCommand = new client_secrets_manager_1.GetSecretValueCommand({
|
|
99
|
+
SecretId: passphraseArn,
|
|
100
|
+
});
|
|
101
|
+
const passphraseResponse = yield secretsClient.send(passphraseCommand);
|
|
102
|
+
if (!passphraseResponse.SecretString) {
|
|
103
|
+
throw new Error(`Secret ${passphraseArn} does not contain a string value`);
|
|
104
|
+
}
|
|
105
|
+
passphrase = passphraseResponse.SecretString.trim();
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
// Provide more specific error messages for common issues
|
|
109
|
+
if (error.name === 'AccessDeniedException') {
|
|
110
|
+
throw new Error(`Access denied when retrieving passphrase secret ${passphraseArn}. ` +
|
|
111
|
+
`Please ensure your AWS credentials have the secretsmanager:GetSecretValue permission for this secret.`);
|
|
112
|
+
}
|
|
113
|
+
if (error.name === 'ResourceNotFoundException') {
|
|
114
|
+
throw new Error(`Passphrase secret ${passphraseArn} not found. Please verify the secret ARN is correct and exists in region ${secretsManagerRegion || region}.`);
|
|
115
|
+
}
|
|
116
|
+
if (error.name === 'InvalidParameterException') {
|
|
117
|
+
throw new Error(`Invalid passphrase secret ARN: ${passphraseArn}. Please verify the ARN format is correct.`);
|
|
118
|
+
}
|
|
119
|
+
throw new Error(`Failed to retrieve passphrase from AWS Secrets Manager: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Read the encrypted file data
|
|
123
|
+
const encryptedString = encryptedData.toString('utf8');
|
|
124
|
+
// Decrypt the file using OpenPGP
|
|
125
|
+
try {
|
|
126
|
+
let message;
|
|
127
|
+
try {
|
|
128
|
+
message = yield openpgp.readMessage({
|
|
129
|
+
armoredMessage: encryptedString,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch (_c) {
|
|
133
|
+
// If armored fails, try as binary
|
|
134
|
+
message = yield openpgp.readMessage({
|
|
135
|
+
binaryMessage: encryptedData,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// Read the private key
|
|
139
|
+
let privateKey = yield openpgp.readPrivateKey({
|
|
140
|
+
armoredKey: privateKeyArmored,
|
|
141
|
+
});
|
|
142
|
+
if (!privateKey.isPrivate()) {
|
|
143
|
+
throw new Error('The provided key is not a private key. Please ensure you are using a private key, not a public key.');
|
|
144
|
+
}
|
|
145
|
+
// Check if the key is encrypted and needs a passphrase
|
|
146
|
+
if (!privateKey.isDecrypted()) {
|
|
147
|
+
if (!passphrase) {
|
|
148
|
+
throw new Error('Private key is encrypted but no passphrase was provided. Please provide a Passphrase ARN.');
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const decryptedKey = yield openpgp.decryptKey({
|
|
152
|
+
privateKey: privateKey,
|
|
153
|
+
passphrase: passphrase,
|
|
154
|
+
});
|
|
155
|
+
privateKey = decryptedKey;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
throw new Error(`Failed to unlock private key with passphrase: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Decrypt the message
|
|
162
|
+
const decrypted = yield openpgp.decrypt({
|
|
163
|
+
message,
|
|
164
|
+
decryptionKeys: privateKey,
|
|
165
|
+
format: 'binary',
|
|
166
|
+
config: {
|
|
167
|
+
allowInsecureDecryptionWithSigningKeys: false,
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
// Get the decrypted data
|
|
171
|
+
const decryptedData = new Uint8Array(yield decrypted.data);
|
|
172
|
+
// Write the decrypted file
|
|
173
|
+
const fileName = (_b = key.split("/").at(-1)) === null || _b === void 0 ? void 0 : _b.toLowerCase().replace(/\.(pgp|gpg)$/i, '');
|
|
174
|
+
return yield context.files.write({
|
|
175
|
+
fileName: fileName !== null && fileName !== void 0 ? fileName : 'decrypted_file',
|
|
176
|
+
data: Buffer.from(decryptedData),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
throw new Error(`Failed to decrypt file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
//# sourceMappingURL=decrypt-pgp-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decrypt-pgp-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/amazon-s3/src/lib/actions/decrypt-pgp-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,4EAAwE;AACxE,yDAAmC;AACnC,6BAAqC;AACrC,sCAAiE;AAEpD,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,gBAAY;IAClB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,wFAAwF;IACrG,KAAK,EAAE;QACL,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACtB,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAA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BACtC,OAAO;oBACP,cAAc,EAAE,UAAU;oBAC1B,MAAM,EAAE,QAAQ;oBAChB,MAAM,EAAE;wBACN,sCAAsC,EAAE,KAAK;qBAC9C;iBACF,CAAC,CAAC;gBAEH,yBAAyB;gBACzB,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;gBAE3D,2BAA2B;gBAC3B,MAAM,QAAQ,GAAG,MAAA,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,0CAAE,WAAW,GAAG,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;gBAEnF,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;oBAC/B,QAAQ,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,gBAAgB;oBACtC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;iBACjC,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;YACzG,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
package/src/lib/common.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { S3 } from '@aws-sdk/client-s3';
|
|
2
|
+
import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
|
|
2
3
|
export declare function createS3(auth: {
|
|
3
4
|
accessKeyId: string;
|
|
4
5
|
secretAccessKey: string;
|
|
5
6
|
region: string | undefined;
|
|
6
7
|
endpoint: string | undefined;
|
|
7
8
|
}): S3;
|
|
9
|
+
export declare function createSecretsManagerClient(auth: {
|
|
10
|
+
accessKeyId: string;
|
|
11
|
+
secretAccessKey: string;
|
|
12
|
+
region: string | undefined;
|
|
13
|
+
}): SecretsManagerClient;
|
package/src/lib/common.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createS3 = createS3;
|
|
4
|
+
exports.createSecretsManagerClient = createSecretsManagerClient;
|
|
4
5
|
const shared_1 = require("@activepieces/shared");
|
|
5
6
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
7
|
+
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
6
8
|
function createS3(auth) {
|
|
7
9
|
const s3 = new client_s3_1.S3({
|
|
8
10
|
credentials: {
|
|
@@ -15,4 +17,15 @@ function createS3(auth) {
|
|
|
15
17
|
});
|
|
16
18
|
return s3;
|
|
17
19
|
}
|
|
20
|
+
function createSecretsManagerClient(auth) {
|
|
21
|
+
const client = new client_secrets_manager_1.SecretsManagerClient({
|
|
22
|
+
credentials: {
|
|
23
|
+
accessKeyId: auth.accessKeyId,
|
|
24
|
+
secretAccessKey: auth.secretAccessKey,
|
|
25
|
+
},
|
|
26
|
+
region: auth.region,
|
|
27
|
+
endpoint: undefined,
|
|
28
|
+
});
|
|
29
|
+
return client;
|
|
30
|
+
}
|
|
18
31
|
//# sourceMappingURL=common.js.map
|
package/src/lib/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/community/amazon-s3/src/lib/common.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/community/amazon-s3/src/lib/common.ts"],"names":[],"mappings":";;AAIA,4BAiBC;AAED,gEAcC;AArCD,iDAA6C;AAC7C,kDAAwC;AACxC,4EAAuE;AAEvE,SAAgB,QAAQ,CAAC,IAKxB;IACC,MAAM,EAAE,GAAG,IAAI,cAAE,CAAC;QAChB,WAAW,EAAE;YACX,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC;QACD,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAChD,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EACN,IAAI,CAAC,QAAQ,KAAK,EAAE,IAAI,IAAA,cAAK,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ;KAC3E,CAAC,CAAC;IACH,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAgB,0BAA0B,CAAC,IAI1C;IACC,MAAM,MAAM,GAAG,IAAI,6CAAoB,CAAC;QACtC,WAAW,EAAE;YACX,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC;QACD,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,SAAS;KACpB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|