asherah 1.0.23 → 1.0.26

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/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  /// <reference types="node" />
2
- declare type KeyMeta = {
2
+ export declare type KeyMeta = {
3
3
  ID: string;
4
4
  Created: string | number;
5
5
  };
6
- declare type EnvelopeKeyRecord = {
6
+ export declare type EnvelopeKeyRecord = {
7
7
  EncryptedKey: Buffer;
8
8
  Created: string | number;
9
9
  ParentKeyMeta: KeyMeta;
10
10
  };
11
- declare type DataRowRecord = {
11
+ export declare type DataRowRecord = {
12
12
  Data: Buffer;
13
13
  Key: EnvelopeKeyRecord;
14
14
  };
15
- declare type AsherahConfig = {
15
+ export declare type AsherahConfig = {
16
16
  kmsType: string;
17
17
  metastore: string;
18
18
  serviceName: string;
@@ -31,4 +31,3 @@ declare type AsherahConfig = {
31
31
  export declare function setup(config: AsherahConfig): void;
32
32
  export declare function decrypt(partitionId: string, dataRowRecord: DataRowRecord): Buffer;
33
33
  export declare function encrypt(partitionId: string, data: Buffer): DataRowRecord;
34
- export {};
package/dist/index.js CHANGED
@@ -1,27 +1,24 @@
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 = exports.decrypt = exports.setup = void 0;
7
- const cobhan_1 = __importDefault(require("cobhan"));
8
- const libasherah = cobhan_1.default.load_platform_library('node_modules/asherah/binaries', 'libasherah', {
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']],
12
9
  });
13
10
  function setup(config) {
14
- const kmsTypeBuffer = cobhan_1.default.string_to_cbuffer(config.kmsType);
15
- const metastoreBuffer = cobhan_1.default.string_to_cbuffer(config.metastore);
16
- const rdbmsConnectionStringBuffer = cobhan_1.default.string_to_cbuffer(config.rdbmsConnectionString);
17
- const dynamoDbEndpointBuffer = cobhan_1.default.string_to_cbuffer(config.dynamoDbEndpoint);
18
- const dynamoDbRegionBuffer = cobhan_1.default.string_to_cbuffer(config.dynamoDbRegion);
19
- const dynamoDbTableNameBuffer = cobhan_1.default.string_to_cbuffer(config.dynamoDbTableName);
11
+ const kmsTypeBuffer = (0, cobhan_1.string_to_cbuffer)(config.kmsType);
12
+ const metastoreBuffer = (0, cobhan_1.string_to_cbuffer)(config.metastore);
13
+ const rdbmsConnectionStringBuffer = (0, cobhan_1.string_to_cbuffer)(config.rdbmsConnectionString);
14
+ const dynamoDbEndpointBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbEndpoint);
15
+ const dynamoDbRegionBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbRegion);
16
+ const dynamoDbTableNameBuffer = (0, cobhan_1.string_to_cbuffer)(config.dynamoDbTableName);
20
17
  const enableRegionSuffixInt = config.enableRegionSuffix ? 1 : 0;
21
- const serviceNameBuffer = cobhan_1.default.string_to_cbuffer(config.serviceName);
22
- const productIdBuffer = cobhan_1.default.string_to_cbuffer(config.productId);
23
- const preferredRegionBuffer = cobhan_1.default.string_to_cbuffer(config.preferredRegion);
24
- const regionMapBuffer = cobhan_1.default.string_to_cbuffer(config.regionMap);
18
+ const serviceNameBuffer = (0, cobhan_1.string_to_cbuffer)(config.serviceName);
19
+ const productIdBuffer = (0, cobhan_1.string_to_cbuffer)(config.productId);
20
+ const preferredRegionBuffer = (0, cobhan_1.string_to_cbuffer)(config.preferredRegion);
21
+ const regionMapBuffer = (0, cobhan_1.string_to_cbuffer)(config.regionMap);
25
22
  const verboseInt = config.verbose ? 1 : 0;
26
23
  const sessionCacheInt = config.sessionCache ? 1 : 0;
27
24
  const debugOutputInt = config.debugOutput ? 1 : 0;
@@ -32,41 +29,41 @@ function setup(config) {
32
29
  }
33
30
  exports.setup = setup;
34
31
  function decrypt(partitionId, dataRowRecord) {
35
- const partitionIdBuffer = cobhan_1.default.string_to_cbuffer(partitionId);
36
- const encryptedDataBuffer = cobhan_1.default.buffer_to_cbuffer(dataRowRecord.Data);
37
- const encryptedKeyBuffer = cobhan_1.default.buffer_to_cbuffer(dataRowRecord.Key.EncryptedKey);
32
+ const partitionIdBuffer = (0, cobhan_1.string_to_cbuffer)(partitionId);
33
+ const encryptedDataBuffer = (0, cobhan_1.buffer_to_cbuffer)(dataRowRecord.Data);
34
+ const encryptedKeyBuffer = (0, cobhan_1.buffer_to_cbuffer)(dataRowRecord.Key.EncryptedKey);
38
35
  const created = dataRowRecord.Key.Created;
39
- const parentKeyIdBuffer = cobhan_1.default.string_to_cbuffer(dataRowRecord.Key.ParentKeyMeta.ID);
36
+ const parentKeyIdBuffer = (0, cobhan_1.string_to_cbuffer)(dataRowRecord.Key.ParentKeyMeta.ID);
40
37
  const parentKeyCreated = dataRowRecord.Key.ParentKeyMeta.Created;
41
- const outputDataBuffer = cobhan_1.default.allocate_cbuffer(encryptedDataBuffer.length + 256);
38
+ const outputDataBuffer = (0, cobhan_1.allocate_cbuffer)(encryptedDataBuffer.length + 256);
42
39
  const result = libasherah.Decrypt(partitionIdBuffer, encryptedDataBuffer, encryptedKeyBuffer, created, parentKeyIdBuffer, parentKeyCreated, outputDataBuffer);
43
40
  if (result < 0) {
44
41
  throw new Error('decrypt failed: ' + result);
45
42
  }
46
- return cobhan_1.default.cbuffer_to_buffer(outputDataBuffer);
43
+ return (0, cobhan_1.cbuffer_to_buffer)(outputDataBuffer);
47
44
  }
48
45
  exports.decrypt = decrypt;
49
46
  function encrypt(partitionId, data) {
50
- const partitionIdBuffer = cobhan_1.default.string_to_cbuffer(partitionId);
51
- const dataBuffer = cobhan_1.default.buffer_to_cbuffer(data);
52
- const outputEncryptedDataBuffer = cobhan_1.default.allocate_cbuffer(data.length + 256);
53
- const outputEncryptedKeyBuffer = cobhan_1.default.allocate_cbuffer(256);
54
- const outputCreatedBuffer = cobhan_1.default.int64_to_buffer(0);
55
- const outputParentKeyIdBuffer = cobhan_1.default.allocate_cbuffer(256);
56
- const outputParentKeyCreatedBuffer = cobhan_1.default.int64_to_buffer(0);
47
+ const partitionIdBuffer = (0, cobhan_1.string_to_cbuffer)(partitionId);
48
+ const dataBuffer = (0, cobhan_1.buffer_to_cbuffer)(data);
49
+ const outputEncryptedDataBuffer = (0, cobhan_1.allocate_cbuffer)(data.length + 256);
50
+ const outputEncryptedKeyBuffer = (0, cobhan_1.allocate_cbuffer)(256);
51
+ const outputCreatedBuffer = (0, cobhan_1.int64_to_buffer)(0);
52
+ const outputParentKeyIdBuffer = (0, cobhan_1.allocate_cbuffer)(256);
53
+ const outputParentKeyCreatedBuffer = (0, cobhan_1.int64_to_buffer)(0);
57
54
  const result = libasherah.Encrypt(partitionIdBuffer, dataBuffer, outputEncryptedDataBuffer, outputEncryptedKeyBuffer, outputCreatedBuffer, outputParentKeyIdBuffer, outputParentKeyCreatedBuffer);
58
55
  if (result < 0) {
59
56
  throw new Error('encrypt failed: ' + result);
60
57
  }
61
- const parentKeyId = cobhan_1.default.cbuffer_to_string(outputParentKeyIdBuffer);
58
+ const parentKeyId = (0, cobhan_1.cbuffer_to_string)(outputParentKeyIdBuffer);
62
59
  const dataRowRecord = {
63
- Data: cobhan_1.default.cbuffer_to_buffer(outputEncryptedDataBuffer),
60
+ Data: (0, cobhan_1.cbuffer_to_buffer)(outputEncryptedDataBuffer),
64
61
  Key: {
65
- EncryptedKey: cobhan_1.default.cbuffer_to_buffer(outputEncryptedKeyBuffer),
66
- Created: cobhan_1.default.buffer_to_int64(outputCreatedBuffer),
62
+ EncryptedKey: (0, cobhan_1.cbuffer_to_buffer)(outputEncryptedKeyBuffer),
63
+ Created: (0, cobhan_1.buffer_to_int64)(outputCreatedBuffer),
67
64
  ParentKeyMeta: {
68
65
  ID: parentKeyId,
69
- Created: cobhan_1.default.buffer_to_int64(outputParentKeyCreatedBuffer)
66
+ Created: (0, cobhan_1.buffer_to_int64)(outputParentKeyCreatedBuffer)
70
67
  }
71
68
  }
72
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asherah",
3
- "version": "1.0.23",
3
+ "version": "1.0.26",
4
4
  "description": "Asherah envelope encryption and key rotation library",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "dist/index.d.ts"
21
21
  ],
22
22
  "dependencies": {
23
- "cobhan": "^1.0.21"
23
+ "cobhan": "^1.0.22"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^17.0.21",
@@ -29,5 +29,5 @@
29
29
  "eslint": "^8.10.0",
30
30
  "typescript": "^4.6.2"
31
31
  },
32
- "types": "./dist/index.d.ts"
32
+ "types": "dist/index.d.ts"
33
33
  }