@takeshape/util 8.97.0 → 8.99.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/es/encryption.js +10 -0
- package/lib/encryption.d.ts +6 -7
- package/lib/encryption.d.ts.map +1 -1
- package/lib/encryption.js +12 -0
- package/package.json +2 -2
package/es/encryption.js
CHANGED
|
@@ -57,4 +57,14 @@ export async function decryptDataKey(keyStr, config) {
|
|
|
57
57
|
encryptedKey: keyStr,
|
|
58
58
|
plaintextKey: res.Plaintext.toString(KEY_ENCODING)
|
|
59
59
|
};
|
|
60
|
+
}
|
|
61
|
+
export async function ensureDataKey(keyStr, config) {
|
|
62
|
+
if (keyStr) {
|
|
63
|
+
try {
|
|
64
|
+
return await decryptDataKey(keyStr, config);
|
|
65
|
+
} catch {// Ignore ciphertext error and generate a new key
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return generateDataKey(config);
|
|
60
70
|
}
|
package/lib/encryption.d.ts
CHANGED
|
@@ -4,13 +4,12 @@ export interface DataKeyConfig {
|
|
|
4
4
|
env: string;
|
|
5
5
|
}
|
|
6
6
|
export declare const encrypt: import("lodash").CurriedFunction2<string, string, string>;
|
|
7
|
-
export declare
|
|
8
|
-
export declare function generateDataKey(config: DataKeyConfig): Promise<{
|
|
9
|
-
encryptedKey: string;
|
|
10
|
-
plaintextKey: string;
|
|
11
|
-
}>;
|
|
12
|
-
export declare function decryptDataKey(keyStr: string, config: DataKeyConfig): Promise<{
|
|
7
|
+
export declare type EncryptionKeys = {
|
|
13
8
|
encryptedKey: string;
|
|
14
9
|
plaintextKey: string;
|
|
15
|
-
}
|
|
10
|
+
};
|
|
11
|
+
export declare const decrypt: import("lodash").CurriedFunction2<string, string, string>;
|
|
12
|
+
export declare function generateDataKey(config: DataKeyConfig): Promise<EncryptionKeys>;
|
|
13
|
+
export declare function decryptDataKey(keyStr: string, config: DataKeyConfig): Promise<EncryptionKeys>;
|
|
14
|
+
export declare function ensureDataKey(keyStr: string | undefined, config: DataKeyConfig): Promise<EncryptionKeys>;
|
|
16
15
|
//# sourceMappingURL=encryption.d.ts.map
|
package/lib/encryption.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/encryption.ts"],"names":[],"mappings":";AAUA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,OAAO,2DAOlB,CAAC;AAEH,eAAO,MAAM,OAAO,2DAalB,CAAC;AAEH,wBAAsB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/encryption.ts"],"names":[],"mappings":";AAUA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,OAAO,2DAOlB,CAAC;AAEH,oBAAY,cAAc,GAAG;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC,CAAC;AAE1E,eAAO,MAAM,OAAO,2DAalB,CAAC;AAEH,wBAAsB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAepF;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CASnG;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAU9G"}
|
package/lib/encryption.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.decrypt = void 0;
|
|
7
7
|
exports.decryptDataKey = decryptDataKey;
|
|
8
8
|
exports.encrypt = void 0;
|
|
9
|
+
exports.ensureDataKey = ensureDataKey;
|
|
9
10
|
exports.generateDataKey = generateDataKey;
|
|
10
11
|
|
|
11
12
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
@@ -80,4 +81,15 @@ async function decryptDataKey(keyStr, config) {
|
|
|
80
81
|
encryptedKey: keyStr,
|
|
81
82
|
plaintextKey: res.Plaintext.toString(KEY_ENCODING)
|
|
82
83
|
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function ensureDataKey(keyStr, config) {
|
|
87
|
+
if (keyStr) {
|
|
88
|
+
try {
|
|
89
|
+
return await decryptDataKey(keyStr, config);
|
|
90
|
+
} catch {// Ignore ciphertext error and generate a new key
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return generateDataKey(config);
|
|
83
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/util",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.99.0",
|
|
4
4
|
"description": "Shared utilities",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"es"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@takeshape/routing": "8.
|
|
24
|
+
"@takeshape/routing": "8.99.0",
|
|
25
25
|
"@types/url-parse": "^1.4.4",
|
|
26
26
|
"aws-sdk": "^2.802.0",
|
|
27
27
|
"classnames": "^2.2.5",
|