@cipherstash/protect-ffi 0.16.1 → 0.17.1

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 CHANGED
@@ -143,13 +143,22 @@ PGHOST=localhost
143
143
  ```
144
144
 
145
145
  To run integration tests:
146
+ ```sh
147
+ mise setup
148
+ mise test:integration
149
+ ```
150
+
151
+ You can also run the integration tests in "watch" mode:
152
+
153
+ ```sh
154
+ mise test:integration --watch
146
155
  ```
147
- npm run debug
148
- cd integration-tests
149
- docker compose up --detach --wait
150
- npm run eql:download
151
- npm run eql:install
152
- npm run test
156
+
157
+ By default lock context tests are not included because invalid lock contexts fire security warnings in ZeroKMS.
158
+ To include these, run:
159
+
160
+ ```sh
161
+ mise test:integration:all
153
162
  ```
154
163
 
155
164
  ## Releasing
package/lib/index.cjs CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  // This module is the CJS entry point for the library.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.decryptBulkFallible = exports.decryptBulk = exports.decrypt = exports.encryptBulk = exports.encrypt = exports.newClient = void 0;
4
+ exports.decryptBulkFallible = exports.decryptBulk = exports.decrypt = exports.isEncrypted = exports.encryptBulk = exports.encrypt = exports.newClient = void 0;
5
5
  var load_cjs_1 = require("./load.cjs");
6
6
  Object.defineProperty(exports, "newClient", { enumerable: true, get: function () { return load_cjs_1.newClient; } });
7
7
  Object.defineProperty(exports, "encrypt", { enumerable: true, get: function () { return load_cjs_1.encrypt; } });
8
8
  Object.defineProperty(exports, "encryptBulk", { enumerable: true, get: function () { return load_cjs_1.encryptBulk; } });
9
+ Object.defineProperty(exports, "isEncrypted", { enumerable: true, get: function () { return load_cjs_1.isEncrypted; } });
9
10
  Object.defineProperty(exports, "decrypt", { enumerable: true, get: function () { return load_cjs_1.decrypt; } });
10
11
  Object.defineProperty(exports, "decryptBulk", { enumerable: true, get: function () { return load_cjs_1.decryptBulk; } });
11
12
  Object.defineProperty(exports, "decryptBulkFallible", { enumerable: true, get: function () { return load_cjs_1.decryptBulkFallible; } });
package/lib/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { newClient, encrypt, encryptBulk, decrypt, decryptBulk, decryptBulkFallible, } from './load.cjs';
1
+ export { newClient, encrypt, encryptBulk, isEncrypted, decrypt, decryptBulk, decryptBulkFallible, } from './load.cjs';
2
2
  declare const sym: unique symbol;
3
3
  export type Client = {
4
4
  readonly [sym]: unknown;
@@ -6,9 +6,10 @@ export type Client = {
6
6
  declare module './load.cjs' {
7
7
  function newClient(opts: NewClientOptions): Promise<Client>;
8
8
  function encrypt(client: Client, opts: EncryptOptions): Promise<Encrypted>;
9
- function decrypt(client: Client, opts: DecryptOptions): Promise<string>;
9
+ function decrypt(client: Client, opts: DecryptOptions): Promise<JsPlaintext>;
10
+ function isEncrypted(encrypted: Encrypted): boolean;
10
11
  function encryptBulk(client: Client, opts: EncryptBulkOptions): Promise<Encrypted[]>;
11
- function decryptBulk(client: Client, opts: DecryptBulkOptions): Promise<string[]>;
12
+ function decryptBulk(client: Client, opts: DecryptBulkOptions): Promise<JsPlaintext[]>;
12
13
  function decryptBulkFallible(client: Client, opts: DecryptBulkOptions): Promise<DecryptResult[]>;
13
14
  }
14
15
  export type DecryptResult = {
@@ -17,13 +18,13 @@ export type DecryptResult = {
17
18
  error: string;
18
19
  };
19
20
  export type EncryptPayload = {
20
- plaintext: string;
21
+ plaintext: JsPlaintext;
21
22
  column: string;
22
23
  table: string;
23
24
  lockContext?: Context;
24
25
  };
25
26
  export type BulkDecryptPayload = {
26
- ciphertext: string;
27
+ ciphertext: Encrypted;
27
28
  lockContext?: Context;
28
29
  };
29
30
  export type CtsToken = {
@@ -34,7 +35,7 @@ export type Context = {
34
35
  identityClaim: string[];
35
36
  };
36
37
  export type Encrypted = {
37
- k: string;
38
+ k: 'ct';
38
39
  c: string;
39
40
  ob: string[] | null;
40
41
  bf: number[] | null;
@@ -44,6 +45,20 @@ export type Encrypted = {
44
45
  t: string;
45
46
  };
46
47
  v: number;
48
+ } | {
49
+ k: 'sv';
50
+ sv: SteVecEncryptedEntry[];
51
+ i: {
52
+ c: string;
53
+ t: string;
54
+ };
55
+ v: number;
56
+ };
57
+ export type SteVecEncryptedEntry = {
58
+ tokenized_selector: string;
59
+ term: string;
60
+ record: string;
61
+ parent_is_array: boolean;
47
62
  };
48
63
  export type EncryptConfig = {
49
64
  v: number;
@@ -53,7 +68,16 @@ export type Column = {
53
68
  cast_as?: CastAs;
54
69
  indexes?: Indexes;
55
70
  };
56
- export type CastAs = 'big_int' | 'boolean' | 'date' | 'real' | 'double' | 'int' | 'small_int' | 'text' | 'jsonb';
71
+ export type CastAs = 'bigint' | 'boolean' | 'date' | 'number' | 'string' | 'json';
72
+ type TablesOf<C extends EncryptConfig> = C['tables'];
73
+ export type Identifier<C extends EncryptConfig> = {
74
+ [T in keyof TablesOf<C>]: {
75
+ [CName in keyof TablesOf<C>[T]]: {
76
+ table: T;
77
+ column: CName;
78
+ };
79
+ }[keyof TablesOf<C>[T]];
80
+ }[keyof TablesOf<C>];
57
81
  export type Indexes = {
58
82
  ore?: OreIndexOpts;
59
83
  unique?: UniqueIndexOpts;
@@ -93,8 +117,9 @@ export type ClientOpts = {
93
117
  clientId?: string;
94
118
  clientKey?: string;
95
119
  };
120
+ export type JsPlaintext = string | number | Record<string, unknown> | JsPlaintext[];
96
121
  export type EncryptOptions = {
97
- plaintext: string;
122
+ plaintext: JsPlaintext;
98
123
  column: string;
99
124
  table: string;
100
125
  lockContext?: Context;
@@ -107,7 +132,7 @@ export type EncryptBulkOptions = {
107
132
  unverifiedContext?: Record<string, unknown>;
108
133
  };
109
134
  export type DecryptOptions = {
110
- ciphertext: string;
135
+ ciphertext: Encrypted;
111
136
  lockContext?: Context;
112
137
  serviceToken?: CtsToken;
113
138
  unverifiedContext?: Record<string, unknown>;
package/lib/load.cjs CHANGED
@@ -12,6 +12,7 @@ module.exports = require('@neon-rs/load').proxy({
12
12
  'darwin-x64': () => require('@cipherstash/protect-ffi-darwin-x64'),
13
13
  'darwin-arm64': () => require('@cipherstash/protect-ffi-darwin-arm64'),
14
14
  'linux-x64-gnu': () => require('@cipherstash/protect-ffi-linux-x64-gnu'),
15
+ 'linux-x64-musl': () => require('@cipherstash/protect-ffi-linux-x64-musl'),
15
16
  'linux-arm64-gnu': () => require('@cipherstash/protect-ffi-linux-arm64-gnu'),
16
17
  },
17
18
  debug: () => require('../index.node'),
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@cipherstash/protect-ffi",
3
- "version": "0.16.1",
3
+ "version": "0.17.1",
4
4
  "description": "",
5
5
  "main": "./lib/index.cjs",
6
6
  "scripts": {
7
7
  "test": "npm run test:typecheck && npm run test:lint && npm run test:format && npm run test:rust",
8
8
  "test:typecheck": "tsc",
9
9
  "test:rust": "cargo test",
10
- "test:lint": "npm run test:lint:rust && npm run test:lint:ts",
10
+ "test:lint": "npm run test:lint:ts",
11
11
  "test:lint:ts": "biome lint",
12
- "test:lint:rust": "cargo clippy --all --no-deps --all-targets --all-features -- -D warnings",
13
- "test:format": "npm run test:format:rust && npm run test:format:ts",
12
+ "test:format": "npm run test:format:ts",
14
13
  "test:format:ts": "biome format",
15
14
  "test:format:rust": "cargo fmt --check",
16
15
  "cargo-build": "tsc &&cargo build --message-format=json-render-diagnostics > cargo.log",
@@ -46,7 +45,14 @@
46
45
  "neon": {
47
46
  "type": "library",
48
47
  "org": "@cipherstash",
49
- "platforms": "common",
48
+ "platforms": [
49
+ "darwin-x64",
50
+ "darwin-arm64",
51
+ "win32-x64-msvc",
52
+ "linux-x64-gnu",
53
+ "linux-arm64-gnu",
54
+ "linux-x64-musl"
55
+ ],
50
56
  "load": "./src/load.cts",
51
57
  "prefix": "protect-ffi-"
52
58
  },
@@ -61,10 +67,11 @@
61
67
  "@neon-rs/load": "^0.1.82"
62
68
  },
63
69
  "optionalDependencies": {
64
- "@cipherstash/protect-ffi-win32-x64-msvc": "0.16.1",
65
- "@cipherstash/protect-ffi-darwin-x64": "0.16.1",
66
- "@cipherstash/protect-ffi-darwin-arm64": "0.16.1",
67
- "@cipherstash/protect-ffi-linux-x64-gnu": "0.16.1",
68
- "@cipherstash/protect-ffi-linux-arm64-gnu": "0.16.1"
70
+ "@cipherstash/protect-ffi-darwin-x64": "0.17.1",
71
+ "@cipherstash/protect-ffi-darwin-arm64": "0.17.1",
72
+ "@cipherstash/protect-ffi-win32-x64-msvc": "0.17.1",
73
+ "@cipherstash/protect-ffi-linux-x64-gnu": "0.17.1",
74
+ "@cipherstash/protect-ffi-linux-arm64-gnu": "0.17.1",
75
+ "@cipherstash/protect-ffi-linux-x64-musl": "0.17.1"
69
76
  }
70
77
  }