@cumulus/common 18.2.0-alpha.0 → 18.2.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/kms.js +6 -11
- package/package.json +5 -5
package/kms.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.KMS = void 0;
|
|
7
|
-
const
|
|
4
|
+
const services_1 = require("@cumulus/aws-client/services");
|
|
8
5
|
const errors_1 = require("@cumulus/errors");
|
|
9
6
|
const util_1 = require("./util");
|
|
10
7
|
const KMSDecryptionFailed = (0, errors_1.createErrorType)('KMSDecryptionFailed');
|
|
@@ -13,27 +10,25 @@ class KMS {
|
|
|
13
10
|
(0, util_1.deprecate)('@cumulus/common/key-pair-provider', '1.17.0', '@cumulus/aws-client/KMS.encrypt');
|
|
14
11
|
const params = {
|
|
15
12
|
KeyId: kmsId,
|
|
16
|
-
Plaintext: text,
|
|
13
|
+
Plaintext: new TextEncoder().encode(text),
|
|
17
14
|
};
|
|
18
|
-
const
|
|
19
|
-
const { CiphertextBlob } = await kms.encrypt(params).promise();
|
|
15
|
+
const { CiphertextBlob } = await (0, services_1.kms)().encrypt(params);
|
|
20
16
|
if (!CiphertextBlob) {
|
|
21
17
|
throw new Error('Encryption failed, undefined CiphertextBlob returned');
|
|
22
18
|
}
|
|
23
|
-
return CiphertextBlob.toString('base64');
|
|
19
|
+
return Buffer.from(CiphertextBlob).toString('base64');
|
|
24
20
|
}
|
|
25
21
|
static async decrypt(text) {
|
|
26
22
|
(0, util_1.deprecate)('@cumulus/common/key-pair-provider', '1.17.0', '@cumulus/aws-client/KMS.decryptBase64String');
|
|
27
23
|
const params = {
|
|
28
24
|
CiphertextBlob: Buffer.from(text, 'base64'),
|
|
29
25
|
};
|
|
30
|
-
const kms = new aws_sdk_1.default.KMS();
|
|
31
26
|
try {
|
|
32
|
-
const { Plaintext } = await kms.decrypt(params)
|
|
27
|
+
const { Plaintext } = await (0, services_1.kms)().decrypt(params);
|
|
33
28
|
if (!Plaintext) {
|
|
34
29
|
throw new Error('Decryption failed, undefined Plaintext returned');
|
|
35
30
|
}
|
|
36
|
-
return Plaintext.toString();
|
|
31
|
+
return Buffer.from(Plaintext).toString();
|
|
37
32
|
}
|
|
38
33
|
catch (error) {
|
|
39
34
|
if (error.toString().includes('InvalidCiphertextException')) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/common",
|
|
3
|
-
"version": "18.2.0
|
|
3
|
+
"version": "18.2.0",
|
|
4
4
|
"description": "Common utilities used across tasks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"GIBS",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@aws-sdk/client-s3": "^3.447.0",
|
|
46
46
|
"@aws-sdk/signature-v4-crt": "^3.447.0",
|
|
47
|
-
"@cumulus/aws-client": "18.2.0
|
|
48
|
-
"@cumulus/errors": "18.2.0
|
|
49
|
-
"@cumulus/logger": "18.2.0
|
|
47
|
+
"@cumulus/aws-client": "18.2.0",
|
|
48
|
+
"@cumulus/errors": "18.2.0",
|
|
49
|
+
"@cumulus/logger": "18.2.0",
|
|
50
50
|
"ajv": "^6.12.3",
|
|
51
51
|
"aws-sdk": "^2.1492.0",
|
|
52
52
|
"follow-redirects": "^1.2.4",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"@types/node-forge": "^0.9.5",
|
|
69
69
|
"@types/url-join": "^4.0.0"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "c3b3d1a8accfbd53df89382ba2e9fa7dcbf46b6e"
|
|
72
72
|
}
|