@cipherstash/protect-ffi 0.26.0 → 0.28.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 (142) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +130 -14
  3. package/dist/wasm/protect_ffi_bg.js +53 -11
  4. package/dist/wasm/protect_ffi_bg.wasm +0 -0
  5. package/dist/wasm/protect_ffi_bg.wasm.d.ts +7 -7
  6. package/dist/wasm/protect_ffi_inline.js +1 -1
  7. package/lib/bigintWire.d.ts +56 -0
  8. package/lib/bigintWire.js +83 -0
  9. package/lib/eql-v3-types/Bigint.d.ts +13 -0
  10. package/lib/eql-v3-types/Bigint.js +2 -0
  11. package/lib/eql-v3-types/BigintEq.d.ts +15 -0
  12. package/lib/eql-v3-types/BigintEq.js +2 -0
  13. package/lib/eql-v3-types/BigintOrd.d.ts +15 -0
  14. package/lib/eql-v3-types/BigintOrd.js +2 -0
  15. package/lib/eql-v3-types/BigintOrdOpe.d.ts +15 -0
  16. package/lib/eql-v3-types/BigintOrdOpe.js +2 -0
  17. package/lib/eql-v3-types/BigintOrdOre.d.ts +15 -0
  18. package/lib/eql-v3-types/BigintOrdOre.js +2 -0
  19. package/lib/eql-v3-types/BloomFilter.d.ts +9 -0
  20. package/lib/eql-v3-types/BloomFilter.js +5 -0
  21. package/lib/eql-v3-types/Boolean.d.ts +13 -0
  22. package/lib/eql-v3-types/Boolean.js +2 -0
  23. package/lib/eql-v3-types/Ciphertext.d.ts +6 -0
  24. package/lib/eql-v3-types/Ciphertext.js +5 -0
  25. package/lib/eql-v3-types/Date.d.ts +13 -0
  26. package/lib/eql-v3-types/Date.js +2 -0
  27. package/lib/eql-v3-types/DateEq.d.ts +15 -0
  28. package/lib/eql-v3-types/DateEq.js +2 -0
  29. package/lib/eql-v3-types/DateOrd.d.ts +15 -0
  30. package/lib/eql-v3-types/DateOrd.js +2 -0
  31. package/lib/eql-v3-types/DateOrdOpe.d.ts +15 -0
  32. package/lib/eql-v3-types/DateOrdOpe.js +2 -0
  33. package/lib/eql-v3-types/DateOrdOre.d.ts +15 -0
  34. package/lib/eql-v3-types/DateOrdOre.js +2 -0
  35. package/lib/eql-v3-types/Double.d.ts +13 -0
  36. package/lib/eql-v3-types/Double.js +2 -0
  37. package/lib/eql-v3-types/DoubleEq.d.ts +15 -0
  38. package/lib/eql-v3-types/DoubleEq.js +2 -0
  39. package/lib/eql-v3-types/DoubleOrd.d.ts +15 -0
  40. package/lib/eql-v3-types/DoubleOrd.js +2 -0
  41. package/lib/eql-v3-types/DoubleOrdOpe.d.ts +15 -0
  42. package/lib/eql-v3-types/DoubleOrdOpe.js +2 -0
  43. package/lib/eql-v3-types/DoubleOrdOre.d.ts +15 -0
  44. package/lib/eql-v3-types/DoubleOrdOre.js +2 -0
  45. package/lib/eql-v3-types/Hmac256.d.ts +5 -0
  46. package/lib/eql-v3-types/Hmac256.js +5 -0
  47. package/lib/eql-v3-types/Identifier.d.ts +15 -0
  48. package/lib/eql-v3-types/Identifier.js +5 -0
  49. package/lib/eql-v3-types/Integer.d.ts +13 -0
  50. package/lib/eql-v3-types/Integer.js +2 -0
  51. package/lib/eql-v3-types/IntegerEq.d.ts +15 -0
  52. package/lib/eql-v3-types/IntegerEq.js +2 -0
  53. package/lib/eql-v3-types/IntegerOrd.d.ts +15 -0
  54. package/lib/eql-v3-types/IntegerOrd.js +2 -0
  55. package/lib/eql-v3-types/IntegerOrdOpe.d.ts +15 -0
  56. package/lib/eql-v3-types/IntegerOrdOpe.js +2 -0
  57. package/lib/eql-v3-types/IntegerOrdOre.d.ts +15 -0
  58. package/lib/eql-v3-types/IntegerOrdOre.js +2 -0
  59. package/lib/eql-v3-types/Numeric.d.ts +13 -0
  60. package/lib/eql-v3-types/Numeric.js +2 -0
  61. package/lib/eql-v3-types/NumericEq.d.ts +15 -0
  62. package/lib/eql-v3-types/NumericEq.js +2 -0
  63. package/lib/eql-v3-types/NumericOrd.d.ts +15 -0
  64. package/lib/eql-v3-types/NumericOrd.js +2 -0
  65. package/lib/eql-v3-types/NumericOrdOpe.d.ts +15 -0
  66. package/lib/eql-v3-types/NumericOrdOpe.js +2 -0
  67. package/lib/eql-v3-types/NumericOrdOre.d.ts +15 -0
  68. package/lib/eql-v3-types/NumericOrdOre.js +2 -0
  69. package/lib/eql-v3-types/OpeCllw.d.ts +9 -0
  70. package/lib/eql-v3-types/OpeCllw.js +5 -0
  71. package/lib/eql-v3-types/OreBlock256.d.ts +9 -0
  72. package/lib/eql-v3-types/OreBlock256.js +5 -0
  73. package/lib/eql-v3-types/OreCllw.d.ts +7 -0
  74. package/lib/eql-v3-types/OreCllw.js +5 -0
  75. package/lib/eql-v3-types/Real.d.ts +13 -0
  76. package/lib/eql-v3-types/Real.js +2 -0
  77. package/lib/eql-v3-types/RealEq.d.ts +15 -0
  78. package/lib/eql-v3-types/RealEq.js +2 -0
  79. package/lib/eql-v3-types/RealOrd.d.ts +15 -0
  80. package/lib/eql-v3-types/RealOrd.js +2 -0
  81. package/lib/eql-v3-types/RealOrdOpe.d.ts +15 -0
  82. package/lib/eql-v3-types/RealOrdOpe.js +2 -0
  83. package/lib/eql-v3-types/RealOrdOre.d.ts +15 -0
  84. package/lib/eql-v3-types/RealOrdOre.js +2 -0
  85. package/lib/eql-v3-types/SchemaVersion.d.ts +10 -0
  86. package/lib/eql-v3-types/SchemaVersion.js +5 -0
  87. package/lib/eql-v3-types/Selector.d.ts +5 -0
  88. package/lib/eql-v3-types/Selector.js +5 -0
  89. package/lib/eql-v3-types/Smallint.d.ts +13 -0
  90. package/lib/eql-v3-types/Smallint.js +2 -0
  91. package/lib/eql-v3-types/SmallintEq.d.ts +15 -0
  92. package/lib/eql-v3-types/SmallintEq.js +2 -0
  93. package/lib/eql-v3-types/SmallintOrd.d.ts +15 -0
  94. package/lib/eql-v3-types/SmallintOrd.js +2 -0
  95. package/lib/eql-v3-types/SmallintOrdOpe.d.ts +15 -0
  96. package/lib/eql-v3-types/SmallintOrdOpe.js +2 -0
  97. package/lib/eql-v3-types/SmallintOrdOre.d.ts +15 -0
  98. package/lib/eql-v3-types/SmallintOrdOre.js +2 -0
  99. package/lib/eql-v3-types/SteVecDocument.d.ts +15 -0
  100. package/lib/eql-v3-types/SteVecDocument.js +2 -0
  101. package/lib/eql-v3-types/SteVecEntry.d.ts +19 -0
  102. package/lib/eql-v3-types/SteVecEntry.js +2 -0
  103. package/lib/eql-v3-types/SteVecForm.d.ts +18 -0
  104. package/lib/eql-v3-types/SteVecForm.js +5 -0
  105. package/lib/eql-v3-types/SteVecQuery.d.ts +7 -0
  106. package/lib/eql-v3-types/SteVecQuery.js +2 -0
  107. package/lib/eql-v3-types/SteVecQueryEntry.d.ts +15 -0
  108. package/lib/eql-v3-types/SteVecQueryEntry.js +2 -0
  109. package/lib/eql-v3-types/SteVecTerm.d.ts +11 -0
  110. package/lib/eql-v3-types/SteVecTerm.js +2 -0
  111. package/lib/eql-v3-types/Text.d.ts +13 -0
  112. package/lib/eql-v3-types/Text.js +2 -0
  113. package/lib/eql-v3-types/TextEq.d.ts +15 -0
  114. package/lib/eql-v3-types/TextEq.js +2 -0
  115. package/lib/eql-v3-types/TextMatch.d.ts +15 -0
  116. package/lib/eql-v3-types/TextMatch.js +2 -0
  117. package/lib/eql-v3-types/TextOrd.d.ts +17 -0
  118. package/lib/eql-v3-types/TextOrd.js +2 -0
  119. package/lib/eql-v3-types/TextOrdOpe.d.ts +17 -0
  120. package/lib/eql-v3-types/TextOrdOpe.js +2 -0
  121. package/lib/eql-v3-types/TextOrdOre.d.ts +17 -0
  122. package/lib/eql-v3-types/TextOrdOre.js +2 -0
  123. package/lib/eql-v3-types/TextSearch.d.ts +19 -0
  124. package/lib/eql-v3-types/TextSearch.js +2 -0
  125. package/lib/eql-v3-types/Timestamp.d.ts +13 -0
  126. package/lib/eql-v3-types/Timestamp.js +2 -0
  127. package/lib/eql-v3-types/TimestampEq.d.ts +15 -0
  128. package/lib/eql-v3-types/TimestampEq.js +2 -0
  129. package/lib/eql-v3-types/TimestampOrd.d.ts +15 -0
  130. package/lib/eql-v3-types/TimestampOrd.js +2 -0
  131. package/lib/eql-v3-types/TimestampOrdOpe.d.ts +15 -0
  132. package/lib/eql-v3-types/TimestampOrdOpe.js +2 -0
  133. package/lib/eql-v3-types/TimestampOrdOre.d.ts +15 -0
  134. package/lib/eql-v3-types/TimestampOrdOre.js +2 -0
  135. package/lib/eql-v3.d.ts +90 -0
  136. package/lib/eql-v3.js +6 -0
  137. package/lib/errors.d.ts +14 -0
  138. package/lib/errors.js +77 -0
  139. package/lib/index.cjs +43 -63
  140. package/lib/index.d.cts +86 -25
  141. package/lib/normalizeEncryptConfig.d.ts +1 -1
  142. package/package.json +12 -12
@@ -0,0 +1,17 @@
1
+ import type { Ciphertext } from "./Ciphertext";
2
+ import type { Hmac256 } from "./Hmac256";
3
+ import type { Identifier } from "./Identifier";
4
+ import type { OreBlock256 } from "./OreBlock256";
5
+ import type { SchemaVersion } from "./SchemaVersion";
6
+ /**
7
+ * `eql_v3.text_ord_ore` — ordering domain.
8
+ *
9
+ * Operators: `=` `<>` `<` `<=` `>` `>=`. Required keys: `v` `i` `c` `hm` `ob`.
10
+ */
11
+ export type TextOrdOre = {
12
+ v: SchemaVersion;
13
+ i: Identifier;
14
+ c: Ciphertext;
15
+ hm: Hmac256;
16
+ ob: OreBlock256;
17
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import type { BloomFilter } from "./BloomFilter";
2
+ import type { Ciphertext } from "./Ciphertext";
3
+ import type { Hmac256 } from "./Hmac256";
4
+ import type { Identifier } from "./Identifier";
5
+ import type { OreBlock256 } from "./OreBlock256";
6
+ import type { SchemaVersion } from "./SchemaVersion";
7
+ /**
8
+ * `eql_v3.text_search` — search domain.
9
+ *
10
+ * Operators: `=` `<>` `<` `<=` `>` `>=` `@>` `<@`. Required keys: `v` `i` `c` `hm` `ob` `bf`.
11
+ */
12
+ export type TextSearch = {
13
+ v: SchemaVersion;
14
+ i: Identifier;
15
+ c: Ciphertext;
16
+ hm: Hmac256;
17
+ ob: OreBlock256;
18
+ bf: BloomFilter;
19
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import type { Ciphertext } from "./Ciphertext";
2
+ import type { Identifier } from "./Identifier";
3
+ import type { SchemaVersion } from "./SchemaVersion";
4
+ /**
5
+ * `eql_v3.timestamp` — storage-only domain.
6
+ *
7
+ * Operators: none. Required keys: `v` `i` `c`.
8
+ */
9
+ export type Timestamp = {
10
+ v: SchemaVersion;
11
+ i: Identifier;
12
+ c: Ciphertext;
13
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import type { Ciphertext } from "./Ciphertext";
2
+ import type { Hmac256 } from "./Hmac256";
3
+ import type { Identifier } from "./Identifier";
4
+ import type { SchemaVersion } from "./SchemaVersion";
5
+ /**
6
+ * `eql_v3.timestamp_eq` — equality domain.
7
+ *
8
+ * Operators: `=` `<>`. Required keys: `v` `i` `c` `hm`.
9
+ */
10
+ export type TimestampEq = {
11
+ v: SchemaVersion;
12
+ i: Identifier;
13
+ c: Ciphertext;
14
+ hm: Hmac256;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import type { Ciphertext } from "./Ciphertext";
2
+ import type { Identifier } from "./Identifier";
3
+ import type { OreBlock256 } from "./OreBlock256";
4
+ import type { SchemaVersion } from "./SchemaVersion";
5
+ /**
6
+ * `eql_v3.timestamp_ord` — ordering domain.
7
+ *
8
+ * Operators: `=` `<>` `<` `<=` `>` `>=`. Required keys: `v` `i` `c` `ob`.
9
+ */
10
+ export type TimestampOrd = {
11
+ v: SchemaVersion;
12
+ i: Identifier;
13
+ c: Ciphertext;
14
+ ob: OreBlock256;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import type { Ciphertext } from "./Ciphertext";
2
+ import type { Identifier } from "./Identifier";
3
+ import type { OpeCllw } from "./OpeCllw";
4
+ import type { SchemaVersion } from "./SchemaVersion";
5
+ /**
6
+ * `eql_v3.timestamp_ord_ope` — ordering domain.
7
+ *
8
+ * Operators: `=` `<>` `<` `<=` `>` `>=`. Required keys: `v` `i` `c` `op`.
9
+ */
10
+ export type TimestampOrdOpe = {
11
+ v: SchemaVersion;
12
+ i: Identifier;
13
+ c: Ciphertext;
14
+ op: OpeCllw;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import type { Ciphertext } from "./Ciphertext";
2
+ import type { Identifier } from "./Identifier";
3
+ import type { OreBlock256 } from "./OreBlock256";
4
+ import type { SchemaVersion } from "./SchemaVersion";
5
+ /**
6
+ * `eql_v3.timestamp_ord_ore` — ordering domain.
7
+ *
8
+ * Operators: `=` `<>` `<` `<=` `>` `>=`. Required keys: `v` `i` `c` `ob`.
9
+ */
10
+ export type TimestampOrdOre = {
11
+ v: SchemaVersion;
12
+ i: Identifier;
13
+ c: Ciphertext;
14
+ ob: OreBlock256;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,90 @@
1
+ import type { Bigint } from './eql-v3-types/Bigint.js';
2
+ import type { BigintEq } from './eql-v3-types/BigintEq.js';
3
+ import type { BigintOrd } from './eql-v3-types/BigintOrd.js';
4
+ import type { BigintOrdOpe } from './eql-v3-types/BigintOrdOpe.js';
5
+ import type { BigintOrdOre } from './eql-v3-types/BigintOrdOre.js';
6
+ import type { Boolean as EqlV3Boolean } from './eql-v3-types/Boolean.js';
7
+ import type { Date as EqlV3Date } from './eql-v3-types/Date.js';
8
+ import type { DateEq } from './eql-v3-types/DateEq.js';
9
+ import type { DateOrd } from './eql-v3-types/DateOrd.js';
10
+ import type { DateOrdOpe } from './eql-v3-types/DateOrdOpe.js';
11
+ import type { DateOrdOre } from './eql-v3-types/DateOrdOre.js';
12
+ import type { Double } from './eql-v3-types/Double.js';
13
+ import type { DoubleEq } from './eql-v3-types/DoubleEq.js';
14
+ import type { DoubleOrd } from './eql-v3-types/DoubleOrd.js';
15
+ import type { DoubleOrdOpe } from './eql-v3-types/DoubleOrdOpe.js';
16
+ import type { DoubleOrdOre } from './eql-v3-types/DoubleOrdOre.js';
17
+ import type { Integer } from './eql-v3-types/Integer.js';
18
+ import type { IntegerEq } from './eql-v3-types/IntegerEq.js';
19
+ import type { IntegerOrd } from './eql-v3-types/IntegerOrd.js';
20
+ import type { IntegerOrdOpe } from './eql-v3-types/IntegerOrdOpe.js';
21
+ import type { IntegerOrdOre } from './eql-v3-types/IntegerOrdOre.js';
22
+ import type { Numeric } from './eql-v3-types/Numeric.js';
23
+ import type { NumericEq } from './eql-v3-types/NumericEq.js';
24
+ import type { NumericOrd } from './eql-v3-types/NumericOrd.js';
25
+ import type { NumericOrdOpe } from './eql-v3-types/NumericOrdOpe.js';
26
+ import type { NumericOrdOre } from './eql-v3-types/NumericOrdOre.js';
27
+ import type { Real } from './eql-v3-types/Real.js';
28
+ import type { RealEq } from './eql-v3-types/RealEq.js';
29
+ import type { RealOrd } from './eql-v3-types/RealOrd.js';
30
+ import type { RealOrdOpe } from './eql-v3-types/RealOrdOpe.js';
31
+ import type { RealOrdOre } from './eql-v3-types/RealOrdOre.js';
32
+ import type { Smallint } from './eql-v3-types/Smallint.js';
33
+ import type { SmallintEq } from './eql-v3-types/SmallintEq.js';
34
+ import type { SmallintOrd } from './eql-v3-types/SmallintOrd.js';
35
+ import type { SmallintOrdOpe } from './eql-v3-types/SmallintOrdOpe.js';
36
+ import type { SmallintOrdOre } from './eql-v3-types/SmallintOrdOre.js';
37
+ import type { SteVecDocument } from './eql-v3-types/SteVecDocument.js';
38
+ import type { SteVecQuery } from './eql-v3-types/SteVecQuery.js';
39
+ import type { Text } from './eql-v3-types/Text.js';
40
+ import type { TextEq } from './eql-v3-types/TextEq.js';
41
+ import type { TextMatch } from './eql-v3-types/TextMatch.js';
42
+ import type { TextOrd } from './eql-v3-types/TextOrd.js';
43
+ import type { TextOrdOpe } from './eql-v3-types/TextOrdOpe.js';
44
+ import type { TextOrdOre } from './eql-v3-types/TextOrdOre.js';
45
+ import type { TextSearch } from './eql-v3-types/TextSearch.js';
46
+ import type { Timestamp } from './eql-v3-types/Timestamp.js';
47
+ import type { TimestampEq } from './eql-v3-types/TimestampEq.js';
48
+ import type { TimestampOrd } from './eql-v3-types/TimestampOrd.js';
49
+ import type { TimestampOrdOpe } from './eql-v3-types/TimestampOrdOpe.js';
50
+ import type { TimestampOrdOre } from './eql-v3-types/TimestampOrdOre.js';
51
+ export type { BloomFilter } from './eql-v3-types/BloomFilter.js';
52
+ export type { Ciphertext } from './eql-v3-types/Ciphertext.js';
53
+ export type { Hmac256 } from './eql-v3-types/Hmac256.js';
54
+ export type { Identifier as EqlV3Identifier } from './eql-v3-types/Identifier.js';
55
+ export type { OpeCllw } from './eql-v3-types/OpeCllw.js';
56
+ export type { OreBlock256 } from './eql-v3-types/OreBlock256.js';
57
+ export type { OreCllw } from './eql-v3-types/OreCllw.js';
58
+ export type { SchemaVersion } from './eql-v3-types/SchemaVersion.js';
59
+ export type { Selector } from './eql-v3-types/Selector.js';
60
+ export type { SteVecDocument } from './eql-v3-types/SteVecDocument.js';
61
+ export type { SteVecEntry as EqlV3SteVecEntry } from './eql-v3-types/SteVecEntry.js';
62
+ export type { SteVecForm } from './eql-v3-types/SteVecForm.js';
63
+ export type { SteVecQuery } from './eql-v3-types/SteVecQuery.js';
64
+ export type { SteVecQueryEntry } from './eql-v3-types/SteVecQueryEntry.js';
65
+ export type { SteVecTerm } from './eql-v3-types/SteVecTerm.js';
66
+ export type { Bigint, BigintEq, BigintOrd, BigintOrdOpe, BigintOrdOre, EqlV3Boolean, EqlV3Date, DateEq, DateOrd, DateOrdOpe, DateOrdOre, Double, DoubleEq, DoubleOrd, DoubleOrdOpe, DoubleOrdOre, Integer, IntegerEq, IntegerOrd, IntegerOrdOpe, IntegerOrdOre, Numeric, NumericEq, NumericOrd, NumericOrdOpe, NumericOrdOre, Real, RealEq, RealOrd, RealOrdOpe, RealOrdOre, Smallint, SmallintEq, SmallintOrd, SmallintOrdOpe, SmallintOrdOre, Text, TextEq, TextMatch, TextOrd, TextOrdOpe, TextOrdOre, TextSearch, Timestamp, TimestampEq, TimestampOrd, TimestampOrdOpe, TimestampOrdOre, };
67
+ /**
68
+ * Every flat scalar EQL v3 storage payload (`{v: 3, i, c, <terms>}`, one
69
+ * struct per `eql_v3` scalar domain).
70
+ */
71
+ export type EncryptedV3Scalar = Bigint | BigintEq | BigintOrd | BigintOrdOpe | BigintOrdOre | EqlV3Boolean | EqlV3Date | DateEq | DateOrd | DateOrdOpe | DateOrdOre | Double | DoubleEq | DoubleOrd | DoubleOrdOpe | DoubleOrdOre | Integer | IntegerEq | IntegerOrd | IntegerOrdOpe | IntegerOrdOre | Numeric | NumericEq | NumericOrd | NumericOrdOpe | NumericOrdOre | Real | RealEq | RealOrd | RealOrdOpe | RealOrdOre | Smallint | SmallintEq | SmallintOrd | SmallintOrdOpe | SmallintOrdOre | Text | TextEq | TextMatch | TextOrd | TextOrdOpe | TextOrdOre | TextSearch | Timestamp | TimestampEq | TimestampOrd | TimestampOrdOpe | TimestampOrdOre;
72
+ /**
73
+ * EQL v3 **storage** payload — returned by `encrypt` / `encryptBulk` when the
74
+ * client was created with `eqlVersion: 3`.
75
+ *
76
+ * Scalars carry no `k` discriminator: they are flat
77
+ * (`{v: 3, i, c, <terms>}`, terms depending on the column's `eql_v3` domain).
78
+ * Encrypted JSONB is a {@link SteVecDocument}, which keeps the `k: "sv"`
79
+ * form discriminator (`{v: 3, k: "sv", i, sv: [...]}`).
80
+ * The record ciphertext lives at `c` on scalars and at `sv[0].c` on SteVec
81
+ * documents (`sv[0]` is always the decryption root).
82
+ */
83
+ export type EncryptedV3 = EncryptedV3Scalar | SteVecDocument;
84
+ /**
85
+ * EQL v3 **query** payload — returned by `encryptQuery` / `encryptQueryBulk`
86
+ * under `eqlVersion: 3`. Only JSONB containment queries are supported (the
87
+ * `eql_v3.jsonb_query` needle); scalar and selector query encryption throws
88
+ * until a v3 scalar query wire shape exists.
89
+ */
90
+ export type EncryptedV3Query = SteVecQuery;
package/lib/eql-v3.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // Hand-written barrel over the vendored (generated) EQL v3 payload types in
3
+ // src/eql-v3-types/. Assembles the public unions and renames the few types
4
+ // whose names would clash with the v2 exports in index.cts (`Identifier`,
5
+ // `SteVecEntry`) or shadow a global (`Boolean`, `Date`).
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ export type ProtectErrorCode = 'INVARIANT_VIOLATION' | 'UNKNOWN_QUERY_OP' | 'UNKNOWN_COLUMN' | 'MISSING_INDEX' | 'INVALID_QUERY_INPUT' | 'INVALID_JSON_PATH' | 'STE_VEC_REQUIRES_JSON_CAST_AS' | 'MATCH_REQUIRES_TEXT' | 'UNSUPPORTED_CONFIG_VERSION' | 'INVALID_EQL_VERSION' | 'EQL_V3_QUERY_UNSUPPORTED' | 'EQL_V3_UNSUPPORTED_COLUMN' | 'EQL_V3_CONVERSION_FAILED' | 'INVALID_CIPHERTEXT' | 'UNKNOWN';
2
+ export declare class ProtectError extends Error {
3
+ code: ProtectErrorCode;
4
+ details?: unknown;
5
+ cause?: unknown;
6
+ constructor(opts: {
7
+ code: ProtectErrorCode;
8
+ message: string;
9
+ details?: unknown;
10
+ cause?: unknown;
11
+ });
12
+ }
13
+ export declare function inferErrorCode(message: string): ProtectErrorCode;
14
+ export declare function normalizeError(err: unknown): unknown;
package/lib/errors.js ADDED
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProtectError = void 0;
4
+ exports.inferErrorCode = inferErrorCode;
5
+ exports.normalizeError = normalizeError;
6
+ class ProtectError extends Error {
7
+ code;
8
+ details;
9
+ cause;
10
+ constructor(opts) {
11
+ super(opts.message);
12
+ this.name = 'ProtectError';
13
+ this.code = opts.code;
14
+ this.details = opts.details;
15
+ this.cause = opts.cause;
16
+ }
17
+ }
18
+ exports.ProtectError = ProtectError;
19
+ function inferErrorCode(message) {
20
+ if (message.startsWith('protect-ffi invariant violation:')) {
21
+ return 'INVARIANT_VIOLATION';
22
+ }
23
+ if (message.startsWith('Unknown query operation:')) {
24
+ return 'UNKNOWN_QUERY_OP';
25
+ }
26
+ if (message.startsWith('Invalid query input for')) {
27
+ return 'INVALID_QUERY_INPUT';
28
+ }
29
+ if (message.startsWith('Invalid JSON path')) {
30
+ return 'INVALID_JSON_PATH';
31
+ }
32
+ if (message.includes(' not found in Encrypt config')) {
33
+ return 'UNKNOWN_COLUMN';
34
+ }
35
+ if (message.includes(' index configured')) {
36
+ return 'MISSING_INDEX';
37
+ }
38
+ if (message.includes('requires plaintext_type: json')) {
39
+ return 'STE_VEC_REQUIRES_JSON_CAST_AS';
40
+ }
41
+ if (message.includes('requires plaintext_type: text')) {
42
+ return 'MATCH_REQUIRES_TEXT';
43
+ }
44
+ if (message.includes('unsupported config version')) {
45
+ return 'UNSUPPORTED_CONFIG_VERSION';
46
+ }
47
+ if (message.startsWith('Invalid eqlVersion')) {
48
+ return 'INVALID_EQL_VERSION';
49
+ }
50
+ if (message.startsWith('EQL v3 scalar query') ||
51
+ message.startsWith('EQL v3 selector query')) {
52
+ return 'EQL_V3_QUERY_UNSUPPORTED';
53
+ }
54
+ if (message.includes('cannot be represented in EQL v3')) {
55
+ return 'EQL_V3_UNSUPPORTED_COLUMN';
56
+ }
57
+ if (message.startsWith('EQL v3 conversion failed')) {
58
+ return 'EQL_V3_CONVERSION_FAILED';
59
+ }
60
+ if (message.startsWith('Invalid EQL ciphertext:')) {
61
+ return 'INVALID_CIPHERTEXT';
62
+ }
63
+ return 'UNKNOWN';
64
+ }
65
+ function normalizeError(err) {
66
+ if (err instanceof ProtectError) {
67
+ return err;
68
+ }
69
+ if (err && typeof err === 'object' && 'message' in err) {
70
+ const message = String(err.message ?? 'Unknown error');
71
+ const code = inferErrorCode(message);
72
+ if (code !== 'UNKNOWN') {
73
+ return new ProtectError({ code, message, cause: err });
74
+ }
75
+ }
76
+ return err;
77
+ }
package/lib/index.cjs CHANGED
@@ -33,6 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  return result;
34
34
  };
35
35
  })();
36
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
37
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
38
+ };
36
39
  Object.defineProperty(exports, "__esModule", { value: true });
37
40
  exports.ProtectError = exports.withEnvCredentials = void 0;
38
41
  exports.newClient = newClient;
@@ -45,73 +48,22 @@ exports.decryptBulkFallible = decryptBulkFallible;
45
48
  exports.encryptQuery = encryptQuery;
46
49
  exports.encryptQueryBulk = encryptQueryBulk;
47
50
  exports.ensureKeyset = ensureKeyset;
51
+ const bigintWire_js_1 = require("./bigintWire.js");
48
52
  const credentials_js_1 = require("./credentials.js");
49
53
  const native = __importStar(require("./load.cjs"));
50
54
  const normalizeEncryptConfig_js_1 = require("./normalizeEncryptConfig.js");
51
55
  var credentials_js_2 = require("./credentials.js");
52
56
  Object.defineProperty(exports, "withEnvCredentials", { enumerable: true, get: function () { return credentials_js_2.withEnvCredentials; } });
53
- class ProtectError extends Error {
54
- code;
55
- details;
56
- cause;
57
- constructor(opts) {
58
- super(opts.message);
59
- this.name = 'ProtectError';
60
- this.code = opts.code;
61
- this.details = opts.details;
62
- this.cause = opts.cause;
63
- }
64
- }
65
- exports.ProtectError = ProtectError;
66
- function inferErrorCode(message) {
67
- if (message.startsWith('protect-ffi invariant violation:')) {
68
- return 'INVARIANT_VIOLATION';
69
- }
70
- if (message.startsWith('Unknown query operation:')) {
71
- return 'UNKNOWN_QUERY_OP';
72
- }
73
- if (message.startsWith('Invalid query input for')) {
74
- return 'INVALID_QUERY_INPUT';
75
- }
76
- if (message.startsWith('Invalid JSON path')) {
77
- return 'INVALID_JSON_PATH';
78
- }
79
- if (message.includes(' not found in Encrypt config')) {
80
- return 'UNKNOWN_COLUMN';
81
- }
82
- if (message.includes(' index configured')) {
83
- return 'MISSING_INDEX';
84
- }
85
- if (message.includes('requires plaintext_type: json')) {
86
- return 'STE_VEC_REQUIRES_JSON_CAST_AS';
87
- }
88
- if (message.includes('requires plaintext_type: text')) {
89
- return 'MATCH_REQUIRES_TEXT';
90
- }
91
- if (message.includes('unsupported config version')) {
92
- return 'UNSUPPORTED_CONFIG_VERSION';
93
- }
94
- return 'UNKNOWN';
95
- }
96
- function normalizeError(err) {
97
- if (err instanceof ProtectError) {
98
- return err;
99
- }
100
- if (err && typeof err === 'object' && 'message' in err) {
101
- const message = String(err.message ?? 'Unknown error');
102
- const code = inferErrorCode(message);
103
- if (code !== 'UNKNOWN') {
104
- return new ProtectError({ code, message, cause: err });
105
- }
106
- }
107
- return err;
108
- }
57
+ __exportStar(require("./eql-v3.js"), exports);
58
+ const errors_js_1 = require("./errors.js");
59
+ var errors_js_2 = require("./errors.js");
60
+ Object.defineProperty(exports, "ProtectError", { enumerable: true, get: function () { return errors_js_2.ProtectError; } });
109
61
  async function wrapAsync(fn) {
110
62
  try {
111
63
  return await fn();
112
64
  }
113
65
  catch (err) {
114
- throw normalizeError(err);
66
+ throw (0, errors_js_1.normalizeError)(err);
115
67
  }
116
68
  }
117
69
  function wrapSync(fn) {
@@ -119,26 +71,37 @@ function wrapSync(fn) {
119
71
  return fn();
120
72
  }
121
73
  catch (err) {
122
- throw normalizeError(err);
74
+ throw (0, errors_js_1.normalizeError)(err);
123
75
  }
124
76
  }
125
77
  function newClient(opts) {
126
78
  return wrapAsync(() => native.newClient({
127
79
  encryptConfig: (0, normalizeEncryptConfig_js_1.normalizeEncryptConfig)(opts.encryptConfig),
128
80
  clientOpts: (0, credentials_js_1.withEnvCredentials)(opts.clientOpts),
81
+ eqlVersion: opts.eqlVersion,
129
82
  }, opts.strategy));
130
83
  }
131
84
  function encrypt(client, opts) {
132
- return wrapAsync(() => native.encrypt(client, opts));
85
+ return wrapAsync(() => native.encrypt(client, (0, bigintWire_js_1.withEncodedPlaintext)(opts)));
133
86
  }
134
87
  function decrypt(client, opts) {
135
88
  return wrapAsync(() => native.decrypt(client, opts));
136
89
  }
90
+ /**
91
+ * True when `encrypted` is a stored EQL payload in EITHER wire format:
92
+ * an EQL v2.3 payload (`k: "ct"` / `k: "sv"`) or an EQL v3 payload
93
+ * (`{v: 3, i, c}` scalar or `{v: 3, k: "sv", i, sv}` SteVec document).
94
+ * Query payloads (including the v3 containment needle) are not stored
95
+ * payloads and return false.
96
+ */
137
97
  function isEncrypted(encrypted) {
138
98
  return wrapSync(() => native.isEncrypted(encrypted));
139
99
  }
140
100
  function encryptBulk(client, opts) {
141
- return wrapAsync(() => native.encryptBulk(client, opts));
101
+ return wrapAsync(() => {
102
+ const plaintexts = (0, bigintWire_js_1.withEncodedPlaintexts)(opts.plaintexts);
103
+ return native.encryptBulk(client, plaintexts === opts.plaintexts ? opts : { ...opts, plaintexts });
104
+ });
142
105
  }
143
106
  function decryptBulk(client, opts) {
144
107
  return wrapAsync(() => native.decryptBulk(client, opts));
@@ -147,16 +110,33 @@ async function decryptBulkFallible(client, opts) {
147
110
  const results = await wrapAsync(() => native.decryptBulkFallible(client, opts));
148
111
  return results.map((item) => {
149
112
  if ('error' in item && typeof item.error === 'string') {
150
- return { ...item, code: inferErrorCode(item.error) };
113
+ return { ...item, code: (0, errors_js_1.inferErrorCode)(item.error) };
151
114
  }
152
115
  return item;
153
116
  });
154
117
  }
118
+ /**
119
+ * Encrypt a query term.
120
+ *
121
+ * Under `eqlVersion: 2` (default) this returns the v2 shapes ({@link
122
+ * Encrypted} for JSON containment, {@link EncryptedQuery} otherwise).
123
+ *
124
+ * Under `eqlVersion: 3` only JSON containment queries are supported and
125
+ * return the `eql_v3.jsonb_query` needle ({@link EncryptedV3Query}). Scalar
126
+ * index queries (`unique` / `ore` / `ope` / `match`) and `ste_vec_selector`
127
+ * queries
128
+ * throw `EQL_V3_QUERY_UNSUPPORTED` — no EQL v3 scalar/selector query wire
129
+ * shape exists yet, so those queries require an `eqlVersion: 2` client.
130
+ */
155
131
  function encryptQuery(client, opts) {
156
- return wrapAsync(() => native.encryptQuery(client, opts));
132
+ return wrapAsync(() => native.encryptQuery(client, (0, bigintWire_js_1.withEncodedPlaintext)(opts)));
157
133
  }
134
+ /** Bulk variant of {@link encryptQuery} — same EQL v3 restrictions apply. */
158
135
  function encryptQueryBulk(client, opts) {
159
- return wrapAsync(() => native.encryptQueryBulk(client, opts));
136
+ return wrapAsync(() => {
137
+ const queries = (0, bigintWire_js_1.withEncodedPlaintexts)(opts.queries);
138
+ return native.encryptQueryBulk(client, queries === opts.queries ? opts : { ...opts, queries });
139
+ });
160
140
  }
161
141
  /**
162
142
  * Test-only helper: ensures a keyset with the given name exists, creating it if necessary,