@cipherstash/stack 0.18.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/README.md +2 -2
  3. package/dist/{chunk-ZYOZHZMJ.js → chunk-36AA7IBJ.js} +151 -160
  4. package/dist/chunk-36AA7IBJ.js.map +1 -0
  5. package/dist/{chunk-VPOTNP4K.js → chunk-4AVL4VZD.js} +1 -1
  6. package/dist/chunk-4AVL4VZD.js.map +1 -0
  7. package/dist/{chunk-XWPGAHBZ.js → chunk-BNO32ZMV.js} +1 -1
  8. package/dist/chunk-BNO32ZMV.js.map +1 -0
  9. package/dist/{chunk-LLCCNKDL.js → chunk-HQANMV7R.js} +3 -3
  10. package/dist/{chunk-LLCCNKDL.js.map → chunk-HQANMV7R.js.map} +1 -1
  11. package/dist/chunk-IADZCZEA.js +23 -0
  12. package/dist/chunk-IADZCZEA.js.map +1 -0
  13. package/dist/chunk-IBSK6P33.js +209 -0
  14. package/dist/chunk-IBSK6P33.js.map +1 -0
  15. package/dist/chunk-JSG2AMDI.js +17 -0
  16. package/dist/chunk-JSG2AMDI.js.map +1 -0
  17. package/dist/chunk-MP3SSDNN.js +4439 -0
  18. package/dist/chunk-MP3SSDNN.js.map +1 -0
  19. package/dist/chunk-OFQ555AX.js +191 -0
  20. package/dist/chunk-OFQ555AX.js.map +1 -0
  21. package/dist/chunk-PZ5AY32C.js +10 -0
  22. package/dist/chunk-PZ5AY32C.js.map +1 -0
  23. package/dist/chunk-U66S7VIF.js +435 -0
  24. package/dist/chunk-U66S7VIF.js.map +1 -0
  25. package/dist/{client-Dt98Rugc.d.cts → client-DSGHBN-g.d.cts} +200 -58
  26. package/dist/{client-CIsfZ2zg.d.ts → client-DfCrlHXh.d.ts} +200 -58
  27. package/dist/client.cjs +4101 -43
  28. package/dist/client.cjs.map +1 -1
  29. package/dist/client.d.cts +5 -5
  30. package/dist/client.d.ts +5 -5
  31. package/dist/client.js +3 -1
  32. package/dist/drizzle/index.cjs +4133 -74
  33. package/dist/drizzle/index.cjs.map +1 -1
  34. package/dist/drizzle/index.d.cts +33 -33
  35. package/dist/drizzle/index.d.ts +33 -33
  36. package/dist/drizzle/index.js +35 -30
  37. package/dist/drizzle/index.js.map +1 -1
  38. package/dist/dynamodb/index.cjs +19 -12
  39. package/dist/dynamodb/index.cjs.map +1 -1
  40. package/dist/dynamodb/index.d.cts +2 -2
  41. package/dist/dynamodb/index.d.ts +2 -2
  42. package/dist/dynamodb/index.js +8 -10
  43. package/dist/dynamodb/index.js.map +1 -1
  44. package/dist/encryption/index.cjs +4448 -212
  45. package/dist/encryption/index.cjs.map +1 -1
  46. package/dist/encryption/index.d.cts +3 -3
  47. package/dist/encryption/index.d.ts +3 -3
  48. package/dist/encryption/index.js +15 -7
  49. package/dist/encryption/v3.cjs +7791 -0
  50. package/dist/encryption/v3.cjs.map +1 -0
  51. package/dist/encryption/v3.d.cts +100 -0
  52. package/dist/encryption/v3.d.ts +100 -0
  53. package/dist/encryption/v3.js +161 -0
  54. package/dist/encryption/v3.js.map +1 -0
  55. package/dist/eql/v3/index.cjs +612 -0
  56. package/dist/eql/v3/index.cjs.map +1 -0
  57. package/dist/eql/v3/index.d.cts +71 -0
  58. package/dist/eql/v3/index.d.ts +71 -0
  59. package/dist/eql/v3/index.js +89 -0
  60. package/dist/eql/v3/index.js.map +1 -0
  61. package/dist/errors/index.js +1 -0
  62. package/dist/identity/index.cjs +55 -35
  63. package/dist/identity/index.cjs.map +1 -1
  64. package/dist/identity/index.d.cts +54 -30
  65. package/dist/identity/index.d.ts +54 -30
  66. package/dist/identity/index.js +9 -177
  67. package/dist/identity/index.js.map +1 -1
  68. package/dist/index.cjs +4480 -228
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.d.cts +18 -7
  71. package/dist/index.d.ts +18 -7
  72. package/dist/index.js +20 -5
  73. package/dist/index.js.map +1 -1
  74. package/dist/schema/index.cjs +4105 -43
  75. package/dist/schema/index.cjs.map +1 -1
  76. package/dist/schema/index.d.cts +1 -1
  77. package/dist/schema/index.d.ts +1 -1
  78. package/dist/schema/index.js +3 -1
  79. package/dist/supabase/index.cjs +4500 -75
  80. package/dist/supabase/index.cjs.map +1 -1
  81. package/dist/supabase/index.d.cts +113 -34
  82. package/dist/supabase/index.d.ts +113 -34
  83. package/dist/supabase/index.js +350 -32
  84. package/dist/supabase/index.js.map +1 -1
  85. package/dist/table-CIH7jZ2h.d.ts +603 -0
  86. package/dist/table-DihEAlxG.d.cts +603 -0
  87. package/dist/{types-public-BTxqjmtv.d.ts → types-public-CpS5KjwX.d.cts} +250 -92
  88. package/dist/{types-public-BTxqjmtv.d.cts → types-public-CpS5KjwX.d.ts} +250 -92
  89. package/dist/types-public.cjs.map +1 -1
  90. package/dist/types-public.d.cts +2 -2
  91. package/dist/types-public.d.ts +2 -2
  92. package/dist/types-public.js +2 -1
  93. package/dist/wasm-inline.d.ts +1269 -0
  94. package/dist/wasm-inline.js +4594 -0
  95. package/dist/wasm-inline.js.map +1 -0
  96. package/package.json +54 -4
  97. package/dist/chunk-VPOTNP4K.js.map +0 -1
  98. package/dist/chunk-XWPGAHBZ.js.map +0 -1
  99. package/dist/chunk-YWQXTZ5M.js +0 -383
  100. package/dist/chunk-YWQXTZ5M.js.map +0 -1
  101. package/dist/chunk-ZYOZHZMJ.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;AAA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A4C,kBAEjD;AAAC;AACI,IAAM,6BAAN,cAAyC,kBAE9C;AAAC;AAOI,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,2BAAN,cAAuC,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-BTxqjmtv.cjs';
2
- import { EncryptionError } from './errors/index.cjs';
3
1
  import { Result } from '@byteslice/result';
4
- import { JsPlaintext } from '@cipherstash/protect-ffi';
5
- import { LockContext } from './identity/index.cjs';
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>;
@@ -36,14 +36,14 @@ declare class BatchEncryptQueryOperation extends EncryptionOperation<EncryptedQu
36
36
  private client;
37
37
  private terms;
38
38
  constructor(client: Client, terms: readonly ScalarQueryTerm[]);
39
- withLockContext(lockContext: LockContext): BatchEncryptQueryOperationWithLockContext;
39
+ withLockContext(lockContext: LockContextInput): BatchEncryptQueryOperationWithLockContext;
40
40
  execute(): Promise<Result<EncryptedQueryResult[], EncryptionError>>;
41
41
  }
42
42
  declare class BatchEncryptQueryOperationWithLockContext extends EncryptionOperation<EncryptedQueryResult[]> {
43
43
  private client;
44
44
  private terms;
45
45
  private lockContext;
46
- constructor(client: Client, terms: readonly ScalarQueryTerm[], lockContext: LockContext, auditMetadata?: Record<string, unknown>);
46
+ constructor(client: Client, terms: readonly ScalarQueryTerm[], lockContext: LockContextInput, auditMetadata?: Record<string, unknown>);
47
47
  execute(): Promise<Result<EncryptedQueryResult[], EncryptionError>>;
48
48
  }
49
49
 
@@ -51,7 +51,7 @@ declare class BulkDecryptOperation extends EncryptionOperation<BulkDecryptedData
51
51
  private client;
52
52
  private encryptedPayloads;
53
53
  constructor(client: Client, encryptedPayloads: BulkDecryptPayload);
54
- withLockContext(lockContext: LockContext): BulkDecryptOperationWithLockContext;
54
+ withLockContext(lockContext: LockContextInput): BulkDecryptOperationWithLockContext;
55
55
  execute(): Promise<Result<BulkDecryptedData, EncryptionError>>;
56
56
  getOperation(): {
57
57
  client: Client;
@@ -61,7 +61,7 @@ declare class BulkDecryptOperation extends EncryptionOperation<BulkDecryptedData
61
61
  declare class BulkDecryptOperationWithLockContext extends EncryptionOperation<BulkDecryptedData> {
62
62
  private operation;
63
63
  private lockContext;
64
- constructor(operation: BulkDecryptOperation, lockContext: LockContext);
64
+ constructor(operation: BulkDecryptOperation, lockContext: LockContextInput);
65
65
  execute(): Promise<Result<BulkDecryptedData, EncryptionError>>;
66
66
  }
67
67
 
@@ -69,7 +69,7 @@ declare class BulkDecryptModelsOperation<T extends Record<string, unknown>> exte
69
69
  private client;
70
70
  private models;
71
71
  constructor(client: Client, models: T[]);
72
- withLockContext(lockContext: LockContext): BulkDecryptModelsOperationWithLockContext<T>;
72
+ withLockContext(lockContext: LockContextInput): BulkDecryptModelsOperationWithLockContext<T>;
73
73
  execute(): Promise<Result<Decrypted<T>[], EncryptionError>>;
74
74
  getOperation(): {
75
75
  client: Client;
@@ -79,7 +79,7 @@ declare class BulkDecryptModelsOperation<T extends Record<string, unknown>> exte
79
79
  declare class BulkDecryptModelsOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<Decrypted<T>[]> {
80
80
  private operation;
81
81
  private lockContext;
82
- constructor(operation: BulkDecryptModelsOperation<T>, lockContext: LockContext);
82
+ constructor(operation: BulkDecryptModelsOperation<T>, lockContext: LockContextInput);
83
83
  execute(): Promise<Result<Decrypted<T>[], EncryptionError>>;
84
84
  }
85
85
 
@@ -89,19 +89,19 @@ declare class BulkEncryptOperation extends EncryptionOperation<BulkEncryptedData
89
89
  private column;
90
90
  private table;
91
91
  constructor(client: Client, plaintexts: BulkEncryptPayload, opts: EncryptOptions);
92
- withLockContext(lockContext: LockContext): BulkEncryptOperationWithLockContext;
92
+ withLockContext(lockContext: LockContextInput): BulkEncryptOperationWithLockContext;
93
93
  execute(): Promise<Result<BulkEncryptedData, EncryptionError>>;
94
94
  getOperation(): {
95
95
  client: Client;
96
96
  plaintexts: BulkEncryptPayload;
97
- column: EncryptedColumn | EncryptedField;
98
- table: EncryptedTable<EncryptedTableColumn>;
97
+ column: BuildableColumn;
98
+ table: BuildableTable;
99
99
  };
100
100
  }
101
101
  declare class BulkEncryptOperationWithLockContext extends EncryptionOperation<BulkEncryptedData> {
102
102
  private operation;
103
103
  private lockContext;
104
- constructor(operation: BulkEncryptOperation, lockContext: LockContext);
104
+ constructor(operation: BulkEncryptOperation, lockContext: LockContextInput);
105
105
  execute(): Promise<Result<BulkEncryptedData, EncryptionError>>;
106
106
  }
107
107
 
@@ -109,19 +109,19 @@ declare class BulkEncryptModelsOperation<T extends Record<string, unknown>> exte
109
109
  private client;
110
110
  private models;
111
111
  private table;
112
- constructor(client: Client, models: Record<string, unknown>[], table: EncryptedTable<EncryptedTableColumn>);
113
- withLockContext(lockContext: LockContext): BulkEncryptModelsOperationWithLockContext<T>;
112
+ constructor(client: Client, models: Record<string, unknown>[], table: BuildableTable);
113
+ withLockContext(lockContext: LockContextInput): BulkEncryptModelsOperationWithLockContext<T>;
114
114
  execute(): Promise<Result<T[], EncryptionError>>;
115
115
  getOperation(): {
116
116
  client: Client;
117
117
  models: Record<string, unknown>[];
118
- table: EncryptedTable<EncryptedTableColumn>;
118
+ table: BuildableTable;
119
119
  };
120
120
  }
121
121
  declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T[]> {
122
122
  private operation;
123
123
  private lockContext;
124
- constructor(operation: BulkEncryptModelsOperation<T>, lockContext: LockContext);
124
+ constructor(operation: BulkEncryptModelsOperation<T>, lockContext: LockContextInput);
125
125
  execute(): Promise<Result<T[], EncryptionError>>;
126
126
  }
127
127
 
@@ -133,7 +133,7 @@ declare class DecryptOperation extends EncryptionOperation<JsPlaintext> {
133
133
  private client;
134
134
  private encryptedData;
135
135
  constructor(client: Client, encryptedData: Encrypted | null);
136
- withLockContext(lockContext: LockContext): DecryptOperationWithLockContext;
136
+ withLockContext(lockContext: LockContextInput): DecryptOperationWithLockContext;
137
137
  execute(): Promise<Result<JsPlaintext, EncryptionError>>;
138
138
  getOperation(): {
139
139
  client: Client;
@@ -144,7 +144,7 @@ declare class DecryptOperation extends EncryptionOperation<JsPlaintext> {
144
144
  declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext> {
145
145
  private operation;
146
146
  private lockContext;
147
- constructor(operation: DecryptOperation, lockContext: LockContext);
147
+ constructor(operation: DecryptOperation, lockContext: LockContextInput);
148
148
  execute(): Promise<Result<JsPlaintext, EncryptionError>>;
149
149
  }
150
150
 
@@ -152,7 +152,7 @@ declare class DecryptModelOperation<T extends Record<string, unknown>> extends E
152
152
  private client;
153
153
  private model;
154
154
  constructor(client: Client, model: T);
155
- withLockContext(lockContext: LockContext): DecryptModelOperationWithLockContext<T>;
155
+ withLockContext(lockContext: LockContextInput): DecryptModelOperationWithLockContext<T>;
156
156
  execute(): Promise<Result<Decrypted<T>, EncryptionError>>;
157
157
  getOperation(): {
158
158
  client: Client;
@@ -162,7 +162,7 @@ declare class DecryptModelOperation<T extends Record<string, unknown>> extends E
162
162
  declare class DecryptModelOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<Decrypted<T>> {
163
163
  private operation;
164
164
  private lockContext;
165
- constructor(operation: DecryptModelOperation<T>, lockContext: LockContext);
165
+ constructor(operation: DecryptModelOperation<T>, lockContext: LockContextInput);
166
166
  execute(): Promise<Result<Decrypted<T>, EncryptionError>>;
167
167
  }
168
168
 
@@ -171,20 +171,20 @@ declare class EncryptOperation extends EncryptionOperation<Encrypted> {
171
171
  private plaintext;
172
172
  private column;
173
173
  private table;
174
- constructor(client: Client, plaintext: JsPlaintext | null, opts: EncryptOptions);
175
- withLockContext(lockContext: LockContext): EncryptOperationWithLockContext;
174
+ constructor(client: Client, plaintext: Plaintext | null, opts: EncryptOptions);
175
+ withLockContext(lockContext: LockContextInput): EncryptOperationWithLockContext;
176
176
  execute(): Promise<Result<Encrypted, EncryptionError>>;
177
177
  getOperation(): {
178
178
  client: Client;
179
- plaintext: JsPlaintext | null;
180
- column: EncryptedColumn | EncryptedField;
181
- table: EncryptedTable<EncryptedTableColumn>;
179
+ plaintext: Plaintext | null;
180
+ column: BuildableColumn;
181
+ table: BuildableTable;
182
182
  };
183
183
  }
184
184
  declare class EncryptOperationWithLockContext extends EncryptionOperation<Encrypted> {
185
185
  private operation;
186
186
  private lockContext;
187
- constructor(operation: EncryptOperation, lockContext: LockContext);
187
+ constructor(operation: EncryptOperation, lockContext: LockContextInput);
188
188
  execute(): Promise<Result<Encrypted, EncryptionError>>;
189
189
  }
190
190
 
@@ -192,19 +192,19 @@ declare class EncryptModelOperation<T extends Record<string, unknown>> extends E
192
192
  private client;
193
193
  private model;
194
194
  private table;
195
- constructor(client: Client, model: Record<string, unknown>, table: EncryptedTable<EncryptedTableColumn>);
196
- withLockContext(lockContext: LockContext): EncryptModelOperationWithLockContext<T>;
195
+ constructor(client: Client, model: Record<string, unknown>, table: BuildableTable);
196
+ withLockContext(lockContext: LockContextInput): EncryptModelOperationWithLockContext<T>;
197
197
  execute(): Promise<Result<T, EncryptionError>>;
198
198
  getOperation(): {
199
199
  client: Client;
200
200
  model: Record<string, unknown>;
201
- table: EncryptedTable<EncryptedTableColumn>;
201
+ table: BuildableTable;
202
202
  };
203
203
  }
204
204
  declare class EncryptModelOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T> {
205
205
  private operation;
206
206
  private lockContext;
207
- constructor(operation: EncryptModelOperation<T>, lockContext: LockContext);
207
+ constructor(operation: EncryptModelOperation<T>, lockContext: LockContextInput);
208
208
  execute(): Promise<Result<T, EncryptionError>>;
209
209
  }
210
210
 
@@ -212,16 +212,16 @@ declare class EncryptQueryOperation extends EncryptionOperation<EncryptedQueryRe
212
212
  private client;
213
213
  private plaintext;
214
214
  private opts;
215
- constructor(client: Client, plaintext: JsPlaintext | null | undefined, opts: EncryptQueryOptions);
216
- withLockContext(lockContext: LockContext): EncryptQueryOperationWithLockContext;
215
+ constructor(client: Client, plaintext: Plaintext | null | undefined, opts: EncryptQueryOptions);
216
+ withLockContext(lockContext: LockContextInput): EncryptQueryOperationWithLockContext;
217
217
  execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
218
218
  getOperation(): {
219
- column: EncryptedColumn;
220
- table: EncryptedTable<EncryptedTableColumn>;
219
+ column: BuildableQueryColumn;
220
+ table: BuildableTable;
221
221
  queryType?: QueryTypeName;
222
222
  returnType?: EncryptedReturnType;
223
223
  client: Client;
224
- plaintext: JsPlaintext | null | undefined;
224
+ plaintext: Plaintext | null | undefined;
225
225
  };
226
226
  }
227
227
  declare class EncryptQueryOperationWithLockContext extends EncryptionOperation<EncryptedQueryResult> {
@@ -229,11 +229,32 @@ declare class EncryptQueryOperationWithLockContext extends EncryptionOperation<E
229
229
  private plaintext;
230
230
  private opts;
231
231
  private lockContext;
232
- constructor(client: Client, plaintext: JsPlaintext | null | undefined, opts: EncryptQueryOptions, lockContext: LockContext, auditMetadata?: Record<string, unknown>);
232
+ constructor(client: Client, plaintext: Plaintext | null | undefined, opts: EncryptQueryOptions, lockContext: LockContextInput, auditMetadata?: Record<string, unknown>);
233
233
  execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
234
234
  }
235
235
 
236
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;
237
258
  /** The EncryptionClient is the main entry point for interacting with the CipherStash Encryption library.
238
259
  * It provides methods for encrypting and decrypting individual values, as well as models (objects) and bulk operations.
239
260
  *
@@ -255,6 +276,8 @@ declare class EncryptionClient {
255
276
  clientId?: string;
256
277
  clientKey?: string;
257
278
  keyset?: KeysetIdentifier;
279
+ authStrategy?: AuthStrategy;
280
+ eqlVersion?: 2 | 3;
258
281
  }): Promise<Result<EncryptionClient, EncryptionError>>;
259
282
  /**
260
283
  * Encrypt a value - returns a promise which resolves to an encrypted value.
@@ -331,7 +354,7 @@ declare class EncryptionClient {
331
354
  * @see {@link LockContext}
332
355
  * @see {@link EncryptOperation}
333
356
  */
334
- encrypt(plaintext: JsPlaintext, opts: EncryptOptions): EncryptOperation;
357
+ encrypt(plaintext: Plaintext, opts: EncryptOptions): EncryptOperation;
335
358
  /**
336
359
  * Encrypt a query value - returns a promise which resolves to an encrypted query value.
337
360
  *
@@ -385,7 +408,7 @@ declare class EncryptionClient {
385
408
  * - String plaintext → `steVecSelector` (JSONPath queries like `'$.user.email'`)
386
409
  * - Object/Array plaintext → `steVecTerm` (containment queries like `{ role: 'admin' }`)
387
410
  */
388
- encryptQuery(plaintext: JsPlaintext, opts: EncryptQueryOptions): EncryptQueryOperation;
411
+ encryptQuery(plaintext: Plaintext, opts: EncryptQueryOptions): EncryptQueryOperation;
389
412
  /**
390
413
  * Encrypt multiple values for use in queries (batch operation).
391
414
  * @param terms - Array of query terms to encrypt
@@ -477,7 +500,7 @@ declare class EncryptionClient {
477
500
  * }
478
501
  * ```
479
502
  */
480
- encryptModel<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: T, table: EncryptedTable<S>): EncryptModelOperation<EncryptedFromSchema<T, S>>;
503
+ encryptModel<T extends Record<string, unknown>, Table extends BuildableTable>(input: T, table: Table): EncryptModelOperation<EncryptedFromBuildableTable<T, Table>>;
481
504
  /**
482
505
  * Decrypt a model (object) whose fields contain encrypted values.
483
506
  *
@@ -552,7 +575,7 @@ declare class EncryptionClient {
552
575
  * }
553
576
  * ```
554
577
  */
555
- bulkEncryptModels<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: Array<T>, table: EncryptedTable<S>): BulkEncryptModelsOperation<EncryptedFromSchema<T, S>>;
578
+ bulkEncryptModels<T extends Record<string, unknown>, Table extends BuildableTable>(input: Array<T>, table: Table): BulkEncryptModelsOperation<EncryptedFromBuildableTable<T, Table>>;
556
579
  /**
557
580
  * Decrypt multiple models (objects) in a single bulk operation.
558
581
  *
@@ -657,36 +680,155 @@ declare class EncryptionClient {
657
680
  */
658
681
  getEncryptConfig(): EncryptConfig | undefined;
659
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;
660
691
  /**
661
692
  * Creates and initializes an Encryption client for encrypting and decrypting data with CipherStash.
662
693
  *
663
694
  * Provide at least one schema (from {@link encryptedTable}) so the client knows which tables and
664
- * columns to use. Credentials are read from the optional `config` or from the environment
665
- * (`CS_WORKSPACE_CRN`, `CS_CLIENT_ID`, `CS_CLIENT_KEY`, `CS_CLIENT_ACCESS_KEY`).
666
- *
667
- * @param config - Initialization options. Must include `schemas`; optionally include `config` for
668
- * workspace/keys. Logging is configured via the `STASH_STACK_LOG` environment variable
669
- * (`debug | info | error`, default: `error`).
670
- * @returns A Promise that resolves to an initialized {@link EncryptionClient} ready for
671
- * {@link EncryptionClient.encrypt}, {@link EncryptionClient.decrypt}, and related operations.
672
- *
673
- * @throws Throws if `schemas` is empty, or if a keyset `id` is supplied but is not a valid UUID.
674
- * Also throws if the client fails to initialize (e.g. invalid credentials or config).
695
+ * columns to use:
675
696
  *
676
- * @example
677
697
  * ```typescript
678
698
  * import { Encryption, encryptedTable, encryptedColumn } from "@cipherstash/stack"
679
699
  *
680
- * const users = encryptedTable("users", {
681
- * email: encryptedColumn("email"),
682
- * })
700
+ * const users = encryptedTable("users", { email: encryptedColumn("email") })
683
701
  * const client = await Encryption({ schemas: [users] })
684
702
  * const result = await client.encrypt("alice@example.com", { column: users.email, table: users })
685
703
  * ```
686
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
+ *
687
828
  * @see {@link EncryptionClientConfig} for full config options.
829
+ * @see {@link ClientConfig.authStrategy} for the auth strategy field.
688
830
  * @see {@link EncryptionClient} for available methods after initialization.
689
831
  */
690
832
  declare const Encryption: (config: EncryptionClientConfig) => Promise<EncryptionClient>;
691
833
 
692
- export { type AuditConfig as A, BatchEncryptQueryOperation as B, DecryptModelOperation as D, Encryption as E, EncryptionClient as a, BulkDecryptModelsOperation as b, BulkDecryptOperation as c, BulkEncryptModelsOperation as d, BulkEncryptOperation as e, DecryptOperation as f, EncryptModelOperation as g, EncryptOperation as h, EncryptQueryOperation as i, noClientError as n };
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 };