asherah 3.0.5 → 3.0.7
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/README.md +68 -0
- package/package.json +1 -1
- package/src/asherah.cc +17 -0
- package/src/asherah.d.ts +1 -0
package/.asherah-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ASHERAH_VERSION=v0.4.
|
|
1
|
+
ASHERAH_VERSION=v0.4.33
|
package/README.md
CHANGED
|
@@ -97,6 +97,74 @@ console.log("Output: " + output)
|
|
|
97
97
|
asherah.shutdown()
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
### Environment Variables and AWS
|
|
101
|
+
|
|
102
|
+
If you're experiencing issues with AWS credentials, you can forcibly set the environment variables prior to calling setup in such a way as to ensure they're set for the Go runtime:
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
|
|
106
|
+
const asherah = require('asherah');
|
|
107
|
+
const fs = require('fs');
|
|
108
|
+
|
|
109
|
+
const config = {
|
|
110
|
+
KMS: 'aws',
|
|
111
|
+
Metastore: 'memory',
|
|
112
|
+
ServiceName: 'TestService',
|
|
113
|
+
ProductID: 'TestProduct',
|
|
114
|
+
Verbose: true,
|
|
115
|
+
EnableSessionCaching: true,
|
|
116
|
+
ExpireAfter: null,
|
|
117
|
+
CheckInterval: null,
|
|
118
|
+
ConnectionString: null,
|
|
119
|
+
ReplicaReadConsistency: null,
|
|
120
|
+
DynamoDBEndpoint: null,
|
|
121
|
+
DynamoDBRegion: null,
|
|
122
|
+
DynamoDBTableName: null,
|
|
123
|
+
SessionCacheMaxSize: null,
|
|
124
|
+
SessionCacheDuration: null,
|
|
125
|
+
RegionMap: {"us-west-2": "arn:aws:kms:us-west-2:XXXXXXXXX:key/XXXXXXXXXX"},
|
|
126
|
+
PreferredRegion: null,
|
|
127
|
+
EnableRegionSuffix: null
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Read the AWS environment variables from the JSON file
|
|
131
|
+
// DO NOT HARDCODE YOUR AWS CREDENTIALS
|
|
132
|
+
const awsEnvPath = './awsEnv.json';
|
|
133
|
+
const awsEnvData = fs.readFileSync(awsEnvPath, 'utf8');
|
|
134
|
+
const awsEnv = JSON.stringify(awsEnvData);
|
|
135
|
+
|
|
136
|
+
// Set the environment variables using the setenv function
|
|
137
|
+
asherah.setenv(awsEnv);
|
|
138
|
+
|
|
139
|
+
asherah.setup(config)
|
|
140
|
+
|
|
141
|
+
const input = 'mysecretdata'
|
|
142
|
+
|
|
143
|
+
console.log("Input: " + input)
|
|
144
|
+
|
|
145
|
+
const data = Buffer.from(input, 'utf8');
|
|
146
|
+
|
|
147
|
+
const encrypted = asherah.encrypt('partition', data);
|
|
148
|
+
|
|
149
|
+
const decrypted = asherah.decrypt('partition', encrypted);
|
|
150
|
+
|
|
151
|
+
const output = decrypted.toString('utf8');
|
|
152
|
+
|
|
153
|
+
console.log("Output: " + output)
|
|
154
|
+
|
|
155
|
+
asherah.shutdown()
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The `awsEnv.json` file would look like this (spelling errors intentional):
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"AXS_ACCESS_KEY_XD": "sample_access_key_xd",
|
|
163
|
+
"AXS_SXCRET_ACCXSS_KEY": "sample_sxcret_accxss_kxy",
|
|
164
|
+
"AXS_SXSSION_TXKEN": "sample_sxssion_txken"
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
100
168
|
### Go and Alpine / musl libc
|
|
101
169
|
|
|
102
170
|
The Golang compiler when creating shared libraries (.so) uses a Thread Local Storage model of init-exec. This model is inheriently incompatible with loading libraries at runtime with dlopen(), unless your libc reserves some space for dlopen()'ed libraries which is something of a hack. The most common libc, glibc does in fact reserve space for dlopen()'ed libraries that use init-exec model. The libc provided with Alpine is musl libc, and it does not participate in this hack / workaround of reserving space. Most compilers generate libraries with a Thread Local Storage model of global-dynamic which does not require this workaround, and the authors of musl libc do not feel that workaround should exist.
|
package/package.json
CHANGED
package/src/asherah.cc
CHANGED
|
@@ -38,6 +38,7 @@ public:
|
|
|
38
38
|
&Asherah::SetSafetyPaddingOverhead),
|
|
39
39
|
InstanceMethod("get_setup_status", &Asherah::GetSetupStatus),
|
|
40
40
|
InstanceMethod("set_log_hook", &Asherah::SetLogHook),
|
|
41
|
+
InstanceMethod("setenv", &Asherah::SetEnv),
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -409,6 +410,22 @@ private:
|
|
|
409
410
|
}
|
|
410
411
|
}
|
|
411
412
|
|
|
413
|
+
void SetEnv(const Napi::CallbackInfo &info) {
|
|
414
|
+
Napi::Env env = info.Env();
|
|
415
|
+
Napi::HandleScope scope(env);
|
|
416
|
+
try {
|
|
417
|
+
NapiUtils::RequireParameterCount(info, 1);
|
|
418
|
+
CobhanBufferNapi env_json(env, info[0]);
|
|
419
|
+
::SetEnv(env_json);
|
|
420
|
+
} catch (Napi::Error &e) {
|
|
421
|
+
e.ThrowAsJavaScriptException();
|
|
422
|
+
return;
|
|
423
|
+
} catch (const std::exception &e) {
|
|
424
|
+
Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
412
429
|
void SetMaxStackAllocItemSize(const Napi::CallbackInfo &info) {
|
|
413
430
|
Napi::Env env = info.Env();
|
|
414
431
|
Napi::HandleScope scope(env);
|
package/src/asherah.d.ts
CHANGED
|
@@ -60,3 +60,4 @@ export declare function set_max_stack_alloc_item_size(max_item_size: number): vo
|
|
|
60
60
|
export declare function set_safety_padding_overhead(safety_padding_overhead: number): void;
|
|
61
61
|
export declare function set_log_hook(logHook: LogHookCallback): void;
|
|
62
62
|
export declare function get_setup_status(): boolean;
|
|
63
|
+
export declare function setenv(environment: string): void;
|