asherah 1.1.1 → 1.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/.asherah-version +1 -1
- package/dist/asherah.js +5 -27
- package/package.json +4 -3
- package/scripts/download-binaries.sh +0 -47
package/.asherah-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ASHERAH_VERSION=v0.4.
|
|
1
|
+
ASHERAH_VERSION=v0.4.14
|
package/dist/asherah.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
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_string = exports.decrypt_string = exports.encrypt = exports.decrypt = exports.shutdown = exports.setup = void 0;
|
|
7
4
|
const cobhan_1 = require("cobhan");
|
|
8
|
-
const
|
|
9
|
-
const ref_napi_1 = __importDefault(require("ref-napi"));
|
|
10
|
-
const binaries_path = find_binaries();
|
|
11
|
-
const libasherah = (0, cobhan_1.load_platform_library)(binaries_path, 'libasherah', {
|
|
12
|
-
'SetupJson': [ref_napi_1.default.types.int32, [ref_napi_1.default.refType(ref_napi_1.default.types.void)]],
|
|
13
|
-
'EncryptToJson': [ref_napi_1.default.types.int32, [ref_napi_1.default.refType(ref_napi_1.default.types.void), ref_napi_1.default.refType(ref_napi_1.default.types.void), ref_napi_1.default.refType(ref_napi_1.default.types.void)]],
|
|
14
|
-
'DecryptFromJson': [ref_napi_1.default.types.int32, [ref_napi_1.default.refType(ref_napi_1.default.types.void), ref_napi_1.default.refType(ref_napi_1.default.types.void), ref_napi_1.default.refType(ref_napi_1.default.types.void)]],
|
|
15
|
-
'Shutdown': [ref_napi_1.default.types.void, []]
|
|
16
|
-
});
|
|
17
|
-
const DecryptFromJson = libasherah["DecryptFromJson"];
|
|
18
|
-
const EncryptToJson = libasherah["EncryptToJson"];
|
|
5
|
+
const napi_asherah = require('../build/Release/napiasherah.node');
|
|
19
6
|
const EstimatedEncryptionOverhead = 48;
|
|
20
7
|
const EstimatedEnvelopeOverhead = 185;
|
|
21
8
|
const Base64Overhead = 1.34;
|
|
@@ -24,33 +11,24 @@ function estimate_buffer(dataLen, partitionLen) {
|
|
|
24
11
|
const estimatedDataLen = (dataLen + EstimatedEncryptionOverhead) * Base64Overhead;
|
|
25
12
|
return EstimatedEnvelopeOverhead + EstimatedIntermediateKeyOverhead + partitionLen + estimatedDataLen;
|
|
26
13
|
}
|
|
27
|
-
function find_binaries() {
|
|
28
|
-
if (fs_1.default.existsSync('node_modules/asherah/binaries')) {
|
|
29
|
-
return 'node_modules/asherah/binaries';
|
|
30
|
-
}
|
|
31
|
-
if (fs_1.default.existsSync('binaries')) {
|
|
32
|
-
return 'binaries';
|
|
33
|
-
}
|
|
34
|
-
throw new Error("Could not locate Asherah binaries!");
|
|
35
|
-
}
|
|
36
14
|
function setup(config) {
|
|
37
15
|
const configJsonBuffer = (0, cobhan_1.json_to_cbuffer)(config);
|
|
38
16
|
EstimatedIntermediateKeyOverhead = config.ProductID.length + config.ServiceName.length;
|
|
39
|
-
const result =
|
|
17
|
+
const result = napi_asherah.Napi_SetupJson(configJsonBuffer);
|
|
40
18
|
if (result < 0) {
|
|
41
19
|
throw new Error('setupJson failed: ' + result);
|
|
42
20
|
}
|
|
43
21
|
}
|
|
44
22
|
exports.setup = setup;
|
|
45
23
|
function shutdown() {
|
|
46
|
-
|
|
24
|
+
napi_asherah.Napi_Shutdown();
|
|
47
25
|
}
|
|
48
26
|
exports.shutdown = shutdown;
|
|
49
27
|
function decrypt(partitionId, dataRowRecord) {
|
|
50
28
|
const partitionIdBuffer = (0, cobhan_1.string_to_cbuffer)(partitionId);
|
|
51
29
|
const jsonBuffer = (0, cobhan_1.string_to_cbuffer)(dataRowRecord);
|
|
52
30
|
const outputDataBuffer = (0, cobhan_1.allocate_cbuffer)(jsonBuffer.byteLength);
|
|
53
|
-
const result =
|
|
31
|
+
const result = napi_asherah.Napi_DecryptFromJson(partitionIdBuffer, jsonBuffer, outputDataBuffer);
|
|
54
32
|
if (result < 0) {
|
|
55
33
|
throw new Error('decrypt failed: ' + result);
|
|
56
34
|
}
|
|
@@ -61,7 +39,7 @@ function encrypt(partitionId, data) {
|
|
|
61
39
|
const partitionIdBuffer = (0, cobhan_1.string_to_cbuffer)(partitionId);
|
|
62
40
|
const dataBuffer = (0, cobhan_1.buffer_to_cbuffer)(data);
|
|
63
41
|
const outputJsonBuffer = (0, cobhan_1.allocate_cbuffer)(estimate_buffer(data.byteLength, partitionId.length));
|
|
64
|
-
const result =
|
|
42
|
+
const result = napi_asherah.Napi_EncryptToJson(partitionIdBuffer, dataBuffer, outputJsonBuffer);
|
|
65
43
|
if (result < 0) {
|
|
66
44
|
throw new Error('encrypt failed: ' + result);
|
|
67
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asherah",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Asherah envelope encryption and key rotation library",
|
|
5
5
|
"main": "dist/asherah.js",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "npx tsc",
|
|
12
|
-
"
|
|
12
|
+
"preinstall": "scripts/download-libraries.sh && node-gyp configure && node-gyp build",
|
|
13
13
|
"test:mocha": "mocha",
|
|
14
14
|
"test": "nyc npm run test:mocha",
|
|
15
15
|
"posttest": "npm run lint",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"dist/asherah.d.ts",
|
|
23
23
|
"scripts/download-binaries.sh",
|
|
24
|
+
"build/Release/napi-asherah.node",
|
|
24
25
|
"SHA256SUMS",
|
|
25
26
|
"SHA256SUMS-darwin",
|
|
26
27
|
".asherah-version"
|
|
@@ -53,6 +54,6 @@
|
|
|
53
54
|
"types": "dist/asherah.d.ts",
|
|
54
55
|
"dependencies": {
|
|
55
56
|
"cobhan": "^1.0.35",
|
|
56
|
-
"
|
|
57
|
+
"node-addon-api": "*"
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
echo "Downloading Asherah binaries"
|
|
4
|
-
|
|
5
|
-
source .asherah-version
|
|
6
|
-
|
|
7
|
-
rm -rf binaries
|
|
8
|
-
mkdir binaries
|
|
9
|
-
cd binaries || exit 1
|
|
10
|
-
|
|
11
|
-
OS=$(uname)
|
|
12
|
-
MACHINE=$(uname -m)
|
|
13
|
-
|
|
14
|
-
if [[ "${OS}" == 'Linux' ]]; then
|
|
15
|
-
if [[ ${MACHINE} == 'x86_64' ]]; then
|
|
16
|
-
echo "Linux x64"
|
|
17
|
-
FILENAME=libasherah-x64.so
|
|
18
|
-
SUMS=../SHA256SUMS
|
|
19
|
-
elif [[ ${MACHINE} == 'aarch64' ]]; then
|
|
20
|
-
echo "Linux arm64"
|
|
21
|
-
FILENAME=libasherah-arm64.so
|
|
22
|
-
SUMS=../SHA256SUMS
|
|
23
|
-
else
|
|
24
|
-
echo "Unsupported CPU architecture"
|
|
25
|
-
exit 1
|
|
26
|
-
fi
|
|
27
|
-
elif [[ ${OS} == 'Darwin' ]]; then
|
|
28
|
-
if [[ ${MACHINE} == 'x86_64' ]]; then
|
|
29
|
-
echo "MacOS x64"
|
|
30
|
-
FILENAME=libasherah-x64.dylib
|
|
31
|
-
SUMS=../SHA256SUMS-darwin
|
|
32
|
-
elif [[ ${MACHINE} == 'arm64' ]]; then
|
|
33
|
-
echo "MacOS arm64"
|
|
34
|
-
FILENAME=libasherah-arm64.dylib
|
|
35
|
-
SUMS=../SHA256SUMS-darwin
|
|
36
|
-
else
|
|
37
|
-
echo "Unsupported CPU architecture"
|
|
38
|
-
exit 1
|
|
39
|
-
fi
|
|
40
|
-
else
|
|
41
|
-
echo "Unsupported operating system"
|
|
42
|
-
exit 1
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
curl -s -L --fail -O --retry 999 --retry-max-time 0 "https://github.com/godaddy/asherah-cobhan/releases/download/${ASHERAH_VERSION}/${FILENAME}"
|
|
46
|
-
grep "${FILENAME}" "${SUMS}" > ./SHA256SUM
|
|
47
|
-
shasum -a 256 -c ./SHA256SUM || (echo 'SHA256 mismatch!' ; rm -f ./*.so ./*.dylib ; exit 1)
|