@cipherstash/stack 1.0.0-rc.1 → 1.0.0-rc.3
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/CHANGELOG.md +33 -0
- package/dist/adapter-kit.cjs +2 -2
- package/dist/adapter-kit.cjs.map +1 -1
- package/dist/adapter-kit.js +1 -1
- package/dist/{chunk-HQANMV7R.js → chunk-BCY6WB24.js} +3 -3
- package/dist/{chunk-HQANMV7R.js.map → chunk-BCY6WB24.js.map} +1 -1
- package/dist/{chunk-IDKP6ABU.js → chunk-Q4WTOYVI.js} +2 -2
- package/dist/{chunk-L7ISHSG7.js → chunk-UI7V2QCK.js} +5 -5
- package/dist/{chunk-L7ISHSG7.js.map → chunk-UI7V2QCK.js.map} +1 -1
- package/dist/dynamodb/index.cjs +2 -2
- package/dist/dynamodb/index.cjs.map +1 -1
- package/dist/dynamodb/index.js +1 -1
- package/dist/encryption/index.cjs +4 -4
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/v3.cjs +4 -4
- package/dist/encryption/v3.cjs.map +1 -1
- package/dist/encryption/v3.js +3 -3
- package/dist/identity/index.cjs +2 -2
- package/dist/identity/index.cjs.map +1 -1
- package/dist/identity/index.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/wasm-inline.d.ts +241 -56
- package/dist/wasm-inline.js +268 -0
- package/dist/wasm-inline.js.map +1 -1
- package/package.json +17 -17
- /package/dist/{chunk-IDKP6ABU.js.map → chunk-Q4WTOYVI.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Encryption
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-UI7V2QCK.js";
|
|
4
|
+
import "./chunk-Q4WTOYVI.js";
|
|
5
5
|
import {
|
|
6
6
|
encryptedToPgComposite,
|
|
7
7
|
isEncryptedPayload
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import "./chunk-7333ZC6L.js";
|
|
15
15
|
import "./chunk-3B5ZX3IS.js";
|
|
16
16
|
import "./chunk-JSG2AMDI.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-BCY6WB24.js";
|
|
18
18
|
import "./chunk-NVKK7UDN.js";
|
|
19
19
|
import "./chunk-PZ5AY32C.js";
|
|
20
20
|
|
package/dist/wasm-inline.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccessKeyStrategy, OidcFederationStrategy } from '@cipherstash/auth/wasm-inline';
|
|
2
2
|
export { AccessKeyStrategy, OidcFederationStrategy } from '@cipherstash/auth/wasm-inline';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { EncryptedPayload } from '@cipherstash/protect-ffi';
|
|
4
|
+
import { EncryptedPayload, EncryptedQuery as EncryptedQuery$1, EncryptedV3Query } from '@cipherstash/protect-ffi';
|
|
5
5
|
|
|
6
6
|
/** Structural type representing encrypted data stored in the database. Always
|
|
7
7
|
* carries a ciphertext. Covers BOTH wire formats: the EQL v2.3 payloads
|
|
@@ -14,6 +14,14 @@ import { EncryptedPayload } from '@cipherstash/protect-ffi';
|
|
|
14
14
|
* and {@link EncryptedQuery} for the search-term shape returned by
|
|
15
15
|
* `encryptQuery`. */
|
|
16
16
|
type Encrypted = EncryptedPayload;
|
|
17
|
+
/** Structural type representing an encrypted query term (search needle)
|
|
18
|
+
* returned by `encryptQuery` / `encryptQueryBulk` for scalar
|
|
19
|
+
* (`unique` / `match` / `ore`) lookups and `ste_vec_selector` JSON path
|
|
20
|
+
* queries, plus — under `eqlVersion: 3` — the `eql_v3.jsonb_query`
|
|
21
|
+
* containment needle. Carries no ciphertext — matched against stored
|
|
22
|
+
* values, never decrypted. v2 JSON containment queries (`ste_vec_term`)
|
|
23
|
+
* return a storage-shaped {@link Encrypted} payload instead. */
|
|
24
|
+
type EncryptedQuery = EncryptedQuery$1 | EncryptedV3Query;
|
|
17
25
|
/** Structural contract for a column builder the client can consume for STORAGE
|
|
18
26
|
* (`encrypt`). Satisfied by v2 `EncryptedColumn` / `EncryptedField` AND v3
|
|
19
27
|
* `EncryptedTextSearchColumn` — fields ARE encryptable, so this stays wide. */
|
|
@@ -21,6 +29,21 @@ interface BuildableColumn {
|
|
|
21
29
|
getName(): string;
|
|
22
30
|
build(): ColumnSchema;
|
|
23
31
|
}
|
|
32
|
+
/** Structural contract for a column the client can consume for QUERIES
|
|
33
|
+
* (`encryptQuery` / search terms). Narrower than `BuildableColumn`: it must
|
|
34
|
+
* EXCLUDE non-queryable `EncryptedField` (a field has no indexes). A v2
|
|
35
|
+
* `EncryptedColumn` qualifies via the nominal arm; a v3 queryable concrete
|
|
36
|
+
* type qualifies via the `getEqlType()` structural arm; `EncryptedField` (no
|
|
37
|
+
* `getEqlType`, not an `EncryptedColumn`) is rejected. */
|
|
38
|
+
interface BuildableV3QueryableColumn extends BuildableColumn {
|
|
39
|
+
getEqlType(): string;
|
|
40
|
+
getQueryCapabilities(): {
|
|
41
|
+
equality: boolean;
|
|
42
|
+
orderAndRange: boolean;
|
|
43
|
+
freeTextSearch: boolean;
|
|
44
|
+
};
|
|
45
|
+
isQueryable(): true;
|
|
46
|
+
}
|
|
24
47
|
/** Structural contract for a table builder the client can consume. Satisfied by
|
|
25
48
|
* v2 and v3 `EncryptedTable` alike. */
|
|
26
49
|
interface BuildableTable {
|
|
@@ -51,6 +74,17 @@ type EncryptOptions = {
|
|
|
51
74
|
column: BuildableColumn;
|
|
52
75
|
table: BuildableTable;
|
|
53
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* User-facing query type names for encrypting query values.
|
|
79
|
+
*
|
|
80
|
+
* - `'equality'`: Exact match. [Exact Queries](https://cipherstash.com/docs/stack/cipherstash/encryption/searchable-encryption)
|
|
81
|
+
* - `'freeTextSearch'`: Text search. [Match Queries](https://cipherstash.com/docs/stack/cipherstash/encryption/searchable-encryption)
|
|
82
|
+
* - `'orderAndRange'`: Comparison and range. [Range Queries](https://cipherstash.com/docs/stack/cipherstash/encryption/searchable-encryption)
|
|
83
|
+
* - `'steVecSelector'`: JSONPath selector (e.g. `'$.user.email'`)
|
|
84
|
+
* - `'steVecTerm'`: Containment (e.g. `{ role: 'admin' }`)
|
|
85
|
+
* - `'searchableJson'`: Auto-infers selector or term from plaintext type (recommended)
|
|
86
|
+
*/
|
|
87
|
+
type QueryTypeName = 'orderAndRange' | 'freeTextSearch' | 'equality' | 'steVecSelector' | 'steVecTerm' | 'searchableJson';
|
|
54
88
|
|
|
55
89
|
declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
56
90
|
cast_as: z.ZodDefault<z.ZodEnum<["bigint", "boolean", "date", "timestamp", "number", "string", "json", "text"]>>;
|
|
@@ -164,11 +198,6 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
164
198
|
}, "strip", z.ZodTypeAny, {
|
|
165
199
|
ore?: {} | undefined;
|
|
166
200
|
ope?: {} | undefined;
|
|
167
|
-
unique?: {
|
|
168
|
-
token_filters?: {
|
|
169
|
-
kind: "downcase";
|
|
170
|
-
}[] | undefined;
|
|
171
|
-
} | undefined;
|
|
172
201
|
match?: {
|
|
173
202
|
token_filters?: {
|
|
174
203
|
kind: "downcase";
|
|
@@ -183,6 +212,11 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
183
212
|
m?: number | undefined;
|
|
184
213
|
include_original?: boolean | undefined;
|
|
185
214
|
} | undefined;
|
|
215
|
+
unique?: {
|
|
216
|
+
token_filters?: {
|
|
217
|
+
kind: "downcase";
|
|
218
|
+
}[] | undefined;
|
|
219
|
+
} | undefined;
|
|
186
220
|
ste_vec?: {
|
|
187
221
|
prefix: string;
|
|
188
222
|
array_index_mode?: "all" | "none" | {
|
|
@@ -195,11 +229,6 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
195
229
|
}, {
|
|
196
230
|
ore?: {} | undefined;
|
|
197
231
|
ope?: {} | undefined;
|
|
198
|
-
unique?: {
|
|
199
|
-
token_filters?: {
|
|
200
|
-
kind: "downcase";
|
|
201
|
-
}[] | undefined;
|
|
202
|
-
} | undefined;
|
|
203
232
|
match?: {
|
|
204
233
|
token_filters?: {
|
|
205
234
|
kind: "downcase";
|
|
@@ -214,6 +243,11 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
214
243
|
m?: number | undefined;
|
|
215
244
|
include_original?: boolean | undefined;
|
|
216
245
|
} | undefined;
|
|
246
|
+
unique?: {
|
|
247
|
+
token_filters?: {
|
|
248
|
+
kind: "downcase";
|
|
249
|
+
}[] | undefined;
|
|
250
|
+
} | undefined;
|
|
217
251
|
ste_vec?: {
|
|
218
252
|
prefix: string;
|
|
219
253
|
array_index_mode?: "all" | "none" | {
|
|
@@ -229,11 +263,6 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
229
263
|
indexes: {
|
|
230
264
|
ore?: {} | undefined;
|
|
231
265
|
ope?: {} | undefined;
|
|
232
|
-
unique?: {
|
|
233
|
-
token_filters?: {
|
|
234
|
-
kind: "downcase";
|
|
235
|
-
}[] | undefined;
|
|
236
|
-
} | undefined;
|
|
237
266
|
match?: {
|
|
238
267
|
token_filters?: {
|
|
239
268
|
kind: "downcase";
|
|
@@ -248,6 +277,11 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
248
277
|
m?: number | undefined;
|
|
249
278
|
include_original?: boolean | undefined;
|
|
250
279
|
} | undefined;
|
|
280
|
+
unique?: {
|
|
281
|
+
token_filters?: {
|
|
282
|
+
kind: "downcase";
|
|
283
|
+
}[] | undefined;
|
|
284
|
+
} | undefined;
|
|
251
285
|
ste_vec?: {
|
|
252
286
|
prefix: string;
|
|
253
287
|
array_index_mode?: "all" | "none" | {
|
|
@@ -263,11 +297,6 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
263
297
|
indexes?: {
|
|
264
298
|
ore?: {} | undefined;
|
|
265
299
|
ope?: {} | undefined;
|
|
266
|
-
unique?: {
|
|
267
|
-
token_filters?: {
|
|
268
|
-
kind: "downcase";
|
|
269
|
-
}[] | undefined;
|
|
270
|
-
} | undefined;
|
|
271
300
|
match?: {
|
|
272
301
|
token_filters?: {
|
|
273
302
|
kind: "downcase";
|
|
@@ -282,6 +311,11 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
282
311
|
m?: number | undefined;
|
|
283
312
|
include_original?: boolean | undefined;
|
|
284
313
|
} | undefined;
|
|
314
|
+
unique?: {
|
|
315
|
+
token_filters?: {
|
|
316
|
+
kind: "downcase";
|
|
317
|
+
}[] | undefined;
|
|
318
|
+
} | undefined;
|
|
285
319
|
ste_vec?: {
|
|
286
320
|
prefix: string;
|
|
287
321
|
array_index_mode?: "all" | "none" | {
|
|
@@ -408,11 +442,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
408
442
|
}, "strip", z.ZodTypeAny, {
|
|
409
443
|
ore?: {} | undefined;
|
|
410
444
|
ope?: {} | undefined;
|
|
411
|
-
unique?: {
|
|
412
|
-
token_filters?: {
|
|
413
|
-
kind: "downcase";
|
|
414
|
-
}[] | undefined;
|
|
415
|
-
} | undefined;
|
|
416
445
|
match?: {
|
|
417
446
|
token_filters?: {
|
|
418
447
|
kind: "downcase";
|
|
@@ -427,6 +456,11 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
427
456
|
m?: number | undefined;
|
|
428
457
|
include_original?: boolean | undefined;
|
|
429
458
|
} | undefined;
|
|
459
|
+
unique?: {
|
|
460
|
+
token_filters?: {
|
|
461
|
+
kind: "downcase";
|
|
462
|
+
}[] | undefined;
|
|
463
|
+
} | undefined;
|
|
430
464
|
ste_vec?: {
|
|
431
465
|
prefix: string;
|
|
432
466
|
array_index_mode?: "all" | "none" | {
|
|
@@ -439,11 +473,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
439
473
|
}, {
|
|
440
474
|
ore?: {} | undefined;
|
|
441
475
|
ope?: {} | undefined;
|
|
442
|
-
unique?: {
|
|
443
|
-
token_filters?: {
|
|
444
|
-
kind: "downcase";
|
|
445
|
-
}[] | undefined;
|
|
446
|
-
} | undefined;
|
|
447
476
|
match?: {
|
|
448
477
|
token_filters?: {
|
|
449
478
|
kind: "downcase";
|
|
@@ -458,6 +487,11 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
458
487
|
m?: number | undefined;
|
|
459
488
|
include_original?: boolean | undefined;
|
|
460
489
|
} | undefined;
|
|
490
|
+
unique?: {
|
|
491
|
+
token_filters?: {
|
|
492
|
+
kind: "downcase";
|
|
493
|
+
}[] | undefined;
|
|
494
|
+
} | undefined;
|
|
461
495
|
ste_vec?: {
|
|
462
496
|
prefix: string;
|
|
463
497
|
array_index_mode?: "all" | "none" | {
|
|
@@ -473,11 +507,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
473
507
|
indexes: {
|
|
474
508
|
ore?: {} | undefined;
|
|
475
509
|
ope?: {} | undefined;
|
|
476
|
-
unique?: {
|
|
477
|
-
token_filters?: {
|
|
478
|
-
kind: "downcase";
|
|
479
|
-
}[] | undefined;
|
|
480
|
-
} | undefined;
|
|
481
510
|
match?: {
|
|
482
511
|
token_filters?: {
|
|
483
512
|
kind: "downcase";
|
|
@@ -492,6 +521,11 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
492
521
|
m?: number | undefined;
|
|
493
522
|
include_original?: boolean | undefined;
|
|
494
523
|
} | undefined;
|
|
524
|
+
unique?: {
|
|
525
|
+
token_filters?: {
|
|
526
|
+
kind: "downcase";
|
|
527
|
+
}[] | undefined;
|
|
528
|
+
} | undefined;
|
|
495
529
|
ste_vec?: {
|
|
496
530
|
prefix: string;
|
|
497
531
|
array_index_mode?: "all" | "none" | {
|
|
@@ -507,11 +541,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
507
541
|
indexes?: {
|
|
508
542
|
ore?: {} | undefined;
|
|
509
543
|
ope?: {} | undefined;
|
|
510
|
-
unique?: {
|
|
511
|
-
token_filters?: {
|
|
512
|
-
kind: "downcase";
|
|
513
|
-
}[] | undefined;
|
|
514
|
-
} | undefined;
|
|
515
544
|
match?: {
|
|
516
545
|
token_filters?: {
|
|
517
546
|
kind: "downcase";
|
|
@@ -526,6 +555,11 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
526
555
|
m?: number | undefined;
|
|
527
556
|
include_original?: boolean | undefined;
|
|
528
557
|
} | undefined;
|
|
558
|
+
unique?: {
|
|
559
|
+
token_filters?: {
|
|
560
|
+
kind: "downcase";
|
|
561
|
+
}[] | undefined;
|
|
562
|
+
} | undefined;
|
|
529
563
|
ste_vec?: {
|
|
530
564
|
prefix: string;
|
|
531
565
|
array_index_mode?: "all" | "none" | {
|
|
@@ -544,11 +578,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
544
578
|
indexes: {
|
|
545
579
|
ore?: {} | undefined;
|
|
546
580
|
ope?: {} | undefined;
|
|
547
|
-
unique?: {
|
|
548
|
-
token_filters?: {
|
|
549
|
-
kind: "downcase";
|
|
550
|
-
}[] | undefined;
|
|
551
|
-
} | undefined;
|
|
552
581
|
match?: {
|
|
553
582
|
token_filters?: {
|
|
554
583
|
kind: "downcase";
|
|
@@ -563,6 +592,11 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
563
592
|
m?: number | undefined;
|
|
564
593
|
include_original?: boolean | undefined;
|
|
565
594
|
} | undefined;
|
|
595
|
+
unique?: {
|
|
596
|
+
token_filters?: {
|
|
597
|
+
kind: "downcase";
|
|
598
|
+
}[] | undefined;
|
|
599
|
+
} | undefined;
|
|
566
600
|
ste_vec?: {
|
|
567
601
|
prefix: string;
|
|
568
602
|
array_index_mode?: "all" | "none" | {
|
|
@@ -581,11 +615,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
581
615
|
indexes?: {
|
|
582
616
|
ore?: {} | undefined;
|
|
583
617
|
ope?: {} | undefined;
|
|
584
|
-
unique?: {
|
|
585
|
-
token_filters?: {
|
|
586
|
-
kind: "downcase";
|
|
587
|
-
}[] | undefined;
|
|
588
|
-
} | undefined;
|
|
589
618
|
match?: {
|
|
590
619
|
token_filters?: {
|
|
591
620
|
kind: "downcase";
|
|
@@ -600,6 +629,11 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
600
629
|
m?: number | undefined;
|
|
601
630
|
include_original?: boolean | undefined;
|
|
602
631
|
} | undefined;
|
|
632
|
+
unique?: {
|
|
633
|
+
token_filters?: {
|
|
634
|
+
kind: "downcase";
|
|
635
|
+
}[] | undefined;
|
|
636
|
+
} | undefined;
|
|
603
637
|
ste_vec?: {
|
|
604
638
|
prefix: string;
|
|
605
639
|
array_index_mode?: "all" | "none" | {
|
|
@@ -1430,6 +1464,17 @@ declare const types: {
|
|
|
1430
1464
|
* table: users,
|
|
1431
1465
|
* })
|
|
1432
1466
|
* const dec = await client.decrypt(enc)
|
|
1467
|
+
*
|
|
1468
|
+
* // Searchable encryption: mint a ciphertext-free QUERY TERM and cast it
|
|
1469
|
+
* // to the column's `eql_v3.query_<domain>` type in SQL to hit the index.
|
|
1470
|
+
* const term = await client.encryptQuery("alice@example.com", {
|
|
1471
|
+
* column: users.email,
|
|
1472
|
+
* table: users,
|
|
1473
|
+
* queryType: "freeTextSearch",
|
|
1474
|
+
* })
|
|
1475
|
+
* // e.g. postgres-js:
|
|
1476
|
+
* // sql`SELECT * FROM users
|
|
1477
|
+
* // WHERE eql_v3.contains(email, ${term}::jsonb::eql_v3.query_text_search)`
|
|
1433
1478
|
* ```
|
|
1434
1479
|
*
|
|
1435
1480
|
* For per-user, identity-bound encryption on the edge, build an
|
|
@@ -1552,13 +1597,55 @@ type WasmEncryptionConfig = {
|
|
|
1552
1597
|
schemas: [AnyV3Table, ...AnyV3Table[]];
|
|
1553
1598
|
config: WasmClientConfig;
|
|
1554
1599
|
};
|
|
1600
|
+
/**
|
|
1601
|
+
* Options for {@link WasmEncryptionClient.encryptQuery}.
|
|
1602
|
+
*
|
|
1603
|
+
* The column must be a QUERYABLE v3 column (authored via the `types.*`
|
|
1604
|
+
* factories re-exported from this entry) — storage-only columns like
|
|
1605
|
+
* `types.Text` with no indexes have nothing to query.
|
|
1606
|
+
*/
|
|
1607
|
+
type WasmEncryptQueryOptions = {
|
|
1608
|
+
/** The `encryptedTable(...)` the column belongs to. */
|
|
1609
|
+
table: EncryptOptions['table'];
|
|
1610
|
+
/** The queryable v3 column the term targets, e.g. `users.email`. */
|
|
1611
|
+
column: BuildableV3QueryableColumn;
|
|
1612
|
+
/**
|
|
1613
|
+
* Which of the column's indexes the term targets:
|
|
1614
|
+
*
|
|
1615
|
+
* - `'equality'` — exact match (`unique` index; `=` / `IN`)
|
|
1616
|
+
* - `'freeTextSearch'` — fuzzy token match (`match` index; one-sided —
|
|
1617
|
+
* a match may be a false positive, a non-match never is)
|
|
1618
|
+
* - `'orderAndRange'` — comparisons and ranges (`ore` index; `<` `>`
|
|
1619
|
+
* `BETWEEN` / `ORDER BY`)
|
|
1620
|
+
* - `'searchableJson'` — encrypted JSON (`ste_vec` index): a **string**
|
|
1621
|
+
* value is treated as a JSONPath selector (`'$.user.email'`), any other
|
|
1622
|
+
* value as a containment needle (`{ role: 'admin' }`)
|
|
1623
|
+
*
|
|
1624
|
+
* Omit to infer from the column's configured indexes (priority:
|
|
1625
|
+
* `unique > match > ore > ste_vec`, matching the native client) —
|
|
1626
|
+
* unambiguous for single-index columns like `types.TextEq`, but be
|
|
1627
|
+
* explicit for multi-index domains like `types.TextSearch` (which
|
|
1628
|
+
* carries all three scalar indexes).
|
|
1629
|
+
*/
|
|
1630
|
+
queryType?: QueryTypeName;
|
|
1631
|
+
};
|
|
1632
|
+
/**
|
|
1633
|
+
* One term for {@link WasmEncryptionClient.encryptQueryBulk} — the
|
|
1634
|
+
* {@link WasmEncryptQueryOptions} plus the plaintext needle. A `null`
|
|
1635
|
+
* value yields `null` at the same position in the result (nothing to
|
|
1636
|
+
* search for).
|
|
1637
|
+
*/
|
|
1638
|
+
type WasmQueryTerm = WasmEncryptQueryOptions & {
|
|
1639
|
+
value: WasmPlaintext;
|
|
1640
|
+
};
|
|
1555
1641
|
/**
|
|
1556
1642
|
* WASM encryption client. Returned by {@link Encryption}.
|
|
1557
1643
|
*
|
|
1558
|
-
* Wraps an opaque `wasmNewClient` handle and exposes
|
|
1559
|
-
* `
|
|
1560
|
-
*
|
|
1561
|
-
*
|
|
1644
|
+
* Wraps an opaque `wasmNewClient` handle and exposes `encrypt`, `decrypt`,
|
|
1645
|
+
* `isEncrypted`, and — since #662 made searchable encryption reachable on
|
|
1646
|
+
* the edge — `encryptQuery` / `encryptQueryBulk` for minting v3 query
|
|
1647
|
+
* terms. Remaining surface (bulk encrypt/decrypt, model helpers) lives on
|
|
1648
|
+
* the Node entry — port lazily as Deno / edge consumers demand it.
|
|
1562
1649
|
*
|
|
1563
1650
|
* Construct via {@link Encryption} — the constructor is private to
|
|
1564
1651
|
* prevent callers from wrapping arbitrary objects in this type.
|
|
@@ -1576,6 +1663,104 @@ declare class WasmEncryptionClient {
|
|
|
1576
1663
|
encrypt(plaintext: WasmPlaintext, opts: EncryptOptions): Promise<Encrypted>;
|
|
1577
1664
|
decrypt(encrypted: Encrypted): Promise<WasmPlaintext>;
|
|
1578
1665
|
isEncrypted(value: unknown): boolean;
|
|
1666
|
+
/**
|
|
1667
|
+
* Encrypt a QUERY TERM (search needle) for a queryable v3 column —
|
|
1668
|
+
* equality, free-text match, ORE range, or JSON containment/selector.
|
|
1669
|
+
*
|
|
1670
|
+
* The returned term is **ciphertext-free**: it is matched against stored
|
|
1671
|
+
* envelopes, never decrypted, so it is safe to log-scrub less aggressively
|
|
1672
|
+
* than storage payloads (though it still derives from the plaintext).
|
|
1673
|
+
* Interpolate it as a parameter and cast to the column's
|
|
1674
|
+
* `eql_v3.query_<domain>` type to reach the indexed operators — the domain
|
|
1675
|
+
* suffix mirrors the storage domain (`eql_v3_text_eq` →
|
|
1676
|
+
* `eql_v3.query_text_eq`; irregular: `eql_v3_json` → `eql_v3.query_jsonb`).
|
|
1677
|
+
*
|
|
1678
|
+
* @example Equality (unique index)
|
|
1679
|
+
* ```ts
|
|
1680
|
+
* const term = await client.encryptQuery("alice@example.com", {
|
|
1681
|
+
* table: users, column: users.email, queryType: "equality",
|
|
1682
|
+
* })
|
|
1683
|
+
* // postgres-js:
|
|
1684
|
+
* sql`SELECT * FROM users
|
|
1685
|
+
* WHERE email = ${term}::jsonb::eql_v3.query_text_eq`
|
|
1686
|
+
* ```
|
|
1687
|
+
*
|
|
1688
|
+
* @example Free-text match (bloom index — one-sided, fuzzy)
|
|
1689
|
+
* ```ts
|
|
1690
|
+
* const term = await client.encryptQuery("needle", {
|
|
1691
|
+
* table: users, column: users.bio, queryType: "freeTextSearch",
|
|
1692
|
+
* })
|
|
1693
|
+
* sql`SELECT * FROM users
|
|
1694
|
+
* WHERE eql_v3.contains(bio, ${term}::jsonb::eql_v3.query_text_search)`
|
|
1695
|
+
* ```
|
|
1696
|
+
*
|
|
1697
|
+
* @example Range / ORDER BY (ORE index)
|
|
1698
|
+
* ```ts
|
|
1699
|
+
* const term = await client.encryptQuery(42, {
|
|
1700
|
+
* table: users, column: users.age, queryType: "orderAndRange",
|
|
1701
|
+
* })
|
|
1702
|
+
* sql`SELECT * FROM users
|
|
1703
|
+
* WHERE eql_v3.gte(age, ${term}::jsonb::eql_v3.query_integer_ord)`
|
|
1704
|
+
* ```
|
|
1705
|
+
*
|
|
1706
|
+
* @example Encrypted JSON — containment and JSONPath selector
|
|
1707
|
+
* ```ts
|
|
1708
|
+
* // Object value → containment needle (a v3 envelope):
|
|
1709
|
+
* const contains = await client.encryptQuery({ role: "admin" }, {
|
|
1710
|
+
* table: users, column: users.prefs, queryType: "searchableJson",
|
|
1711
|
+
* })
|
|
1712
|
+
* sql`SELECT * FROM users
|
|
1713
|
+
* WHERE prefs @> ${contains}::jsonb::eql_v3.query_jsonb`
|
|
1714
|
+
*
|
|
1715
|
+
* // String value → JSONPath selector. NOTE: v3 has no encrypted-selector
|
|
1716
|
+
* // envelope — this returns the BARE selector-hash string, bound as the
|
|
1717
|
+
* // text argument of -> / ->>:
|
|
1718
|
+
* const selector = await client.encryptQuery("$.role", {
|
|
1719
|
+
* table: users, column: users.prefs, queryType: "searchableJson",
|
|
1720
|
+
* })
|
|
1721
|
+
* sql`SELECT prefs -> ${selector} FROM users`
|
|
1722
|
+
* ```
|
|
1723
|
+
*
|
|
1724
|
+
* @param plaintext - The search needle. `null`/`undefined` returns `null`
|
|
1725
|
+
* without contacting ZeroKMS (nothing to search for), mirroring the
|
|
1726
|
+
* native client.
|
|
1727
|
+
* @param opts - Table, column, and (optionally) which index to target —
|
|
1728
|
+
* see {@link WasmEncryptQueryOptions.queryType} for the inference rules.
|
|
1729
|
+
* @returns The v3 query term, or `null` for null plaintext.
|
|
1730
|
+
* @throws When the requested `queryType` isn't configured on the column,
|
|
1731
|
+
* the column has no indexes at all, the value fails the same pre-flight
|
|
1732
|
+
* validation the native client runs (NaN / Infinity / out-of-int64
|
|
1733
|
+
* bigint, or a numeric value against a `freeTextSearch` index), or
|
|
1734
|
+
* encryption fails. Errors THROW, consistent with this surface's
|
|
1735
|
+
* `encrypt`/`decrypt` (the native entry's `{ data } | { failure }`
|
|
1736
|
+
* envelope lives on the Node client only).
|
|
1737
|
+
*/
|
|
1738
|
+
encryptQuery(plaintext: WasmPlaintext, opts: WasmEncryptQueryOptions): Promise<EncryptedQuery | null>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Batch form of {@link encryptQuery} — one ZeroKMS round trip for many
|
|
1741
|
+
* terms, which is the shape query builders want (encrypt every needle in
|
|
1742
|
+
* a WHERE clause together).
|
|
1743
|
+
*
|
|
1744
|
+
* Position-stable: the result array is index-aligned with `terms`, and a
|
|
1745
|
+
* `null`/`undefined` value yields `null` at the same index (an all-null
|
|
1746
|
+
* batch short-circuits without calling ZeroKMS). Terms may mix query
|
|
1747
|
+
* types and columns freely.
|
|
1748
|
+
*
|
|
1749
|
+
* @example
|
|
1750
|
+
* ```ts
|
|
1751
|
+
* const [emailEq, bioMatch] = await client.encryptQueryBulk([
|
|
1752
|
+
* { value: "alice@example.com", table: users, column: users.email,
|
|
1753
|
+
* queryType: "equality" },
|
|
1754
|
+
* { value: "needle", table: users, column: users.bio,
|
|
1755
|
+
* queryType: "freeTextSearch" },
|
|
1756
|
+
* ])
|
|
1757
|
+
* ```
|
|
1758
|
+
*
|
|
1759
|
+
* @param terms - The needles to encrypt; see {@link WasmQueryTerm}.
|
|
1760
|
+
* @returns Index-aligned array of v3 query terms (or `null` per null value).
|
|
1761
|
+
* @throws As {@link encryptQuery} — the first invalid term aborts the batch.
|
|
1762
|
+
*/
|
|
1763
|
+
encryptQueryBulk(terms: readonly WasmQueryTerm[]): Promise<Array<EncryptedQuery | null>>;
|
|
1579
1764
|
}
|
|
1580
1765
|
/**
|
|
1581
1766
|
* Initialize a WASM-backed encryption client.
|
|
@@ -1640,4 +1825,4 @@ declare function __resetStrategyDeprecationWarningForTests(): void;
|
|
|
1640
1825
|
*/
|
|
1641
1826
|
declare function resolveStrategy(cfg: WasmClientConfig): WasmAuthStrategy;
|
|
1642
1827
|
|
|
1643
|
-
export { type AnyEncryptedV3Column, type AnyV3Table, type ColumnsOf, type Encrypted, EncryptedBigintColumn, EncryptedBigintEqColumn, EncryptedBigintOrdColumn, EncryptedBigintOrdOreColumn, EncryptedBooleanColumn, EncryptedDateColumn, EncryptedDateEqColumn, EncryptedDateOrdColumn, EncryptedDateOrdOreColumn, EncryptedDoubleColumn, EncryptedDoubleEqColumn, EncryptedDoubleOrdColumn, EncryptedDoubleOrdOreColumn, EncryptedIntegerColumn, EncryptedIntegerEqColumn, EncryptedIntegerOrdColumn, EncryptedIntegerOrdOreColumn, EncryptedJsonColumn, EncryptedNumericColumn, EncryptedNumericEqColumn, EncryptedNumericOrdColumn, EncryptedNumericOrdOreColumn, EncryptedRealColumn, EncryptedRealEqColumn, EncryptedRealOrdColumn, EncryptedRealOrdOreColumn, EncryptedSmallintColumn, EncryptedSmallintEqColumn, EncryptedSmallintOrdColumn, EncryptedSmallintOrdOreColumn, EncryptedTable, EncryptedTextColumn, EncryptedTextEqColumn, EncryptedTextMatchColumn, EncryptedTextOrdColumn, EncryptedTextOrdOreColumn, EncryptedTextSearchColumn, EncryptedTimestampColumn, EncryptedTimestampEqColumn, EncryptedTimestampOrdColumn, EncryptedTimestampOrdOreColumn, type EncryptedV3TableColumn, Encryption, type EqlTypeForColumn, type InferEncrypted, type InferPlaintext, type JsonDocument, type JsonValue, type PlaintextForColumn, type QueryCapabilities, type QueryTypesForColumn, type QueryableColumnsOf, TEXT_SEARCH_EQL_TYPE, type V3DecryptedModel, type V3EncryptedModel, type V3ModelInput, type WasmAuthStrategy, type WasmClientConfig, WasmEncryptionClient, type WasmEncryptionConfig, type WasmPlaintext, __resetStrategyDeprecationWarningForTests, buildEncryptConfig, encryptedTable, getColumnName, isEncrypted, normalizeCastAs, resolveStrategy, types };
|
|
1828
|
+
export { type AnyEncryptedV3Column, type AnyV3Table, type ColumnsOf, type Encrypted, EncryptedBigintColumn, EncryptedBigintEqColumn, EncryptedBigintOrdColumn, EncryptedBigintOrdOreColumn, EncryptedBooleanColumn, EncryptedDateColumn, EncryptedDateEqColumn, EncryptedDateOrdColumn, EncryptedDateOrdOreColumn, EncryptedDoubleColumn, EncryptedDoubleEqColumn, EncryptedDoubleOrdColumn, EncryptedDoubleOrdOreColumn, EncryptedIntegerColumn, EncryptedIntegerEqColumn, EncryptedIntegerOrdColumn, EncryptedIntegerOrdOreColumn, EncryptedJsonColumn, EncryptedNumericColumn, EncryptedNumericEqColumn, EncryptedNumericOrdColumn, EncryptedNumericOrdOreColumn, EncryptedRealColumn, EncryptedRealEqColumn, EncryptedRealOrdColumn, EncryptedRealOrdOreColumn, EncryptedSmallintColumn, EncryptedSmallintEqColumn, EncryptedSmallintOrdColumn, EncryptedSmallintOrdOreColumn, EncryptedTable, EncryptedTextColumn, EncryptedTextEqColumn, EncryptedTextMatchColumn, EncryptedTextOrdColumn, EncryptedTextOrdOreColumn, EncryptedTextSearchColumn, EncryptedTimestampColumn, EncryptedTimestampEqColumn, EncryptedTimestampOrdColumn, EncryptedTimestampOrdOreColumn, type EncryptedV3TableColumn, Encryption, type EqlTypeForColumn, type InferEncrypted, type InferPlaintext, type JsonDocument, type JsonValue, type PlaintextForColumn, type QueryCapabilities, type QueryTypesForColumn, type QueryableColumnsOf, TEXT_SEARCH_EQL_TYPE, type V3DecryptedModel, type V3EncryptedModel, type V3ModelInput, type WasmAuthStrategy, type WasmClientConfig, type WasmEncryptQueryOptions, WasmEncryptionClient, type WasmEncryptionConfig, type WasmPlaintext, type WasmQueryTerm, __resetStrategyDeprecationWarningForTests, buildEncryptConfig, encryptedTable, getColumnName, isEncrypted, normalizeCastAs, resolveStrategy, types };
|