@cipherstash/protect-ffi 0.22.0 → 0.24.0
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/wasm/package.json +3 -0
- package/dist/wasm/protect_ffi.d.ts +83 -0
- package/dist/wasm/protect_ffi.js +9 -0
- package/dist/wasm/protect_ffi_bg.js +1047 -0
- package/dist/wasm/protect_ffi_bg.wasm +0 -0
- package/dist/wasm/protect_ffi_bg.wasm.d.ts +40 -0
- package/dist/wasm/protect_ffi_inline.js +16 -0
- package/lib/index.d.cts +62 -35
- package/package.json +36 -16
package/lib/index.d.cts
CHANGED
|
@@ -9,12 +9,12 @@ declare module './load.cjs' {
|
|
|
9
9
|
function newClient(opts: NativeNewClientOptions): Promise<Client>;
|
|
10
10
|
function encrypt(client: Client, opts: EncryptOptions): Promise<Encrypted>;
|
|
11
11
|
function decrypt(client: Client, opts: DecryptOptions): Promise<JsPlaintext>;
|
|
12
|
-
function isEncrypted(encrypted:
|
|
12
|
+
function isEncrypted(encrypted: unknown): boolean;
|
|
13
13
|
function encryptBulk(client: Client, opts: EncryptBulkOptions): Promise<Encrypted[]>;
|
|
14
14
|
function decryptBulk(client: Client, opts: DecryptBulkOptions): Promise<JsPlaintext[]>;
|
|
15
15
|
function decryptBulkFallible(client: Client, opts: DecryptBulkOptions): Promise<DecryptResult[]>;
|
|
16
|
-
function encryptQuery(client: Client, opts: EncryptQueryOptions): Promise<Encrypted>;
|
|
17
|
-
function encryptQueryBulk(client: Client, opts: EncryptQueryBulkOptions): Promise<Encrypted[]>;
|
|
16
|
+
function encryptQuery(client: Client, opts: EncryptQueryOptions): Promise<Encrypted | EncryptedQuery>;
|
|
17
|
+
function encryptQueryBulk(client: Client, opts: EncryptQueryBulkOptions): Promise<(Encrypted | EncryptedQuery)[]>;
|
|
18
18
|
function ensureKeyset(opts: EnsureKeysetOpts): Promise<EnsureKeysetResult>;
|
|
19
19
|
}
|
|
20
20
|
export type ProtectErrorCode = 'INVARIANT_VIOLATION' | 'UNKNOWN_QUERY_OP' | 'UNKNOWN_COLUMN' | 'MISSING_INDEX' | 'INVALID_QUERY_INPUT' | 'INVALID_JSON_PATH' | 'STE_VEC_REQUIRES_JSON_CAST_AS' | 'MATCH_REQUIRES_TEXT' | 'UNSUPPORTED_CONFIG_VERSION' | 'UNKNOWN';
|
|
@@ -38,12 +38,12 @@ export type DecryptResult = {
|
|
|
38
38
|
export declare function newClient(opts: NewClientOptions): Promise<Client>;
|
|
39
39
|
export declare function encrypt(client: Client, opts: EncryptOptions): Promise<Encrypted>;
|
|
40
40
|
export declare function decrypt(client: Client, opts: DecryptOptions): Promise<JsPlaintext>;
|
|
41
|
-
export declare function isEncrypted(encrypted:
|
|
41
|
+
export declare function isEncrypted(encrypted: unknown): boolean;
|
|
42
42
|
export declare function encryptBulk(client: Client, opts: EncryptBulkOptions): Promise<Encrypted[]>;
|
|
43
43
|
export declare function decryptBulk(client: Client, opts: DecryptBulkOptions): Promise<JsPlaintext[]>;
|
|
44
44
|
export declare function decryptBulkFallible(client: Client, opts: DecryptBulkOptions): Promise<DecryptResult[]>;
|
|
45
|
-
export declare function encryptQuery(client: Client, opts: EncryptQueryOptions): Promise<Encrypted>;
|
|
46
|
-
export declare function encryptQueryBulk(client: Client, opts: EncryptQueryBulkOptions): Promise<Encrypted[]>;
|
|
45
|
+
export declare function encryptQuery(client: Client, opts: EncryptQueryOptions): Promise<Encrypted | EncryptedQuery>;
|
|
46
|
+
export declare function encryptQueryBulk(client: Client, opts: EncryptQueryBulkOptions): Promise<(Encrypted | EncryptedQuery)[]>;
|
|
47
47
|
/**
|
|
48
48
|
* Test-only helper: ensures a keyset with the given name exists, creating it if necessary,
|
|
49
49
|
* and grants the current client access. Not safe for concurrent use — intended for
|
|
@@ -68,28 +68,22 @@ export type Context = {
|
|
|
68
68
|
identityClaim: string[];
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* EQL v2.3 **storage** payload — the shape persisted in an `eql_v2_encrypted`
|
|
72
|
+
* column. Returned by {@link encrypt} / {@link encryptBulk}; the only shape
|
|
73
|
+
* {@link decrypt} accepts.
|
|
72
74
|
*
|
|
73
|
-
* Discriminated
|
|
74
|
-
*
|
|
75
|
+
* Discriminated on `k`. A storage payload always carries the ciphertext — `c`
|
|
76
|
+
* on the scalar variant, or `sv[0].c` on the STE-vector variant. Query payloads
|
|
77
|
+
* carry no ciphertext and are a separate type — see {@link EncryptedQuery}.
|
|
75
78
|
*
|
|
76
79
|
* ```ts
|
|
77
80
|
* if (payload.k === 'sv') {
|
|
78
|
-
* payload.sv
|
|
81
|
+
* payload.sv.forEach(...)
|
|
79
82
|
* }
|
|
80
83
|
* ```
|
|
81
|
-
*
|
|
82
|
-
* - `k: "ct"` — scalar payload (storage or query for `unique` / `match` / `ore`
|
|
83
|
-
* indexes). Storage payloads always carry `c`; query payloads omit `c` and
|
|
84
|
-
* carry exactly one of `hm`, `bf`, or `ob`.
|
|
85
|
-
* - `k: "sv"` — STE-vector payload. The FFI emits this for SteVec storage
|
|
86
|
-
* *and* for JSON containment queries (`ste_vec_term`), both of which carry
|
|
87
|
-
* per-selector entries in `sv` with the root document ciphertext at
|
|
88
|
-
* `sv[0].c`. Selector queries (`ste_vec_selector`) instead carry a single
|
|
89
|
-
* tokenized selector `s` and omit `sv`.
|
|
90
84
|
*/
|
|
91
85
|
export type Encrypted = EncryptedScalar | EncryptedSteVec;
|
|
92
|
-
/** Scalar EQL v2.3 payload (`k: "ct"`). */
|
|
86
|
+
/** Scalar EQL v2.3 storage payload (`k: "ct"`). */
|
|
93
87
|
export type EncryptedScalar = {
|
|
94
88
|
k: 'ct';
|
|
95
89
|
/** EQL schema version */
|
|
@@ -99,26 +93,20 @@ export type EncryptedScalar = {
|
|
|
99
93
|
t: string;
|
|
100
94
|
c: string;
|
|
101
95
|
};
|
|
102
|
-
/** Encrypted ciphertext (mp_base85).
|
|
103
|
-
c
|
|
104
|
-
/** HMAC-SHA256
|
|
96
|
+
/** Encrypted ciphertext (mp_base85). Always present on a storage payload. */
|
|
97
|
+
c: string;
|
|
98
|
+
/** HMAC-SHA256 term — present when a `unique` index is configured. */
|
|
105
99
|
hm?: string;
|
|
106
|
-
/** Bloom filter (set bit positions) —
|
|
100
|
+
/** Bloom filter (set bit positions) — present when a `match` index is configured. */
|
|
107
101
|
bf?: number[];
|
|
108
|
-
/** Block ORE u64_8_256 term —
|
|
102
|
+
/** Block ORE u64_8_256 term — present when an `ore` index is configured. */
|
|
109
103
|
ob?: string[];
|
|
110
104
|
};
|
|
111
105
|
/**
|
|
112
|
-
* STE-vector EQL v2.3 payload (`k: "sv"`).
|
|
113
|
-
*
|
|
114
|
-
* - {@link EncryptedSteVecStorage} for storage encryption and JSON containment
|
|
115
|
-
* queries — carries a non-empty `sv` with the root ciphertext at `sv[0].c`.
|
|
116
|
-
* - {@link EncryptedSteVecSelector} for `ste_vec_selector` queries — carries
|
|
117
|
-
* only a tokenized selector `s`.
|
|
106
|
+
* STE-vector EQL v2.3 storage payload (`k: "sv"`). Carries the per-selector
|
|
107
|
+
* entries in `sv`; the root document ciphertext lives at `sv[0].c`.
|
|
118
108
|
*/
|
|
119
|
-
export type EncryptedSteVec =
|
|
120
|
-
/** SteVec storage payload (also used for containment queries). */
|
|
121
|
-
export type EncryptedSteVecStorage = {
|
|
109
|
+
export type EncryptedSteVec = {
|
|
122
110
|
k: 'sv';
|
|
123
111
|
v: number;
|
|
124
112
|
i: {
|
|
@@ -129,7 +117,46 @@ export type EncryptedSteVecStorage = {
|
|
|
129
117
|
sv: [SteVecEntry, ...SteVecEntry[]];
|
|
130
118
|
s?: never;
|
|
131
119
|
};
|
|
132
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* EQL v2.3 **query** payload — an encrypted search term. Returned, alongside
|
|
122
|
+
* {@link Encrypted}, by {@link encryptQuery} / {@link encryptQueryBulk}.
|
|
123
|
+
*
|
|
124
|
+
* Unlike a storage payload, a query payload carries no ciphertext (`c`): it is
|
|
125
|
+
* matched against stored values, never decrypted. It must not be passed to
|
|
126
|
+
* {@link decrypt}.
|
|
127
|
+
*
|
|
128
|
+
* This covers the query shapes protect-ffi currently emits. cipherstash-client
|
|
129
|
+
* additionally defines `k: "sv"` hmac / ore / containment query terms; the FFI
|
|
130
|
+
* does not emit those today — JSON containment queries come back as an
|
|
131
|
+
* {@link EncryptedSteVec} storage payload.
|
|
132
|
+
*/
|
|
133
|
+
export type EncryptedQuery = EncryptedScalarQuery | EncryptedSteVecSelector;
|
|
134
|
+
/**
|
|
135
|
+
* Scalar query term (`k: "ct"`, no ciphertext) — a `unique` / `match` / `ore`
|
|
136
|
+
* lookup term carrying exactly one of `hm`, `bf`, or `ob`.
|
|
137
|
+
*/
|
|
138
|
+
export type EncryptedScalarQuery = {
|
|
139
|
+
k: 'ct';
|
|
140
|
+
/** EQL schema version */
|
|
141
|
+
v: number;
|
|
142
|
+
/** Table and column identifier */
|
|
143
|
+
i: {
|
|
144
|
+
t: string;
|
|
145
|
+
c: string;
|
|
146
|
+
};
|
|
147
|
+
/** Query payloads carry no ciphertext — discriminates against {@link EncryptedScalar}. */
|
|
148
|
+
c?: never;
|
|
149
|
+
} & ({
|
|
150
|
+
hm: string;
|
|
151
|
+
} | {
|
|
152
|
+
bf: number[];
|
|
153
|
+
} | {
|
|
154
|
+
ob: string[];
|
|
155
|
+
});
|
|
156
|
+
/**
|
|
157
|
+
* STE-vector selector query payload (`ste_vec_selector`) — a tokenized JSON
|
|
158
|
+
* path selector, no ciphertext.
|
|
159
|
+
*/
|
|
133
160
|
export type EncryptedSteVecSelector = {
|
|
134
161
|
k: 'sv';
|
|
135
162
|
v: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cipherstash/protect-ffi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.cjs",
|
|
6
6
|
"scripts": {
|
|
@@ -26,25 +26,45 @@
|
|
|
26
26
|
"prepack": "tsc &&neon update",
|
|
27
27
|
"version": "neon bump --binaries platforms && git add .",
|
|
28
28
|
"release": "gh workflow run release.yml -f dryrun=false -f version=patch",
|
|
29
|
-
"dryrun": "gh workflow run publish.yml -f dryrun=true"
|
|
29
|
+
"dryrun": "gh workflow run publish.yml -f dryrun=true",
|
|
30
|
+
"build:wasm": "wasm-pack build crates/protect-ffi --target bundler --out-dir ../../dist/wasm --no-pack",
|
|
31
|
+
"postbuild:wasm": "node scripts/inline-wasm.mjs"
|
|
30
32
|
},
|
|
31
33
|
"author": "",
|
|
32
34
|
"license": "ISC",
|
|
33
35
|
"exports": {
|
|
34
36
|
".": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
37
|
+
"node": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./lib/index.d.mts",
|
|
40
|
+
"default": "./lib/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./lib/index.d.cts",
|
|
44
|
+
"default": "./lib/index.cjs"
|
|
45
|
+
}
|
|
38
46
|
},
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
"default": "./dist/wasm/protect_ffi.js"
|
|
48
|
+
},
|
|
49
|
+
"./wasm": {
|
|
50
|
+
"types": "./dist/wasm/protect_ffi.d.ts",
|
|
51
|
+
"default": "./dist/wasm/protect_ffi.js"
|
|
52
|
+
},
|
|
53
|
+
"./wasm-inline": {
|
|
54
|
+
"types": "./dist/wasm/protect_ffi.d.ts",
|
|
55
|
+
"default": "./dist/wasm/protect_ffi_inline.js"
|
|
43
56
|
}
|
|
44
57
|
},
|
|
45
58
|
"types": "./lib/index.d.cts",
|
|
46
59
|
"files": [
|
|
47
|
-
"lib/**/*.?({c,m}){t,j}s"
|
|
60
|
+
"lib/**/*.?({c,m}){t,j}s",
|
|
61
|
+
"dist/wasm/package.json",
|
|
62
|
+
"dist/wasm/protect_ffi.js",
|
|
63
|
+
"dist/wasm/protect_ffi_bg.js",
|
|
64
|
+
"dist/wasm/protect_ffi_bg.wasm",
|
|
65
|
+
"dist/wasm/protect_ffi.d.ts",
|
|
66
|
+
"dist/wasm/protect_ffi_bg.wasm.d.ts",
|
|
67
|
+
"dist/wasm/protect_ffi_inline.js"
|
|
48
68
|
],
|
|
49
69
|
"neon": {
|
|
50
70
|
"type": "library",
|
|
@@ -75,11 +95,11 @@
|
|
|
75
95
|
"vite": "^8.0.5"
|
|
76
96
|
},
|
|
77
97
|
"optionalDependencies": {
|
|
78
|
-
"@cipherstash/protect-ffi-darwin-x64": "0.
|
|
79
|
-
"@cipherstash/protect-ffi-darwin-arm64": "0.
|
|
80
|
-
"@cipherstash/protect-ffi-win32-x64-msvc": "0.
|
|
81
|
-
"@cipherstash/protect-ffi-linux-x64-gnu": "0.
|
|
82
|
-
"@cipherstash/protect-ffi-linux-arm64-gnu": "0.
|
|
83
|
-
"@cipherstash/protect-ffi-linux-x64-musl": "0.
|
|
98
|
+
"@cipherstash/protect-ffi-darwin-x64": "0.24.0",
|
|
99
|
+
"@cipherstash/protect-ffi-darwin-arm64": "0.24.0",
|
|
100
|
+
"@cipherstash/protect-ffi-win32-x64-msvc": "0.24.0",
|
|
101
|
+
"@cipherstash/protect-ffi-linux-x64-gnu": "0.24.0",
|
|
102
|
+
"@cipherstash/protect-ffi-linux-arm64-gnu": "0.24.0",
|
|
103
|
+
"@cipherstash/protect-ffi-linux-x64-musl": "0.24.0"
|
|
84
104
|
}
|
|
85
105
|
}
|