@cipherstash/stack 0.3.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 +6 -0
- package/README.md +1 -1
- package/dist/bin/stash.js +46 -141
- 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-JLI27P46.js → chunk-KOU2MHXJ.js} +1 -1
- package/dist/chunk-KOU2MHXJ.js.map +1 -0
- package/dist/{chunk-MW6D52V2.js → chunk-WUZGKTMG.js} +45 -134
- package/dist/chunk-WUZGKTMG.js.map +1 -0
- package/dist/{chunk-TBAIVO6T.js → chunk-Y35W4WFN.js} +6 -6
- package/dist/chunk-Y35W4WFN.js.map +1 -0
- package/dist/{client-Bf0Xw2xo.d.cts → client-CUGXheRq.d.cts} +15 -16
- package/dist/{client-Kfp8OsPB.d.ts → client-CrGQnSlk.d.ts} +15 -16
- package/dist/client.cjs +5 -5
- 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 +5 -5
- 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 +2 -2
- package/dist/dynamodb/index.d.cts +2 -2
- package/dist/dynamodb/index.d.ts +2 -2
- package/dist/index.cjs +46 -141
- 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 +4 -4
- package/dist/schema/index.cjs +5 -5
- 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/secrets/index.cjs +46 -141
- 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/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 +2 -2
- package/dist/{types-public-0CzBV45X.d.cts → types-public-Wj6tB_ux.d.cts} +47 -26
- package/dist/{types-public-0CzBV45X.d.ts → types-public-Wj6tB_ux.d.ts} +47 -26
- 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-JLI27P46.js.map +0 -1
- package/dist/chunk-MW6D52V2.js.map +0 -1
- package/dist/chunk-SUYMGQBY.js.map +0 -1
- package/dist/chunk-TBAIVO6T.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -170,7 +170,7 @@ All bulk methods make a single call to ZeroKMS regardless of the number of recor
|
|
|
170
170
|
const plaintexts = [
|
|
171
171
|
{ id: "u1", plaintext: "alice@example.com" },
|
|
172
172
|
{ id: "u2", plaintext: "bob@example.com" },
|
|
173
|
-
{ id: "u3", plaintext:
|
|
173
|
+
{ id: "u3", plaintext: "charlie@example.com" },
|
|
174
174
|
]
|
|
175
175
|
|
|
176
176
|
const encrypted = await client.bulkEncrypt(plaintexts, {
|
package/dist/bin/stash.js
CHANGED
|
@@ -1470,15 +1470,9 @@ function encryptedToPgComposite(obj) {
|
|
|
1470
1470
|
};
|
|
1471
1471
|
}
|
|
1472
1472
|
function encryptedToCompositeLiteral(obj) {
|
|
1473
|
-
if (obj === null) {
|
|
1474
|
-
throw new Error("encryptedToCompositeLiteral: obj cannot be null");
|
|
1475
|
-
}
|
|
1476
1473
|
return `(${JSON.stringify(JSON.stringify(obj))})`;
|
|
1477
1474
|
}
|
|
1478
1475
|
function encryptedToEscapedCompositeLiteral(obj) {
|
|
1479
|
-
if (obj === null) {
|
|
1480
|
-
throw new Error("encryptedToEscapedCompositeLiteral: obj cannot be null");
|
|
1481
|
-
}
|
|
1482
1476
|
return JSON.stringify(encryptedToCompositeLiteral(obj));
|
|
1483
1477
|
}
|
|
1484
1478
|
function formatEncryptedResult(encrypted, returnType) {
|
|
@@ -1518,7 +1512,7 @@ var EncryptionErrorTypes = {
|
|
|
1518
1512
|
|
|
1519
1513
|
// src/schema/index.ts
|
|
1520
1514
|
import { z as z2 } from "zod";
|
|
1521
|
-
var castAsEnum = z2.enum(["bigint", "boolean", "date", "number", "string", "json"]).default("
|
|
1515
|
+
var castAsEnum = z2.enum(["bigint", "boolean", "date", "number", "string", "json", "text"]).default("text");
|
|
1522
1516
|
var tokenFilterSchema = z2.object({
|
|
1523
1517
|
kind: z2.literal("downcase")
|
|
1524
1518
|
});
|
|
@@ -1566,7 +1560,7 @@ var EncryptedField = class {
|
|
|
1566
1560
|
castAsValue;
|
|
1567
1561
|
constructor(valueName) {
|
|
1568
1562
|
this.valueName = valueName;
|
|
1569
|
-
this.castAsValue = "
|
|
1563
|
+
this.castAsValue = "text";
|
|
1570
1564
|
}
|
|
1571
1565
|
/**
|
|
1572
1566
|
* Set or override the plaintext data type for this field.
|
|
@@ -1575,7 +1569,7 @@ var EncryptedField = class {
|
|
|
1575
1569
|
* a different type so the encryption layer knows how to encode the plaintext
|
|
1576
1570
|
* before encrypting.
|
|
1577
1571
|
*
|
|
1578
|
-
* @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'bigint'`, or `'json'`.
|
|
1572
|
+
* @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'text'`, `'bigint'`, or `'json'`.
|
|
1579
1573
|
* @returns This `EncryptedField` instance for method chaining.
|
|
1580
1574
|
*
|
|
1581
1575
|
* @example
|
|
@@ -1591,7 +1585,7 @@ var EncryptedField = class {
|
|
|
1591
1585
|
}
|
|
1592
1586
|
build() {
|
|
1593
1587
|
return {
|
|
1594
|
-
cast_as: this.castAsValue,
|
|
1588
|
+
cast_as: this.castAsValue === "string" ? "text" : this.castAsValue,
|
|
1595
1589
|
indexes: {}
|
|
1596
1590
|
};
|
|
1597
1591
|
}
|
|
@@ -1745,7 +1739,7 @@ var EncryptedColumn = class {
|
|
|
1745
1739
|
}
|
|
1746
1740
|
build() {
|
|
1747
1741
|
return {
|
|
1748
|
-
cast_as: this.castAsValue,
|
|
1742
|
+
cast_as: this.castAsValue === "string" ? "text" : this.castAsValue,
|
|
1749
1743
|
indexes: this.indexesValue
|
|
1750
1744
|
};
|
|
1751
1745
|
}
|
|
@@ -2120,18 +2114,6 @@ var EncryptionOperation = class {
|
|
|
2120
2114
|
};
|
|
2121
2115
|
|
|
2122
2116
|
// src/encryption/operations/batch-encrypt-query.ts
|
|
2123
|
-
function filterNullTerms(terms) {
|
|
2124
|
-
const nullIndices = /* @__PURE__ */ new Set();
|
|
2125
|
-
const nonNullTerms = [];
|
|
2126
|
-
terms.forEach((term, index) => {
|
|
2127
|
-
if (term.value === null || term.value === void 0) {
|
|
2128
|
-
nullIndices.add(index);
|
|
2129
|
-
} else {
|
|
2130
|
-
nonNullTerms.push({ term, originalIndex: index });
|
|
2131
|
-
}
|
|
2132
|
-
});
|
|
2133
|
-
return { nullIndices, nonNullTerms };
|
|
2134
|
-
}
|
|
2135
2117
|
function buildQueryPayload(term, lockContext) {
|
|
2136
2118
|
assertValidNumericValue(term.value);
|
|
2137
2119
|
const { indexType, queryOp } = resolveIndexType(
|
|
@@ -2152,13 +2134,10 @@ function buildQueryPayload(term, lockContext) {
|
|
|
2152
2134
|
}
|
|
2153
2135
|
return payload;
|
|
2154
2136
|
}
|
|
2155
|
-
function assembleResults(
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
results[originalIndex] = formatEncryptedResult(encrypted, term.returnType);
|
|
2160
|
-
});
|
|
2161
|
-
return results;
|
|
2137
|
+
function assembleResults(terms, encryptedValues) {
|
|
2138
|
+
return terms.map(
|
|
2139
|
+
(term, i) => formatEncryptedResult(encryptedValues[i], term.returnType)
|
|
2140
|
+
);
|
|
2162
2141
|
}
|
|
2163
2142
|
var BatchEncryptQueryOperation = class extends EncryptionOperation {
|
|
2164
2143
|
constructor(client, terms) {
|
|
@@ -2185,23 +2164,18 @@ var BatchEncryptQueryOperation = class extends EncryptionOperation {
|
|
|
2185
2164
|
log.emit();
|
|
2186
2165
|
return { data: [] };
|
|
2187
2166
|
}
|
|
2188
|
-
const { nullIndices, nonNullTerms } = filterNullTerms(this.terms);
|
|
2189
|
-
if (nonNullTerms.length === 0) {
|
|
2190
|
-
log.emit();
|
|
2191
|
-
return { data: this.terms.map(() => null) };
|
|
2192
|
-
}
|
|
2193
2167
|
const result = await withResult(
|
|
2194
2168
|
async () => {
|
|
2195
2169
|
if (!this.client) throw noClientError();
|
|
2196
2170
|
const { metadata } = this.getAuditData();
|
|
2197
|
-
const queries =
|
|
2198
|
-
(
|
|
2171
|
+
const queries = this.terms.map(
|
|
2172
|
+
(term) => buildQueryPayload(term)
|
|
2199
2173
|
);
|
|
2200
2174
|
const encrypted = await ffiEncryptQueryBulk(this.client, {
|
|
2201
2175
|
queries,
|
|
2202
2176
|
unverifiedContext: metadata
|
|
2203
2177
|
});
|
|
2204
|
-
return assembleResults(this.terms
|
|
2178
|
+
return assembleResults(this.terms, encrypted);
|
|
2205
2179
|
},
|
|
2206
2180
|
(error) => {
|
|
2207
2181
|
log.set({ errorCode: getErrorCode(error) ?? "unknown" });
|
|
@@ -2235,11 +2209,6 @@ var BatchEncryptQueryOperationWithLockContext = class extends EncryptionOperatio
|
|
|
2235
2209
|
log.emit();
|
|
2236
2210
|
return { data: [] };
|
|
2237
2211
|
}
|
|
2238
|
-
const { nullIndices, nonNullTerms } = filterNullTerms(this.terms);
|
|
2239
|
-
if (nonNullTerms.length === 0) {
|
|
2240
|
-
log.emit();
|
|
2241
|
-
return { data: this.terms.map(() => null) };
|
|
2242
|
-
}
|
|
2243
2212
|
const lockContextResult = await this.lockContext.getLockContext();
|
|
2244
2213
|
if (lockContextResult.failure) {
|
|
2245
2214
|
log.emit();
|
|
@@ -2250,15 +2219,15 @@ var BatchEncryptQueryOperationWithLockContext = class extends EncryptionOperatio
|
|
|
2250
2219
|
async () => {
|
|
2251
2220
|
if (!this.client) throw noClientError();
|
|
2252
2221
|
const { metadata } = this.getAuditData();
|
|
2253
|
-
const queries =
|
|
2254
|
-
(
|
|
2222
|
+
const queries = this.terms.map(
|
|
2223
|
+
(term) => buildQueryPayload(term, context)
|
|
2255
2224
|
);
|
|
2256
2225
|
const encrypted = await ffiEncryptQueryBulk(this.client, {
|
|
2257
2226
|
queries,
|
|
2258
2227
|
serviceToken: ctsToken,
|
|
2259
2228
|
unverifiedContext: metadata
|
|
2260
2229
|
});
|
|
2261
|
-
return assembleResults(this.terms
|
|
2230
|
+
return assembleResults(this.terms, encrypted);
|
|
2262
2231
|
},
|
|
2263
2232
|
(error) => {
|
|
2264
2233
|
log.set({ errorCode: getErrorCode(error) ?? "unknown" });
|
|
@@ -2280,42 +2249,25 @@ import {
|
|
|
2280
2249
|
decryptBulkFallible
|
|
2281
2250
|
} from "@cipherstash/protect-ffi";
|
|
2282
2251
|
var createDecryptPayloads = (encryptedPayloads, lockContext) => {
|
|
2283
|
-
return encryptedPayloads.map((
|
|
2252
|
+
return encryptedPayloads.map(({ id, data }) => ({
|
|
2284
2253
|
id,
|
|
2285
2254
|
ciphertext: data,
|
|
2286
|
-
originalIndex,
|
|
2287
2255
|
...lockContext && { lockContext }
|
|
2288
2256
|
}));
|
|
2289
2257
|
};
|
|
2290
|
-
var createNullResult = (encryptedPayloads) => {
|
|
2291
|
-
return encryptedPayloads.map(({ id }) => ({
|
|
2292
|
-
id,
|
|
2293
|
-
data: null
|
|
2294
|
-
}));
|
|
2295
|
-
};
|
|
2296
2258
|
var mapDecryptedDataToResult = (encryptedPayloads, decryptedData) => {
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
const decryptResult = decryptedData[decryptedIndex];
|
|
2304
|
-
if ("error" in decryptResult) {
|
|
2305
|
-
result[i] = {
|
|
2306
|
-
id: encryptedPayloads[i].id,
|
|
2307
|
-
error: decryptResult.error
|
|
2308
|
-
};
|
|
2309
|
-
} else {
|
|
2310
|
-
result[i] = {
|
|
2311
|
-
id: encryptedPayloads[i].id,
|
|
2312
|
-
data: decryptResult.data
|
|
2313
|
-
};
|
|
2314
|
-
}
|
|
2315
|
-
decryptedIndex++;
|
|
2259
|
+
return decryptedData.map((decryptResult, i) => {
|
|
2260
|
+
if ("error" in decryptResult) {
|
|
2261
|
+
return {
|
|
2262
|
+
id: encryptedPayloads[i].id,
|
|
2263
|
+
error: decryptResult.error
|
|
2264
|
+
};
|
|
2316
2265
|
}
|
|
2317
|
-
|
|
2318
|
-
|
|
2266
|
+
return {
|
|
2267
|
+
id: encryptedPayloads[i].id,
|
|
2268
|
+
data: decryptResult.data
|
|
2269
|
+
};
|
|
2270
|
+
});
|
|
2319
2271
|
};
|
|
2320
2272
|
var BulkDecryptOperation = class extends EncryptionOperation {
|
|
2321
2273
|
client;
|
|
@@ -2340,13 +2292,10 @@ var BulkDecryptOperation = class extends EncryptionOperation {
|
|
|
2340
2292
|
if (!this.client) throw noClientError();
|
|
2341
2293
|
if (!this.encryptedPayloads || this.encryptedPayloads.length === 0)
|
|
2342
2294
|
return [];
|
|
2343
|
-
const
|
|
2344
|
-
if (nonNullPayloads.length === 0) {
|
|
2345
|
-
return createNullResult(this.encryptedPayloads);
|
|
2346
|
-
}
|
|
2295
|
+
const payloads = createDecryptPayloads(this.encryptedPayloads);
|
|
2347
2296
|
const { metadata } = this.getAuditData();
|
|
2348
2297
|
const decryptedData = await decryptBulkFallible(this.client, {
|
|
2349
|
-
ciphertexts:
|
|
2298
|
+
ciphertexts: payloads,
|
|
2350
2299
|
unverifiedContext: metadata
|
|
2351
2300
|
});
|
|
2352
2301
|
return mapDecryptedDataToResult(this.encryptedPayloads, decryptedData);
|
|
@@ -2398,16 +2347,13 @@ var BulkDecryptOperationWithLockContext = class extends EncryptionOperation {
|
|
|
2398
2347
|
if (context.failure) {
|
|
2399
2348
|
throw new Error(`[encryption]: ${context.failure.message}`);
|
|
2400
2349
|
}
|
|
2401
|
-
const
|
|
2350
|
+
const payloads = createDecryptPayloads(
|
|
2402
2351
|
encryptedPayloads,
|
|
2403
2352
|
context.data.context
|
|
2404
2353
|
);
|
|
2405
|
-
if (nonNullPayloads.length === 0) {
|
|
2406
|
-
return createNullResult(encryptedPayloads);
|
|
2407
|
-
}
|
|
2408
2354
|
const { metadata } = this.getAuditData();
|
|
2409
2355
|
const decryptedData = await decryptBulkFallible(client, {
|
|
2410
|
-
ciphertexts:
|
|
2356
|
+
ciphertexts: payloads,
|
|
2411
2357
|
serviceToken: context.data.ctsToken,
|
|
2412
2358
|
unverifiedContext: metadata
|
|
2413
2359
|
});
|
|
@@ -3049,34 +2995,14 @@ var BulkDecryptModelsOperationWithLockContext = class extends EncryptionOperatio
|
|
|
3049
2995
|
import { withResult as withResult4 } from "@byteslice/result";
|
|
3050
2996
|
import { encryptBulk as encryptBulk2 } from "@cipherstash/protect-ffi";
|
|
3051
2997
|
var createEncryptPayloads = (plaintexts, column, table, lockContext) => {
|
|
3052
|
-
return plaintexts.map((
|
|
2998
|
+
return plaintexts.map(({ id, plaintext }) => ({
|
|
3053
2999
|
id,
|
|
3054
3000
|
plaintext,
|
|
3055
3001
|
column: column.getName(),
|
|
3056
3002
|
table: table.tableName,
|
|
3057
|
-
originalIndex,
|
|
3058
3003
|
...lockContext && { lockContext }
|
|
3059
3004
|
}));
|
|
3060
3005
|
};
|
|
3061
|
-
var createNullResult2 = (plaintexts) => {
|
|
3062
|
-
return plaintexts.map(({ id }) => ({ id, data: null }));
|
|
3063
|
-
};
|
|
3064
|
-
var mapEncryptedDataToResult = (plaintexts, encryptedData) => {
|
|
3065
|
-
const result = new Array(plaintexts.length);
|
|
3066
|
-
let encryptedIndex = 0;
|
|
3067
|
-
for (let i = 0; i < plaintexts.length; i++) {
|
|
3068
|
-
if (plaintexts[i].plaintext === null) {
|
|
3069
|
-
result[i] = { id: plaintexts[i].id, data: null };
|
|
3070
|
-
} else {
|
|
3071
|
-
result[i] = {
|
|
3072
|
-
id: plaintexts[i].id,
|
|
3073
|
-
data: encryptedData[encryptedIndex]
|
|
3074
|
-
};
|
|
3075
|
-
encryptedIndex++;
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
return result;
|
|
3079
|
-
};
|
|
3080
3006
|
var BulkEncryptOperation = class extends EncryptionOperation {
|
|
3081
3007
|
client;
|
|
3082
3008
|
plaintexts;
|
|
@@ -3109,20 +3035,20 @@ var BulkEncryptOperation = class extends EncryptionOperation {
|
|
|
3109
3035
|
if (!this.plaintexts || this.plaintexts.length === 0) {
|
|
3110
3036
|
return [];
|
|
3111
3037
|
}
|
|
3112
|
-
const
|
|
3038
|
+
const payloads = createEncryptPayloads(
|
|
3113
3039
|
this.plaintexts,
|
|
3114
3040
|
this.column,
|
|
3115
3041
|
this.table
|
|
3116
3042
|
);
|
|
3117
|
-
if (nonNullPayloads.length === 0) {
|
|
3118
|
-
return createNullResult2(this.plaintexts);
|
|
3119
|
-
}
|
|
3120
3043
|
const { metadata } = this.getAuditData();
|
|
3121
3044
|
const encryptedData = await encryptBulk2(this.client, {
|
|
3122
|
-
plaintexts:
|
|
3045
|
+
plaintexts: payloads,
|
|
3123
3046
|
unverifiedContext: metadata
|
|
3124
3047
|
});
|
|
3125
|
-
return
|
|
3048
|
+
return encryptedData.map((data, i) => ({
|
|
3049
|
+
id: this.plaintexts[i].id,
|
|
3050
|
+
data
|
|
3051
|
+
}));
|
|
3126
3052
|
},
|
|
3127
3053
|
(error) => {
|
|
3128
3054
|
log.set({ errorCode: getErrorCode(error) ?? "unknown" });
|
|
@@ -3179,22 +3105,22 @@ var BulkEncryptOperationWithLockContext = class extends EncryptionOperation {
|
|
|
3179
3105
|
if (context.failure) {
|
|
3180
3106
|
throw new Error(`[encryption]: ${context.failure.message}`);
|
|
3181
3107
|
}
|
|
3182
|
-
const
|
|
3108
|
+
const payloads = createEncryptPayloads(
|
|
3183
3109
|
plaintexts,
|
|
3184
3110
|
column,
|
|
3185
3111
|
table,
|
|
3186
3112
|
context.data.context
|
|
3187
3113
|
);
|
|
3188
|
-
if (nonNullPayloads.length === 0) {
|
|
3189
|
-
return createNullResult2(plaintexts);
|
|
3190
|
-
}
|
|
3191
3114
|
const { metadata } = this.getAuditData();
|
|
3192
3115
|
const encryptedData = await encryptBulk2(client, {
|
|
3193
|
-
plaintexts:
|
|
3116
|
+
plaintexts: payloads,
|
|
3194
3117
|
serviceToken: context.data.ctsToken,
|
|
3195
3118
|
unverifiedContext: metadata
|
|
3196
3119
|
});
|
|
3197
|
-
return
|
|
3120
|
+
return encryptedData.map((data, i) => ({
|
|
3121
|
+
id: plaintexts[i].id,
|
|
3122
|
+
data
|
|
3123
|
+
}));
|
|
3198
3124
|
},
|
|
3199
3125
|
(error) => {
|
|
3200
3126
|
log.set({ errorCode: getErrorCode(error) ?? "unknown" });
|
|
@@ -3346,9 +3272,6 @@ var DecryptOperation = class extends EncryptionOperation {
|
|
|
3346
3272
|
if (!this.client) {
|
|
3347
3273
|
throw noClientError();
|
|
3348
3274
|
}
|
|
3349
|
-
if (this.encryptedData === null) {
|
|
3350
|
-
return null;
|
|
3351
|
-
}
|
|
3352
3275
|
const { metadata } = this.getAuditData();
|
|
3353
3276
|
return await ffiDecrypt(this.client, {
|
|
3354
3277
|
ciphertext: this.encryptedData,
|
|
@@ -3399,9 +3322,6 @@ var DecryptOperationWithLockContext = class extends EncryptionOperation {
|
|
|
3399
3322
|
if (!client) {
|
|
3400
3323
|
throw noClientError();
|
|
3401
3324
|
}
|
|
3402
|
-
if (encryptedData === null) {
|
|
3403
|
-
return null;
|
|
3404
|
-
}
|
|
3405
3325
|
const { metadata } = this.getAuditData();
|
|
3406
3326
|
const context = await this.lockContext.getLockContext();
|
|
3407
3327
|
if (context.failure) {
|
|
@@ -3557,9 +3477,6 @@ var EncryptOperation = class extends EncryptionOperation {
|
|
|
3557
3477
|
if (!this.client) {
|
|
3558
3478
|
throw noClientError();
|
|
3559
3479
|
}
|
|
3560
|
-
if (this.plaintext === null) {
|
|
3561
|
-
return null;
|
|
3562
|
-
}
|
|
3563
3480
|
if (typeof this.plaintext === "number" && Number.isNaN(this.plaintext)) {
|
|
3564
3481
|
throw new Error("[encryption]: Cannot encrypt NaN value");
|
|
3565
3482
|
}
|
|
@@ -3621,9 +3538,6 @@ var EncryptOperationWithLockContext = class extends EncryptionOperation {
|
|
|
3621
3538
|
if (!client) {
|
|
3622
3539
|
throw noClientError();
|
|
3623
3540
|
}
|
|
3624
|
-
if (plaintext === null) {
|
|
3625
|
-
return null;
|
|
3626
|
-
}
|
|
3627
3541
|
const { metadata } = this.getAuditData();
|
|
3628
3542
|
const context = await this.lockContext.getLockContext();
|
|
3629
3543
|
if (context.failure) {
|
|
@@ -3789,10 +3703,6 @@ var EncryptQueryOperation = class extends EncryptionOperation {
|
|
|
3789
3703
|
queryType: this.opts.queryType,
|
|
3790
3704
|
lockContext: false
|
|
3791
3705
|
});
|
|
3792
|
-
if (this.plaintext === null || this.plaintext === void 0) {
|
|
3793
|
-
log.emit();
|
|
3794
|
-
return { data: null };
|
|
3795
|
-
}
|
|
3796
3706
|
const validationError = validateNumericValue(this.plaintext);
|
|
3797
3707
|
if (validationError?.failure) {
|
|
3798
3708
|
log.emit();
|
|
@@ -3856,10 +3766,6 @@ var EncryptQueryOperationWithLockContext = class extends EncryptionOperation {
|
|
|
3856
3766
|
queryType: this.opts.queryType,
|
|
3857
3767
|
lockContext: true
|
|
3858
3768
|
});
|
|
3859
|
-
if (this.plaintext === null || this.plaintext === void 0) {
|
|
3860
|
-
log.emit();
|
|
3861
|
-
return { data: null };
|
|
3862
|
-
}
|
|
3863
3769
|
const validationError = validateNumericValue(this.plaintext);
|
|
3864
3770
|
if (validationError?.failure) {
|
|
3865
3771
|
log.emit();
|
|
@@ -3964,7 +3870,7 @@ var EncryptionClient = class {
|
|
|
3964
3870
|
/**
|
|
3965
3871
|
* Encrypt a value - returns a promise which resolves to an encrypted value.
|
|
3966
3872
|
*
|
|
3967
|
-
* @param plaintext - The plaintext value to be encrypted.
|
|
3873
|
+
* @param plaintext - The plaintext value to be encrypted.
|
|
3968
3874
|
* @param opts - Options specifying the column (or nested field) and table for encryption. See {@link EncryptOptions}.
|
|
3969
3875
|
* @returns An EncryptOperation that can be awaited or chained with additional methods.
|
|
3970
3876
|
*
|
|
@@ -4265,7 +4171,7 @@ var EncryptionClient = class {
|
|
|
4265
4171
|
*
|
|
4266
4172
|
* Each value is encrypted with its own unique key via a single call to ZeroKMS.
|
|
4267
4173
|
* Values can include optional `id` fields for correlating results back to
|
|
4268
|
-
* your application data.
|
|
4174
|
+
* your application data.
|
|
4269
4175
|
*
|
|
4270
4176
|
* @param plaintexts - An array of objects with `plaintext` (and optional `id`) fields.
|
|
4271
4177
|
* @param opts - Options specifying the target column (or nested {@link encryptedField}) and table. See {@link EncryptOptions}.
|
|
@@ -4286,7 +4192,6 @@ var EncryptionClient = class {
|
|
|
4286
4192
|
* [
|
|
4287
4193
|
* { id: "u1", plaintext: "alice@example.com" },
|
|
4288
4194
|
* { id: "u2", plaintext: "bob@example.com" },
|
|
4289
|
-
* { id: "u3", plaintext: null },
|
|
4290
4195
|
* ],
|
|
4291
4196
|
* { column: users.email, table: users },
|
|
4292
4197
|
* )
|