asherah 1.0.25 → 1.0.28
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.
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare type AsherahConfig = {
|
|
|
28
28
|
sessionCache: boolean;
|
|
29
29
|
debugOutput: boolean;
|
|
30
30
|
};
|
|
31
|
+
export declare function setupJson(config: AsherahConfig): void;
|
|
31
32
|
export declare function setup(config: AsherahConfig): void;
|
|
32
33
|
export declare function decrypt(partitionId: string, dataRowRecord: DataRowRecord): Buffer;
|
|
33
34
|
export declare function encrypt(partitionId: string, data: Buffer): DataRowRecord;
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
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
|
-
exports.encrypt = exports.decrypt = exports.setup = void 0;
|
|
7
|
-
const cobhan_1 =
|
|
8
|
-
const libasherah = cobhan_1.
|
|
3
|
+
exports.encrypt = exports.decrypt = exports.setup = exports.setupJson = void 0;
|
|
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']],
|
|
9
|
+
'SetupJson': ['int32', ['pointer']]
|
|
12
10
|
});
|
|
11
|
+
function setupJson(config) {
|
|
12
|
+
const configJsonBuffer = (0, cobhan_1.string_to_cbuffer)(JSON.stringify(config));
|
|
13
|
+
const result = libasherah.SetupJson(configJsonBuffer);
|
|
14
|
+
if (result < 0) {
|
|
15
|
+
throw new Error('setupJson failed: ' + result);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.setupJson = setupJson;
|
|
13
19
|
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.
|
|
20
|
+
const kmsTypeBuffer = (0, cobhan_1.string_to_cbuffer)(config.kmsType);
|
|
21
|
+
const metastoreBuffer = (0, cobhan_1.string_to_cbuffer)(config.metastore);
|
|
22
|
+
const rdbmsConnectionStringBuffer = (0, cobhan_1.string_to_cbuffer)(config.rdbmsConnectionString);
|
|
23
|
+
const dynamoDbEndpointBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbEndpoint);
|
|
24
|
+
const dynamoDbRegionBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbRegion);
|
|
25
|
+
const dynamoDbTableNameBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbTableName);
|
|
20
26
|
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.
|
|
27
|
+
const serviceNameBuffer = (0, cobhan_1.string_to_cbuffer)(config.serviceName);
|
|
28
|
+
const productIdBuffer = (0, cobhan_1.string_to_cbuffer)(config.productId);
|
|
29
|
+
const preferredRegionBuffer = (0, cobhan_1.string_to_cbuffer)(config.preferredRegion);
|
|
30
|
+
const regionMapBuffer = (0, cobhan_1.string_to_cbuffer)(config.regionMap);
|
|
25
31
|
const verboseInt = config.verbose ? 1 : 0;
|
|
26
32
|
const sessionCacheInt = config.sessionCache ? 1 : 0;
|
|
27
33
|
const debugOutputInt = config.debugOutput ? 1 : 0;
|
|
@@ -32,41 +38,41 @@ function setup(config) {
|
|
|
32
38
|
}
|
|
33
39
|
exports.setup = setup;
|
|
34
40
|
function decrypt(partitionId, dataRowRecord) {
|
|
35
|
-
const partitionIdBuffer = cobhan_1.
|
|
36
|
-
const encryptedDataBuffer = cobhan_1.
|
|
37
|
-
const encryptedKeyBuffer = cobhan_1.
|
|
41
|
+
const partitionIdBuffer = (0, cobhan_1.string_to_cbuffer)(partitionId);
|
|
42
|
+
const encryptedDataBuffer = (0, cobhan_1.buffer_to_cbuffer)(dataRowRecord.Data);
|
|
43
|
+
const encryptedKeyBuffer = (0, cobhan_1.buffer_to_cbuffer)(dataRowRecord.Key.EncryptedKey);
|
|
38
44
|
const created = dataRowRecord.Key.Created;
|
|
39
|
-
const parentKeyIdBuffer = cobhan_1.
|
|
45
|
+
const parentKeyIdBuffer = (0, cobhan_1.string_to_cbuffer)(dataRowRecord.Key.ParentKeyMeta.ID);
|
|
40
46
|
const parentKeyCreated = dataRowRecord.Key.ParentKeyMeta.Created;
|
|
41
|
-
const outputDataBuffer = cobhan_1.
|
|
47
|
+
const outputDataBuffer = (0, cobhan_1.allocate_cbuffer)(encryptedDataBuffer.length + 256);
|
|
42
48
|
const result = libasherah.Decrypt(partitionIdBuffer, encryptedDataBuffer, encryptedKeyBuffer, created, parentKeyIdBuffer, parentKeyCreated, outputDataBuffer);
|
|
43
49
|
if (result < 0) {
|
|
44
50
|
throw new Error('decrypt failed: ' + result);
|
|
45
51
|
}
|
|
46
|
-
return cobhan_1.
|
|
52
|
+
return (0, cobhan_1.cbuffer_to_buffer)(outputDataBuffer);
|
|
47
53
|
}
|
|
48
54
|
exports.decrypt = decrypt;
|
|
49
55
|
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.
|
|
56
|
+
const partitionIdBuffer = (0, cobhan_1.string_to_cbuffer)(partitionId);
|
|
57
|
+
const dataBuffer = (0, cobhan_1.buffer_to_cbuffer)(data);
|
|
58
|
+
const outputEncryptedDataBuffer = (0, cobhan_1.allocate_cbuffer)(data.length + 256);
|
|
59
|
+
const outputEncryptedKeyBuffer = (0, cobhan_1.allocate_cbuffer)(256);
|
|
60
|
+
const outputCreatedBuffer = (0, cobhan_1.int64_to_buffer)(0);
|
|
61
|
+
const outputParentKeyIdBuffer = (0, cobhan_1.allocate_cbuffer)(256);
|
|
62
|
+
const outputParentKeyCreatedBuffer = (0, cobhan_1.int64_to_buffer)(0);
|
|
57
63
|
const result = libasherah.Encrypt(partitionIdBuffer, dataBuffer, outputEncryptedDataBuffer, outputEncryptedKeyBuffer, outputCreatedBuffer, outputParentKeyIdBuffer, outputParentKeyCreatedBuffer);
|
|
58
64
|
if (result < 0) {
|
|
59
65
|
throw new Error('encrypt failed: ' + result);
|
|
60
66
|
}
|
|
61
|
-
const parentKeyId = cobhan_1.
|
|
67
|
+
const parentKeyId = (0, cobhan_1.cbuffer_to_string)(outputParentKeyIdBuffer);
|
|
62
68
|
const dataRowRecord = {
|
|
63
|
-
Data: cobhan_1.
|
|
69
|
+
Data: (0, cobhan_1.cbuffer_to_buffer)(outputEncryptedDataBuffer),
|
|
64
70
|
Key: {
|
|
65
|
-
EncryptedKey: cobhan_1.
|
|
66
|
-
Created: cobhan_1.
|
|
71
|
+
EncryptedKey: (0, cobhan_1.cbuffer_to_buffer)(outputEncryptedKeyBuffer),
|
|
72
|
+
Created: (0, cobhan_1.buffer_to_int64)(outputCreatedBuffer),
|
|
67
73
|
ParentKeyMeta: {
|
|
68
74
|
ID: parentKeyId,
|
|
69
|
-
Created: cobhan_1.
|
|
75
|
+
Created: (0, cobhan_1.buffer_to_int64)(outputParentKeyCreatedBuffer)
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asherah",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
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
|
}
|