asherah 1.0.25 → 1.0.26
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/index.js +30 -33
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
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.encrypt = exports.decrypt = exports.setup = void 0;
|
|
7
|
-
const cobhan_1 =
|
|
8
|
-
const libasherah = cobhan_1.
|
|
4
|
+
const cobhan_1 = require("cobhan");
|
|
5
|
+
const libasherah = (0, cobhan_1.load_platform_library)('node_modules/asherah/binaries', 'libasherah', {
|
|
9
6
|
'Encrypt': ['int32', ['pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer']],
|
|
10
7
|
'Decrypt': ['int32', ['pointer', 'pointer', 'pointer', 'int64', 'pointer', 'int64', 'pointer']],
|
|
11
8
|
'Setup': ['int32', ['pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'int32', 'pointer', 'pointer', 'pointer', 'pointer', 'int32', 'int32', 'int32']],
|
|
12
9
|
});
|
|
13
10
|
function setup(config) {
|
|
14
|
-
const kmsTypeBuffer = cobhan_1.
|
|
15
|
-
const metastoreBuffer = cobhan_1.
|
|
16
|
-
const rdbmsConnectionStringBuffer = cobhan_1.
|
|
17
|
-
const dynamoDbEndpointBuffer = cobhan_1.
|
|
18
|
-
const dynamoDbRegionBuffer = cobhan_1.
|
|
19
|
-
const dynamoDbTableNameBuffer = cobhan_1.
|
|
11
|
+
const kmsTypeBuffer = (0, cobhan_1.string_to_cbuffer)(config.kmsType);
|
|
12
|
+
const metastoreBuffer = (0, cobhan_1.string_to_cbuffer)(config.metastore);
|
|
13
|
+
const rdbmsConnectionStringBuffer = (0, cobhan_1.string_to_cbuffer)(config.rdbmsConnectionString);
|
|
14
|
+
const dynamoDbEndpointBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbEndpoint);
|
|
15
|
+
const dynamoDbRegionBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbRegion);
|
|
16
|
+
const dynamoDbTableNameBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbTableName);
|
|
20
17
|
const enableRegionSuffixInt = config.enableRegionSuffix ? 1 : 0;
|
|
21
|
-
const serviceNameBuffer = cobhan_1.
|
|
22
|
-
const productIdBuffer = cobhan_1.
|
|
23
|
-
const preferredRegionBuffer = cobhan_1.
|
|
24
|
-
const regionMapBuffer = cobhan_1.
|
|
18
|
+
const serviceNameBuffer = (0, cobhan_1.string_to_cbuffer)(config.serviceName);
|
|
19
|
+
const productIdBuffer = (0, cobhan_1.string_to_cbuffer)(config.productId);
|
|
20
|
+
const preferredRegionBuffer = (0, cobhan_1.string_to_cbuffer)(config.preferredRegion);
|
|
21
|
+
const regionMapBuffer = (0, cobhan_1.string_to_cbuffer)(config.regionMap);
|
|
25
22
|
const verboseInt = config.verbose ? 1 : 0;
|
|
26
23
|
const sessionCacheInt = config.sessionCache ? 1 : 0;
|
|
27
24
|
const debugOutputInt = config.debugOutput ? 1 : 0;
|
|
@@ -32,41 +29,41 @@ function setup(config) {
|
|
|
32
29
|
}
|
|
33
30
|
exports.setup = setup;
|
|
34
31
|
function decrypt(partitionId, dataRowRecord) {
|
|
35
|
-
const partitionIdBuffer = cobhan_1.
|
|
36
|
-
const encryptedDataBuffer = cobhan_1.
|
|
37
|
-
const encryptedKeyBuffer = cobhan_1.
|
|
32
|
+
const partitionIdBuffer = (0, cobhan_1.string_to_cbuffer)(partitionId);
|
|
33
|
+
const encryptedDataBuffer = (0, cobhan_1.buffer_to_cbuffer)(dataRowRecord.Data);
|
|
34
|
+
const encryptedKeyBuffer = (0, cobhan_1.buffer_to_cbuffer)(dataRowRecord.Key.EncryptedKey);
|
|
38
35
|
const created = dataRowRecord.Key.Created;
|
|
39
|
-
const parentKeyIdBuffer = cobhan_1.
|
|
36
|
+
const parentKeyIdBuffer = (0, cobhan_1.string_to_cbuffer)(dataRowRecord.Key.ParentKeyMeta.ID);
|
|
40
37
|
const parentKeyCreated = dataRowRecord.Key.ParentKeyMeta.Created;
|
|
41
|
-
const outputDataBuffer = cobhan_1.
|
|
38
|
+
const outputDataBuffer = (0, cobhan_1.allocate_cbuffer)(encryptedDataBuffer.length + 256);
|
|
42
39
|
const result = libasherah.Decrypt(partitionIdBuffer, encryptedDataBuffer, encryptedKeyBuffer, created, parentKeyIdBuffer, parentKeyCreated, outputDataBuffer);
|
|
43
40
|
if (result < 0) {
|
|
44
41
|
throw new Error('decrypt failed: ' + result);
|
|
45
42
|
}
|
|
46
|
-
return cobhan_1.
|
|
43
|
+
return (0, cobhan_1.cbuffer_to_buffer)(outputDataBuffer);
|
|
47
44
|
}
|
|
48
45
|
exports.decrypt = decrypt;
|
|
49
46
|
function encrypt(partitionId, data) {
|
|
50
|
-
const partitionIdBuffer = cobhan_1.
|
|
51
|
-
const dataBuffer = cobhan_1.
|
|
52
|
-
const outputEncryptedDataBuffer = cobhan_1.
|
|
53
|
-
const outputEncryptedKeyBuffer = cobhan_1.
|
|
54
|
-
const outputCreatedBuffer = cobhan_1.
|
|
55
|
-
const outputParentKeyIdBuffer = cobhan_1.
|
|
56
|
-
const outputParentKeyCreatedBuffer = cobhan_1.
|
|
47
|
+
const partitionIdBuffer = (0, cobhan_1.string_to_cbuffer)(partitionId);
|
|
48
|
+
const dataBuffer = (0, cobhan_1.buffer_to_cbuffer)(data);
|
|
49
|
+
const outputEncryptedDataBuffer = (0, cobhan_1.allocate_cbuffer)(data.length + 256);
|
|
50
|
+
const outputEncryptedKeyBuffer = (0, cobhan_1.allocate_cbuffer)(256);
|
|
51
|
+
const outputCreatedBuffer = (0, cobhan_1.int64_to_buffer)(0);
|
|
52
|
+
const outputParentKeyIdBuffer = (0, cobhan_1.allocate_cbuffer)(256);
|
|
53
|
+
const outputParentKeyCreatedBuffer = (0, cobhan_1.int64_to_buffer)(0);
|
|
57
54
|
const result = libasherah.Encrypt(partitionIdBuffer, dataBuffer, outputEncryptedDataBuffer, outputEncryptedKeyBuffer, outputCreatedBuffer, outputParentKeyIdBuffer, outputParentKeyCreatedBuffer);
|
|
58
55
|
if (result < 0) {
|
|
59
56
|
throw new Error('encrypt failed: ' + result);
|
|
60
57
|
}
|
|
61
|
-
const parentKeyId = cobhan_1.
|
|
58
|
+
const parentKeyId = (0, cobhan_1.cbuffer_to_string)(outputParentKeyIdBuffer);
|
|
62
59
|
const dataRowRecord = {
|
|
63
|
-
Data: cobhan_1.
|
|
60
|
+
Data: (0, cobhan_1.cbuffer_to_buffer)(outputEncryptedDataBuffer),
|
|
64
61
|
Key: {
|
|
65
|
-
EncryptedKey: cobhan_1.
|
|
66
|
-
Created: cobhan_1.
|
|
62
|
+
EncryptedKey: (0, cobhan_1.cbuffer_to_buffer)(outputEncryptedKeyBuffer),
|
|
63
|
+
Created: (0, cobhan_1.buffer_to_int64)(outputCreatedBuffer),
|
|
67
64
|
ParentKeyMeta: {
|
|
68
65
|
ID: parentKeyId,
|
|
69
|
-
Created: cobhan_1.
|
|
66
|
+
Created: (0, cobhan_1.buffer_to_int64)(outputParentKeyCreatedBuffer)
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asherah",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "Asherah envelope encryption and key rotation library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"eslint": "^8.10.0",
|
|
30
30
|
"typescript": "^4.6.2"
|
|
31
31
|
},
|
|
32
|
-
"types": "
|
|
32
|
+
"types": "dist/index.d.ts"
|
|
33
33
|
}
|