@cipherstash/stack 0.16.0 → 0.18.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 +52 -0
- package/dist/{chunk-6FD7OBGM.js → chunk-LLCCNKDL.js} +3 -3
- package/dist/chunk-LLCCNKDL.js.map +1 -0
- package/dist/{chunk-MD6742R6.js → chunk-VPOTNP4K.js} +1 -1
- package/dist/chunk-VPOTNP4K.js.map +1 -0
- package/dist/{chunk-4RNBI3UH.js → chunk-XWPGAHBZ.js} +1 -1
- package/dist/chunk-XWPGAHBZ.js.map +1 -0
- package/dist/{chunk-JDZ2QUUF.js → chunk-YWQXTZ5M.js} +4 -2
- package/dist/{chunk-JDZ2QUUF.js.map → chunk-YWQXTZ5M.js.map} +1 -1
- package/dist/{chunk-CY5B4LIF.js → chunk-ZYOZHZMJ.js} +160 -52
- package/dist/chunk-ZYOZHZMJ.js.map +1 -0
- package/dist/{client-BLbA6aFD.d.ts → client-CIsfZ2zg.d.ts} +17 -22
- package/dist/{client-C_7TF8EL.d.cts → client-Dt98Rugc.d.cts} +17 -22
- package/dist/client.cjs +2 -0
- 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 +1 -1
- package/dist/drizzle/index.cjs +6 -3
- package/dist/drizzle/index.cjs.map +1 -1
- package/dist/drizzle/index.d.cts +2 -2
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +6 -5
- package/dist/drizzle/index.js.map +1 -1
- package/dist/dynamodb/index.cjs +14 -4
- package/dist/dynamodb/index.cjs.map +1 -1
- package/dist/dynamodb/index.d.cts +12 -12
- package/dist/dynamodb/index.d.ts +12 -12
- package/dist/dynamodb/index.js +9 -3
- package/dist/dynamodb/index.js.map +1 -1
- package/dist/encryption/index.cjs +168 -50
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +2 -2
- package/dist/encryption/index.d.ts +2 -2
- package/dist/encryption/index.js +25 -5
- package/dist/identity/index.cjs +2 -2
- package/dist/identity/index.cjs.map +1 -1
- package/dist/identity/index.js +3 -3
- package/dist/index.cjs +150 -50
- 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 +5 -5
- package/dist/schema/index.cjs +3 -1
- 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 +1 -1
- package/dist/supabase/index.cjs +2 -2
- package/dist/supabase/index.cjs.map +1 -1
- package/dist/supabase/index.d.cts +2 -2
- package/dist/supabase/index.d.ts +2 -2
- package/dist/supabase/index.js +3 -3
- package/dist/{types-public-Dv-r6Ik0.d.ts → types-public-BTxqjmtv.d.cts} +95 -80
- package/dist/{types-public-Dv-r6Ik0.d.cts → types-public-BTxqjmtv.d.ts} +95 -80
- 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 +12 -12
- package/dist/chunk-4RNBI3UH.js.map +0 -1
- package/dist/chunk-6FD7OBGM.js.map +0 -1
- package/dist/chunk-CY5B4LIF.js.map +0 -1
- package/dist/chunk-MD6742R6.js.map +0 -1
|
@@ -2,19 +2,19 @@ import {
|
|
|
2
2
|
formatEncryptedResult,
|
|
3
3
|
isEncryptedPayload,
|
|
4
4
|
toFfiKeysetIdentifier
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XWPGAHBZ.js";
|
|
6
6
|
import {
|
|
7
7
|
buildEncryptConfig,
|
|
8
8
|
encryptConfigSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YWQXTZ5M.js";
|
|
10
10
|
import {
|
|
11
11
|
queryTypeToFfi,
|
|
12
12
|
queryTypeToQueryOp
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VPOTNP4K.js";
|
|
14
14
|
import {
|
|
15
15
|
createRequestLogger,
|
|
16
16
|
logger
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LLCCNKDL.js";
|
|
18
18
|
import {
|
|
19
19
|
EncryptionErrorTypes
|
|
20
20
|
} from "./chunk-LBMC4D6D.js";
|
|
@@ -176,6 +176,15 @@ var EncryptionOperation = class {
|
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
// src/encryption/operations/batch-encrypt-query.ts
|
|
179
|
+
function filterNullTerms(terms) {
|
|
180
|
+
const nonNullTerms = [];
|
|
181
|
+
terms.forEach((term, index) => {
|
|
182
|
+
if (term.value !== null && term.value !== void 0) {
|
|
183
|
+
nonNullTerms.push({ term, originalIndex: index });
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return { nonNullTerms };
|
|
187
|
+
}
|
|
179
188
|
function buildQueryPayload(term, lockContext) {
|
|
180
189
|
assertValidNumericValue(term.value);
|
|
181
190
|
const { indexType, queryOp } = resolveIndexType(
|
|
@@ -196,10 +205,15 @@ function buildQueryPayload(term, lockContext) {
|
|
|
196
205
|
}
|
|
197
206
|
return payload;
|
|
198
207
|
}
|
|
199
|
-
function assembleResults(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
208
|
+
function assembleResults(totalLength, encryptedValues, nonNullTerms) {
|
|
209
|
+
const results = new Array(totalLength).fill(null);
|
|
210
|
+
nonNullTerms.forEach(({ term, originalIndex }, i) => {
|
|
211
|
+
results[originalIndex] = formatEncryptedResult(
|
|
212
|
+
encryptedValues[i],
|
|
213
|
+
term.returnType
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
return results;
|
|
203
217
|
}
|
|
204
218
|
var BatchEncryptQueryOperation = class extends EncryptionOperation {
|
|
205
219
|
constructor(client, terms) {
|
|
@@ -207,6 +221,8 @@ var BatchEncryptQueryOperation = class extends EncryptionOperation {
|
|
|
207
221
|
this.client = client;
|
|
208
222
|
this.terms = terms;
|
|
209
223
|
}
|
|
224
|
+
client;
|
|
225
|
+
terms;
|
|
210
226
|
withLockContext(lockContext) {
|
|
211
227
|
return new BatchEncryptQueryOperationWithLockContext(
|
|
212
228
|
this.client,
|
|
@@ -226,18 +242,23 @@ var BatchEncryptQueryOperation = class extends EncryptionOperation {
|
|
|
226
242
|
log.emit();
|
|
227
243
|
return { data: [] };
|
|
228
244
|
}
|
|
245
|
+
const { nonNullTerms } = filterNullTerms(this.terms);
|
|
246
|
+
if (nonNullTerms.length === 0) {
|
|
247
|
+
log.emit();
|
|
248
|
+
return { data: this.terms.map(() => null) };
|
|
249
|
+
}
|
|
229
250
|
const result = await withResult(
|
|
230
251
|
async () => {
|
|
231
252
|
if (!this.client) throw noClientError();
|
|
232
253
|
const { metadata } = this.getAuditData();
|
|
233
|
-
const queries =
|
|
234
|
-
(term) => buildQueryPayload(term)
|
|
254
|
+
const queries = nonNullTerms.map(
|
|
255
|
+
({ term }) => buildQueryPayload(term)
|
|
235
256
|
);
|
|
236
257
|
const encrypted = await ffiEncryptQueryBulk(this.client, {
|
|
237
258
|
queries,
|
|
238
259
|
unverifiedContext: metadata
|
|
239
260
|
});
|
|
240
|
-
return assembleResults(this.terms, encrypted);
|
|
261
|
+
return assembleResults(this.terms.length, encrypted, nonNullTerms);
|
|
241
262
|
},
|
|
242
263
|
(error) => {
|
|
243
264
|
log.set({ errorCode: getErrorCode(error) ?? "unknown" });
|
|
@@ -260,6 +281,9 @@ var BatchEncryptQueryOperationWithLockContext = class extends EncryptionOperatio
|
|
|
260
281
|
this.lockContext = lockContext;
|
|
261
282
|
this.auditMetadata = auditMetadata;
|
|
262
283
|
}
|
|
284
|
+
client;
|
|
285
|
+
terms;
|
|
286
|
+
lockContext;
|
|
263
287
|
async execute() {
|
|
264
288
|
const log = createRequestLogger();
|
|
265
289
|
log.set({
|
|
@@ -271,6 +295,11 @@ var BatchEncryptQueryOperationWithLockContext = class extends EncryptionOperatio
|
|
|
271
295
|
log.emit();
|
|
272
296
|
return { data: [] };
|
|
273
297
|
}
|
|
298
|
+
const { nonNullTerms } = filterNullTerms(this.terms);
|
|
299
|
+
if (nonNullTerms.length === 0) {
|
|
300
|
+
log.emit();
|
|
301
|
+
return { data: this.terms.map(() => null) };
|
|
302
|
+
}
|
|
274
303
|
const lockContextResult = await this.lockContext.getLockContext();
|
|
275
304
|
if (lockContextResult.failure) {
|
|
276
305
|
log.emit();
|
|
@@ -281,15 +310,15 @@ var BatchEncryptQueryOperationWithLockContext = class extends EncryptionOperatio
|
|
|
281
310
|
async () => {
|
|
282
311
|
if (!this.client) throw noClientError();
|
|
283
312
|
const { metadata } = this.getAuditData();
|
|
284
|
-
const queries =
|
|
285
|
-
(term) => buildQueryPayload(term, context)
|
|
313
|
+
const queries = nonNullTerms.map(
|
|
314
|
+
({ term }) => buildQueryPayload(term, context)
|
|
286
315
|
);
|
|
287
316
|
const encrypted = await ffiEncryptQueryBulk(this.client, {
|
|
288
317
|
queries,
|
|
289
318
|
serviceToken: ctsToken,
|
|
290
319
|
unverifiedContext: metadata
|
|
291
320
|
});
|
|
292
|
-
return assembleResults(this.terms, encrypted);
|
|
321
|
+
return assembleResults(this.terms.length, encrypted, nonNullTerms);
|
|
293
322
|
},
|
|
294
323
|
(error) => {
|
|
295
324
|
log.set({ errorCode: getErrorCode(error) ?? "unknown" });
|
|
@@ -311,25 +340,30 @@ import {
|
|
|
311
340
|
decryptBulkFallible
|
|
312
341
|
} from "@cipherstash/protect-ffi";
|
|
313
342
|
var createDecryptPayloads = (encryptedPayloads, lockContext) => {
|
|
314
|
-
return encryptedPayloads.map(({ id, data }) => ({
|
|
343
|
+
return encryptedPayloads.filter(({ data }) => data !== null).map(({ id, data }) => ({
|
|
315
344
|
id,
|
|
316
345
|
ciphertext: data,
|
|
317
346
|
...lockContext && { lockContext }
|
|
318
347
|
}));
|
|
319
348
|
};
|
|
349
|
+
var createNullResult = (encryptedPayloads) => encryptedPayloads.map(({ id }) => ({ id, data: null }));
|
|
320
350
|
var mapDecryptedDataToResult = (encryptedPayloads, decryptedData) => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
351
|
+
const result = new Array(encryptedPayloads.length);
|
|
352
|
+
let decryptedIndex = 0;
|
|
353
|
+
for (let i = 0; i < encryptedPayloads.length; i++) {
|
|
354
|
+
if (encryptedPayloads[i].data === null) {
|
|
355
|
+
result[i] = { id: encryptedPayloads[i].id, data: null };
|
|
356
|
+
} else {
|
|
357
|
+
const decryptResult = decryptedData[decryptedIndex];
|
|
358
|
+
if ("error" in decryptResult) {
|
|
359
|
+
result[i] = { id: encryptedPayloads[i].id, error: decryptResult.error };
|
|
360
|
+
} else {
|
|
361
|
+
result[i] = { id: encryptedPayloads[i].id, data: decryptResult.data };
|
|
362
|
+
}
|
|
363
|
+
decryptedIndex++;
|
|
327
364
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
data: decryptResult.data
|
|
331
|
-
};
|
|
332
|
-
});
|
|
365
|
+
}
|
|
366
|
+
return result;
|
|
333
367
|
};
|
|
334
368
|
var BulkDecryptOperation = class extends EncryptionOperation {
|
|
335
369
|
client;
|
|
@@ -354,10 +388,13 @@ var BulkDecryptOperation = class extends EncryptionOperation {
|
|
|
354
388
|
if (!this.client) throw noClientError();
|
|
355
389
|
if (!this.encryptedPayloads || this.encryptedPayloads.length === 0)
|
|
356
390
|
return [];
|
|
357
|
-
const
|
|
391
|
+
const nonNullPayloads = createDecryptPayloads(this.encryptedPayloads);
|
|
392
|
+
if (nonNullPayloads.length === 0) {
|
|
393
|
+
return createNullResult(this.encryptedPayloads);
|
|
394
|
+
}
|
|
358
395
|
const { metadata } = this.getAuditData();
|
|
359
396
|
const decryptedData = await decryptBulkFallible(this.client, {
|
|
360
|
-
ciphertexts:
|
|
397
|
+
ciphertexts: nonNullPayloads,
|
|
361
398
|
unverifiedContext: metadata
|
|
362
399
|
});
|
|
363
400
|
return mapDecryptedDataToResult(this.encryptedPayloads, decryptedData);
|
|
@@ -409,13 +446,16 @@ var BulkDecryptOperationWithLockContext = class extends EncryptionOperation {
|
|
|
409
446
|
if (context.failure) {
|
|
410
447
|
throw new Error(`[encryption]: ${context.failure.message}`);
|
|
411
448
|
}
|
|
412
|
-
const
|
|
449
|
+
const nonNullPayloads = createDecryptPayloads(
|
|
413
450
|
encryptedPayloads,
|
|
414
451
|
context.data.context
|
|
415
452
|
);
|
|
453
|
+
if (nonNullPayloads.length === 0) {
|
|
454
|
+
return createNullResult(encryptedPayloads);
|
|
455
|
+
}
|
|
416
456
|
const { metadata } = this.getAuditData();
|
|
417
457
|
const decryptedData = await decryptBulkFallible(client, {
|
|
418
|
-
ciphertexts:
|
|
458
|
+
ciphertexts: nonNullPayloads,
|
|
419
459
|
serviceToken: context.data.ctsToken,
|
|
420
460
|
unverifiedContext: metadata
|
|
421
461
|
});
|
|
@@ -1057,7 +1097,7 @@ var BulkDecryptModelsOperationWithLockContext = class extends EncryptionOperatio
|
|
|
1057
1097
|
import { withResult as withResult4 } from "@byteslice/result";
|
|
1058
1098
|
import { encryptBulk as encryptBulk2 } from "@cipherstash/protect-ffi";
|
|
1059
1099
|
var createEncryptPayloads = (plaintexts, column, table, lockContext) => {
|
|
1060
|
-
return plaintexts.map(({ id, plaintext }) => ({
|
|
1100
|
+
return plaintexts.filter(({ plaintext }) => plaintext !== null).map(({ id, plaintext }) => ({
|
|
1061
1101
|
id,
|
|
1062
1102
|
plaintext,
|
|
1063
1103
|
column: column.getName(),
|
|
@@ -1065,6 +1105,20 @@ var createEncryptPayloads = (plaintexts, column, table, lockContext) => {
|
|
|
1065
1105
|
...lockContext && { lockContext }
|
|
1066
1106
|
}));
|
|
1067
1107
|
};
|
|
1108
|
+
var createNullResult2 = (plaintexts) => plaintexts.map(({ id }) => ({ id, data: null }));
|
|
1109
|
+
var mapEncryptedDataToResult = (plaintexts, encryptedData) => {
|
|
1110
|
+
const result = new Array(plaintexts.length);
|
|
1111
|
+
let encryptedIndex = 0;
|
|
1112
|
+
for (let i = 0; i < plaintexts.length; i++) {
|
|
1113
|
+
if (plaintexts[i].plaintext === null) {
|
|
1114
|
+
result[i] = { id: plaintexts[i].id, data: null };
|
|
1115
|
+
} else {
|
|
1116
|
+
result[i] = { id: plaintexts[i].id, data: encryptedData[encryptedIndex] };
|
|
1117
|
+
encryptedIndex++;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
return result;
|
|
1121
|
+
};
|
|
1068
1122
|
var BulkEncryptOperation = class extends EncryptionOperation {
|
|
1069
1123
|
client;
|
|
1070
1124
|
plaintexts;
|
|
@@ -1097,20 +1151,20 @@ var BulkEncryptOperation = class extends EncryptionOperation {
|
|
|
1097
1151
|
if (!this.plaintexts || this.plaintexts.length === 0) {
|
|
1098
1152
|
return [];
|
|
1099
1153
|
}
|
|
1100
|
-
const
|
|
1154
|
+
const nonNullPayloads = createEncryptPayloads(
|
|
1101
1155
|
this.plaintexts,
|
|
1102
1156
|
this.column,
|
|
1103
1157
|
this.table
|
|
1104
1158
|
);
|
|
1159
|
+
if (nonNullPayloads.length === 0) {
|
|
1160
|
+
return createNullResult2(this.plaintexts);
|
|
1161
|
+
}
|
|
1105
1162
|
const { metadata } = this.getAuditData();
|
|
1106
1163
|
const encryptedData = await encryptBulk2(this.client, {
|
|
1107
|
-
plaintexts:
|
|
1164
|
+
plaintexts: nonNullPayloads,
|
|
1108
1165
|
unverifiedContext: metadata
|
|
1109
1166
|
});
|
|
1110
|
-
return
|
|
1111
|
-
id: this.plaintexts[i].id,
|
|
1112
|
-
data
|
|
1113
|
-
}));
|
|
1167
|
+
return mapEncryptedDataToResult(this.plaintexts, encryptedData);
|
|
1114
1168
|
},
|
|
1115
1169
|
(error) => {
|
|
1116
1170
|
log.set({ errorCode: getErrorCode(error) ?? "unknown" });
|
|
@@ -1167,22 +1221,22 @@ var BulkEncryptOperationWithLockContext = class extends EncryptionOperation {
|
|
|
1167
1221
|
if (context.failure) {
|
|
1168
1222
|
throw new Error(`[encryption]: ${context.failure.message}`);
|
|
1169
1223
|
}
|
|
1170
|
-
const
|
|
1224
|
+
const nonNullPayloads = createEncryptPayloads(
|
|
1171
1225
|
plaintexts,
|
|
1172
1226
|
column,
|
|
1173
1227
|
table,
|
|
1174
1228
|
context.data.context
|
|
1175
1229
|
);
|
|
1230
|
+
if (nonNullPayloads.length === 0) {
|
|
1231
|
+
return createNullResult2(plaintexts);
|
|
1232
|
+
}
|
|
1176
1233
|
const { metadata } = this.getAuditData();
|
|
1177
1234
|
const encryptedData = await encryptBulk2(client, {
|
|
1178
|
-
plaintexts:
|
|
1235
|
+
plaintexts: nonNullPayloads,
|
|
1179
1236
|
serviceToken: context.data.ctsToken,
|
|
1180
1237
|
unverifiedContext: metadata
|
|
1181
1238
|
});
|
|
1182
|
-
return
|
|
1183
|
-
id: plaintexts[i].id,
|
|
1184
|
-
data
|
|
1185
|
-
}));
|
|
1239
|
+
return mapEncryptedDataToResult(plaintexts, encryptedData);
|
|
1186
1240
|
},
|
|
1187
1241
|
(error) => {
|
|
1188
1242
|
log.set({ errorCode: getErrorCode(error) ?? "unknown" });
|
|
@@ -1314,6 +1368,10 @@ import {
|
|
|
1314
1368
|
} from "@cipherstash/protect-ffi";
|
|
1315
1369
|
var DecryptOperation = class extends EncryptionOperation {
|
|
1316
1370
|
client;
|
|
1371
|
+
// Internally widened to allow null so the runtime guard below can
|
|
1372
|
+
// short-circuit on legacy / manually-NULLed rows. The public
|
|
1373
|
+
// `Encryption.decrypt()` signature still rejects null at the type
|
|
1374
|
+
// layer; this is defense in depth for direct construction.
|
|
1317
1375
|
encryptedData;
|
|
1318
1376
|
constructor(client, encryptedData) {
|
|
1319
1377
|
super();
|
|
@@ -1334,6 +1392,9 @@ var DecryptOperation = class extends EncryptionOperation {
|
|
|
1334
1392
|
if (!this.client) {
|
|
1335
1393
|
throw noClientError();
|
|
1336
1394
|
}
|
|
1395
|
+
if (this.encryptedData === null) {
|
|
1396
|
+
return null;
|
|
1397
|
+
}
|
|
1337
1398
|
const { metadata } = this.getAuditData();
|
|
1338
1399
|
return await ffiDecrypt(this.client, {
|
|
1339
1400
|
ciphertext: this.encryptedData,
|
|
@@ -1384,6 +1445,9 @@ var DecryptOperationWithLockContext = class extends EncryptionOperation {
|
|
|
1384
1445
|
if (!client) {
|
|
1385
1446
|
throw noClientError();
|
|
1386
1447
|
}
|
|
1448
|
+
if (encryptedData === null) {
|
|
1449
|
+
return null;
|
|
1450
|
+
}
|
|
1387
1451
|
const { metadata } = this.getAuditData();
|
|
1388
1452
|
const context = await this.lockContext.getLockContext();
|
|
1389
1453
|
if (context.failure) {
|
|
@@ -1513,6 +1577,10 @@ import {
|
|
|
1513
1577
|
} from "@cipherstash/protect-ffi";
|
|
1514
1578
|
var EncryptOperation = class extends EncryptionOperation {
|
|
1515
1579
|
client;
|
|
1580
|
+
// Internally widened to allow null so the runtime guard below can
|
|
1581
|
+
// short-circuit. The public `Encryption.encrypt()` signature still
|
|
1582
|
+
// rejects null at the type layer; this is defense in depth for callers
|
|
1583
|
+
// that reach this class through casts or dynamic field walking.
|
|
1516
1584
|
plaintext;
|
|
1517
1585
|
column;
|
|
1518
1586
|
table;
|
|
@@ -1539,6 +1607,9 @@ var EncryptOperation = class extends EncryptionOperation {
|
|
|
1539
1607
|
if (!this.client) {
|
|
1540
1608
|
throw noClientError();
|
|
1541
1609
|
}
|
|
1610
|
+
if (this.plaintext === null) {
|
|
1611
|
+
return null;
|
|
1612
|
+
}
|
|
1542
1613
|
if (typeof this.plaintext === "number" && Number.isNaN(this.plaintext)) {
|
|
1543
1614
|
throw new Error("[encryption]: Cannot encrypt NaN value");
|
|
1544
1615
|
}
|
|
@@ -1600,6 +1671,9 @@ var EncryptOperationWithLockContext = class extends EncryptionOperation {
|
|
|
1600
1671
|
if (!client) {
|
|
1601
1672
|
throw noClientError();
|
|
1602
1673
|
}
|
|
1674
|
+
if (plaintext === null) {
|
|
1675
|
+
return null;
|
|
1676
|
+
}
|
|
1603
1677
|
const { metadata } = this.getAuditData();
|
|
1604
1678
|
const context = await this.lockContext.getLockContext();
|
|
1605
1679
|
if (context.failure) {
|
|
@@ -1747,6 +1821,9 @@ var EncryptQueryOperation = class extends EncryptionOperation {
|
|
|
1747
1821
|
this.plaintext = plaintext;
|
|
1748
1822
|
this.opts = opts;
|
|
1749
1823
|
}
|
|
1824
|
+
client;
|
|
1825
|
+
plaintext;
|
|
1826
|
+
opts;
|
|
1750
1827
|
withLockContext(lockContext) {
|
|
1751
1828
|
return new EncryptQueryOperationWithLockContext(
|
|
1752
1829
|
this.client,
|
|
@@ -1765,7 +1842,12 @@ var EncryptQueryOperation = class extends EncryptionOperation {
|
|
|
1765
1842
|
queryType: this.opts.queryType,
|
|
1766
1843
|
lockContext: false
|
|
1767
1844
|
});
|
|
1768
|
-
|
|
1845
|
+
if (this.plaintext === null || this.plaintext === void 0) {
|
|
1846
|
+
log.emit();
|
|
1847
|
+
return { data: null };
|
|
1848
|
+
}
|
|
1849
|
+
const plaintext = this.plaintext;
|
|
1850
|
+
const validationError = validateNumericValue(plaintext);
|
|
1769
1851
|
if (validationError?.failure) {
|
|
1770
1852
|
log.emit();
|
|
1771
1853
|
return { failure: validationError.failure };
|
|
@@ -1777,15 +1859,15 @@ var EncryptQueryOperation = class extends EncryptionOperation {
|
|
|
1777
1859
|
const { indexType, queryOp } = resolveIndexType(
|
|
1778
1860
|
this.opts.column,
|
|
1779
1861
|
this.opts.queryType,
|
|
1780
|
-
|
|
1862
|
+
plaintext
|
|
1781
1863
|
);
|
|
1782
1864
|
assertValueIndexCompatibility(
|
|
1783
|
-
|
|
1865
|
+
plaintext,
|
|
1784
1866
|
indexType,
|
|
1785
1867
|
this.opts.column.getName()
|
|
1786
1868
|
);
|
|
1787
1869
|
const encrypted = await ffiEncryptQuery(this.client, {
|
|
1788
|
-
plaintext
|
|
1870
|
+
plaintext,
|
|
1789
1871
|
column: this.opts.column.getName(),
|
|
1790
1872
|
table: this.opts.table.tableName,
|
|
1791
1873
|
indexType,
|
|
@@ -1819,6 +1901,10 @@ var EncryptQueryOperationWithLockContext = class extends EncryptionOperation {
|
|
|
1819
1901
|
this.lockContext = lockContext;
|
|
1820
1902
|
this.auditMetadata = auditMetadata;
|
|
1821
1903
|
}
|
|
1904
|
+
client;
|
|
1905
|
+
plaintext;
|
|
1906
|
+
opts;
|
|
1907
|
+
lockContext;
|
|
1822
1908
|
async execute() {
|
|
1823
1909
|
const log = createRequestLogger();
|
|
1824
1910
|
log.set({
|
|
@@ -1828,7 +1914,12 @@ var EncryptQueryOperationWithLockContext = class extends EncryptionOperation {
|
|
|
1828
1914
|
queryType: this.opts.queryType,
|
|
1829
1915
|
lockContext: true
|
|
1830
1916
|
});
|
|
1831
|
-
|
|
1917
|
+
if (this.plaintext === null || this.plaintext === void 0) {
|
|
1918
|
+
log.emit();
|
|
1919
|
+
return { data: null };
|
|
1920
|
+
}
|
|
1921
|
+
const plaintext = this.plaintext;
|
|
1922
|
+
const validationError = validateNumericValue(plaintext);
|
|
1832
1923
|
if (validationError?.failure) {
|
|
1833
1924
|
log.emit();
|
|
1834
1925
|
return { failure: validationError.failure };
|
|
@@ -1846,15 +1937,15 @@ var EncryptQueryOperationWithLockContext = class extends EncryptionOperation {
|
|
|
1846
1937
|
const { indexType, queryOp } = resolveIndexType(
|
|
1847
1938
|
this.opts.column,
|
|
1848
1939
|
this.opts.queryType,
|
|
1849
|
-
|
|
1940
|
+
plaintext
|
|
1850
1941
|
);
|
|
1851
1942
|
assertValueIndexCompatibility(
|
|
1852
|
-
|
|
1943
|
+
plaintext,
|
|
1853
1944
|
indexType,
|
|
1854
1945
|
this.opts.column.getName()
|
|
1855
1946
|
);
|
|
1856
1947
|
const encrypted = await ffiEncryptQuery(this.client, {
|
|
1857
|
-
plaintext
|
|
1948
|
+
plaintext,
|
|
1858
1949
|
column: this.opts.column.getName(),
|
|
1859
1950
|
table: this.opts.table.tableName,
|
|
1860
1951
|
indexType,
|
|
@@ -2050,6 +2141,13 @@ var EncryptionClient = class {
|
|
|
2050
2141
|
* .withLockContext(lockContext)
|
|
2051
2142
|
* ```
|
|
2052
2143
|
*
|
|
2144
|
+
* @remarks
|
|
2145
|
+
* The public input type rejects null, but at runtime `decrypt` will
|
|
2146
|
+
* short-circuit and return null when given a null ciphertext
|
|
2147
|
+
* (defense in depth for legacy / manually-NULLed DB rows reached via
|
|
2148
|
+
* casts or dynamic field walking). The narrow return type holds for
|
|
2149
|
+
* any caller that respects the input contract.
|
|
2150
|
+
*
|
|
2053
2151
|
* @see {@link LockContext}
|
|
2054
2152
|
* @see {@link DecryptOperation}
|
|
2055
2153
|
*/
|
|
@@ -2329,8 +2427,18 @@ var Encryption = async (config) => {
|
|
|
2329
2427
|
};
|
|
2330
2428
|
|
|
2331
2429
|
export {
|
|
2430
|
+
BatchEncryptQueryOperation,
|
|
2431
|
+
BulkDecryptOperation,
|
|
2432
|
+
BulkDecryptModelsOperation,
|
|
2433
|
+
BulkEncryptOperation,
|
|
2434
|
+
BulkEncryptModelsOperation,
|
|
2435
|
+
DecryptOperation,
|
|
2436
|
+
DecryptModelOperation,
|
|
2437
|
+
EncryptOperation,
|
|
2438
|
+
EncryptModelOperation,
|
|
2439
|
+
EncryptQueryOperation,
|
|
2332
2440
|
noClientError,
|
|
2333
2441
|
EncryptionClient,
|
|
2334
2442
|
Encryption
|
|
2335
2443
|
};
|
|
2336
|
-
//# sourceMappingURL=chunk-
|
|
2444
|
+
//# sourceMappingURL=chunk-ZYOZHZMJ.js.map
|