@creator.co/wapi 1.5.1 → 1.5.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.
package/dist/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EncryptionAlgorithmSpec } from '@aws-sdk/client-kms';
|
|
1
2
|
/**
|
|
2
3
|
* Represents a Crypto class that provides encryption and decryption functionality using AWS KMS.
|
|
3
4
|
*/
|
|
@@ -17,12 +18,17 @@ export default class Crypto {
|
|
|
17
18
|
*/
|
|
18
19
|
private readonly keyId;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
* Specifies the encryption algorithm used for encryption.
|
|
22
|
+
*/
|
|
23
|
+
private readonly encryptionAlgorithm;
|
|
24
|
+
/**
|
|
25
|
+
* Constructs a new instance of a KeyManager with the provided region, keyId, and optional encryption algorithm.
|
|
26
|
+
* @param {string} region - The region where the key is stored.
|
|
27
|
+
* @param {string} keyId - The ID of the key.
|
|
28
|
+
* @param {EncryptionAlgorithmSpec} [optEncryptionAlgorithm='RSAES_OAEP_SHA_256'] - The encryption algorithm to use (default is RSAES_OAEP_SHA_256).
|
|
23
29
|
* @returns None
|
|
24
30
|
*/
|
|
25
|
-
constructor(region: string, keyId: string);
|
|
31
|
+
constructor(region: string, keyId: string, optEncryptionAlgorithm?: EncryptionAlgorithmSpec);
|
|
26
32
|
/**
|
|
27
33
|
* Encrypts the given data using RSAES_OAEP_SHA_256 encryption algorithm.
|
|
28
34
|
* @param {string | any} data - The data to be encrypted.
|
|
@@ -42,14 +42,16 @@ var client_kms_1 = require("@aws-sdk/client-kms");
|
|
|
42
42
|
*/
|
|
43
43
|
var Crypto = /** @class */ (function () {
|
|
44
44
|
/**
|
|
45
|
-
* Constructs a new instance of the
|
|
46
|
-
* @param {string} region - The
|
|
47
|
-
* @param {string} keyId - The
|
|
45
|
+
* Constructs a new instance of a KeyManager with the provided region, keyId, and optional encryption algorithm.
|
|
46
|
+
* @param {string} region - The region where the key is stored.
|
|
47
|
+
* @param {string} keyId - The ID of the key.
|
|
48
|
+
* @param {EncryptionAlgorithmSpec} [optEncryptionAlgorithm='RSAES_OAEP_SHA_256'] - The encryption algorithm to use (default is RSAES_OAEP_SHA_256).
|
|
48
49
|
* @returns None
|
|
49
50
|
*/
|
|
50
|
-
function Crypto(region, keyId) {
|
|
51
|
+
function Crypto(region, keyId, optEncryptionAlgorithm) {
|
|
51
52
|
this.region = region;
|
|
52
53
|
this.keyId = keyId;
|
|
54
|
+
this.encryptionAlgorithm = optEncryptionAlgorithm || 'RSAES_OAEP_SHA_256';
|
|
53
55
|
this.client = new client_kms_1.KMSClient({ region: this.region });
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
@@ -66,7 +68,7 @@ var Crypto = /** @class */ (function () {
|
|
|
66
68
|
_a.trys.push([0, 2, , 3]);
|
|
67
69
|
return [4 /*yield*/, this.client.send(new client_kms_1.EncryptCommand({
|
|
68
70
|
KeyId: this.keyId,
|
|
69
|
-
EncryptionAlgorithm:
|
|
71
|
+
EncryptionAlgorithm: this.encryptionAlgorithm,
|
|
70
72
|
Plaintext: new TextEncoder().encode(typeof data === 'string' ? data : JSON.stringify(data)),
|
|
71
73
|
}))];
|
|
72
74
|
case 1:
|
|
@@ -97,7 +99,7 @@ var Crypto = /** @class */ (function () {
|
|
|
97
99
|
return [4 /*yield*/, this.client.send(new client_kms_1.DecryptCommand({
|
|
98
100
|
KeyId: this.keyId,
|
|
99
101
|
CiphertextBlob: Buffer.from(data, 'hex'),
|
|
100
|
-
EncryptionAlgorithm:
|
|
102
|
+
EncryptionAlgorithm: this.encryptionAlgorithm,
|
|
101
103
|
}))];
|
|
102
104
|
case 1:
|
|
103
105
|
resp = _a.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../../../src/Crypto/Crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;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AI,CAAC,MAAM,CAAC,IAAI,CACjC,IAAI,2BAAc,CAAC;gCACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gCACjB,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;gCACxC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;6BAC9C,CAAC,CACH,EAAA;;wBANK,IAAI,GAAG,SAMZ;wBACD,sBAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAA;;;wBAE/C,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAC,CAAC,CAAA;wBACtC,sBAAO,IAAI,EAAA;;;;;KAEd;IACH,aAAC;AAAD,CAAC,AA9ED,IA8EC"}
|
package/package.json
CHANGED
package/src/Crypto/Crypto.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
KMSClient,
|
|
3
|
+
EncryptCommand,
|
|
4
|
+
DecryptCommand,
|
|
5
|
+
EncryptionAlgorithmSpec,
|
|
6
|
+
} from '@aws-sdk/client-kms'
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Represents a Crypto class that provides encryption and decryption functionality using AWS KMS.
|
|
@@ -18,16 +23,22 @@ export default class Crypto {
|
|
|
18
23
|
* @type {string}
|
|
19
24
|
*/
|
|
20
25
|
private readonly keyId: string
|
|
26
|
+
/**
|
|
27
|
+
* Specifies the encryption algorithm used for encryption.
|
|
28
|
+
*/
|
|
29
|
+
private readonly encryptionAlgorithm: EncryptionAlgorithmSpec
|
|
21
30
|
|
|
22
31
|
/**
|
|
23
|
-
* Constructs a new instance of the
|
|
24
|
-
* @param {string} region - The
|
|
25
|
-
* @param {string} keyId - The
|
|
32
|
+
* Constructs a new instance of a KeyManager with the provided region, keyId, and optional encryption algorithm.
|
|
33
|
+
* @param {string} region - The region where the key is stored.
|
|
34
|
+
* @param {string} keyId - The ID of the key.
|
|
35
|
+
* @param {EncryptionAlgorithmSpec} [optEncryptionAlgorithm='RSAES_OAEP_SHA_256'] - The encryption algorithm to use (default is RSAES_OAEP_SHA_256).
|
|
26
36
|
* @returns None
|
|
27
37
|
*/
|
|
28
|
-
constructor(region: string, keyId: string) {
|
|
38
|
+
constructor(region: string, keyId: string, optEncryptionAlgorithm?: EncryptionAlgorithmSpec) {
|
|
29
39
|
this.region = region
|
|
30
40
|
this.keyId = keyId
|
|
41
|
+
this.encryptionAlgorithm = optEncryptionAlgorithm || 'RSAES_OAEP_SHA_256'
|
|
31
42
|
this.client = new KMSClient({ region: this.region })
|
|
32
43
|
}
|
|
33
44
|
|
|
@@ -41,7 +52,7 @@ export default class Crypto {
|
|
|
41
52
|
const resp = await this.client.send(
|
|
42
53
|
new EncryptCommand({
|
|
43
54
|
KeyId: this.keyId,
|
|
44
|
-
EncryptionAlgorithm:
|
|
55
|
+
EncryptionAlgorithm: this.encryptionAlgorithm,
|
|
45
56
|
Plaintext: new TextEncoder().encode(
|
|
46
57
|
typeof data === 'string' ? data : JSON.stringify(data)
|
|
47
58
|
),
|
|
@@ -66,7 +77,7 @@ export default class Crypto {
|
|
|
66
77
|
new DecryptCommand({
|
|
67
78
|
KeyId: this.keyId,
|
|
68
79
|
CiphertextBlob: Buffer.from(data, 'hex'),
|
|
69
|
-
EncryptionAlgorithm:
|
|
80
|
+
EncryptionAlgorithm: this.encryptionAlgorithm,
|
|
70
81
|
})
|
|
71
82
|
)
|
|
72
83
|
return new TextDecoder().decode(resp.Plaintext)
|