asherah 1.0.7 → 1.0.10
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/README.md +13 -8
- package/binaries/libasherah-arm64.dylib +0 -0
- package/binaries/libasherah-arm64.so +0 -0
- package/binaries/libasherah-debug-arm64.dylib +0 -0
- package/binaries/libasherah-debug-arm64.so +0 -0
- package/binaries/libasherah-debug-x64.dylib +0 -0
- package/binaries/libasherah-debug-x64.so +0 -0
- package/binaries/libasherah-x64.dylib +0 -0
- package/binaries/libasherah-x64.so +0 -0
- package/index.js +31 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,18 +5,23 @@ This is a wrapper of the Asherah Go implementation using the Cobhan FFI library
|
|
|
5
5
|
Example code:
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
```
|
|
9
|
-
import
|
|
8
|
+
```javascript
|
|
9
|
+
import { setup, encrypt, decrypt } from 'asherah'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
setup({
|
|
12
|
+
kmsType: 'static',
|
|
13
|
+
metastore: 'memory',
|
|
14
|
+
serviceName: 'TestService',
|
|
15
|
+
productId: 'TestProduct',
|
|
16
|
+
verbose: true,
|
|
17
|
+
sessionCache: true
|
|
18
|
+
});
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
const data = Buffer.from('mysecretdata', 'utf8');
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
const encrypted = encrypt('partition', data);
|
|
16
23
|
console.log(encrypted);
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
const decrypted = decrypt('partition', encrypted);
|
|
20
26
|
console.log("Decrypted: " + decrypted.toString('utf8'));
|
|
21
|
-
|
|
22
27
|
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -36,20 +36,35 @@ import cobhan from 'cobhan'
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* @param {string} kmsType
|
|
40
|
-
* @param {string} metastore
|
|
41
|
-
* @param {string}
|
|
42
|
-
* @param {string}
|
|
43
|
-
* @param {string} [
|
|
44
|
-
* @param {string} [
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {string}
|
|
47
|
-
* @param {
|
|
48
|
-
* @param {string} [preferredRegion]
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {boolean}
|
|
39
|
+
* @param {string} args.kmsType
|
|
40
|
+
* @param {string} args.metastore
|
|
41
|
+
* @param {string} args.serviceName
|
|
42
|
+
* @param {string} args.productId
|
|
43
|
+
* @param {string} [args.rdbmsConnectionString]
|
|
44
|
+
* @param {string} [args.dynamoDbEndpoint]
|
|
45
|
+
* @param {string} [args.dynamoDbRegion]
|
|
46
|
+
* @param {string} [args.dynamoDbTableName]
|
|
47
|
+
* @param {boolean} [args.enableRegionSuffix]
|
|
48
|
+
* @param {string} [args.preferredRegion]
|
|
49
|
+
* @param {string} [args.regionMap]
|
|
50
|
+
* @param {boolean} [args.verbose]
|
|
51
|
+
* @param {boolean} [args.sessionCache]
|
|
51
52
|
*/
|
|
52
|
-
function setup(
|
|
53
|
+
function setup({
|
|
54
|
+
kmsType,
|
|
55
|
+
metastore,
|
|
56
|
+
serviceName,
|
|
57
|
+
productId,
|
|
58
|
+
rdbmsConnectionString = null,
|
|
59
|
+
dynamoDbEndpoint = null,
|
|
60
|
+
dynamoDbRegion = null,
|
|
61
|
+
dynamoDbTableName = null,
|
|
62
|
+
enableRegionSuffix = null,
|
|
63
|
+
preferredRegion = null,
|
|
64
|
+
regionMap = null,
|
|
65
|
+
verbose = false,
|
|
66
|
+
sessionCache = false
|
|
67
|
+
}) {
|
|
53
68
|
const kmsTypeBuffer = cobhan.string_to_cbuffer(kmsType)
|
|
54
69
|
const metastoreBuffer = cobhan.string_to_cbuffer(metastore)
|
|
55
70
|
const rdbmsConnectionStringBuffer = cobhan.string_to_cbuffer(rdbmsConnectionString)
|
|
@@ -60,10 +75,11 @@ function setup(kmsType, metastore, rdbmsConnectionString, dynamoDbEndpoint, dyna
|
|
|
60
75
|
const serviceNameBuffer = cobhan.string_to_cbuffer(serviceName)
|
|
61
76
|
const productIdBuffer = cobhan.string_to_cbuffer(productId)
|
|
62
77
|
const preferredRegionBuffer = cobhan.string_to_cbuffer(preferredRegion)
|
|
78
|
+
const regionMapBuffer = cobhan.string_to_cbuffer(regionMap)
|
|
63
79
|
const verboseInt = verbose ? 1 : 0
|
|
64
80
|
const sessionCacheInt = sessionCache ? 1 : 0
|
|
65
81
|
|
|
66
|
-
const result = libasherah.Setup(kmsTypeBuffer, metastoreBuffer, rdbmsConnectionStringBuffer, dynamoDbEndpointBuffer, dynamoDbRegionBuffer, dynamoDbTableNameBuffer, enableRegionSuffixInt, serviceNameBuffer, productIdBuffer, preferredRegionBuffer, verboseInt, sessionCacheInt);
|
|
82
|
+
const result = libasherah.Setup(kmsTypeBuffer, metastoreBuffer, rdbmsConnectionStringBuffer, dynamoDbEndpointBuffer, dynamoDbRegionBuffer, dynamoDbTableNameBuffer, enableRegionSuffixInt, serviceNameBuffer, productIdBuffer, preferredRegionBuffer, regionMapBuffer, verboseInt, sessionCacheInt);
|
|
67
83
|
if (result < 0) {
|
|
68
84
|
throw new Error('setup failed: ' + result);
|
|
69
85
|
}
|
|
@@ -128,4 +144,4 @@ function encrypt(partitionId, data) {
|
|
|
128
144
|
return dataRowRecord;
|
|
129
145
|
}
|
|
130
146
|
|
|
131
|
-
export
|
|
147
|
+
export { encrypt, decrypt, setup };
|