@cipherstash/stack 0.1.0 → 0.3.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/CHANGELOG.md +12 -0
- package/README.md +11 -14
- package/dist/bin/stash.js +90 -57
- package/dist/bin/stash.js.map +1 -1
- package/dist/{chunk-SJ7JO4ME.js → chunk-JLI27P46.js} +1 -1
- package/dist/chunk-JLI27P46.js.map +1 -0
- package/dist/{chunk-2GZMIJFO.js → chunk-MW6D52V2.js} +69 -43
- package/dist/chunk-MW6D52V2.js.map +1 -0
- package/dist/{chunk-5DCT6YU2.js → chunk-OAPLZLR5.js} +7 -3
- package/dist/{chunk-5DCT6YU2.js.map → chunk-OAPLZLR5.js.map} +1 -1
- package/dist/{chunk-7XRPN2KX.js → chunk-TBAIVO6T.js} +26 -23
- package/dist/chunk-TBAIVO6T.js.map +1 -0
- package/dist/{client-BxJG56Ey.d.cts → client-Bf0Xw2xo.d.cts} +44 -26
- package/dist/{client-DtGq9dJp.d.ts → client-Kfp8OsPB.d.ts} +44 -26
- package/dist/client.cjs +25 -22
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -5
- package/dist/drizzle/index.cjs +19 -16
- package/dist/drizzle/index.cjs.map +1 -1
- package/dist/drizzle/index.d.cts +5 -5
- package/dist/drizzle/index.d.ts +5 -5
- package/dist/drizzle/index.js +2 -2
- package/dist/drizzle/index.js.map +1 -1
- package/dist/dynamodb/index.cjs.map +1 -1
- package/dist/dynamodb/index.d.cts +10 -10
- package/dist/dynamodb/index.d.ts +10 -10
- package/dist/dynamodb/index.js.map +1 -1
- package/dist/identity/index.cjs +6 -2
- package/dist/identity/index.cjs.map +1 -1
- package/dist/identity/index.js +1 -1
- package/dist/index.cjs +94 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/schema/index.cjs +31 -28
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +11 -11
- package/dist/secrets/index.cjs +90 -57
- package/dist/secrets/index.cjs.map +1 -1
- package/dist/secrets/index.d.cts +1 -1
- package/dist/secrets/index.d.ts +1 -1
- package/dist/secrets/index.js +4 -4
- package/dist/secrets/index.js.map +1 -1
- package/dist/supabase/index.cjs +7 -7
- package/dist/supabase/index.cjs.map +1 -1
- package/dist/supabase/index.d.cts +3 -3
- package/dist/supabase/index.d.ts +3 -3
- package/dist/supabase/index.js +3 -3
- package/dist/supabase/index.js.map +1 -1
- package/dist/{types-public-BCj1L4fi.d.ts → types-public-0CzBV45X.d.cts} +100 -58
- package/dist/{types-public-BCj1L4fi.d.cts → types-public-0CzBV45X.d.ts} +100 -58
- package/dist/types-public.cjs.map +1 -1
- package/dist/types-public.d.cts +1 -1
- package/dist/types-public.d.ts +1 -1
- package/dist/types-public.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2GZMIJFO.js.map +0 -1
- package/dist/chunk-7XRPN2KX.js.map +0 -1
- package/dist/chunk-SJ7JO4ME.js.map +0 -1
|
@@ -61,20 +61,26 @@ type ClientConfig = {
|
|
|
61
61
|
};
|
|
62
62
|
type AtLeastOneCsTable<T> = [T, ...T[]];
|
|
63
63
|
type EncryptionClientConfig = {
|
|
64
|
-
schemas: AtLeastOneCsTable<
|
|
64
|
+
schemas: AtLeastOneCsTable<EncryptedTable<EncryptedTableColumn>>;
|
|
65
65
|
config?: ClientConfig;
|
|
66
66
|
logging?: LoggingConfig;
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Options for single-value encrypt operations.
|
|
70
|
+
* Use a column from your table schema (from {@link encryptedColumn}) or a nested
|
|
71
|
+
* field (from {@link encryptedField}) as the target for encryption.
|
|
72
|
+
*/
|
|
68
73
|
type EncryptOptions = {
|
|
69
|
-
column
|
|
70
|
-
|
|
74
|
+
/** The column or nested field to encrypt into. From {@link EncryptedColumn} or {@link EncryptedField}. */
|
|
75
|
+
column: EncryptedColumn | EncryptedField;
|
|
76
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
71
77
|
};
|
|
72
78
|
/** Format for encrypted query/search term return values */
|
|
73
79
|
type EncryptedReturnType = 'eql' | 'composite-literal' | 'escaped-composite-literal';
|
|
74
80
|
type SearchTerm = {
|
|
75
81
|
value: JsPlaintext;
|
|
76
|
-
column:
|
|
77
|
-
table:
|
|
82
|
+
column: EncryptedColumn;
|
|
83
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
78
84
|
returnType?: EncryptedReturnType;
|
|
79
85
|
};
|
|
80
86
|
/** Encrypted search term result: EQL object or composite literal string */
|
|
@@ -92,6 +98,30 @@ type DecryptedFields<T> = {
|
|
|
92
98
|
};
|
|
93
99
|
/** Model with encrypted fields replaced by plaintext (decrypted) values */
|
|
94
100
|
type Decrypted<T> = OtherFields<T> & DecryptedFields<T>;
|
|
101
|
+
/**
|
|
102
|
+
* Maps a plaintext model type to its encrypted form using the table schema.
|
|
103
|
+
*
|
|
104
|
+
* Fields whose keys match columns defined in `S` become `Encrypted`;
|
|
105
|
+
* all other fields retain their original types from `T`.
|
|
106
|
+
*
|
|
107
|
+
* When `S` is the widened `EncryptedTableColumn` (e.g. when a user passes an
|
|
108
|
+
* explicit `<User>` type argument without specifying `S`), the type degrades
|
|
109
|
+
* gracefully to `T` — preserving backward compatibility.
|
|
110
|
+
*
|
|
111
|
+
* @typeParam T - The plaintext model type (e.g. `{ id: string; email: string }`)
|
|
112
|
+
* @typeParam S - The table schema column definition, inferred from the `table` argument
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* type User = { id: string; email: string }
|
|
117
|
+
* // With a schema that defines `email`:
|
|
118
|
+
* type Encrypted = EncryptedFromSchema<User, { email: EncryptedColumn }>
|
|
119
|
+
* // => { id: string; email: Encrypted }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
type EncryptedFromSchema<T, S extends EncryptedTableColumn> = {
|
|
123
|
+
[K in keyof T]: [K] extends [keyof S] ? [S[K & keyof S]] extends [EncryptedColumn | EncryptedField] ? Encrypted : T[K] : T[K];
|
|
124
|
+
};
|
|
95
125
|
type BulkEncryptPayload = Array<{
|
|
96
126
|
id?: string;
|
|
97
127
|
plaintext: JsPlaintext | null;
|
|
@@ -142,8 +172,8 @@ declare const queryTypes: {
|
|
|
142
172
|
};
|
|
143
173
|
/** @internal */
|
|
144
174
|
type QueryTermBase = {
|
|
145
|
-
column:
|
|
146
|
-
table:
|
|
175
|
+
column: EncryptedColumn;
|
|
176
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
147
177
|
queryType?: QueryTypeName;
|
|
148
178
|
returnType?: EncryptedReturnType;
|
|
149
179
|
};
|
|
@@ -339,7 +369,6 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
339
369
|
prefix: string;
|
|
340
370
|
}>>;
|
|
341
371
|
}, "strip", z.ZodTypeAny, {
|
|
342
|
-
ore?: {} | undefined;
|
|
343
372
|
match?: {
|
|
344
373
|
token_filters?: {
|
|
345
374
|
kind: "downcase";
|
|
@@ -354,6 +383,7 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
354
383
|
m?: number | undefined;
|
|
355
384
|
include_original?: boolean | undefined;
|
|
356
385
|
} | undefined;
|
|
386
|
+
ore?: {} | undefined;
|
|
357
387
|
unique?: {
|
|
358
388
|
token_filters?: {
|
|
359
389
|
kind: "downcase";
|
|
@@ -363,7 +393,6 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
363
393
|
prefix: string;
|
|
364
394
|
} | undefined;
|
|
365
395
|
}, {
|
|
366
|
-
ore?: {} | undefined;
|
|
367
396
|
match?: {
|
|
368
397
|
token_filters?: {
|
|
369
398
|
kind: "downcase";
|
|
@@ -378,6 +407,7 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
378
407
|
m?: number | undefined;
|
|
379
408
|
include_original?: boolean | undefined;
|
|
380
409
|
} | undefined;
|
|
410
|
+
ore?: {} | undefined;
|
|
381
411
|
unique?: {
|
|
382
412
|
token_filters?: {
|
|
383
413
|
kind: "downcase";
|
|
@@ -390,7 +420,6 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
390
420
|
}, "strip", z.ZodTypeAny, {
|
|
391
421
|
cast_as: "string" | "number" | "bigint" | "boolean" | "date" | "json";
|
|
392
422
|
indexes: {
|
|
393
|
-
ore?: {} | undefined;
|
|
394
423
|
match?: {
|
|
395
424
|
token_filters?: {
|
|
396
425
|
kind: "downcase";
|
|
@@ -405,6 +434,7 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
405
434
|
m?: number | undefined;
|
|
406
435
|
include_original?: boolean | undefined;
|
|
407
436
|
} | undefined;
|
|
437
|
+
ore?: {} | undefined;
|
|
408
438
|
unique?: {
|
|
409
439
|
token_filters?: {
|
|
410
440
|
kind: "downcase";
|
|
@@ -417,7 +447,6 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
417
447
|
}, {
|
|
418
448
|
cast_as?: "string" | "number" | "bigint" | "boolean" | "date" | "json" | undefined;
|
|
419
449
|
indexes?: {
|
|
420
|
-
ore?: {} | undefined;
|
|
421
450
|
match?: {
|
|
422
451
|
token_filters?: {
|
|
423
452
|
kind: "downcase";
|
|
@@ -432,6 +461,7 @@ declare const columnSchema: z.ZodDefault<z.ZodObject<{
|
|
|
432
461
|
m?: number | undefined;
|
|
433
462
|
include_original?: boolean | undefined;
|
|
434
463
|
} | undefined;
|
|
464
|
+
ore?: {} | undefined;
|
|
435
465
|
unique?: {
|
|
436
466
|
token_filters?: {
|
|
437
467
|
kind: "downcase";
|
|
@@ -528,7 +558,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
528
558
|
prefix: string;
|
|
529
559
|
}>>;
|
|
530
560
|
}, "strip", z.ZodTypeAny, {
|
|
531
|
-
ore?: {} | undefined;
|
|
532
561
|
match?: {
|
|
533
562
|
token_filters?: {
|
|
534
563
|
kind: "downcase";
|
|
@@ -543,6 +572,7 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
543
572
|
m?: number | undefined;
|
|
544
573
|
include_original?: boolean | undefined;
|
|
545
574
|
} | undefined;
|
|
575
|
+
ore?: {} | undefined;
|
|
546
576
|
unique?: {
|
|
547
577
|
token_filters?: {
|
|
548
578
|
kind: "downcase";
|
|
@@ -552,7 +582,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
552
582
|
prefix: string;
|
|
553
583
|
} | undefined;
|
|
554
584
|
}, {
|
|
555
|
-
ore?: {} | undefined;
|
|
556
585
|
match?: {
|
|
557
586
|
token_filters?: {
|
|
558
587
|
kind: "downcase";
|
|
@@ -567,6 +596,7 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
567
596
|
m?: number | undefined;
|
|
568
597
|
include_original?: boolean | undefined;
|
|
569
598
|
} | undefined;
|
|
599
|
+
ore?: {} | undefined;
|
|
570
600
|
unique?: {
|
|
571
601
|
token_filters?: {
|
|
572
602
|
kind: "downcase";
|
|
@@ -579,7 +609,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
579
609
|
}, "strip", z.ZodTypeAny, {
|
|
580
610
|
cast_as: "string" | "number" | "bigint" | "boolean" | "date" | "json";
|
|
581
611
|
indexes: {
|
|
582
|
-
ore?: {} | undefined;
|
|
583
612
|
match?: {
|
|
584
613
|
token_filters?: {
|
|
585
614
|
kind: "downcase";
|
|
@@ -594,6 +623,7 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
594
623
|
m?: number | undefined;
|
|
595
624
|
include_original?: boolean | undefined;
|
|
596
625
|
} | undefined;
|
|
626
|
+
ore?: {} | undefined;
|
|
597
627
|
unique?: {
|
|
598
628
|
token_filters?: {
|
|
599
629
|
kind: "downcase";
|
|
@@ -606,7 +636,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
606
636
|
}, {
|
|
607
637
|
cast_as?: "string" | "number" | "bigint" | "boolean" | "date" | "json" | undefined;
|
|
608
638
|
indexes?: {
|
|
609
|
-
ore?: {} | undefined;
|
|
610
639
|
match?: {
|
|
611
640
|
token_filters?: {
|
|
612
641
|
kind: "downcase";
|
|
@@ -621,6 +650,7 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
621
650
|
m?: number | undefined;
|
|
622
651
|
include_original?: boolean | undefined;
|
|
623
652
|
} | undefined;
|
|
653
|
+
ore?: {} | undefined;
|
|
624
654
|
unique?: {
|
|
625
655
|
token_filters?: {
|
|
626
656
|
kind: "downcase";
|
|
@@ -636,7 +666,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
636
666
|
tables: Record<string, Record<string, {
|
|
637
667
|
cast_as: "string" | "number" | "bigint" | "boolean" | "date" | "json";
|
|
638
668
|
indexes: {
|
|
639
|
-
ore?: {} | undefined;
|
|
640
669
|
match?: {
|
|
641
670
|
token_filters?: {
|
|
642
671
|
kind: "downcase";
|
|
@@ -651,6 +680,7 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
651
680
|
m?: number | undefined;
|
|
652
681
|
include_original?: boolean | undefined;
|
|
653
682
|
} | undefined;
|
|
683
|
+
ore?: {} | undefined;
|
|
654
684
|
unique?: {
|
|
655
685
|
token_filters?: {
|
|
656
686
|
kind: "downcase";
|
|
@@ -666,7 +696,6 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
666
696
|
tables?: Record<string, Record<string, {
|
|
667
697
|
cast_as?: "string" | "number" | "bigint" | "boolean" | "date" | "json" | undefined;
|
|
668
698
|
indexes?: {
|
|
669
|
-
ore?: {} | undefined;
|
|
670
699
|
match?: {
|
|
671
700
|
token_filters?: {
|
|
672
701
|
kind: "downcase";
|
|
@@ -681,6 +710,7 @@ declare const encryptConfigSchema: z.ZodObject<{
|
|
|
681
710
|
m?: number | undefined;
|
|
682
711
|
include_original?: boolean | undefined;
|
|
683
712
|
} | undefined;
|
|
713
|
+
ore?: {} | undefined;
|
|
684
714
|
unique?: {
|
|
685
715
|
token_filters?: {
|
|
686
716
|
kind: "downcase";
|
|
@@ -705,35 +735,44 @@ type SteVecIndexOpts = z.infer<typeof steVecIndexOptsSchema>;
|
|
|
705
735
|
type UniqueIndexOpts = z.infer<typeof uniqueIndexOptsSchema>;
|
|
706
736
|
type OreIndexOpts = z.infer<typeof oreIndexOptsSchema>;
|
|
707
737
|
type ColumnSchema = z.infer<typeof columnSchema>;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
738
|
+
/**
|
|
739
|
+
* Shape of table columns: either top-level {@link EncryptedColumn} or nested
|
|
740
|
+
* objects whose leaves are {@link EncryptedField}. Used with {@link encryptedTable}.
|
|
741
|
+
*/
|
|
742
|
+
type EncryptedTableColumn = {
|
|
743
|
+
[key: string]: EncryptedColumn | {
|
|
744
|
+
[key: string]: EncryptedField | {
|
|
745
|
+
[key: string]: EncryptedField | {
|
|
746
|
+
[key: string]: EncryptedField;
|
|
713
747
|
};
|
|
714
748
|
};
|
|
715
749
|
};
|
|
716
750
|
};
|
|
717
751
|
type EncryptConfig = z.infer<typeof encryptConfigSchema>;
|
|
718
|
-
|
|
752
|
+
/**
|
|
753
|
+
* Builder for a nested encrypted field (encrypted but not searchable).
|
|
754
|
+
* Create with {@link encryptedField}. Use inside nested objects in {@link encryptedTable};
|
|
755
|
+
* supports `.dataType()` for plaintext type. No index methods (equality, orderAndRange, etc.).
|
|
756
|
+
*/
|
|
757
|
+
declare class EncryptedField {
|
|
719
758
|
private valueName;
|
|
720
759
|
private castAsValue;
|
|
721
760
|
constructor(valueName: string);
|
|
722
761
|
/**
|
|
723
|
-
* Set or override the plaintext data type for this
|
|
762
|
+
* Set or override the plaintext data type for this field.
|
|
724
763
|
*
|
|
725
764
|
* By default all values are treated as `'string'`. Use this method to specify
|
|
726
765
|
* a different type so the encryption layer knows how to encode the plaintext
|
|
727
766
|
* before encrypting.
|
|
728
767
|
*
|
|
729
768
|
* @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'bigint'`, or `'json'`.
|
|
730
|
-
* @returns This `
|
|
769
|
+
* @returns This `EncryptedField` instance for method chaining.
|
|
731
770
|
*
|
|
732
771
|
* @example
|
|
733
772
|
* ```typescript
|
|
734
|
-
* import {
|
|
773
|
+
* import { encryptedField } from "@cipherstash/stack/schema"
|
|
735
774
|
*
|
|
736
|
-
* const age =
|
|
775
|
+
* const age = encryptedField("age").dataType("number")
|
|
737
776
|
* ```
|
|
738
777
|
*/
|
|
739
778
|
dataType(castAs: CastAs): this;
|
|
@@ -743,7 +782,7 @@ declare class ProtectValue {
|
|
|
743
782
|
};
|
|
744
783
|
getName(): string;
|
|
745
784
|
}
|
|
746
|
-
declare class
|
|
785
|
+
declare class EncryptedColumn {
|
|
747
786
|
private columnName;
|
|
748
787
|
private castAsValue;
|
|
749
788
|
private indexesValue;
|
|
@@ -756,7 +795,7 @@ declare class ProtectColumn {
|
|
|
756
795
|
* before encrypting.
|
|
757
796
|
*
|
|
758
797
|
* @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'bigint'`, or `'json'`.
|
|
759
|
-
* @returns This `
|
|
798
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
760
799
|
*
|
|
761
800
|
* @example
|
|
762
801
|
* ```typescript
|
|
@@ -772,7 +811,7 @@ declare class ProtectColumn {
|
|
|
772
811
|
* ORE allows sorting, comparison, and range queries on encrypted data.
|
|
773
812
|
* Use with `encryptQuery` and `queryType: 'orderAndRange'`.
|
|
774
813
|
*
|
|
775
|
-
* @returns This `
|
|
814
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
776
815
|
*
|
|
777
816
|
* @example
|
|
778
817
|
* ```typescript
|
|
@@ -792,7 +831,7 @@ declare class ProtectColumn {
|
|
|
792
831
|
*
|
|
793
832
|
* @param tokenFilters - Optional array of token filters (e.g. `[{ kind: 'downcase' }]`).
|
|
794
833
|
* When omitted, no token filters are applied.
|
|
795
|
-
* @returns This `
|
|
834
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
796
835
|
*
|
|
797
836
|
* @example
|
|
798
837
|
* ```typescript
|
|
@@ -812,7 +851,7 @@ declare class ProtectColumn {
|
|
|
812
851
|
*
|
|
813
852
|
* @param opts - Optional match index configuration. Defaults to 3-character ngram
|
|
814
853
|
* tokenization with a downcase filter, `k=6`, `m=2048`, and `include_original=true`.
|
|
815
|
-
* @returns This `
|
|
854
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
816
855
|
*
|
|
817
856
|
* @example
|
|
818
857
|
* ```typescript
|
|
@@ -844,7 +883,7 @@ declare class ProtectColumn {
|
|
|
844
883
|
* the plaintext type: strings become selector queries, objects/arrays become
|
|
845
884
|
* containment queries.
|
|
846
885
|
*
|
|
847
|
-
* @returns This `
|
|
886
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
848
887
|
*
|
|
849
888
|
* @example
|
|
850
889
|
* ```typescript
|
|
@@ -871,9 +910,11 @@ interface TableDefinition {
|
|
|
871
910
|
tableName: string;
|
|
872
911
|
columns: Record<string, ColumnSchema>;
|
|
873
912
|
}
|
|
874
|
-
declare class
|
|
913
|
+
declare class EncryptedTable<T extends EncryptedTableColumn> {
|
|
875
914
|
readonly tableName: string;
|
|
876
915
|
private readonly columnBuilders;
|
|
916
|
+
/** @internal Type-level brand so TypeScript can infer `T` from `EncryptedTable<T>`. */
|
|
917
|
+
readonly _columnType: T;
|
|
877
918
|
constructor(tableName: string, columnBuilders: T);
|
|
878
919
|
/**
|
|
879
920
|
* Compile this table schema into a `TableDefinition` used internally by the encryption client.
|
|
@@ -897,7 +938,7 @@ declare class ProtectTable<T extends ProtectTableColumn> {
|
|
|
897
938
|
build(): TableDefinition;
|
|
898
939
|
}
|
|
899
940
|
/**
|
|
900
|
-
* Infer the plaintext (decrypted) type from a
|
|
941
|
+
* Infer the plaintext (decrypted) type from a EncryptedTable schema.
|
|
901
942
|
*
|
|
902
943
|
* @example
|
|
903
944
|
* ```typescript
|
|
@@ -910,11 +951,11 @@ declare class ProtectTable<T extends ProtectTableColumn> {
|
|
|
910
951
|
* // => { email: string; name: string }
|
|
911
952
|
* ```
|
|
912
953
|
*/
|
|
913
|
-
type InferPlaintext<T extends
|
|
914
|
-
[K in keyof C as C[K] extends
|
|
954
|
+
type InferPlaintext<T extends EncryptedTable<any>> = T extends EncryptedTable<infer C> ? {
|
|
955
|
+
[K in keyof C as C[K] extends EncryptedColumn | EncryptedField ? K : never]: string;
|
|
915
956
|
} : never;
|
|
916
957
|
/**
|
|
917
|
-
* Infer the encrypted type from a
|
|
958
|
+
* Infer the encrypted type from a EncryptedTable schema.
|
|
918
959
|
*
|
|
919
960
|
* @example
|
|
920
961
|
* ```typescript
|
|
@@ -926,13 +967,13 @@ type InferPlaintext<T extends ProtectTable<any>> = T extends ProtectTable<infer
|
|
|
926
967
|
* // => { email: Encrypted }
|
|
927
968
|
* ```
|
|
928
969
|
*/
|
|
929
|
-
type InferEncrypted<T extends
|
|
930
|
-
[K in keyof C as C[K] extends
|
|
970
|
+
type InferEncrypted<T extends EncryptedTable<any>> = T extends EncryptedTable<infer C> ? {
|
|
971
|
+
[K in keyof C as C[K] extends EncryptedColumn | EncryptedField ? K : never]: Encrypted;
|
|
931
972
|
} : never;
|
|
932
973
|
/**
|
|
933
974
|
* Define an encrypted table schema.
|
|
934
975
|
*
|
|
935
|
-
* Creates a `
|
|
976
|
+
* Creates a `EncryptedTable` that maps a database table name to a set of encrypted
|
|
936
977
|
* column definitions. Pass the resulting object to `Encryption({ schemas: [...] })`
|
|
937
978
|
* when initializing the client.
|
|
938
979
|
*
|
|
@@ -942,8 +983,9 @@ type InferEncrypted<T extends ProtectTable<any>> = T extends ProtectTable<infer
|
|
|
942
983
|
*
|
|
943
984
|
* @param tableName - The name of the database table this schema represents.
|
|
944
985
|
* @param columns - An object whose keys are logical column names and values are
|
|
945
|
-
*
|
|
946
|
-
* @
|
|
986
|
+
* {@link EncryptedColumn} from {@link encryptedColumn}, or nested objects whose
|
|
987
|
+
* leaves are {@link EncryptedField} from {@link encryptedField}.
|
|
988
|
+
* @returns A `EncryptedTable<T> & T` that can be used as both a schema definition
|
|
947
989
|
* and a column accessor.
|
|
948
990
|
*
|
|
949
991
|
* @example
|
|
@@ -962,17 +1004,17 @@ type InferEncrypted<T extends ProtectTable<any>> = T extends ProtectTable<infer
|
|
|
962
1004
|
* await client.encrypt("hello@example.com", { column: users.email, table: users })
|
|
963
1005
|
* ```
|
|
964
1006
|
*/
|
|
965
|
-
declare function encryptedTable<T extends
|
|
1007
|
+
declare function encryptedTable<T extends EncryptedTableColumn>(tableName: string, columns: T): EncryptedTable<T> & T;
|
|
966
1008
|
/**
|
|
967
1009
|
* Define an encrypted column within a table schema.
|
|
968
1010
|
*
|
|
969
|
-
* Creates a `
|
|
1011
|
+
* Creates a `EncryptedColumn` builder for the given column name. Chain index
|
|
970
1012
|
* methods (`.equality()`, `.freeTextSearch()`, `.orderAndRange()`,
|
|
971
1013
|
* `.searchableJson()`) and/or `.dataType()` to configure searchable encryption
|
|
972
1014
|
* and the plaintext data type.
|
|
973
1015
|
*
|
|
974
1016
|
* @param columnName - The name of the database column to encrypt.
|
|
975
|
-
* @returns A new `
|
|
1017
|
+
* @returns A new `EncryptedColumn` builder.
|
|
976
1018
|
*
|
|
977
1019
|
* @example
|
|
978
1020
|
* ```typescript
|
|
@@ -983,31 +1025,31 @@ declare function encryptedTable<T extends ProtectTableColumn>(tableName: string,
|
|
|
983
1025
|
* })
|
|
984
1026
|
* ```
|
|
985
1027
|
*/
|
|
986
|
-
declare function encryptedColumn(columnName: string):
|
|
1028
|
+
declare function encryptedColumn(columnName: string): EncryptedColumn;
|
|
987
1029
|
/**
|
|
988
|
-
* Define an encrypted
|
|
1030
|
+
* Define an encrypted field for use in nested or structured schemas.
|
|
989
1031
|
*
|
|
990
|
-
* `
|
|
991
|
-
*
|
|
992
|
-
*
|
|
1032
|
+
* `encryptedField` is similar to {@link encryptedColumn} but creates an {@link EncryptedField}
|
|
1033
|
+
* for nested fields that are encrypted but not searchable (no indexes). Use `.dataType()`
|
|
1034
|
+
* to specify the plaintext type.
|
|
993
1035
|
*
|
|
994
1036
|
* @param valueName - The name of the value field.
|
|
995
|
-
* @returns A new `
|
|
1037
|
+
* @returns A new `EncryptedField` builder.
|
|
996
1038
|
*
|
|
997
1039
|
* @example
|
|
998
1040
|
* ```typescript
|
|
999
|
-
* import { encryptedTable,
|
|
1041
|
+
* import { encryptedTable, encryptedField } from "@cipherstash/stack/schema"
|
|
1000
1042
|
*
|
|
1001
1043
|
* const orders = encryptedTable("orders", {
|
|
1002
1044
|
* details: {
|
|
1003
|
-
* amount:
|
|
1004
|
-
* currency:
|
|
1045
|
+
* amount: encryptedField("amount").dataType("number"),
|
|
1046
|
+
* currency: encryptedField("currency"),
|
|
1005
1047
|
* },
|
|
1006
1048
|
* })
|
|
1007
1049
|
* ```
|
|
1008
1050
|
*/
|
|
1009
|
-
declare function
|
|
1051
|
+
declare function encryptedField(valueName: string): EncryptedField;
|
|
1010
1052
|
/** @internal */
|
|
1011
|
-
declare function buildEncryptConfig(...protectTables: Array<
|
|
1053
|
+
declare function buildEncryptConfig(...protectTables: Array<EncryptedTable<EncryptedTableColumn>>): EncryptConfig;
|
|
1012
1054
|
|
|
1013
|
-
export { type
|
|
1055
|
+
export { type ClientConfig as A, type BulkDecryptedData as B, type CastAs as C, type Decrypted as D, type EncryptionClientConfig as E, type SearchTerm as F, type EncryptedSearchTerm as G, type EncryptedFields as H, type InferPlaintext as I, type OtherFields as J, type KeysetIdentifier as K, type DecryptedFields as L, type MatchIndexOpts as M, type DecryptionResult as N, type OreIndexOpts as O, type LoggingConfig as P, type QueryTypeName as Q, queryTypes as R, type ScalarQueryTerm as S, type TokenFilter as T, type UniqueIndexOpts as U, encryptedColumn as a, encryptedField as b, type InferEncrypted as c, EncryptedColumn as d, encryptedTable as e, EncryptedTable as f, type EncryptedTableColumn as g, EncryptedField as h, type EncryptedFromSchema as i, type Encrypted as j, type EncryptedValue as k, type EncryptedQueryResult as l, type Client as m, type BulkDecryptPayload as n, type BulkEncryptedData as o, type BulkEncryptPayload as p, type EncryptOptions as q, type EncryptQueryOptions as r, type EncryptedReturnType as s, type EncryptConfig as t, castAsEnum as u, encryptConfigSchema as v, type SteVecIndexOpts as w, type ColumnSchema as x, buildEncryptConfig as y, type EncryptPayload as z };
|