asherah 1.2.2 → 1.2.3
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/binding.gyp +14 -0
- package/package.json +3 -1
- package/src/napiasherah.cc +87 -0
package/binding.gyp
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
'targets': [
|
|
3
|
+
{
|
|
4
|
+
'target_name': 'napiasherah',
|
|
5
|
+
'include_dirs': ["<!(node -p \"require('node-addon-api').include_dir\")"],
|
|
6
|
+
'sources': [
|
|
7
|
+
'lib/libasherah.h',
|
|
8
|
+
'src/napiasherah.cc'
|
|
9
|
+
],
|
|
10
|
+
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
|
|
11
|
+
'libraries': [ '../lib/libasherah.a' ]
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asherah",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Asherah envelope encryption and key rotation library",
|
|
5
5
|
"main": "dist/asherah.js",
|
|
6
6
|
"repository": {
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"author": "Jeremiah Gowdy <jeremiah@gowdy.me>",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"files": [
|
|
23
|
+
"binding.gyp",
|
|
24
|
+
"src/napiasherah.cc",
|
|
23
25
|
"dist/asherah.d.ts",
|
|
24
26
|
"scripts/download-libraries.sh",
|
|
25
27
|
"build/Release/napi-asherah.node",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
#include "../lib/libasherah.h"
|
|
3
|
+
|
|
4
|
+
//extern GoInt32 SetupJson(void* configJson);
|
|
5
|
+
Napi::Value Napi_SetupJson(const Napi::CallbackInfo& info) {
|
|
6
|
+
Napi::Env env = info.Env();
|
|
7
|
+
|
|
8
|
+
if (info.Length() < 1) {
|
|
9
|
+
Napi::TypeError::New(env, "Wrong number of arguments")
|
|
10
|
+
.ThrowAsJavaScriptException();
|
|
11
|
+
return env.Null();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Napi::Buffer<unsigned char> configJson = info[0].As<Napi::Buffer<unsigned char>>();
|
|
15
|
+
|
|
16
|
+
GoInt32 result = SetupJson(configJson.Data());
|
|
17
|
+
|
|
18
|
+
Napi::Number num = Napi::Number::New(env, result);
|
|
19
|
+
return num;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//extern GoInt32 EncryptToJson(void* partitionIdPtr, void* dataPtr, void* jsonPtr);
|
|
23
|
+
Napi::Value Napi_EncryptToJson(const Napi::CallbackInfo& info) {
|
|
24
|
+
Napi::Env env = info.Env();
|
|
25
|
+
|
|
26
|
+
if (info.Length() < 3) {
|
|
27
|
+
Napi::TypeError::New(env, "Wrong number of arguments")
|
|
28
|
+
.ThrowAsJavaScriptException();
|
|
29
|
+
return env.Null();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!info[0].IsBuffer() || !info[1].IsBuffer() || !info[2].IsBuffer()) {
|
|
33
|
+
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
34
|
+
return env.Null();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Napi::Buffer<unsigned char> partitionId = info[0].As<Napi::Buffer<unsigned char>>();
|
|
38
|
+
Napi::Buffer<unsigned char> data = info[1].As<Napi::Buffer<unsigned char>>();
|
|
39
|
+
Napi::Buffer<unsigned char> outputJson = info[2].As<Napi::Buffer<unsigned char>>();
|
|
40
|
+
|
|
41
|
+
GoInt32 result = EncryptToJson(partitionId.Data(), data.Data(), outputJson.Data());
|
|
42
|
+
|
|
43
|
+
Napi::Number num = Napi::Number::New(env, result);
|
|
44
|
+
return num;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//extern GoInt32 DecryptFromJson(void* partitionIdPtr, void* jsonPtr, void* dataPtr);
|
|
48
|
+
Napi::Value Napi_DecryptFromJson(const Napi::CallbackInfo& info) {
|
|
49
|
+
Napi::Env env = info.Env();
|
|
50
|
+
|
|
51
|
+
if (info.Length() < 3) {
|
|
52
|
+
Napi::TypeError::New(env, "Wrong number of arguments")
|
|
53
|
+
.ThrowAsJavaScriptException();
|
|
54
|
+
return env.Null();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!info[0].IsBuffer() || !info[1].IsBuffer() || !info[2].IsBuffer()) {
|
|
58
|
+
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
59
|
+
return env.Null();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Napi::Buffer<unsigned char> partitionId = info[0].As<Napi::Buffer<unsigned char>>();
|
|
63
|
+
Napi::Buffer<unsigned char> inputJson = info[1].As<Napi::Buffer<unsigned char>>();
|
|
64
|
+
Napi::Buffer<unsigned char> outputData = info[2].As<Napi::Buffer<unsigned char>>();
|
|
65
|
+
|
|
66
|
+
GoInt32 result = DecryptFromJson(partitionId.Data(), inputJson.Data(), outputData.Data());
|
|
67
|
+
|
|
68
|
+
Napi::Number num = Napi::Number::New(env, result);
|
|
69
|
+
return num;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//extern void Shutdown();
|
|
73
|
+
Napi::Value Napi_Shutdown(const Napi::CallbackInfo& info) {
|
|
74
|
+
Napi::Env env = info.Env();
|
|
75
|
+
Shutdown();
|
|
76
|
+
return env.Null();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
80
|
+
exports.Set(Napi::String::New(env, "Napi_SetupJson"), Napi::Function::New(env, Napi_SetupJson));
|
|
81
|
+
exports.Set(Napi::String::New(env, "Napi_EncryptToJson"), Napi::Function::New(env, Napi_EncryptToJson));
|
|
82
|
+
exports.Set(Napi::String::New(env, "Napi_DecryptFromJson"), Napi::Function::New(env, Napi_DecryptFromJson));
|
|
83
|
+
exports.Set(Napi::String::New(env, "Napi_Shutdown"), Napi::Function::New(env, Napi_Shutdown));
|
|
84
|
+
return exports;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
NODE_API_MODULE(napiasherah, Init)
|