@cipherstash/stack 0.16.0 → 0.19.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 +225 -0
- package/README.md +2 -2
- package/dist/{chunk-CY5B4LIF.js → chunk-36AA7IBJ.js} +303 -204
- package/dist/chunk-36AA7IBJ.js.map +1 -0
- package/dist/{chunk-MD6742R6.js → chunk-4AVL4VZD.js} +1 -1
- package/dist/chunk-4AVL4VZD.js.map +1 -0
- package/dist/{chunk-4RNBI3UH.js → chunk-BNO32ZMV.js} +1 -1
- package/dist/chunk-BNO32ZMV.js.map +1 -0
- package/dist/{chunk-6FD7OBGM.js → chunk-HQANMV7R.js} +3 -3
- package/dist/chunk-HQANMV7R.js.map +1 -0
- package/dist/chunk-IADZCZEA.js +23 -0
- package/dist/chunk-IADZCZEA.js.map +1 -0
- package/dist/chunk-IBSK6P33.js +209 -0
- package/dist/chunk-IBSK6P33.js.map +1 -0
- package/dist/chunk-JSG2AMDI.js +17 -0
- package/dist/chunk-JSG2AMDI.js.map +1 -0
- package/dist/chunk-MP3SSDNN.js +4439 -0
- package/dist/chunk-MP3SSDNN.js.map +1 -0
- package/dist/chunk-OFQ555AX.js +191 -0
- package/dist/chunk-OFQ555AX.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-U66S7VIF.js +435 -0
- package/dist/chunk-U66S7VIF.js.map +1 -0
- package/dist/{client-C_7TF8EL.d.cts → client-DSGHBN-g.d.cts} +209 -72
- package/dist/{client-BLbA6aFD.d.ts → client-DfCrlHXh.d.ts} +209 -72
- package/dist/client.cjs +4103 -43
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.js +3 -1
- package/dist/drizzle/index.cjs +4139 -77
- package/dist/drizzle/index.cjs.map +1 -1
- package/dist/drizzle/index.d.cts +33 -33
- package/dist/drizzle/index.d.ts +33 -33
- package/dist/drizzle/index.js +39 -33
- package/dist/drizzle/index.js.map +1 -1
- package/dist/dynamodb/index.cjs +31 -14
- 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 +16 -12
- package/dist/dynamodb/index.js.map +1 -1
- package/dist/encryption/index.cjs +4611 -257
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +3 -3
- package/dist/encryption/index.d.ts +3 -3
- package/dist/encryption/index.js +35 -7
- package/dist/encryption/v3.cjs +7791 -0
- package/dist/encryption/v3.cjs.map +1 -0
- package/dist/encryption/v3.d.cts +100 -0
- package/dist/encryption/v3.d.ts +100 -0
- package/dist/encryption/v3.js +161 -0
- package/dist/encryption/v3.js.map +1 -0
- package/dist/eql/v3/index.cjs +612 -0
- package/dist/eql/v3/index.cjs.map +1 -0
- package/dist/eql/v3/index.d.cts +71 -0
- package/dist/eql/v3/index.d.ts +71 -0
- package/dist/eql/v3/index.js +89 -0
- package/dist/eql/v3/index.js.map +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/identity/index.cjs +55 -35
- package/dist/identity/index.cjs.map +1 -1
- package/dist/identity/index.d.cts +54 -30
- package/dist/identity/index.d.ts +54 -30
- package/dist/identity/index.js +9 -177
- package/dist/identity/index.js.map +1 -1
- package/dist/index.cjs +4625 -273
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -7
- package/dist/index.d.ts +18 -7
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/schema/index.cjs +4108 -44
- 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 +3 -1
- package/dist/supabase/index.cjs +4500 -75
- package/dist/supabase/index.cjs.map +1 -1
- package/dist/supabase/index.d.cts +113 -34
- package/dist/supabase/index.d.ts +113 -34
- package/dist/supabase/index.js +350 -32
- package/dist/supabase/index.js.map +1 -1
- package/dist/table-CIH7jZ2h.d.ts +603 -0
- package/dist/table-DihEAlxG.d.cts +603 -0
- package/dist/{types-public-Dv-r6Ik0.d.ts → types-public-CpS5KjwX.d.cts} +209 -36
- package/dist/{types-public-Dv-r6Ik0.d.cts → types-public-CpS5KjwX.d.ts} +209 -36
- package/dist/types-public.cjs.map +1 -1
- package/dist/types-public.d.cts +2 -2
- package/dist/types-public.d.ts +2 -2
- package/dist/types-public.js +2 -1
- package/dist/wasm-inline.d.ts +1269 -0
- package/dist/wasm-inline.js +4594 -0
- package/dist/wasm-inline.js.map +1 -0
- package/package.json +63 -13
- 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-JDZ2QUUF.js +0 -381
- package/dist/chunk-JDZ2QUUF.js.map +0 -1
- package/dist/chunk-MD6742R6.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eql/v3/columns.ts"],"sourcesContent":["import type { ColumnSchema, MatchIndexOpts } from '@/schema'\nimport {\n type BuiltMatchIndexOpts,\n cloneMatchOpts,\n defaultMatchOpts,\n} from '@/schema/match-defaults'\n\n/**\n * The query capabilities a v3 concrete domain exposes. These are SDK-facing\n * semantic flags describing what kinds of query terms a column can produce —\n * NOT the raw EQL index keys. They are metadata only and never emitted by\n * `build()`.\n *\n * - `equality`: exact-match lookups (EQL `hm`, or comparison via `ob`).\n * - `orderAndRange`: comparison / range lookups (EQL `ob`).\n * - `freeTextSearch`: tokenised substring match (EQL `bf`).\n */\nexport type QueryCapabilities = Readonly<{\n equality: boolean\n orderAndRange: boolean\n freeTextSearch: boolean\n}>\n\n/** The plaintext (TypeScript) kind a v3 domain decrypts to. A subset of the\n * SDK `CastAs` enum, restricted to the scalar kinds v3 domains actually use. */\ntype PlaintextKind = 'string' | 'number' | 'boolean' | 'date' | 'timestamp'\n\n/**\n * The full, literal definition of a v3 domain. This is the LOAD-BEARING type:\n * the base column class carries a private field of this type so that every\n * concrete (otherwise-empty) subclass is discriminated by its literal\n * `eqlType`/`castAs`/`capabilities` — TypeScript empty subclasses are NOT\n * nominal, so without this a storage-only `boolean` column would be assignable to\n * a storage-only `date` column and plaintext inference would collapse.\n */\ntype V3DomainDefinition = Readonly<{\n eqlType: `eql_v3.${string}`\n castAs: PlaintextKind\n capabilities: QueryCapabilities\n}>\n\n/** Type-level mirror of {@link isQueryableCapabilities}: `false` for a\n * storage-only domain (all capability flags `false`), `true` otherwise. */\ntype QueryableFlag<D extends V3DomainDefinition> = D['capabilities'] extends {\n equality: false\n orderAndRange: false\n freeTextSearch: false\n}\n ? false\n : true\n\nconst STORAGE_ONLY = {\n equality: false,\n orderAndRange: false,\n freeTextSearch: false,\n} as const\n\nconst EQUALITY_ONLY = {\n equality: true,\n orderAndRange: false,\n freeTextSearch: false,\n} as const\n\nconst ORDER_AND_RANGE = {\n equality: true,\n orderAndRange: true,\n freeTextSearch: false,\n} as const\n\nconst MATCH_ONLY = {\n equality: false,\n orderAndRange: false,\n freeTextSearch: true,\n} as const\n\nconst TEXT_SEARCH = {\n equality: true,\n orderAndRange: true,\n freeTextSearch: true,\n} as const\n\n/**\n * The concrete EQL v3 domain name for a full-capability text column.\n * Recorded as metadata for future DDL / query-dialect increments; it is\n * intentionally absent from the emitted encrypt config.\n */\nexport const TEXT_SEARCH_EQL_TYPE = 'eql_v3.text_search'\n\n// Per-domain literal definitions. Each concrete column subclass is parameterised\n// by `typeof <CONST>`; the literal `eqlType`/`castAs`/`capabilities` on each is\n// what makes the otherwise-empty subclasses nominally distinct (see\n// V3DomainDefinition). Order mirrors eql-bindings `CATALOG` order.\n//\n// Exported for the `types` namespace factory (see ./types); they are internal\n// building blocks and are intentionally NOT re-exported from the public barrel.\nexport const INTEGER = {\n eqlType: 'eql_v3.integer',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const INTEGER_EQ = {\n eqlType: 'eql_v3.integer_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const INTEGER_ORD_ORE = {\n eqlType: 'eql_v3.integer_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const INTEGER_ORD = {\n eqlType: 'eql_v3.integer_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const SMALLINT = {\n eqlType: 'eql_v3.smallint',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const SMALLINT_EQ = {\n eqlType: 'eql_v3.smallint_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const SMALLINT_ORD_ORE = {\n eqlType: 'eql_v3.smallint_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const SMALLINT_ORD = {\n eqlType: 'eql_v3.smallint_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\n// NOTE: bigint (int8) domains are intentionally NOT defined yet. The native\n// protect-ffi build cannot round-trip a 64-bit int losslessly: a JS `bigint`\n// fails JSON serialization, and a `string` is rejected for a `big_int` column\n// (\"Cannot convert String to BigInt\"), while `number` loses precision above\n// 2^53. Re-add BIGINT/BIGINT_EQ/BIGINT_ORD_ORE/BIGINT_ORD and their builders once the\n// FFI accepts a lossless bigint on input and returns it on decrypt.\n\nexport const DATE = {\n eqlType: 'eql_v3.date',\n castAs: 'date',\n capabilities: STORAGE_ONLY,\n} as const\nexport const DATE_EQ = {\n eqlType: 'eql_v3.date_eq',\n castAs: 'date',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const DATE_ORD_ORE = {\n eqlType: 'eql_v3.date_ord_ore',\n castAs: 'date',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const DATE_ORD = {\n eqlType: 'eql_v3.date_ord',\n castAs: 'date',\n capabilities: ORDER_AND_RANGE,\n} as const\n\n// Timestamp domains cast as 'timestamp' (not 'date') so decrypt preserves the\n// time-of-day component — the FFI's 'date' variant truncates to midnight.\n// Both kinds decrypt to a JS `Date`.\nexport const TIMESTAMP = {\n eqlType: 'eql_v3.timestamp',\n castAs: 'timestamp',\n capabilities: STORAGE_ONLY,\n} as const\nexport const TIMESTAMP_EQ = {\n eqlType: 'eql_v3.timestamp_eq',\n castAs: 'timestamp',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const TIMESTAMP_ORD_ORE = {\n eqlType: 'eql_v3.timestamp_ord_ore',\n castAs: 'timestamp',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const TIMESTAMP_ORD = {\n eqlType: 'eql_v3.timestamp_ord',\n castAs: 'timestamp',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const NUMERIC = {\n eqlType: 'eql_v3.numeric',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const NUMERIC_EQ = {\n eqlType: 'eql_v3.numeric_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const NUMERIC_ORD_ORE = {\n eqlType: 'eql_v3.numeric_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const NUMERIC_ORD = {\n eqlType: 'eql_v3.numeric_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const TEXT = {\n eqlType: 'eql_v3.text',\n castAs: 'string',\n capabilities: STORAGE_ONLY,\n} as const\nexport const TEXT_EQ = {\n eqlType: 'eql_v3.text_eq',\n castAs: 'string',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const TEXT_MATCH = {\n eqlType: 'eql_v3.text_match',\n castAs: 'string',\n capabilities: MATCH_ONLY,\n} as const\nexport const TEXT_ORD_ORE = {\n eqlType: 'eql_v3.text_ord_ore',\n castAs: 'string',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const TEXT_ORD = {\n eqlType: 'eql_v3.text_ord',\n castAs: 'string',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const BOOLEAN = {\n eqlType: 'eql_v3.boolean',\n castAs: 'boolean',\n capabilities: STORAGE_ONLY,\n} as const\n\nexport const REAL = {\n eqlType: 'eql_v3.real',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const REAL_EQ = {\n eqlType: 'eql_v3.real_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const REAL_ORD_ORE = {\n eqlType: 'eql_v3.real_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const REAL_ORD = {\n eqlType: 'eql_v3.real_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const DOUBLE = {\n eqlType: 'eql_v3.double',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const DOUBLE_EQ = {\n eqlType: 'eql_v3.double_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const DOUBLE_ORD_ORE = {\n eqlType: 'eql_v3.double_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const DOUBLE_ORD = {\n eqlType: 'eql_v3.double_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\n/**\n * Translate a domain's semantic {@link QueryCapabilities} (plus its plaintext\n * `castAs`, which decides how equality is answered) into the concrete EQL index\n * block emitted by `build()`.\n *\n * - `unique` (the `hm` HMAC index) whenever equality is answered via HMAC:\n * equality-only domains of ANY type, AND text order domains. Text equality is\n * HMAC-based — the `eql_v3.text_ord` / `eql_v3.text_ord_ore` SQL domains\n * REQUIRE `hm` in the stored ciphertext (their `eql_v3.eq_term` extracts it).\n * - `ore` for any order/range domain (the `ob` term). For numeric/date order\n * domains `ob` also answers equality (via the SQL `=` operator), so those emit\n * `ore` ONLY — no `hm`. Text order domains emit BOTH `unique` and `ore`.\n * - `match` (the `bf` bloom-filter index) for free-text search, deep-cloned from\n * the per-call defaults so no nested object is ever shared across columns.\n */\nfunction indexesForCapabilities(\n capabilities: QueryCapabilities,\n castAs: PlaintextKind,\n): ColumnSchema['indexes'] {\n const indexes: ColumnSchema['indexes'] = {}\n\n // Text equality is always HMAC-based, so a text order domain (`string` +\n // order/range) still needs `unique`; numeric/date order domains answer\n // equality via `ob` and must NOT emit `unique`.\n if (\n capabilities.equality &&\n (!capabilities.orderAndRange || castAs === 'string')\n ) {\n indexes.unique = { token_filters: [] }\n }\n\n if (capabilities.orderAndRange) {\n indexes.ore = {}\n }\n\n if (capabilities.freeTextSearch) {\n // The factory returns fresh, unaliased nested objects per call, so no\n // column's emitted match block ever shares state with another's.\n indexes.match = defaultMatchOpts()\n }\n\n return indexes\n}\n\n/** Whether a domain's capabilities make it queryable at all (any flag set). */\nfunction isQueryableCapabilities(capabilities: QueryCapabilities): boolean {\n return (\n capabilities.equality ||\n capabilities.orderAndRange ||\n capabilities.freeTextSearch\n )\n}\n\n/**\n * Shared base for every v3 concrete domain column. Parameterised by the FULL\n * literal {@link V3DomainDefinition} (not by capabilities alone): the private\n * `definition` field carries the literal `eqlType`/`castAs`/`capabilities`, so\n * two otherwise-empty subclasses (e.g. `EncryptedBooleanColumn` and\n * `EncryptedDateColumn`, both storage-only) are NOT mutually assignable. This\n * nominality is what keeps plaintext inference precise.\n */\nexport class EncryptedV3Column<D extends V3DomainDefinition> {\n constructor(\n private readonly columnName: string,\n private readonly definition: D,\n ) {}\n\n getName(): string {\n return this.columnName\n }\n\n /** The concrete EQL v3 domain name. Metadata only; not emitted by `build()`. */\n getEqlType(): D['eqlType'] {\n return this.definition.eqlType\n }\n\n /** The semantic query capabilities this domain exposes. Metadata only. */\n getQueryCapabilities(): D['capabilities'] {\n return this.definition.capabilities\n }\n\n /** `true` when this domain can produce at least one kind of query term. */\n isQueryable(): QueryableFlag<D> {\n return isQueryableCapabilities(\n this.definition.capabilities,\n ) as QueryableFlag<D>\n }\n\n /** Emit the encrypt-config column: `cast_as` plus capability-derived indexes. */\n build(): ColumnSchema {\n return {\n cast_as: this.definition.castAs,\n indexes: indexesForCapabilities(\n this.definition.capabilities,\n this.definition.castAs,\n ),\n }\n }\n}\n\nconst TEXT_SEARCH_DOMAIN = {\n eqlType: TEXT_SEARCH_EQL_TYPE,\n castAs: 'string',\n capabilities: TEXT_SEARCH,\n} as const\n\n/**\n * Builder for an `eql_v3.text_search` column.\n *\n * The concrete type inherently enables equality + order/range + free-text\n * match — there are no capability-enabling methods. `.freeTextSearch(opts?)`\n * tunes the match index only.\n *\n * NOTE — querying: a `text_search` column emits all three indexes (`unique`,\n * `ore`, `match`), and the shared index-inference picks them by fixed priority\n * `unique > match > ore`. So `encryptQuery(value, { column, table })` with NO\n * explicit `queryType` builds an EQUALITY term (via `unique`), NOT a free-text\n * match — a substring like `'joh'` then matches nothing. To run a free-text\n * match query you MUST pass `queryType: 'freeTextSearch'`:\n *\n * ```typescript\n * // equality (default): exact value only\n * client.encryptQuery('john@example.com', { column: users.email, table: users })\n * // free-text match: substring/token search\n * client.encryptQuery('joh', { column: users.email, table: users, queryType: 'freeTextSearch' })\n * ```\n */\nexport class EncryptedTextSearchColumn extends EncryptedV3Column<\n typeof TEXT_SEARCH_DOMAIN\n> {\n private matchOpts: BuiltMatchIndexOpts\n\n constructor(columnName: string) {\n super(columnName, TEXT_SEARCH_DOMAIN)\n this.matchOpts = defaultMatchOpts()\n }\n\n /**\n * Tune the match index. Each provided key replaces its default; omitted\n * keys keep the default. This NEVER enables a capability — match is always\n * on for this type. Merge semantics mirror v2's `opts?.x ?? default`.\n */\n freeTextSearch(opts?: MatchIndexOpts): this {\n // A fresh defaults object per call supplies the `?? ` fallbacks, so no\n // nested default object is ever shared into `this.matchOpts` by reference.\n const defaults = defaultMatchOpts()\n // Clone-on-write: deep-copy the nested tokenizer / token_filters when\n // storing them so a caller mutating their own opts object between\n // freeTextSearch(opts) and build() cannot leak into the emitted config.\n this.matchOpts = cloneMatchOpts({\n tokenizer: opts?.tokenizer ?? defaults.tokenizer,\n token_filters: opts?.token_filters ?? defaults.token_filters,\n k: opts?.k ?? defaults.k,\n m: opts?.m ?? defaults.m,\n include_original: opts?.include_original ?? defaults.include_original,\n })\n return this\n }\n\n /** Emit the encrypt-config column. Byte-identical to a v2 equality+order+match column. */\n override build(): ColumnSchema {\n // Deep-clone the match block so the returned config NEVER aliases this\n // builder's internal `matchOpts` (or any caller-supplied opts merged into\n // it). A caller mutating the returned object cannot corrupt this builder's\n // state or another column's defaults.\n return {\n cast_as: 'string',\n indexes: {\n unique: { token_filters: [] },\n ore: {},\n match: cloneMatchOpts(this.matchOpts),\n },\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Concrete domain columns\n//\n// Every concrete class is an empty subclass parameterised by its literal domain\n// definition (see EncryptedV3Column). The `types` namespace (see ./types)\n// constructs these with the SAME literal constant so the instance's private\n// `definition` field carries full literal type data — that is what keeps\n// distinct domains nominally incompatible.\n// ---------------------------------------------------------------------------\n\n// integer\nexport class EncryptedIntegerColumn extends EncryptedV3Column<typeof INTEGER> {}\nexport class EncryptedIntegerEqColumn extends EncryptedV3Column<\n typeof INTEGER_EQ\n> {}\nexport class EncryptedIntegerOrdOreColumn extends EncryptedV3Column<\n typeof INTEGER_ORD_ORE\n> {}\nexport class EncryptedIntegerOrdColumn extends EncryptedV3Column<\n typeof INTEGER_ORD\n> {}\n\n// smallint\nexport class EncryptedSmallintColumn extends EncryptedV3Column<\n typeof SMALLINT\n> {}\nexport class EncryptedSmallintEqColumn extends EncryptedV3Column<\n typeof SMALLINT_EQ\n> {}\nexport class EncryptedSmallintOrdOreColumn extends EncryptedV3Column<\n typeof SMALLINT_ORD_ORE\n> {}\nexport class EncryptedSmallintOrdColumn extends EncryptedV3Column<\n typeof SMALLINT_ORD\n> {}\n\n// bigint (int8) domain builders are intentionally omitted pending FFI support\n// for lossless bigint round-tripping — see the note by the INTEGER/DATE domain\n// definitions above.\n\n// date\nexport class EncryptedDateColumn extends EncryptedV3Column<typeof DATE> {}\nexport class EncryptedDateEqColumn extends EncryptedV3Column<typeof DATE_EQ> {}\nexport class EncryptedDateOrdOreColumn extends EncryptedV3Column<\n typeof DATE_ORD_ORE\n> {}\nexport class EncryptedDateOrdColumn extends EncryptedV3Column<\n typeof DATE_ORD\n> {}\n\n// timestamp\nexport class EncryptedTimestampColumn extends EncryptedV3Column<\n typeof TIMESTAMP\n> {}\nexport class EncryptedTimestampEqColumn extends EncryptedV3Column<\n typeof TIMESTAMP_EQ\n> {}\nexport class EncryptedTimestampOrdOreColumn extends EncryptedV3Column<\n typeof TIMESTAMP_ORD_ORE\n> {}\nexport class EncryptedTimestampOrdColumn extends EncryptedV3Column<\n typeof TIMESTAMP_ORD\n> {}\n\n// numeric\nexport class EncryptedNumericColumn extends EncryptedV3Column<typeof NUMERIC> {}\nexport class EncryptedNumericEqColumn extends EncryptedV3Column<\n typeof NUMERIC_EQ\n> {}\nexport class EncryptedNumericOrdOreColumn extends EncryptedV3Column<\n typeof NUMERIC_ORD_ORE\n> {}\nexport class EncryptedNumericOrdColumn extends EncryptedV3Column<\n typeof NUMERIC_ORD\n> {}\n\n// text (text_search is defined above with its match-tuning override)\nexport class EncryptedTextColumn extends EncryptedV3Column<typeof TEXT> {}\nexport class EncryptedTextEqColumn extends EncryptedV3Column<typeof TEXT_EQ> {}\nexport class EncryptedTextMatchColumn extends EncryptedV3Column<\n typeof TEXT_MATCH\n> {}\nexport class EncryptedTextOrdOreColumn extends EncryptedV3Column<\n typeof TEXT_ORD_ORE\n> {}\nexport class EncryptedTextOrdColumn extends EncryptedV3Column<\n typeof TEXT_ORD\n> {}\n\n// boolean\nexport class EncryptedBooleanColumn extends EncryptedV3Column<typeof BOOLEAN> {}\n\n// real\nexport class EncryptedRealColumn extends EncryptedV3Column<typeof REAL> {}\nexport class EncryptedRealEqColumn extends EncryptedV3Column<typeof REAL_EQ> {}\nexport class EncryptedRealOrdOreColumn extends EncryptedV3Column<\n typeof REAL_ORD_ORE\n> {}\nexport class EncryptedRealOrdColumn extends EncryptedV3Column<\n typeof REAL_ORD\n> {}\n\n// double\nexport class EncryptedDoubleColumn extends EncryptedV3Column<typeof DOUBLE> {}\nexport class EncryptedDoubleEqColumn extends EncryptedV3Column<\n typeof DOUBLE_EQ\n> {}\nexport class EncryptedDoubleOrdOreColumn extends EncryptedV3Column<\n typeof DOUBLE_ORD_ORE\n> {}\nexport class EncryptedDoubleOrdColumn extends EncryptedV3Column<\n typeof DOUBLE_ORD\n> {}\n\n/**\n * Union of every v3 concrete column type. Used as the value type for v3 table\n * columns so a table may mix any generated domains.\n */\nexport type AnyEncryptedV3Column =\n | EncryptedIntegerColumn\n | EncryptedIntegerEqColumn\n | EncryptedIntegerOrdOreColumn\n | EncryptedIntegerOrdColumn\n | EncryptedSmallintColumn\n | EncryptedSmallintEqColumn\n | EncryptedSmallintOrdOreColumn\n | EncryptedSmallintOrdColumn\n | EncryptedDateColumn\n | EncryptedDateEqColumn\n | EncryptedDateOrdOreColumn\n | EncryptedDateOrdColumn\n | EncryptedTimestampColumn\n | EncryptedTimestampEqColumn\n | EncryptedTimestampOrdOreColumn\n | EncryptedTimestampOrdColumn\n | EncryptedNumericColumn\n | EncryptedNumericEqColumn\n | EncryptedNumericOrdOreColumn\n | EncryptedNumericOrdColumn\n | EncryptedTextColumn\n | EncryptedTextEqColumn\n | EncryptedTextMatchColumn\n | EncryptedTextOrdOreColumn\n | EncryptedTextOrdColumn\n | EncryptedTextSearchColumn\n | EncryptedBooleanColumn\n | EncryptedRealColumn\n | EncryptedRealEqColumn\n | EncryptedRealOrdOreColumn\n | EncryptedRealOrdColumn\n | EncryptedDoubleColumn\n | EncryptedDoubleEqColumn\n | EncryptedDoubleOrdOreColumn\n | EncryptedDoubleOrdColumn\n\n/**\n * Shape of v3 table columns: every value is a v3 concrete column builder.\n * (Nested fields are deferred to later increments.)\n */\nexport type EncryptedV3TableColumn = {\n [key: string]: AnyEncryptedV3Column\n}\n\n/** Map a domain's {@link PlaintextKind} to its TypeScript plaintext type. */\ntype PlaintextFromKind<K extends PlaintextKind> = K extends 'string'\n ? string\n : K extends 'number'\n ? number\n : K extends 'boolean'\n ? boolean\n : K extends 'date' | 'timestamp'\n ? Date\n : never\n\n/**\n * The plaintext type for a single v3 column, read from the literal domain\n * definition carried on the base class's private field. This is stable across\n * empty subclasses that share the same base generic — a subclass-name\n * conditional would collapse because those subclasses are structurally\n * assignable to one another.\n */\nexport type PlaintextForColumn<C> =\n C extends EncryptedV3Column<infer D> ? PlaintextFromKind<D['castAs']> : never\n\n/**\n * The user-facing `queryType` names a v3 column supports, derived 1:1 from its\n * capability flags. Resolves to `never` for a storage-only column (all flags\n * `false`) and for any non-v3 value. The names mirror the {@link QueryCapabilities}\n * keys and the first three {@link import('@/types').QueryTypeName} members.\n */\nexport type QueryTypesForColumn<C> =\n C extends EncryptedV3Column<infer D>\n ?\n | (D['capabilities']['equality'] extends true ? 'equality' : never)\n | (D['capabilities']['orderAndRange'] extends true\n ? 'orderAndRange'\n : never)\n | (D['capabilities']['freeTextSearch'] extends true\n ? 'freeTextSearch'\n : never)\n : never\n\n/**\n * The concrete EQL v3 type string for a single column, read from the literal\n * domain definition carried on the base class's private field (mirrors\n * {@link PlaintextForColumn}). Distributes over a union of columns, so\n * `EqlTypeForColumn<AnyEncryptedV3Column>` yields the union of every domain's\n * `eqlType` — the canonical, source-of-truth key set for a type-driven test\n * matrix keyed by domain.\n */\nexport type EqlTypeForColumn<C> =\n C extends EncryptedV3Column<infer D> ? D['eqlType'] : never\n"],"mappings":";;;;;;AAmDA,IAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,eAAe;AAAA,EACf,gBAAgB;AAClB;AAEA,IAAM,gBAAgB;AAAA,EACpB,UAAU;AAAA,EACV,eAAe;AAAA,EACf,gBAAgB;AAClB;AAEA,IAAM,kBAAkB;AAAA,EACtB,UAAU;AAAA,EACV,eAAe;AAAA,EACf,gBAAgB;AAClB;AAEA,IAAM,aAAa;AAAA,EACjB,UAAU;AAAA,EACV,eAAe;AAAA,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AAuC,kBAE5C;AAAC;AACI,IAAM,6BAAN,cAAyC,kBAE9C;AAAC;AACI,IAAM,iCAAN,cAA6C,kBAElD;AAAC;AACI,IAAM,8BAAN,cAA0C,kBAE/C;AAAC;AAGI,IAAM,yBAAN,cAAqC,kBAAkC;AAAC;AACxE,IAAM,2BAAN,cAAuC,kBAE5C;AAAC;AACI,IAAM,+BAAN,cAA2C,kBAEhD;AAAC;AACI,IAAM,4BAAN,cAAwC,kBAE7C;AAAC;AAGI,IAAM,sBAAN,cAAkC,kBAA+B;AAAC;AAClE,IAAM,wBAAN,cAAoC,kBAAkC;AAAC;AACvE,IAAM,2BAAN,cAAuC,kBAE5C;AAAC;AACI,IAAM,4BAAN,cAAwC,kBAE7C;AAAC;AACI,IAAM,yBAAN,cAAqC,kBAE1C;AAAC;AAGI,IAAM,yBAAN,cAAqC,kBAAkC;AAAC;AAGxE,IAAM,sBAAN,cAAkC,kBAA+B;AAAC;AAClE,IAAM,wBAAN,cAAoC,kBAAkC;AAAC;AACvE,IAAM,4BAAN,cAAwC,kBAE7C;AAAC;AACI,IAAM,yBAAN,cAAqC,kBAE1C;AAAC;AAGI,IAAM,wBAAN,cAAoC,kBAAiC;AAAC;AACtE,IAAM,0BAAN,cAAsC,kBAE3C;AAAC;AACI,IAAM,8BAAN,cAA0C,kBAE/C;AAAC;AACI,IAAM,2BAAN,cAAuC,kBAE5C;AAAC;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { h as EncryptedQueryResult, i as Client, S as ScalarQueryTerm, B as BulkDecryptedData, j as BulkDecryptPayload, D as Decrypted, k as BulkEncryptedData, l as BulkEncryptPayload, m as EncryptOptions, f as EncryptedColumn, n as EncryptedField, c as EncryptedTable, d as EncryptedTableColumn, E as Encrypted, o as EncryptQueryOptions, Q as QueryTypeName, p as EncryptedReturnType, q as EncryptConfig, K as KeysetIdentifier, r as EncryptedFromSchema, s as EncryptionClientConfig } from './types-public-Dv-r6Ik0.cjs';
|
|
2
|
-
import { EncryptionError } from './errors/index.cjs';
|
|
3
1
|
import { Result } from '@byteslice/result';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { EncryptionError } from './errors/index.cjs';
|
|
3
|
+
import { n as EncryptedQueryResult, o as Client, S as ScalarQueryTerm, p as BulkDecryptedData, c as BulkDecryptPayload, D as Decrypted, q as BulkEncryptedData, B as BulkEncryptPayload, b as EncryptOptions, r as BuildableColumn, s as BuildableTable, a as Encrypted, P as Plaintext, t as EncryptQueryOptions, u as BuildableQueryColumn, Q as QueryTypeName, E as EncryptedReturnType, j as EncryptConfig, K as KeysetIdentifier, v as EncryptedFromBuildableTable, w as EncryptionClientConfig } from './types-public-CpS5KjwX.cjs';
|
|
4
|
+
import { LockContextInput } from './identity/index.cjs';
|
|
5
|
+
import { JsPlaintext, AuthStrategy } from '@cipherstash/protect-ffi';
|
|
6
6
|
|
|
7
7
|
type AuditConfig = {
|
|
8
8
|
metadata?: Record<string, unknown>;
|
|
@@ -32,24 +32,18 @@ declare abstract class EncryptionOperation<T> {
|
|
|
32
32
|
then<TResult1 = Result<T, EncryptionError>, TResult2 = never>(onfulfilled?: ((value: Result<T, EncryptionError>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* @internal Use {@link EncryptionClient.encryptQuery} with array input instead.
|
|
37
|
-
*/
|
|
38
35
|
declare class BatchEncryptQueryOperation extends EncryptionOperation<EncryptedQueryResult[]> {
|
|
39
36
|
private client;
|
|
40
37
|
private terms;
|
|
41
38
|
constructor(client: Client, terms: readonly ScalarQueryTerm[]);
|
|
42
|
-
withLockContext(lockContext:
|
|
39
|
+
withLockContext(lockContext: LockContextInput): BatchEncryptQueryOperationWithLockContext;
|
|
43
40
|
execute(): Promise<Result<EncryptedQueryResult[], EncryptionError>>;
|
|
44
41
|
}
|
|
45
|
-
/**
|
|
46
|
-
* @internal Use {@link EncryptionClient.encryptQuery} with array input and `.withLockContext()` instead.
|
|
47
|
-
*/
|
|
48
42
|
declare class BatchEncryptQueryOperationWithLockContext extends EncryptionOperation<EncryptedQueryResult[]> {
|
|
49
43
|
private client;
|
|
50
44
|
private terms;
|
|
51
45
|
private lockContext;
|
|
52
|
-
constructor(client: Client, terms: readonly ScalarQueryTerm[], lockContext:
|
|
46
|
+
constructor(client: Client, terms: readonly ScalarQueryTerm[], lockContext: LockContextInput, auditMetadata?: Record<string, unknown>);
|
|
53
47
|
execute(): Promise<Result<EncryptedQueryResult[], EncryptionError>>;
|
|
54
48
|
}
|
|
55
49
|
|
|
@@ -57,7 +51,7 @@ declare class BulkDecryptOperation extends EncryptionOperation<BulkDecryptedData
|
|
|
57
51
|
private client;
|
|
58
52
|
private encryptedPayloads;
|
|
59
53
|
constructor(client: Client, encryptedPayloads: BulkDecryptPayload);
|
|
60
|
-
withLockContext(lockContext:
|
|
54
|
+
withLockContext(lockContext: LockContextInput): BulkDecryptOperationWithLockContext;
|
|
61
55
|
execute(): Promise<Result<BulkDecryptedData, EncryptionError>>;
|
|
62
56
|
getOperation(): {
|
|
63
57
|
client: Client;
|
|
@@ -67,7 +61,7 @@ declare class BulkDecryptOperation extends EncryptionOperation<BulkDecryptedData
|
|
|
67
61
|
declare class BulkDecryptOperationWithLockContext extends EncryptionOperation<BulkDecryptedData> {
|
|
68
62
|
private operation;
|
|
69
63
|
private lockContext;
|
|
70
|
-
constructor(operation: BulkDecryptOperation, lockContext:
|
|
64
|
+
constructor(operation: BulkDecryptOperation, lockContext: LockContextInput);
|
|
71
65
|
execute(): Promise<Result<BulkDecryptedData, EncryptionError>>;
|
|
72
66
|
}
|
|
73
67
|
|
|
@@ -75,7 +69,7 @@ declare class BulkDecryptModelsOperation<T extends Record<string, unknown>> exte
|
|
|
75
69
|
private client;
|
|
76
70
|
private models;
|
|
77
71
|
constructor(client: Client, models: T[]);
|
|
78
|
-
withLockContext(lockContext:
|
|
72
|
+
withLockContext(lockContext: LockContextInput): BulkDecryptModelsOperationWithLockContext<T>;
|
|
79
73
|
execute(): Promise<Result<Decrypted<T>[], EncryptionError>>;
|
|
80
74
|
getOperation(): {
|
|
81
75
|
client: Client;
|
|
@@ -85,7 +79,7 @@ declare class BulkDecryptModelsOperation<T extends Record<string, unknown>> exte
|
|
|
85
79
|
declare class BulkDecryptModelsOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<Decrypted<T>[]> {
|
|
86
80
|
private operation;
|
|
87
81
|
private lockContext;
|
|
88
|
-
constructor(operation: BulkDecryptModelsOperation<T>, lockContext:
|
|
82
|
+
constructor(operation: BulkDecryptModelsOperation<T>, lockContext: LockContextInput);
|
|
89
83
|
execute(): Promise<Result<Decrypted<T>[], EncryptionError>>;
|
|
90
84
|
}
|
|
91
85
|
|
|
@@ -95,19 +89,19 @@ declare class BulkEncryptOperation extends EncryptionOperation<BulkEncryptedData
|
|
|
95
89
|
private column;
|
|
96
90
|
private table;
|
|
97
91
|
constructor(client: Client, plaintexts: BulkEncryptPayload, opts: EncryptOptions);
|
|
98
|
-
withLockContext(lockContext:
|
|
92
|
+
withLockContext(lockContext: LockContextInput): BulkEncryptOperationWithLockContext;
|
|
99
93
|
execute(): Promise<Result<BulkEncryptedData, EncryptionError>>;
|
|
100
94
|
getOperation(): {
|
|
101
95
|
client: Client;
|
|
102
96
|
plaintexts: BulkEncryptPayload;
|
|
103
|
-
column:
|
|
104
|
-
table:
|
|
97
|
+
column: BuildableColumn;
|
|
98
|
+
table: BuildableTable;
|
|
105
99
|
};
|
|
106
100
|
}
|
|
107
101
|
declare class BulkEncryptOperationWithLockContext extends EncryptionOperation<BulkEncryptedData> {
|
|
108
102
|
private operation;
|
|
109
103
|
private lockContext;
|
|
110
|
-
constructor(operation: BulkEncryptOperation, lockContext:
|
|
104
|
+
constructor(operation: BulkEncryptOperation, lockContext: LockContextInput);
|
|
111
105
|
execute(): Promise<Result<BulkEncryptedData, EncryptionError>>;
|
|
112
106
|
}
|
|
113
107
|
|
|
@@ -115,19 +109,19 @@ declare class BulkEncryptModelsOperation<T extends Record<string, unknown>> exte
|
|
|
115
109
|
private client;
|
|
116
110
|
private models;
|
|
117
111
|
private table;
|
|
118
|
-
constructor(client: Client, models: Record<string, unknown>[], table:
|
|
119
|
-
withLockContext(lockContext:
|
|
112
|
+
constructor(client: Client, models: Record<string, unknown>[], table: BuildableTable);
|
|
113
|
+
withLockContext(lockContext: LockContextInput): BulkEncryptModelsOperationWithLockContext<T>;
|
|
120
114
|
execute(): Promise<Result<T[], EncryptionError>>;
|
|
121
115
|
getOperation(): {
|
|
122
116
|
client: Client;
|
|
123
117
|
models: Record<string, unknown>[];
|
|
124
|
-
table:
|
|
118
|
+
table: BuildableTable;
|
|
125
119
|
};
|
|
126
120
|
}
|
|
127
121
|
declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T[]> {
|
|
128
122
|
private operation;
|
|
129
123
|
private lockContext;
|
|
130
|
-
constructor(operation: BulkEncryptModelsOperation<T>, lockContext:
|
|
124
|
+
constructor(operation: BulkEncryptModelsOperation<T>, lockContext: LockContextInput);
|
|
131
125
|
execute(): Promise<Result<T[], EncryptionError>>;
|
|
132
126
|
}
|
|
133
127
|
|
|
@@ -138,19 +132,19 @@ declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string,
|
|
|
138
132
|
declare class DecryptOperation extends EncryptionOperation<JsPlaintext> {
|
|
139
133
|
private client;
|
|
140
134
|
private encryptedData;
|
|
141
|
-
constructor(client: Client, encryptedData: Encrypted);
|
|
142
|
-
withLockContext(lockContext:
|
|
135
|
+
constructor(client: Client, encryptedData: Encrypted | null);
|
|
136
|
+
withLockContext(lockContext: LockContextInput): DecryptOperationWithLockContext;
|
|
143
137
|
execute(): Promise<Result<JsPlaintext, EncryptionError>>;
|
|
144
138
|
getOperation(): {
|
|
145
139
|
client: Client;
|
|
146
|
-
encryptedData: Encrypted;
|
|
140
|
+
encryptedData: Encrypted | null;
|
|
147
141
|
auditData?: Record<string, unknown>;
|
|
148
142
|
};
|
|
149
143
|
}
|
|
150
144
|
declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext> {
|
|
151
145
|
private operation;
|
|
152
146
|
private lockContext;
|
|
153
|
-
constructor(operation: DecryptOperation, lockContext:
|
|
147
|
+
constructor(operation: DecryptOperation, lockContext: LockContextInput);
|
|
154
148
|
execute(): Promise<Result<JsPlaintext, EncryptionError>>;
|
|
155
149
|
}
|
|
156
150
|
|
|
@@ -158,7 +152,7 @@ declare class DecryptModelOperation<T extends Record<string, unknown>> extends E
|
|
|
158
152
|
private client;
|
|
159
153
|
private model;
|
|
160
154
|
constructor(client: Client, model: T);
|
|
161
|
-
withLockContext(lockContext:
|
|
155
|
+
withLockContext(lockContext: LockContextInput): DecryptModelOperationWithLockContext<T>;
|
|
162
156
|
execute(): Promise<Result<Decrypted<T>, EncryptionError>>;
|
|
163
157
|
getOperation(): {
|
|
164
158
|
client: Client;
|
|
@@ -168,7 +162,7 @@ declare class DecryptModelOperation<T extends Record<string, unknown>> extends E
|
|
|
168
162
|
declare class DecryptModelOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<Decrypted<T>> {
|
|
169
163
|
private operation;
|
|
170
164
|
private lockContext;
|
|
171
|
-
constructor(operation: DecryptModelOperation<T>, lockContext:
|
|
165
|
+
constructor(operation: DecryptModelOperation<T>, lockContext: LockContextInput);
|
|
172
166
|
execute(): Promise<Result<Decrypted<T>, EncryptionError>>;
|
|
173
167
|
}
|
|
174
168
|
|
|
@@ -177,20 +171,20 @@ declare class EncryptOperation extends EncryptionOperation<Encrypted> {
|
|
|
177
171
|
private plaintext;
|
|
178
172
|
private column;
|
|
179
173
|
private table;
|
|
180
|
-
constructor(client: Client, plaintext:
|
|
181
|
-
withLockContext(lockContext:
|
|
174
|
+
constructor(client: Client, plaintext: Plaintext | null, opts: EncryptOptions);
|
|
175
|
+
withLockContext(lockContext: LockContextInput): EncryptOperationWithLockContext;
|
|
182
176
|
execute(): Promise<Result<Encrypted, EncryptionError>>;
|
|
183
177
|
getOperation(): {
|
|
184
178
|
client: Client;
|
|
185
|
-
plaintext:
|
|
186
|
-
column:
|
|
187
|
-
table:
|
|
179
|
+
plaintext: Plaintext | null;
|
|
180
|
+
column: BuildableColumn;
|
|
181
|
+
table: BuildableTable;
|
|
188
182
|
};
|
|
189
183
|
}
|
|
190
184
|
declare class EncryptOperationWithLockContext extends EncryptionOperation<Encrypted> {
|
|
191
185
|
private operation;
|
|
192
186
|
private lockContext;
|
|
193
|
-
constructor(operation: EncryptOperation, lockContext:
|
|
187
|
+
constructor(operation: EncryptOperation, lockContext: LockContextInput);
|
|
194
188
|
execute(): Promise<Result<Encrypted, EncryptionError>>;
|
|
195
189
|
}
|
|
196
190
|
|
|
@@ -198,54 +192,69 @@ declare class EncryptModelOperation<T extends Record<string, unknown>> extends E
|
|
|
198
192
|
private client;
|
|
199
193
|
private model;
|
|
200
194
|
private table;
|
|
201
|
-
constructor(client: Client, model: Record<string, unknown>, table:
|
|
202
|
-
withLockContext(lockContext:
|
|
195
|
+
constructor(client: Client, model: Record<string, unknown>, table: BuildableTable);
|
|
196
|
+
withLockContext(lockContext: LockContextInput): EncryptModelOperationWithLockContext<T>;
|
|
203
197
|
execute(): Promise<Result<T, EncryptionError>>;
|
|
204
198
|
getOperation(): {
|
|
205
199
|
client: Client;
|
|
206
200
|
model: Record<string, unknown>;
|
|
207
|
-
table:
|
|
201
|
+
table: BuildableTable;
|
|
208
202
|
};
|
|
209
203
|
}
|
|
210
204
|
declare class EncryptModelOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T> {
|
|
211
205
|
private operation;
|
|
212
206
|
private lockContext;
|
|
213
|
-
constructor(operation: EncryptModelOperation<T>, lockContext:
|
|
207
|
+
constructor(operation: EncryptModelOperation<T>, lockContext: LockContextInput);
|
|
214
208
|
execute(): Promise<Result<T, EncryptionError>>;
|
|
215
209
|
}
|
|
216
210
|
|
|
217
|
-
/**
|
|
218
|
-
* @internal Use {@link EncryptionClient.encryptQuery} instead.
|
|
219
|
-
*/
|
|
220
211
|
declare class EncryptQueryOperation extends EncryptionOperation<EncryptedQueryResult> {
|
|
221
212
|
private client;
|
|
222
213
|
private plaintext;
|
|
223
214
|
private opts;
|
|
224
|
-
constructor(client: Client, plaintext:
|
|
225
|
-
withLockContext(lockContext:
|
|
215
|
+
constructor(client: Client, plaintext: Plaintext | null | undefined, opts: EncryptQueryOptions);
|
|
216
|
+
withLockContext(lockContext: LockContextInput): EncryptQueryOperationWithLockContext;
|
|
226
217
|
execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
|
|
227
218
|
getOperation(): {
|
|
228
|
-
column:
|
|
229
|
-
table:
|
|
219
|
+
column: BuildableQueryColumn;
|
|
220
|
+
table: BuildableTable;
|
|
230
221
|
queryType?: QueryTypeName;
|
|
231
222
|
returnType?: EncryptedReturnType;
|
|
232
223
|
client: Client;
|
|
233
|
-
plaintext:
|
|
224
|
+
plaintext: Plaintext | null | undefined;
|
|
234
225
|
};
|
|
235
226
|
}
|
|
236
|
-
/**
|
|
237
|
-
* @internal Use {@link EncryptionClient.encryptQuery} with `.withLockContext()` instead.
|
|
238
|
-
*/
|
|
239
227
|
declare class EncryptQueryOperationWithLockContext extends EncryptionOperation<EncryptedQueryResult> {
|
|
240
228
|
private client;
|
|
241
229
|
private plaintext;
|
|
242
230
|
private opts;
|
|
243
231
|
private lockContext;
|
|
244
|
-
constructor(client: Client, plaintext:
|
|
232
|
+
constructor(client: Client, plaintext: Plaintext | null | undefined, opts: EncryptQueryOptions, lockContext: LockContextInput, auditMetadata?: Record<string, unknown>);
|
|
245
233
|
execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
|
|
246
234
|
}
|
|
247
235
|
|
|
248
236
|
declare const noClientError: () => Error;
|
|
237
|
+
/**
|
|
238
|
+
* Resolve the EQL wire version for a client from its schema set.
|
|
239
|
+
*
|
|
240
|
+
* One FFI client emits exactly one wire format, so the whole schema set must
|
|
241
|
+
* agree. EQL v3 tables (from `@cipherstash/stack/v3`) are detected by their
|
|
242
|
+
* `buildColumnKeyMap()` marker — v2 tables don't have one:
|
|
243
|
+
*
|
|
244
|
+
* - every schema is v3 → `3`;
|
|
245
|
+
* - no schema is v3 → `undefined`, leaving the FFI's v2 default (and its
|
|
246
|
+
* byte-identical v2 output) untouched;
|
|
247
|
+
* - a mix of the two → throws: the v2 tables target `eql_v2_encrypted`
|
|
248
|
+
* columns and the v3 tables target `eql_v3` domains, so no single wire
|
|
249
|
+
* format serves both. Split them across two clients.
|
|
250
|
+
*
|
|
251
|
+
* An explicit `config.eqlVersion` bypasses detection (the wire format is
|
|
252
|
+
* then unambiguous — e.g. writing v2-wire from a v3 schema set during a
|
|
253
|
+
* migration), but a mixed schema set still throws.
|
|
254
|
+
*
|
|
255
|
+
* @internal exported for unit-test coverage of the detection matrix.
|
|
256
|
+
*/
|
|
257
|
+
declare function resolveEqlVersion(schemas: readonly BuildableTable[], explicit?: 2 | 3): 2 | 3 | undefined;
|
|
249
258
|
/** The EncryptionClient is the main entry point for interacting with the CipherStash Encryption library.
|
|
250
259
|
* It provides methods for encrypting and decrypting individual values, as well as models (objects) and bulk operations.
|
|
251
260
|
*
|
|
@@ -267,6 +276,8 @@ declare class EncryptionClient {
|
|
|
267
276
|
clientId?: string;
|
|
268
277
|
clientKey?: string;
|
|
269
278
|
keyset?: KeysetIdentifier;
|
|
279
|
+
authStrategy?: AuthStrategy;
|
|
280
|
+
eqlVersion?: 2 | 3;
|
|
270
281
|
}): Promise<Result<EncryptionClient, EncryptionError>>;
|
|
271
282
|
/**
|
|
272
283
|
* Encrypt a value - returns a promise which resolves to an encrypted value.
|
|
@@ -343,7 +354,7 @@ declare class EncryptionClient {
|
|
|
343
354
|
* @see {@link LockContext}
|
|
344
355
|
* @see {@link EncryptOperation}
|
|
345
356
|
*/
|
|
346
|
-
encrypt(plaintext:
|
|
357
|
+
encrypt(plaintext: Plaintext, opts: EncryptOptions): EncryptOperation;
|
|
347
358
|
/**
|
|
348
359
|
* Encrypt a query value - returns a promise which resolves to an encrypted query value.
|
|
349
360
|
*
|
|
@@ -397,7 +408,7 @@ declare class EncryptionClient {
|
|
|
397
408
|
* - String plaintext → `steVecSelector` (JSONPath queries like `'$.user.email'`)
|
|
398
409
|
* - Object/Array plaintext → `steVecTerm` (containment queries like `{ role: 'admin' }`)
|
|
399
410
|
*/
|
|
400
|
-
encryptQuery(plaintext:
|
|
411
|
+
encryptQuery(plaintext: Plaintext, opts: EncryptQueryOptions): EncryptQueryOperation;
|
|
401
412
|
/**
|
|
402
413
|
* Encrypt multiple values for use in queries (batch operation).
|
|
403
414
|
* @param terms - Array of query terms to encrypt
|
|
@@ -432,6 +443,13 @@ declare class EncryptionClient {
|
|
|
432
443
|
* .withLockContext(lockContext)
|
|
433
444
|
* ```
|
|
434
445
|
*
|
|
446
|
+
* @remarks
|
|
447
|
+
* The public input type rejects null, but at runtime `decrypt` will
|
|
448
|
+
* short-circuit and return null when given a null ciphertext
|
|
449
|
+
* (defense in depth for legacy / manually-NULLed DB rows reached via
|
|
450
|
+
* casts or dynamic field walking). The narrow return type holds for
|
|
451
|
+
* any caller that respects the input contract.
|
|
452
|
+
*
|
|
435
453
|
* @see {@link LockContext}
|
|
436
454
|
* @see {@link DecryptOperation}
|
|
437
455
|
*/
|
|
@@ -482,7 +500,7 @@ declare class EncryptionClient {
|
|
|
482
500
|
* }
|
|
483
501
|
* ```
|
|
484
502
|
*/
|
|
485
|
-
encryptModel<T extends Record<string, unknown>,
|
|
503
|
+
encryptModel<T extends Record<string, unknown>, Table extends BuildableTable>(input: T, table: Table): EncryptModelOperation<EncryptedFromBuildableTable<T, Table>>;
|
|
486
504
|
/**
|
|
487
505
|
* Decrypt a model (object) whose fields contain encrypted values.
|
|
488
506
|
*
|
|
@@ -557,7 +575,7 @@ declare class EncryptionClient {
|
|
|
557
575
|
* }
|
|
558
576
|
* ```
|
|
559
577
|
*/
|
|
560
|
-
bulkEncryptModels<T extends Record<string, unknown>,
|
|
578
|
+
bulkEncryptModels<T extends Record<string, unknown>, Table extends BuildableTable>(input: Array<T>, table: Table): BulkEncryptModelsOperation<EncryptedFromBuildableTable<T, Table>>;
|
|
561
579
|
/**
|
|
562
580
|
* Decrypt multiple models (objects) in a single bulk operation.
|
|
563
581
|
*
|
|
@@ -662,36 +680,155 @@ declare class EncryptionClient {
|
|
|
662
680
|
*/
|
|
663
681
|
getEncryptConfig(): EncryptConfig | undefined;
|
|
664
682
|
}
|
|
683
|
+
/**
|
|
684
|
+
* Reset the once-per-process deprecation-warning latch. Test-only hook so
|
|
685
|
+
* suites can assert the warning fires deterministically, independent of test
|
|
686
|
+
* ordering. Not re-exported from the package entry, so it stays off the public
|
|
687
|
+
* API surface.
|
|
688
|
+
* @internal
|
|
689
|
+
*/
|
|
690
|
+
declare function __resetStrategyDeprecationWarningForTests(): void;
|
|
665
691
|
/**
|
|
666
692
|
* Creates and initializes an Encryption client for encrypting and decrypting data with CipherStash.
|
|
667
693
|
*
|
|
668
694
|
* Provide at least one schema (from {@link encryptedTable}) so the client knows which tables and
|
|
669
|
-
* columns to use
|
|
670
|
-
* (`CS_WORKSPACE_CRN`, `CS_CLIENT_ID`, `CS_CLIENT_KEY`, `CS_CLIENT_ACCESS_KEY`).
|
|
671
|
-
*
|
|
672
|
-
* @param config - Initialization options. Must include `schemas`; optionally include `config` for
|
|
673
|
-
* workspace/keys. Logging is configured via the `STASH_STACK_LOG` environment variable
|
|
674
|
-
* (`debug | info | error`, default: `error`).
|
|
675
|
-
* @returns A Promise that resolves to an initialized {@link EncryptionClient} ready for
|
|
676
|
-
* {@link EncryptionClient.encrypt}, {@link EncryptionClient.decrypt}, and related operations.
|
|
695
|
+
* columns to use:
|
|
677
696
|
*
|
|
678
|
-
* @throws Throws if `schemas` is empty, or if a keyset `id` is supplied but is not a valid UUID.
|
|
679
|
-
* Also throws if {@link EncryptionClient.init} fails (e.g. invalid credentials or config).
|
|
680
|
-
*
|
|
681
|
-
* @example
|
|
682
697
|
* ```typescript
|
|
683
698
|
* import { Encryption, encryptedTable, encryptedColumn } from "@cipherstash/stack"
|
|
684
699
|
*
|
|
685
|
-
* const users = encryptedTable("users", {
|
|
686
|
-
* email: encryptedColumn("email"),
|
|
687
|
-
* })
|
|
700
|
+
* const users = encryptedTable("users", { email: encryptedColumn("email") })
|
|
688
701
|
* const client = await Encryption({ schemas: [users] })
|
|
689
702
|
* const result = await client.encrypt("alice@example.com", { column: users.email, table: users })
|
|
690
703
|
* ```
|
|
691
704
|
*
|
|
705
|
+
* ## Authentication
|
|
706
|
+
*
|
|
707
|
+
* The snippets in this section reuse the `users` schema from the example above, and
|
|
708
|
+
* `workspaceCrn` / `accessKey` stand in for your own workspace credentials (from the
|
|
709
|
+
* [dashboard](https://dashboard.cipherstash.com) or the `CS_*` variables below).
|
|
710
|
+
*
|
|
711
|
+
* By default the client uses the `auto` auth strategy. `auto` first looks for the `CS_*`
|
|
712
|
+
* environment variables (see below) and, if they are not set, falls back to the local **dev
|
|
713
|
+
* profile** on your machine. The dev profile also supplies the client key, so during local
|
|
714
|
+
* development you generally don't need to set any environment variables at all.
|
|
715
|
+
*
|
|
716
|
+
* ### Local development — create a dev profile
|
|
717
|
+
*
|
|
718
|
+
* Log in once to create the dev profile that `auto` picks up automatically:
|
|
719
|
+
*
|
|
720
|
+
* ```bash
|
|
721
|
+
* npx stash auth login
|
|
722
|
+
* ```
|
|
723
|
+
*
|
|
724
|
+
* ### Production / CI — environment variables
|
|
725
|
+
*
|
|
726
|
+
* In production and CI you typically authenticate with the four `CS_*` environment variables
|
|
727
|
+
* instead of a dev profile. Developers can obtain these values from the
|
|
728
|
+
* [CipherStash dashboard](https://dashboard.cipherstash.com):
|
|
729
|
+
*
|
|
730
|
+
* | Environment variable | Description |
|
|
731
|
+
* | ---------------------- | ------------------------------------------------------------------------------ |
|
|
732
|
+
* | `CS_WORKSPACE_CRN` | The workspace Cloud Resource Name (CRN) that identifies your workspace. |
|
|
733
|
+
* | `CS_CLIENT_ID` | The client identifier issued when you create an access key. |
|
|
734
|
+
* | `CS_CLIENT_KEY` | The client key material combined with ZeroKMS to perform encryption. |
|
|
735
|
+
* | `CS_CLIENT_ACCESS_KEY` | The API access key used to authenticate requests to CipherStash. |
|
|
736
|
+
*
|
|
737
|
+
* When these are set, `auto` uses them in preference to the local dev profile.
|
|
738
|
+
*
|
|
739
|
+
* ### Custom auth strategies — `config.authStrategy`
|
|
740
|
+
*
|
|
741
|
+
* For finer control, pass an explicit strategy via `config.authStrategy` (from `@cipherstash/auth`,
|
|
742
|
+
* re-exported by `@cipherstash/stack`). See the `@cipherstash/auth` package for the full list. Two
|
|
743
|
+
* common choices:
|
|
744
|
+
*
|
|
745
|
+
* `AccessKeyStrategy` — like `auto`, but only ever uses an access key; it never falls back to the
|
|
746
|
+
* local dev profile. Ideal for services and CI:
|
|
747
|
+
*
|
|
748
|
+
* ```typescript
|
|
749
|
+
* import { Encryption, AccessKeyStrategy } from "@cipherstash/stack"
|
|
750
|
+
*
|
|
751
|
+
* const client = await Encryption({
|
|
752
|
+
* schemas: [users],
|
|
753
|
+
* config: {
|
|
754
|
+
* authStrategy: AccessKeyStrategy.create(workspaceCrn, accessKey),
|
|
755
|
+
* },
|
|
756
|
+
* })
|
|
757
|
+
* ```
|
|
758
|
+
*
|
|
759
|
+
* `OidcFederationStrategy` — authenticate end users through your own identity provider (Supabase,
|
|
760
|
+
* Clerk, Auth0 or Okta) by federating their OIDC JWT into a CipherStash token. Add the provider to
|
|
761
|
+
* your workspace first at
|
|
762
|
+
* [dashboard.cipherstash.com/workspaces/_/oidc-providers](https://dashboard.cipherstash.com/workspaces/_/oidc-providers)
|
|
763
|
+
* (the `_` in the URL resolves to whichever workspace you select):
|
|
764
|
+
*
|
|
765
|
+
* ```typescript
|
|
766
|
+
* import { Encryption, OidcFederationStrategy } from "@cipherstash/stack"
|
|
767
|
+
*
|
|
768
|
+
* // Authenticate every ZeroKMS request as the signed-in user.
|
|
769
|
+
* const client = await Encryption({
|
|
770
|
+
* schemas: [users],
|
|
771
|
+
* config: {
|
|
772
|
+
* authStrategy: OidcFederationStrategy.create(workspaceCrn, () => getUserJwt()),
|
|
773
|
+
* },
|
|
774
|
+
* })
|
|
775
|
+
* ```
|
|
776
|
+
*
|
|
777
|
+
* ### Lock context (identity-bound encryption)
|
|
778
|
+
*
|
|
779
|
+
* Lock context is an **additional** capability layered on top of `OidcFederationStrategy`: it
|
|
780
|
+
* requires that strategy, but `OidcFederationStrategy` does not require lock context. It binds a
|
|
781
|
+
* value to a claim from the user's JWT (typically `sub`) so that only the user who encrypted a
|
|
782
|
+
* value can decrypt it:
|
|
783
|
+
*
|
|
784
|
+
* ```typescript
|
|
785
|
+
* // Bind the data key to the user's `sub` claim.
|
|
786
|
+
* const result = await client
|
|
787
|
+
* .encrypt("alice@example.com", { column: users.email, table: users })
|
|
788
|
+
* .withLockContext({ identityClaim: ["sub"] })
|
|
789
|
+
* ```
|
|
790
|
+
*
|
|
791
|
+
* Because the lock is tied to a specific end user's identity, `AccessKeyStrategy` (which
|
|
792
|
+
* authenticates a service, not a user) is not valid for lock context — there is no user `sub`
|
|
793
|
+
* claim to bind to.
|
|
794
|
+
*
|
|
795
|
+
* ## Keysets (multi-tenant isolation)
|
|
796
|
+
*
|
|
797
|
+
* Pass `config.keyset` to encrypt under a specific **keyset** — a named or UUID-identified keyspace
|
|
798
|
+
* that gives each tenant its own cryptographic isolation, so data encrypted under one keyset cannot
|
|
799
|
+
* be decrypted under another. Create and manage keysets in the
|
|
800
|
+
* [dashboard](https://dashboard.cipherstash.com/workspaces/_/keysets) (the `_` in the URL resolves
|
|
801
|
+
* to whichever workspace you select); omit `config.keyset` to use the workspace's default keyset.
|
|
802
|
+
*
|
|
803
|
+
* ```typescript
|
|
804
|
+
* // `users` is the schema from the first example above.
|
|
805
|
+
* const client = await Encryption({
|
|
806
|
+
* schemas: [users],
|
|
807
|
+
* config: {
|
|
808
|
+
* keyset: { name: "tenant-a" }, // or { id: "<uuid>" }
|
|
809
|
+
* },
|
|
810
|
+
* })
|
|
811
|
+
* ```
|
|
812
|
+
*
|
|
813
|
+
* A client is bound to a single keyset for its lifetime, so multi-tenant applications use **one
|
|
814
|
+
* `Encryption()` client per tenant**. Keysets are orthogonal to `authStrategy` and lock context —
|
|
815
|
+
* they isolate a whole tenant's *keyspace* (coarse, fixed per client), whereas lock context binds
|
|
816
|
+
* an individual value to a user's identity claim (fine-grained, per operation) — and can be
|
|
817
|
+
* combined with both.
|
|
818
|
+
*
|
|
819
|
+
* @param config - Initialization options. Must include `schemas`; optionally include `config` for
|
|
820
|
+
* credentials and authentication. Logging is configured via the `STASH_STACK_LOG` environment
|
|
821
|
+
* variable (`debug | info | error`, default: `error`).
|
|
822
|
+
* @returns A Promise that resolves to an initialized {@link EncryptionClient} ready for
|
|
823
|
+
* {@link EncryptionClient.encrypt}, {@link EncryptionClient.decrypt}, and related operations.
|
|
824
|
+
*
|
|
825
|
+
* @throws Throws if `schemas` is empty, or if a keyset `id` is supplied but is not a valid UUID.
|
|
826
|
+
* Also throws if the client fails to initialize (e.g. invalid credentials or config).
|
|
827
|
+
*
|
|
692
828
|
* @see {@link EncryptionClientConfig} for full config options.
|
|
829
|
+
* @see {@link ClientConfig.authStrategy} for the auth strategy field.
|
|
693
830
|
* @see {@link EncryptionClient} for available methods after initialization.
|
|
694
831
|
*/
|
|
695
832
|
declare const Encryption: (config: EncryptionClientConfig) => Promise<EncryptionClient>;
|
|
696
833
|
|
|
697
|
-
export { type AuditConfig as A,
|
|
834
|
+
export { type AuditConfig as A, BulkEncryptModelsOperation as B, DecryptOperation as D, EncryptOperation as E, __resetStrategyDeprecationWarningForTests as _, EncryptQueryOperation as a, EncryptModelOperation as b, BulkEncryptOperation as c, BulkDecryptOperation as d, EncryptionClient as e, Encryption as f, BatchEncryptQueryOperation as g, BulkDecryptModelsOperation as h, DecryptModelOperation as i, noClientError as n, resolveEqlVersion as r };
|