@cipherstash/stack 0.2.0 → 0.4.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 +2 -3
- package/dist/bin/stash.js +109 -186
- package/dist/bin/stash.js.map +1 -1
- package/dist/{chunk-SUYMGQBY.js → chunk-4RNBI3UH.js} +1 -7
- package/dist/chunk-4RNBI3UH.js.map +1 -0
- package/dist/{chunk-5G4F4JJG.js → chunk-KOU2MHXJ.js} +1 -1
- package/dist/chunk-KOU2MHXJ.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-LHZ6KZIG.js → chunk-WUZGKTMG.js} +84 -162
- package/dist/chunk-WUZGKTMG.js.map +1 -0
- package/dist/{chunk-7XRPN2KX.js → chunk-Y35W4WFN.js} +31 -28
- package/dist/chunk-Y35W4WFN.js.map +1 -0
- package/dist/{client-D-ZH8SB2.d.cts → client-CUGXheRq.d.cts} +33 -31
- package/dist/{client-BV9pXC-d.d.ts → client-CrGQnSlk.d.ts} +33 -31
- package/dist/client.cjs +30 -27
- 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 +24 -21
- 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 +113 -190
- 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 +8 -8
- package/dist/schema/index.cjs +36 -33
- 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 +109 -186
- 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 +5 -5
- package/dist/secrets/index.js.map +1 -1
- package/dist/supabase/index.cjs +9 -9
- 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 +4 -4
- package/dist/supabase/index.js.map +1 -1
- package/dist/{types-public-Dfg-hkuQ.d.cts → types-public-Wj6tB_ux.d.cts} +115 -76
- package/dist/{types-public-Dfg-hkuQ.d.ts → types-public-Wj6tB_ux.d.ts} +115 -76
- 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 +2 -2
- package/dist/chunk-5G4F4JJG.js.map +0 -1
- package/dist/chunk-7XRPN2KX.js.map +0 -1
- package/dist/chunk-LHZ6KZIG.js.map +0 -1
- package/dist/chunk-SUYMGQBY.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as EncryptedQueryResult, m as Client, S as ScalarQueryTerm, B as BulkDecryptedData, n as BulkDecryptPayload, D as Decrypted, o as BulkEncryptedData, p as BulkEncryptPayload, q as EncryptOptions, d as EncryptedColumn, h as EncryptedField, f as EncryptedTable, g as EncryptedTableColumn, j as Encrypted, r as EncryptQueryOptions, Q as QueryTypeName, s as EncryptedReturnType, t as EncryptConfig, K as KeysetIdentifier, i as EncryptedFromSchema } from './types-public-Wj6tB_ux.cjs';
|
|
2
2
|
import { a as EncryptionError, d as LockContext } from './index-9-Ya3fDK.cjs';
|
|
3
3
|
import { Result } from '@byteslice/result';
|
|
4
4
|
import { JsPlaintext } from '@cipherstash/protect-ffi';
|
|
@@ -99,8 +99,8 @@ declare class BulkEncryptOperation extends EncryptionOperation<BulkEncryptedData
|
|
|
99
99
|
getOperation(): {
|
|
100
100
|
client: Client;
|
|
101
101
|
plaintexts: BulkEncryptPayload;
|
|
102
|
-
column:
|
|
103
|
-
table:
|
|
102
|
+
column: EncryptedColumn | EncryptedField;
|
|
103
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
declare class BulkEncryptOperationWithLockContext extends EncryptionOperation<BulkEncryptedData> {
|
|
@@ -114,13 +114,13 @@ declare class BulkEncryptModelsOperation<T extends Record<string, unknown>> exte
|
|
|
114
114
|
private client;
|
|
115
115
|
private models;
|
|
116
116
|
private table;
|
|
117
|
-
constructor(client: Client, models: Record<string, unknown>[], table:
|
|
117
|
+
constructor(client: Client, models: Record<string, unknown>[], table: EncryptedTable<EncryptedTableColumn>);
|
|
118
118
|
withLockContext(lockContext: LockContext): BulkEncryptModelsOperationWithLockContext<T>;
|
|
119
119
|
execute(): Promise<Result<T[], EncryptionError>>;
|
|
120
120
|
getOperation(): {
|
|
121
121
|
client: Client;
|
|
122
122
|
models: Record<string, unknown>[];
|
|
123
|
-
table:
|
|
123
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T[]> {
|
|
@@ -134,23 +134,23 @@ declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string,
|
|
|
134
134
|
* Decrypts an encrypted payload using the provided client.
|
|
135
135
|
* This is the type returned by the {@link EncryptionClient.decrypt | decrypt} method of the {@link EncryptionClient}.
|
|
136
136
|
*/
|
|
137
|
-
declare class DecryptOperation extends EncryptionOperation<JsPlaintext
|
|
137
|
+
declare class DecryptOperation extends EncryptionOperation<JsPlaintext> {
|
|
138
138
|
private client;
|
|
139
139
|
private encryptedData;
|
|
140
140
|
constructor(client: Client, encryptedData: Encrypted);
|
|
141
141
|
withLockContext(lockContext: LockContext): DecryptOperationWithLockContext;
|
|
142
|
-
execute(): Promise<Result<JsPlaintext
|
|
142
|
+
execute(): Promise<Result<JsPlaintext, EncryptionError>>;
|
|
143
143
|
getOperation(): {
|
|
144
144
|
client: Client;
|
|
145
145
|
encryptedData: Encrypted;
|
|
146
146
|
auditData?: Record<string, unknown>;
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext
|
|
149
|
+
declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext> {
|
|
150
150
|
private operation;
|
|
151
151
|
private lockContext;
|
|
152
152
|
constructor(operation: DecryptOperation, lockContext: LockContext);
|
|
153
|
-
execute(): Promise<Result<JsPlaintext
|
|
153
|
+
execute(): Promise<Result<JsPlaintext, EncryptionError>>;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
declare class DecryptModelOperation<T extends Record<string, unknown>> extends EncryptionOperation<Decrypted<T>> {
|
|
@@ -176,14 +176,14 @@ declare class EncryptOperation extends EncryptionOperation<Encrypted> {
|
|
|
176
176
|
private plaintext;
|
|
177
177
|
private column;
|
|
178
178
|
private table;
|
|
179
|
-
constructor(client: Client, plaintext: JsPlaintext
|
|
179
|
+
constructor(client: Client, plaintext: JsPlaintext, opts: EncryptOptions);
|
|
180
180
|
withLockContext(lockContext: LockContext): EncryptOperationWithLockContext;
|
|
181
181
|
execute(): Promise<Result<Encrypted, EncryptionError>>;
|
|
182
182
|
getOperation(): {
|
|
183
183
|
client: Client;
|
|
184
|
-
plaintext: JsPlaintext
|
|
185
|
-
column:
|
|
186
|
-
table:
|
|
184
|
+
plaintext: JsPlaintext;
|
|
185
|
+
column: EncryptedColumn | EncryptedField;
|
|
186
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
189
|
declare class EncryptOperationWithLockContext extends EncryptionOperation<Encrypted> {
|
|
@@ -197,13 +197,13 @@ declare class EncryptModelOperation<T extends Record<string, unknown>> extends E
|
|
|
197
197
|
private client;
|
|
198
198
|
private model;
|
|
199
199
|
private table;
|
|
200
|
-
constructor(client: Client, model: Record<string, unknown>, table:
|
|
200
|
+
constructor(client: Client, model: Record<string, unknown>, table: EncryptedTable<EncryptedTableColumn>);
|
|
201
201
|
withLockContext(lockContext: LockContext): EncryptModelOperationWithLockContext<T>;
|
|
202
202
|
execute(): Promise<Result<T, EncryptionError>>;
|
|
203
203
|
getOperation(): {
|
|
204
204
|
client: Client;
|
|
205
205
|
model: Record<string, unknown>;
|
|
206
|
-
table:
|
|
206
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
declare class EncryptModelOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T> {
|
|
@@ -220,16 +220,16 @@ declare class EncryptQueryOperation extends EncryptionOperation<EncryptedQueryRe
|
|
|
220
220
|
private client;
|
|
221
221
|
private plaintext;
|
|
222
222
|
private opts;
|
|
223
|
-
constructor(client: Client, plaintext: JsPlaintext
|
|
223
|
+
constructor(client: Client, plaintext: JsPlaintext, opts: EncryptQueryOptions);
|
|
224
224
|
withLockContext(lockContext: LockContext): EncryptQueryOperationWithLockContext;
|
|
225
225
|
execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
|
|
226
226
|
getOperation(): {
|
|
227
|
-
column:
|
|
228
|
-
table:
|
|
227
|
+
column: EncryptedColumn;
|
|
228
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
229
229
|
queryType?: QueryTypeName;
|
|
230
230
|
returnType?: EncryptedReturnType;
|
|
231
231
|
client: Client;
|
|
232
|
-
plaintext: JsPlaintext
|
|
232
|
+
plaintext: JsPlaintext;
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
@@ -240,11 +240,11 @@ declare class EncryptQueryOperationWithLockContext extends EncryptionOperation<E
|
|
|
240
240
|
private plaintext;
|
|
241
241
|
private opts;
|
|
242
242
|
private lockContext;
|
|
243
|
-
constructor(client: Client, plaintext: JsPlaintext
|
|
243
|
+
constructor(client: Client, plaintext: JsPlaintext, opts: EncryptQueryOptions, lockContext: LockContext, auditMetadata?: Record<string, unknown>);
|
|
244
244
|
execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
/** The EncryptionClient is the main entry point for interacting with the CipherStash
|
|
247
|
+
/** The EncryptionClient is the main entry point for interacting with the CipherStash Encryption library.
|
|
248
248
|
* It provides methods for encrypting and decrypting individual values, as well as models (objects) and bulk operations.
|
|
249
249
|
*
|
|
250
250
|
* The client must be initialized using the {@link Encryption} function before it can be used.
|
|
@@ -271,8 +271,8 @@ declare class EncryptionClient {
|
|
|
271
271
|
/**
|
|
272
272
|
* Encrypt a value - returns a promise which resolves to an encrypted value.
|
|
273
273
|
*
|
|
274
|
-
* @param plaintext - The plaintext value to be encrypted.
|
|
275
|
-
* @param opts - Options specifying the column and table for encryption.
|
|
274
|
+
* @param plaintext - The plaintext value to be encrypted.
|
|
275
|
+
* @param opts - Options specifying the column (or nested field) and table for encryption. See {@link EncryptOptions}.
|
|
276
276
|
* @returns An EncryptOperation that can be awaited or chained with additional methods.
|
|
277
277
|
*
|
|
278
278
|
* @example
|
|
@@ -335,16 +335,19 @@ declare class EncryptionClient {
|
|
|
335
335
|
* .withLockContext(lockContext)
|
|
336
336
|
* ```
|
|
337
337
|
*
|
|
338
|
+
* @see {@link EncryptOptions}
|
|
338
339
|
* @see {@link Result}
|
|
339
340
|
* @see {@link encryptedTable}
|
|
341
|
+
* @see {@link encryptedColumn}
|
|
342
|
+
* @see {@link encryptedField}
|
|
340
343
|
* @see {@link LockContext}
|
|
341
344
|
* @see {@link EncryptOperation}
|
|
342
345
|
*/
|
|
343
|
-
encrypt(plaintext: JsPlaintext
|
|
346
|
+
encrypt(plaintext: JsPlaintext, opts: EncryptOptions): EncryptOperation;
|
|
344
347
|
/**
|
|
345
348
|
* Encrypt a query value - returns a promise which resolves to an encrypted query value.
|
|
346
349
|
*
|
|
347
|
-
* @param plaintext - The plaintext value to be encrypted for querying.
|
|
350
|
+
* @param plaintext - The plaintext value to be encrypted for querying.
|
|
348
351
|
* @param opts - Options specifying the column, table, and optional queryType for encryption.
|
|
349
352
|
* @returns An EncryptQueryOperation that can be awaited or chained with additional methods.
|
|
350
353
|
*
|
|
@@ -394,7 +397,7 @@ declare class EncryptionClient {
|
|
|
394
397
|
* - String plaintext → `steVecSelector` (JSONPath queries like `'$.user.email'`)
|
|
395
398
|
* - Object/Array plaintext → `steVecTerm` (containment queries like `{ role: 'admin' }`)
|
|
396
399
|
*/
|
|
397
|
-
encryptQuery(plaintext: JsPlaintext
|
|
400
|
+
encryptQuery(plaintext: JsPlaintext, opts: EncryptQueryOptions): EncryptQueryOperation;
|
|
398
401
|
/**
|
|
399
402
|
* Encrypt multiple values for use in queries (batch operation).
|
|
400
403
|
* @param terms - Array of query terms to encrypt
|
|
@@ -479,7 +482,7 @@ declare class EncryptionClient {
|
|
|
479
482
|
* }
|
|
480
483
|
* ```
|
|
481
484
|
*/
|
|
482
|
-
encryptModel<T extends Record<string, unknown>, S extends
|
|
485
|
+
encryptModel<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: T, table: EncryptedTable<S>): EncryptModelOperation<EncryptedFromSchema<T, S>>;
|
|
483
486
|
/**
|
|
484
487
|
* Decrypt a model (object) whose fields contain encrypted values.
|
|
485
488
|
*
|
|
@@ -554,7 +557,7 @@ declare class EncryptionClient {
|
|
|
554
557
|
* }
|
|
555
558
|
* ```
|
|
556
559
|
*/
|
|
557
|
-
bulkEncryptModels<T extends Record<string, unknown>, S extends
|
|
560
|
+
bulkEncryptModels<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: Array<T>, table: EncryptedTable<S>): BulkEncryptModelsOperation<EncryptedFromSchema<T, S>>;
|
|
558
561
|
/**
|
|
559
562
|
* Decrypt multiple models (objects) in a single bulk operation.
|
|
560
563
|
*
|
|
@@ -589,10 +592,10 @@ declare class EncryptionClient {
|
|
|
589
592
|
*
|
|
590
593
|
* Each value is encrypted with its own unique key via a single call to ZeroKMS.
|
|
591
594
|
* Values can include optional `id` fields for correlating results back to
|
|
592
|
-
* your application data.
|
|
595
|
+
* your application data.
|
|
593
596
|
*
|
|
594
597
|
* @param plaintexts - An array of objects with `plaintext` (and optional `id`) fields.
|
|
595
|
-
* @param opts - Options specifying the target column and table
|
|
598
|
+
* @param opts - Options specifying the target column (or nested {@link encryptedField}) and table. See {@link EncryptOptions}.
|
|
596
599
|
* @returns A `BulkEncryptOperation` that can be awaited to get a `Result`
|
|
597
600
|
* containing an array of `{ id?, data: Encrypted }` objects, or an `EncryptionError`.
|
|
598
601
|
*
|
|
@@ -610,7 +613,6 @@ declare class EncryptionClient {
|
|
|
610
613
|
* [
|
|
611
614
|
* { id: "u1", plaintext: "alice@example.com" },
|
|
612
615
|
* { id: "u2", plaintext: "bob@example.com" },
|
|
613
|
-
* { id: "u3", plaintext: null },
|
|
614
616
|
* ],
|
|
615
617
|
* { column: users.email, table: users },
|
|
616
618
|
* )
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as EncryptedQueryResult, m as Client, S as ScalarQueryTerm, B as BulkDecryptedData, n as BulkDecryptPayload, D as Decrypted, o as BulkEncryptedData, p as BulkEncryptPayload, q as EncryptOptions, d as EncryptedColumn, h as EncryptedField, f as EncryptedTable, g as EncryptedTableColumn, j as Encrypted, r as EncryptQueryOptions, Q as QueryTypeName, s as EncryptedReturnType, t as EncryptConfig, K as KeysetIdentifier, i as EncryptedFromSchema } from './types-public-Wj6tB_ux.js';
|
|
2
2
|
import { a as EncryptionError, d as LockContext } from './index-9-Ya3fDK.js';
|
|
3
3
|
import { Result } from '@byteslice/result';
|
|
4
4
|
import { JsPlaintext } from '@cipherstash/protect-ffi';
|
|
@@ -99,8 +99,8 @@ declare class BulkEncryptOperation extends EncryptionOperation<BulkEncryptedData
|
|
|
99
99
|
getOperation(): {
|
|
100
100
|
client: Client;
|
|
101
101
|
plaintexts: BulkEncryptPayload;
|
|
102
|
-
column:
|
|
103
|
-
table:
|
|
102
|
+
column: EncryptedColumn | EncryptedField;
|
|
103
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
declare class BulkEncryptOperationWithLockContext extends EncryptionOperation<BulkEncryptedData> {
|
|
@@ -114,13 +114,13 @@ declare class BulkEncryptModelsOperation<T extends Record<string, unknown>> exte
|
|
|
114
114
|
private client;
|
|
115
115
|
private models;
|
|
116
116
|
private table;
|
|
117
|
-
constructor(client: Client, models: Record<string, unknown>[], table:
|
|
117
|
+
constructor(client: Client, models: Record<string, unknown>[], table: EncryptedTable<EncryptedTableColumn>);
|
|
118
118
|
withLockContext(lockContext: LockContext): BulkEncryptModelsOperationWithLockContext<T>;
|
|
119
119
|
execute(): Promise<Result<T[], EncryptionError>>;
|
|
120
120
|
getOperation(): {
|
|
121
121
|
client: Client;
|
|
122
122
|
models: Record<string, unknown>[];
|
|
123
|
-
table:
|
|
123
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T[]> {
|
|
@@ -134,23 +134,23 @@ declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string,
|
|
|
134
134
|
* Decrypts an encrypted payload using the provided client.
|
|
135
135
|
* This is the type returned by the {@link EncryptionClient.decrypt | decrypt} method of the {@link EncryptionClient}.
|
|
136
136
|
*/
|
|
137
|
-
declare class DecryptOperation extends EncryptionOperation<JsPlaintext
|
|
137
|
+
declare class DecryptOperation extends EncryptionOperation<JsPlaintext> {
|
|
138
138
|
private client;
|
|
139
139
|
private encryptedData;
|
|
140
140
|
constructor(client: Client, encryptedData: Encrypted);
|
|
141
141
|
withLockContext(lockContext: LockContext): DecryptOperationWithLockContext;
|
|
142
|
-
execute(): Promise<Result<JsPlaintext
|
|
142
|
+
execute(): Promise<Result<JsPlaintext, EncryptionError>>;
|
|
143
143
|
getOperation(): {
|
|
144
144
|
client: Client;
|
|
145
145
|
encryptedData: Encrypted;
|
|
146
146
|
auditData?: Record<string, unknown>;
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext
|
|
149
|
+
declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext> {
|
|
150
150
|
private operation;
|
|
151
151
|
private lockContext;
|
|
152
152
|
constructor(operation: DecryptOperation, lockContext: LockContext);
|
|
153
|
-
execute(): Promise<Result<JsPlaintext
|
|
153
|
+
execute(): Promise<Result<JsPlaintext, EncryptionError>>;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
declare class DecryptModelOperation<T extends Record<string, unknown>> extends EncryptionOperation<Decrypted<T>> {
|
|
@@ -176,14 +176,14 @@ declare class EncryptOperation extends EncryptionOperation<Encrypted> {
|
|
|
176
176
|
private plaintext;
|
|
177
177
|
private column;
|
|
178
178
|
private table;
|
|
179
|
-
constructor(client: Client, plaintext: JsPlaintext
|
|
179
|
+
constructor(client: Client, plaintext: JsPlaintext, opts: EncryptOptions);
|
|
180
180
|
withLockContext(lockContext: LockContext): EncryptOperationWithLockContext;
|
|
181
181
|
execute(): Promise<Result<Encrypted, EncryptionError>>;
|
|
182
182
|
getOperation(): {
|
|
183
183
|
client: Client;
|
|
184
|
-
plaintext: JsPlaintext
|
|
185
|
-
column:
|
|
186
|
-
table:
|
|
184
|
+
plaintext: JsPlaintext;
|
|
185
|
+
column: EncryptedColumn | EncryptedField;
|
|
186
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
189
|
declare class EncryptOperationWithLockContext extends EncryptionOperation<Encrypted> {
|
|
@@ -197,13 +197,13 @@ declare class EncryptModelOperation<T extends Record<string, unknown>> extends E
|
|
|
197
197
|
private client;
|
|
198
198
|
private model;
|
|
199
199
|
private table;
|
|
200
|
-
constructor(client: Client, model: Record<string, unknown>, table:
|
|
200
|
+
constructor(client: Client, model: Record<string, unknown>, table: EncryptedTable<EncryptedTableColumn>);
|
|
201
201
|
withLockContext(lockContext: LockContext): EncryptModelOperationWithLockContext<T>;
|
|
202
202
|
execute(): Promise<Result<T, EncryptionError>>;
|
|
203
203
|
getOperation(): {
|
|
204
204
|
client: Client;
|
|
205
205
|
model: Record<string, unknown>;
|
|
206
|
-
table:
|
|
206
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
declare class EncryptModelOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T> {
|
|
@@ -220,16 +220,16 @@ declare class EncryptQueryOperation extends EncryptionOperation<EncryptedQueryRe
|
|
|
220
220
|
private client;
|
|
221
221
|
private plaintext;
|
|
222
222
|
private opts;
|
|
223
|
-
constructor(client: Client, plaintext: JsPlaintext
|
|
223
|
+
constructor(client: Client, plaintext: JsPlaintext, opts: EncryptQueryOptions);
|
|
224
224
|
withLockContext(lockContext: LockContext): EncryptQueryOperationWithLockContext;
|
|
225
225
|
execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
|
|
226
226
|
getOperation(): {
|
|
227
|
-
column:
|
|
228
|
-
table:
|
|
227
|
+
column: EncryptedColumn;
|
|
228
|
+
table: EncryptedTable<EncryptedTableColumn>;
|
|
229
229
|
queryType?: QueryTypeName;
|
|
230
230
|
returnType?: EncryptedReturnType;
|
|
231
231
|
client: Client;
|
|
232
|
-
plaintext: JsPlaintext
|
|
232
|
+
plaintext: JsPlaintext;
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
@@ -240,11 +240,11 @@ declare class EncryptQueryOperationWithLockContext extends EncryptionOperation<E
|
|
|
240
240
|
private plaintext;
|
|
241
241
|
private opts;
|
|
242
242
|
private lockContext;
|
|
243
|
-
constructor(client: Client, plaintext: JsPlaintext
|
|
243
|
+
constructor(client: Client, plaintext: JsPlaintext, opts: EncryptQueryOptions, lockContext: LockContext, auditMetadata?: Record<string, unknown>);
|
|
244
244
|
execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
/** The EncryptionClient is the main entry point for interacting with the CipherStash
|
|
247
|
+
/** The EncryptionClient is the main entry point for interacting with the CipherStash Encryption library.
|
|
248
248
|
* It provides methods for encrypting and decrypting individual values, as well as models (objects) and bulk operations.
|
|
249
249
|
*
|
|
250
250
|
* The client must be initialized using the {@link Encryption} function before it can be used.
|
|
@@ -271,8 +271,8 @@ declare class EncryptionClient {
|
|
|
271
271
|
/**
|
|
272
272
|
* Encrypt a value - returns a promise which resolves to an encrypted value.
|
|
273
273
|
*
|
|
274
|
-
* @param plaintext - The plaintext value to be encrypted.
|
|
275
|
-
* @param opts - Options specifying the column and table for encryption.
|
|
274
|
+
* @param plaintext - The plaintext value to be encrypted.
|
|
275
|
+
* @param opts - Options specifying the column (or nested field) and table for encryption. See {@link EncryptOptions}.
|
|
276
276
|
* @returns An EncryptOperation that can be awaited or chained with additional methods.
|
|
277
277
|
*
|
|
278
278
|
* @example
|
|
@@ -335,16 +335,19 @@ declare class EncryptionClient {
|
|
|
335
335
|
* .withLockContext(lockContext)
|
|
336
336
|
* ```
|
|
337
337
|
*
|
|
338
|
+
* @see {@link EncryptOptions}
|
|
338
339
|
* @see {@link Result}
|
|
339
340
|
* @see {@link encryptedTable}
|
|
341
|
+
* @see {@link encryptedColumn}
|
|
342
|
+
* @see {@link encryptedField}
|
|
340
343
|
* @see {@link LockContext}
|
|
341
344
|
* @see {@link EncryptOperation}
|
|
342
345
|
*/
|
|
343
|
-
encrypt(plaintext: JsPlaintext
|
|
346
|
+
encrypt(plaintext: JsPlaintext, opts: EncryptOptions): EncryptOperation;
|
|
344
347
|
/**
|
|
345
348
|
* Encrypt a query value - returns a promise which resolves to an encrypted query value.
|
|
346
349
|
*
|
|
347
|
-
* @param plaintext - The plaintext value to be encrypted for querying.
|
|
350
|
+
* @param plaintext - The plaintext value to be encrypted for querying.
|
|
348
351
|
* @param opts - Options specifying the column, table, and optional queryType for encryption.
|
|
349
352
|
* @returns An EncryptQueryOperation that can be awaited or chained with additional methods.
|
|
350
353
|
*
|
|
@@ -394,7 +397,7 @@ declare class EncryptionClient {
|
|
|
394
397
|
* - String plaintext → `steVecSelector` (JSONPath queries like `'$.user.email'`)
|
|
395
398
|
* - Object/Array plaintext → `steVecTerm` (containment queries like `{ role: 'admin' }`)
|
|
396
399
|
*/
|
|
397
|
-
encryptQuery(plaintext: JsPlaintext
|
|
400
|
+
encryptQuery(plaintext: JsPlaintext, opts: EncryptQueryOptions): EncryptQueryOperation;
|
|
398
401
|
/**
|
|
399
402
|
* Encrypt multiple values for use in queries (batch operation).
|
|
400
403
|
* @param terms - Array of query terms to encrypt
|
|
@@ -479,7 +482,7 @@ declare class EncryptionClient {
|
|
|
479
482
|
* }
|
|
480
483
|
* ```
|
|
481
484
|
*/
|
|
482
|
-
encryptModel<T extends Record<string, unknown>, S extends
|
|
485
|
+
encryptModel<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: T, table: EncryptedTable<S>): EncryptModelOperation<EncryptedFromSchema<T, S>>;
|
|
483
486
|
/**
|
|
484
487
|
* Decrypt a model (object) whose fields contain encrypted values.
|
|
485
488
|
*
|
|
@@ -554,7 +557,7 @@ declare class EncryptionClient {
|
|
|
554
557
|
* }
|
|
555
558
|
* ```
|
|
556
559
|
*/
|
|
557
|
-
bulkEncryptModels<T extends Record<string, unknown>, S extends
|
|
560
|
+
bulkEncryptModels<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: Array<T>, table: EncryptedTable<S>): BulkEncryptModelsOperation<EncryptedFromSchema<T, S>>;
|
|
558
561
|
/**
|
|
559
562
|
* Decrypt multiple models (objects) in a single bulk operation.
|
|
560
563
|
*
|
|
@@ -589,10 +592,10 @@ declare class EncryptionClient {
|
|
|
589
592
|
*
|
|
590
593
|
* Each value is encrypted with its own unique key via a single call to ZeroKMS.
|
|
591
594
|
* Values can include optional `id` fields for correlating results back to
|
|
592
|
-
* your application data.
|
|
595
|
+
* your application data.
|
|
593
596
|
*
|
|
594
597
|
* @param plaintexts - An array of objects with `plaintext` (and optional `id`) fields.
|
|
595
|
-
* @param opts - Options specifying the target column and table
|
|
598
|
+
* @param opts - Options specifying the target column (or nested {@link encryptedField}) and table. See {@link EncryptOptions}.
|
|
596
599
|
* @returns A `BulkEncryptOperation` that can be awaited to get a `Result`
|
|
597
600
|
* containing an array of `{ id?, data: Encrypted }` objects, or an `EncryptionError`.
|
|
598
601
|
*
|
|
@@ -610,7 +613,6 @@ declare class EncryptionClient {
|
|
|
610
613
|
* [
|
|
611
614
|
* { id: "u1", plaintext: "alice@example.com" },
|
|
612
615
|
* { id: "u2", plaintext: "bob@example.com" },
|
|
613
|
-
* { id: "u3", plaintext: null },
|
|
614
616
|
* ],
|
|
615
617
|
* { column: users.email, table: users },
|
|
616
618
|
* )
|
package/dist/client.cjs
CHANGED
|
@@ -21,14 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var client_exports = {};
|
|
22
22
|
__export(client_exports, {
|
|
23
23
|
encryptedColumn: () => encryptedColumn,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
encryptedField: () => encryptedField,
|
|
25
|
+
encryptedTable: () => encryptedTable
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(client_exports);
|
|
28
28
|
|
|
29
29
|
// src/schema/index.ts
|
|
30
30
|
var import_zod = require("zod");
|
|
31
|
-
var castAsEnum = import_zod.z.enum(["bigint", "boolean", "date", "number", "string", "json"]).default("
|
|
31
|
+
var castAsEnum = import_zod.z.enum(["bigint", "boolean", "date", "number", "string", "json", "text"]).default("text");
|
|
32
32
|
var tokenFilterSchema = import_zod.z.object({
|
|
33
33
|
kind: import_zod.z.literal("downcase")
|
|
34
34
|
});
|
|
@@ -71,28 +71,28 @@ var encryptConfigSchema = import_zod.z.object({
|
|
|
71
71
|
v: import_zod.z.number(),
|
|
72
72
|
tables: tablesSchema
|
|
73
73
|
});
|
|
74
|
-
var
|
|
74
|
+
var EncryptedField = class {
|
|
75
75
|
valueName;
|
|
76
76
|
castAsValue;
|
|
77
77
|
constructor(valueName) {
|
|
78
78
|
this.valueName = valueName;
|
|
79
|
-
this.castAsValue = "
|
|
79
|
+
this.castAsValue = "text";
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* Set or override the plaintext data type for this
|
|
82
|
+
* Set or override the plaintext data type for this field.
|
|
83
83
|
*
|
|
84
84
|
* By default all values are treated as `'string'`. Use this method to specify
|
|
85
85
|
* a different type so the encryption layer knows how to encode the plaintext
|
|
86
86
|
* before encrypting.
|
|
87
87
|
*
|
|
88
|
-
* @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'bigint'`, or `'json'`.
|
|
89
|
-
* @returns This `
|
|
88
|
+
* @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'text'`, `'bigint'`, or `'json'`.
|
|
89
|
+
* @returns This `EncryptedField` instance for method chaining.
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
92
|
* ```typescript
|
|
93
|
-
* import {
|
|
93
|
+
* import { encryptedField } from "@cipherstash/stack/schema"
|
|
94
94
|
*
|
|
95
|
-
* const age =
|
|
95
|
+
* const age = encryptedField("age").dataType("number")
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
98
98
|
dataType(castAs) {
|
|
@@ -101,7 +101,7 @@ var ProtectValue = class {
|
|
|
101
101
|
}
|
|
102
102
|
build() {
|
|
103
103
|
return {
|
|
104
|
-
cast_as: this.castAsValue,
|
|
104
|
+
cast_as: this.castAsValue === "string" ? "text" : this.castAsValue,
|
|
105
105
|
indexes: {}
|
|
106
106
|
};
|
|
107
107
|
}
|
|
@@ -109,7 +109,7 @@ var ProtectValue = class {
|
|
|
109
109
|
return this.valueName;
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
var
|
|
112
|
+
var EncryptedColumn = class {
|
|
113
113
|
columnName;
|
|
114
114
|
castAsValue;
|
|
115
115
|
indexesValue = {};
|
|
@@ -125,7 +125,7 @@ var ProtectColumn = class {
|
|
|
125
125
|
* before encrypting.
|
|
126
126
|
*
|
|
127
127
|
* @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'bigint'`, or `'json'`.
|
|
128
|
-
* @returns This `
|
|
128
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
129
129
|
*
|
|
130
130
|
* @example
|
|
131
131
|
* ```typescript
|
|
@@ -144,7 +144,7 @@ var ProtectColumn = class {
|
|
|
144
144
|
* ORE allows sorting, comparison, and range queries on encrypted data.
|
|
145
145
|
* Use with `encryptQuery` and `queryType: 'orderAndRange'`.
|
|
146
146
|
*
|
|
147
|
-
* @returns This `
|
|
147
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
148
148
|
*
|
|
149
149
|
* @example
|
|
150
150
|
* ```typescript
|
|
@@ -167,7 +167,7 @@ var ProtectColumn = class {
|
|
|
167
167
|
*
|
|
168
168
|
* @param tokenFilters - Optional array of token filters (e.g. `[{ kind: 'downcase' }]`).
|
|
169
169
|
* When omitted, no token filters are applied.
|
|
170
|
-
* @returns This `
|
|
170
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
171
171
|
*
|
|
172
172
|
* @example
|
|
173
173
|
* ```typescript
|
|
@@ -192,7 +192,7 @@ var ProtectColumn = class {
|
|
|
192
192
|
*
|
|
193
193
|
* @param opts - Optional match index configuration. Defaults to 3-character ngram
|
|
194
194
|
* tokenization with a downcase filter, `k=6`, `m=2048`, and `include_original=true`.
|
|
195
|
-
* @returns This `
|
|
195
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
196
196
|
*
|
|
197
197
|
* @example
|
|
198
198
|
* ```typescript
|
|
@@ -237,7 +237,7 @@ var ProtectColumn = class {
|
|
|
237
237
|
* the plaintext type: strings become selector queries, objects/arrays become
|
|
238
238
|
* containment queries.
|
|
239
239
|
*
|
|
240
|
-
* @returns This `
|
|
240
|
+
* @returns This `EncryptedColumn` instance for method chaining.
|
|
241
241
|
*
|
|
242
242
|
* @example
|
|
243
243
|
* ```typescript
|
|
@@ -255,7 +255,7 @@ var ProtectColumn = class {
|
|
|
255
255
|
}
|
|
256
256
|
build() {
|
|
257
257
|
return {
|
|
258
|
-
cast_as: this.castAsValue,
|
|
258
|
+
cast_as: this.castAsValue === "string" ? "text" : this.castAsValue,
|
|
259
259
|
indexes: this.indexesValue
|
|
260
260
|
};
|
|
261
261
|
}
|
|
@@ -263,7 +263,7 @@ var ProtectColumn = class {
|
|
|
263
263
|
return this.columnName;
|
|
264
264
|
}
|
|
265
265
|
};
|
|
266
|
-
var
|
|
266
|
+
var EncryptedTable = class {
|
|
267
267
|
constructor(tableName, columnBuilders) {
|
|
268
268
|
this.tableName = tableName;
|
|
269
269
|
this.columnBuilders = columnBuilders;
|
|
@@ -290,7 +290,7 @@ var ProtectTable = class {
|
|
|
290
290
|
build() {
|
|
291
291
|
const builtColumns = {};
|
|
292
292
|
const processColumn = (builder, colName) => {
|
|
293
|
-
if (builder instanceof
|
|
293
|
+
if (builder instanceof EncryptedColumn) {
|
|
294
294
|
const builtColumn = builder.build();
|
|
295
295
|
if (builtColumn.cast_as === "json" && builtColumn.indexes.ste_vec?.prefix === "enabled") {
|
|
296
296
|
builtColumns[colName] = {
|
|
@@ -307,7 +307,7 @@ var ProtectTable = class {
|
|
|
307
307
|
}
|
|
308
308
|
} else {
|
|
309
309
|
for (const [key, value] of Object.entries(builder)) {
|
|
310
|
-
if (value instanceof
|
|
310
|
+
if (value instanceof EncryptedField) {
|
|
311
311
|
builtColumns[value.getName()] = value.build();
|
|
312
312
|
} else {
|
|
313
313
|
processColumn(value, key);
|
|
@@ -325,7 +325,10 @@ var ProtectTable = class {
|
|
|
325
325
|
}
|
|
326
326
|
};
|
|
327
327
|
function encryptedTable(tableName, columns) {
|
|
328
|
-
const tableBuilder = new
|
|
328
|
+
const tableBuilder = new EncryptedTable(
|
|
329
|
+
tableName,
|
|
330
|
+
columns
|
|
331
|
+
);
|
|
329
332
|
for (const [colName, colBuilder] of Object.entries(columns)) {
|
|
330
333
|
;
|
|
331
334
|
tableBuilder[colName] = colBuilder;
|
|
@@ -333,15 +336,15 @@ function encryptedTable(tableName, columns) {
|
|
|
333
336
|
return tableBuilder;
|
|
334
337
|
}
|
|
335
338
|
function encryptedColumn(columnName) {
|
|
336
|
-
return new
|
|
339
|
+
return new EncryptedColumn(columnName);
|
|
337
340
|
}
|
|
338
|
-
function
|
|
339
|
-
return new
|
|
341
|
+
function encryptedField(valueName) {
|
|
342
|
+
return new EncryptedField(valueName);
|
|
340
343
|
}
|
|
341
344
|
// Annotate the CommonJS export names for ESM import in node:
|
|
342
345
|
0 && (module.exports = {
|
|
343
346
|
encryptedColumn,
|
|
344
|
-
|
|
345
|
-
|
|
347
|
+
encryptedField,
|
|
348
|
+
encryptedTable
|
|
346
349
|
});
|
|
347
350
|
//# sourceMappingURL=client.cjs.map
|