asherah 1.0.30 → 1.0.33

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.
Binary file
Binary file
Binary file
Binary file
@@ -1,14 +1,28 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.encrypt = exports.decrypt = exports.setup = void 0;
4
7
  const cobhan_1 = require("cobhan");
5
- const libasherah = (0, cobhan_1.load_platform_library)('node_modules/asherah/binaries', 'libasherah', {
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const binaries_path = find_binaries();
10
+ const libasherah = (0, cobhan_1.load_platform_library)(binaries_path, 'libasherah', {
6
11
  'Encrypt': ['int32', ['pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer']],
7
12
  'Decrypt': ['int32', ['pointer', 'pointer', 'pointer', 'int64', 'pointer', 'int64', 'pointer']],
8
13
  'SetupJson': ['int32', ['pointer']]
9
14
  });
15
+ function find_binaries() {
16
+ if (fs_1.default.existsSync('node_modules/asherah/binaries')) {
17
+ return 'node_modules/asherah/binaries';
18
+ }
19
+ if (fs_1.default.existsSync('binaries')) {
20
+ return 'binaries';
21
+ }
22
+ throw new Error("Could not locate Asherah binaries!");
23
+ }
10
24
  function setup(config) {
11
- const configJsonBuffer = (0, cobhan_1.string_to_cbuffer)(JSON.stringify(config));
25
+ const configJsonBuffer = (0, cobhan_1.json_to_cbuffer)(config);
12
26
  const result = libasherah.SetupJson(configJsonBuffer);
13
27
  if (result < 0) {
14
28
  throw new Error('setupJson failed: ' + result);
package/package.json CHANGED
@@ -1,15 +1,18 @@
1
1
  {
2
2
  "name": "asherah",
3
- "version": "1.0.30",
3
+ "version": "1.0.33",
4
4
  "description": "Asherah envelope encryption and key rotation library",
5
- "main": "dist/index.js",
5
+ "main": "dist/asherah.js",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/jgowdy/asherah-cobhan.git"
9
9
  },
10
10
  "scripts": {
11
11
  "build": "npx tsc",
12
- "test": "echo \"Error: no test specified\" && exit 1"
12
+ "test:mocha": "mocha",
13
+ "test": "nyc npm run test:mocha",
14
+ "posttest": "npm run lint",
15
+ "lint": "eslint src/ --ext .ts --fix"
13
16
  },
14
17
  "keywords": [],
15
18
  "author": "Jeremiah Gowdy <jeremiah@gowdy.me>",
@@ -23,11 +26,25 @@
23
26
  "cobhan": "^1.0.22"
24
27
  },
25
28
  "devDependencies": {
29
+ "@types/chai": "^4.3.0",
30
+ "@types/mocha": "^9.1.0",
26
31
  "@types/node": "^17.0.21",
27
32
  "@typescript-eslint/eslint-plugin": "^5.13.0",
28
33
  "@typescript-eslint/parser": "^5.13.0",
34
+ "chai": "^4.3.6",
29
35
  "eslint": "^8.10.0",
36
+ "mocha": "^9.2.1",
37
+ "nyc": "^15.1.0",
38
+ "ts-mocha": "^9.0.2",
30
39
  "typescript": "^4.6.2"
31
40
  },
32
- "types": "dist/index.d.ts"
41
+ "mocha": {
42
+ "extension": [
43
+ "ts"
44
+ ],
45
+ "recursive": true,
46
+ "spec": "test/**/*.spec.ts",
47
+ "require": "ts-node/register"
48
+ },
49
+ "types": "dist/asherah.d.ts"
33
50
  }
package/dist/index.d.ts DELETED
@@ -1,33 +0,0 @@
1
- /// <reference types="node" />
2
- export declare type KeyMeta = {
3
- ID: string;
4
- Created: string | number;
5
- };
6
- export declare type EnvelopeKeyRecord = {
7
- EncryptedKey: Buffer;
8
- Created: string | number;
9
- ParentKeyMeta: KeyMeta;
10
- };
11
- export declare type DataRowRecord = {
12
- Data: Buffer;
13
- Key: EnvelopeKeyRecord;
14
- };
15
- export declare type AsherahConfig = {
16
- kmsType: string;
17
- metastore: string;
18
- serviceName: string;
19
- productId: string;
20
- rdbmsConnectionString: string | null;
21
- dynamoDbEndpoint: string | null;
22
- dynamoDbRegion: string | null;
23
- dynamoDbTableName: string | null;
24
- enableRegionSuffix: boolean;
25
- preferredRegion: string | null;
26
- regionMap: string | null;
27
- verbose: boolean;
28
- sessionCache: boolean;
29
- debugOutput: boolean;
30
- };
31
- export declare function setup(config: AsherahConfig): void;
32
- export declare function decrypt(partitionId: string, dataRowRecord: DataRowRecord): Buffer;
33
- export declare function encrypt(partitionId: string, data: Buffer): DataRowRecord;