@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.
Files changed (102) hide show
  1. package/CHANGELOG.md +225 -0
  2. package/README.md +2 -2
  3. package/dist/{chunk-CY5B4LIF.js → chunk-36AA7IBJ.js} +303 -204
  4. package/dist/chunk-36AA7IBJ.js.map +1 -0
  5. package/dist/{chunk-MD6742R6.js → chunk-4AVL4VZD.js} +1 -1
  6. package/dist/chunk-4AVL4VZD.js.map +1 -0
  7. package/dist/{chunk-4RNBI3UH.js → chunk-BNO32ZMV.js} +1 -1
  8. package/dist/chunk-BNO32ZMV.js.map +1 -0
  9. package/dist/{chunk-6FD7OBGM.js → chunk-HQANMV7R.js} +3 -3
  10. package/dist/chunk-HQANMV7R.js.map +1 -0
  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-C_7TF8EL.d.cts → client-DSGHBN-g.d.cts} +209 -72
  26. package/dist/{client-BLbA6aFD.d.ts → client-DfCrlHXh.d.ts} +209 -72
  27. package/dist/client.cjs +4103 -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 +4139 -77
  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 +39 -33
  37. package/dist/drizzle/index.js.map +1 -1
  38. package/dist/dynamodb/index.cjs +31 -14
  39. package/dist/dynamodb/index.cjs.map +1 -1
  40. package/dist/dynamodb/index.d.cts +12 -12
  41. package/dist/dynamodb/index.d.ts +12 -12
  42. package/dist/dynamodb/index.js +16 -12
  43. package/dist/dynamodb/index.js.map +1 -1
  44. package/dist/encryption/index.cjs +4611 -257
  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 +35 -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 +4625 -273
  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 +4108 -44
  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-Dv-r6Ik0.d.ts → types-public-CpS5KjwX.d.cts} +209 -36
  88. package/dist/{types-public-Dv-r6Ik0.d.cts → types-public-CpS5KjwX.d.ts} +209 -36
  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 +63 -13
  97. package/dist/chunk-4RNBI3UH.js.map +0 -1
  98. package/dist/chunk-6FD7OBGM.js.map +0 -1
  99. package/dist/chunk-CY5B4LIF.js.map +0 -1
  100. package/dist/chunk-JDZ2QUUF.js +0 -381
  101. package/dist/chunk-JDZ2QUUF.js.map +0 -1
  102. package/dist/chunk-MD6742R6.js.map +0 -1
@@ -0,0 +1,191 @@
1
+ import {
2
+ withResult
3
+ } from "./chunk-JSG2AMDI.js";
4
+ import {
5
+ logger
6
+ } from "./chunk-HQANMV7R.js";
7
+ import {
8
+ EncryptionErrorTypes
9
+ } from "./chunk-LBMC4D6D.js";
10
+
11
+ // src/utils/config/index.ts
12
+ import fs from "fs";
13
+ import path from "path";
14
+ function getWorkspaceCrn(tomlString) {
15
+ let currentSection = "";
16
+ let workspaceCrn;
17
+ const lines = tomlString.split(/\r?\n/);
18
+ for (const line of lines) {
19
+ const trimmedLine = line.trim();
20
+ if (!trimmedLine || trimmedLine.startsWith("#")) {
21
+ continue;
22
+ }
23
+ const sectionMatch = trimmedLine.match(/^\[([^\]]+)\]$/);
24
+ if (sectionMatch) {
25
+ currentSection = sectionMatch[1];
26
+ continue;
27
+ }
28
+ const kvMatch = trimmedLine.match(/^(\w+)\s*=\s*"([^"]+)"$/);
29
+ if (kvMatch) {
30
+ const [_, key, value] = kvMatch;
31
+ if (currentSection === "auth" && key === "workspace_crn") {
32
+ workspaceCrn = value;
33
+ break;
34
+ }
35
+ }
36
+ }
37
+ return workspaceCrn;
38
+ }
39
+ function extractWorkspaceIdFromCrn(crn) {
40
+ const match = crn.match(/crn:[^:]+:([^:]+)$/);
41
+ if (!match) {
42
+ throw new Error("Invalid CRN format");
43
+ }
44
+ return match[1];
45
+ }
46
+ function loadWorkSpaceId(suppliedCrn) {
47
+ const configPath = path.join(process.cwd(), "cipherstash.toml");
48
+ if (suppliedCrn) {
49
+ return extractWorkspaceIdFromCrn(suppliedCrn);
50
+ }
51
+ if (!fs.existsSync(configPath) && !process.env.CS_WORKSPACE_CRN) {
52
+ throw new Error(
53
+ "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
54
+ );
55
+ }
56
+ if (process.env.CS_WORKSPACE_CRN) {
57
+ return extractWorkspaceIdFromCrn(process.env.CS_WORKSPACE_CRN);
58
+ }
59
+ if (!fs.existsSync(configPath)) {
60
+ throw new Error(
61
+ "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
62
+ );
63
+ }
64
+ const tomlString = fs.readFileSync(configPath, "utf8");
65
+ const workspaceCrn = getWorkspaceCrn(tomlString);
66
+ if (!workspaceCrn) {
67
+ throw new Error(
68
+ "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
69
+ );
70
+ }
71
+ return extractWorkspaceIdFromCrn(workspaceCrn);
72
+ }
73
+
74
+ // src/identity/index.ts
75
+ function resolveLockContext(input) {
76
+ return input instanceof LockContext || "identityContext" in input ? input.identityContext : input;
77
+ }
78
+ var LockContext = class {
79
+ ctsToken;
80
+ workspaceId;
81
+ context;
82
+ constructor({
83
+ context = { identityClaim: ["sub"] },
84
+ ctsToken
85
+ } = {}) {
86
+ const workspaceId = loadWorkSpaceId();
87
+ if (!workspaceId) {
88
+ throw new Error(
89
+ "You have not defined a workspace ID in your config file, or the CS_WORKSPACE_CRN environment variable."
90
+ );
91
+ }
92
+ if (ctsToken) {
93
+ this.ctsToken = ctsToken;
94
+ }
95
+ this.workspaceId = workspaceId;
96
+ this.context = context;
97
+ logger.debug("Successfully initialized the EQL lock context.");
98
+ }
99
+ /**
100
+ * The identity-claim context this lock context binds to, e.g.
101
+ * `{ identityClaim: ['sub'] }`. Resolved synchronously — `.withLockContext()`
102
+ * uses this directly; no CTS token is required.
103
+ */
104
+ get identityContext() {
105
+ return this.context;
106
+ }
107
+ /**
108
+ * Exchange a user's JWT for a CTS token and bind it to this lock context.
109
+ *
110
+ * @deprecated Per-operation CTS tokens were removed in protect-ffi 0.25.
111
+ * Authenticate the client as the user with an `OidcFederationStrategy`
112
+ * (`config.authStrategy`) instead, and pass the claim to `.withLockContext()`.
113
+ * The token fetched here is no longer used by encryption operations. This
114
+ * method is kept for backwards compatibility and will be removed in a
115
+ * future major release.
116
+ *
117
+ * @param jwtToken - A valid OIDC / JWT token for the current user.
118
+ * @returns A `Result` containing this `LockContext` or an error.
119
+ */
120
+ async identify(jwtToken) {
121
+ const workspaceId = this.workspaceId;
122
+ const ctsEndpoint = process.env.CS_CTS_ENDPOINT || "https://ap-southeast-2.aws.auth.viturhosted.net";
123
+ const ctsFetchResult = await withResult(
124
+ () => fetch(`${ctsEndpoint}/api/authorize`, {
125
+ method: "POST",
126
+ headers: {
127
+ "Content-Type": "application/json"
128
+ },
129
+ body: JSON.stringify({
130
+ workspaceId,
131
+ oidcToken: jwtToken
132
+ })
133
+ }),
134
+ (error) => ({
135
+ type: EncryptionErrorTypes.CtsTokenError,
136
+ message: error.message
137
+ })
138
+ );
139
+ if (ctsFetchResult.failure) {
140
+ return ctsFetchResult;
141
+ }
142
+ const identifiedLockContext = await withResult(
143
+ async () => {
144
+ const ctsToken = await ctsFetchResult.data.json();
145
+ if (!ctsToken.accessToken) {
146
+ throw new Error(
147
+ "The response from the CipherStash API did not contain an access token. Please contact support."
148
+ );
149
+ }
150
+ this.ctsToken = ctsToken;
151
+ return this;
152
+ },
153
+ (error) => ({
154
+ type: EncryptionErrorTypes.CtsTokenError,
155
+ message: error.message
156
+ })
157
+ );
158
+ return identifiedLockContext;
159
+ }
160
+ /**
161
+ * Retrieve the identity context (and CTS token, if one was set).
162
+ *
163
+ * @deprecated Encryption operations no longer consume a CTS token — they read
164
+ * the identity claim directly via {@link identityContext}. Pass the claim to
165
+ * `.withLockContext()` and authenticate the client with an
166
+ * `OidcFederationStrategy` instead. Kept for backwards compatibility; the
167
+ * returned `ctsToken` is `undefined` unless one was supplied to the
168
+ * constructor or {@link identify} was called.
169
+ */
170
+ getLockContext() {
171
+ return withResult(
172
+ () => ({
173
+ context: this.context,
174
+ // Only include `ctsToken` when one was actually set, so the
175
+ // returned shape matches the optional `ctsToken?` type rather
176
+ // than carrying an explicit `undefined`.
177
+ ...this.ctsToken ? { ctsToken: this.ctsToken } : {}
178
+ }),
179
+ (error) => ({
180
+ type: EncryptionErrorTypes.CtsTokenError,
181
+ message: error.message
182
+ })
183
+ );
184
+ }
185
+ };
186
+
187
+ export {
188
+ resolveLockContext,
189
+ LockContext
190
+ };
191
+ //# sourceMappingURL=chunk-OFQ555AX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/config/index.ts","../src/identity/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\n/**\n * A lightweight function that parses a TOML-like string\n * and returns the `workspace_crn` value found under `[auth]`.\n *\n * @param tomlString The contents of the TOML file as a string.\n * @returns The workspace_crn if found, otherwise undefined.\n */\nfunction getWorkspaceCrn(tomlString: string): string | undefined {\n let currentSection = ''\n let workspaceCrn: string | undefined\n\n const lines = tomlString.split(/\\r?\\n/)\n\n for (const line of lines) {\n const trimmedLine = line.trim()\n\n if (!trimmedLine || trimmedLine.startsWith('#')) {\n continue\n }\n\n const sectionMatch = trimmedLine.match(/^\\[([^\\]]+)\\]$/)\n if (sectionMatch) {\n currentSection = sectionMatch[1]\n continue\n }\n\n const kvMatch = trimmedLine.match(/^(\\w+)\\s*=\\s*\"([^\"]+)\"$/)\n if (kvMatch) {\n const [_, key, value] = kvMatch\n\n if (currentSection === 'auth' && key === 'workspace_crn') {\n workspaceCrn = value\n break\n }\n }\n }\n\n return workspaceCrn\n}\n\n/**\n * Extracts the workspace ID from a CRN string.\n * CRN format: crn:region.aws:ID\n *\n * @param crn The CRN string to extract from\n * @returns The workspace ID portion of the CRN\n */\nexport function extractWorkspaceIdFromCrn(crn: string): string {\n const match = crn.match(/crn:[^:]+:([^:]+)$/)\n if (!match) {\n throw new Error('Invalid CRN format')\n }\n return match[1]\n}\n\nexport function loadWorkSpaceId(suppliedCrn?: string): string {\n const configPath = path.join(process.cwd(), 'cipherstash.toml')\n\n if (suppliedCrn) {\n return extractWorkspaceIdFromCrn(suppliedCrn)\n }\n\n if (!fs.existsSync(configPath) && !process.env.CS_WORKSPACE_CRN) {\n throw new Error(\n 'You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable.',\n )\n }\n\n // Environment variables take precedence over config files\n if (process.env.CS_WORKSPACE_CRN) {\n return extractWorkspaceIdFromCrn(process.env.CS_WORKSPACE_CRN)\n }\n\n if (!fs.existsSync(configPath)) {\n throw new Error(\n 'You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable.',\n )\n }\n\n const tomlString = fs.readFileSync(configPath, 'utf8')\n const workspaceCrn = getWorkspaceCrn(tomlString)\n\n if (!workspaceCrn) {\n throw new Error(\n 'You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable.',\n )\n }\n\n return extractWorkspaceIdFromCrn(workspaceCrn)\n}\n","import { type Result, withResult } from '@byteslice/result'\nimport { type EncryptionError, EncryptionErrorTypes } from '@/errors'\nimport { loadWorkSpaceId } from '@/utils/config'\nimport { logger } from '@/utils/logger'\n\nexport type CtsRegions = 'ap-southeast-2'\n\nexport type IdentifyOptions = {\n fetchFromCts?: boolean\n}\n\nexport type CtsToken = {\n accessToken: string\n expiry: number\n}\n\nexport type Context = {\n identityClaim: string[]\n}\n\nexport type LockContextOptions = {\n context?: Context\n ctsToken?: CtsToken\n}\n\nexport type GetLockContextResponse = {\n ctsToken?: CtsToken\n context: Context\n}\n\n/**\n * The accepted argument to `.withLockContext()` — either a {@link LockContext}\n * or a plain identity-claim spec (e.g. `{ identityClaim: ['sub'] }`).\n */\nexport type LockContextInput = LockContext | Context\n\n/**\n * Resolve a {@link LockContextInput} to the {@link Context} (identity claim)\n * that protect-ffi expects. Synchronous — no token round-trip.\n */\nexport function resolveLockContext(input: LockContextInput): Context {\n // Use a structural check as well as `instanceof` so a `LockContext`\n // constructed in another realm (or from a duplicate module instance) is still\n // resolved rather than slipping through as a raw `Context`.\n return input instanceof LockContext || 'identityContext' in input\n ? (input as LockContext).identityContext\n : input\n}\n\n/**\n * Binds an encryption/decryption operation to a user's identity by selecting\n * which JWT claim(s) ZeroKMS bakes into the data key's tag (the *lock context*).\n *\n * The claim **value** is resolved by ZeroKMS from the token that authenticates\n * the request — so to bind to a real end user, authenticate the client as that\n * user with an `OidcFederationStrategy` (from `@cipherstash/auth`) and pass the\n * claim to `.withLockContext()`. The same context must be supplied to decrypt.\n *\n * You can pass a plain `{ identityClaim }` directly — constructing a\n * `LockContext` is optional.\n *\n * @example\n * ```typescript\n * import { Encryption } from \"@cipherstash/stack\"\n * import { OidcFederationStrategy } from \"@cipherstash/auth\"\n *\n * // Authenticate the client as the end user (replaces the old identify() flow).\n * const client = await Encryption({\n * schemas,\n * config: {\n * authStrategy: OidcFederationStrategy.create(workspaceCrn, () => getJwt()),\n * },\n * })\n *\n * // Bind the key to the user's `sub` claim — no token, no identify().\n * const result = await client\n * .encrypt(value, { column: users.email, table: users })\n * .withLockContext({ identityClaim: [\"sub\"] })\n * ```\n */\nexport class LockContext {\n private ctsToken: CtsToken | undefined\n private workspaceId: string\n private context: Context\n\n constructor({\n context = { identityClaim: ['sub'] },\n ctsToken,\n }: LockContextOptions = {}) {\n const workspaceId = loadWorkSpaceId()\n\n if (!workspaceId) {\n throw new Error(\n 'You have not defined a workspace ID in your config file, or the CS_WORKSPACE_CRN environment variable.',\n )\n }\n\n if (ctsToken) {\n this.ctsToken = ctsToken\n }\n\n this.workspaceId = workspaceId\n this.context = context\n logger.debug('Successfully initialized the EQL lock context.')\n }\n\n /**\n * The identity-claim context this lock context binds to, e.g.\n * `{ identityClaim: ['sub'] }`. Resolved synchronously — `.withLockContext()`\n * uses this directly; no CTS token is required.\n */\n get identityContext(): Context {\n return this.context\n }\n\n /**\n * Exchange a user's JWT for a CTS token and bind it to this lock context.\n *\n * @deprecated Per-operation CTS tokens were removed in protect-ffi 0.25.\n * Authenticate the client as the user with an `OidcFederationStrategy`\n * (`config.authStrategy`) instead, and pass the claim to `.withLockContext()`.\n * The token fetched here is no longer used by encryption operations. This\n * method is kept for backwards compatibility and will be removed in a\n * future major release.\n *\n * @param jwtToken - A valid OIDC / JWT token for the current user.\n * @returns A `Result` containing this `LockContext` or an error.\n */\n async identify(\n jwtToken: string,\n ): Promise<Result<LockContext, EncryptionError>> {\n const workspaceId = this.workspaceId\n\n const ctsEndpoint =\n process.env.CS_CTS_ENDPOINT ||\n 'https://ap-southeast-2.aws.auth.viturhosted.net'\n\n const ctsFetchResult = await withResult(\n () =>\n fetch(`${ctsEndpoint}/api/authorize`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n workspaceId,\n oidcToken: jwtToken,\n }),\n }),\n (error) => ({\n type: EncryptionErrorTypes.CtsTokenError,\n message: error.message,\n }),\n )\n\n if (ctsFetchResult.failure) {\n return ctsFetchResult\n }\n\n const identifiedLockContext = await withResult(\n async () => {\n const ctsToken = (await ctsFetchResult.data.json()) as CtsToken\n\n if (!ctsToken.accessToken) {\n throw new Error(\n 'The response from the CipherStash API did not contain an access token. Please contact support.',\n )\n }\n\n this.ctsToken = ctsToken\n return this\n },\n (error) => ({\n type: EncryptionErrorTypes.CtsTokenError,\n message: error.message,\n }),\n )\n\n return identifiedLockContext\n }\n\n /**\n * Retrieve the identity context (and CTS token, if one was set).\n *\n * @deprecated Encryption operations no longer consume a CTS token — they read\n * the identity claim directly via {@link identityContext}. Pass the claim to\n * `.withLockContext()` and authenticate the client with an\n * `OidcFederationStrategy` instead. Kept for backwards compatibility; the\n * returned `ctsToken` is `undefined` unless one was supplied to the\n * constructor or {@link identify} was called.\n */\n getLockContext(): Promise<Result<GetLockContextResponse, EncryptionError>> {\n return withResult(\n () => ({\n context: this.context,\n // Only include `ctsToken` when one was actually set, so the\n // returned shape matches the optional `ctsToken?` type rather\n // than carrying an explicit `undefined`.\n ...(this.ctsToken ? { ctsToken: this.ctsToken } : {}),\n }),\n (error) => ({\n type: EncryptionErrorTypes.CtsTokenError,\n message: error.message,\n }),\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AASjB,SAAS,gBAAgB,YAAwC;AAC/D,MAAI,iBAAiB;AACrB,MAAI;AAEJ,QAAM,QAAQ,WAAW,MAAM,OAAO;AAEtC,aAAW,QAAQ,OAAO;AACxB,UAAM,cAAc,KAAK,KAAK;AAE9B,QAAI,CAAC,eAAe,YAAY,WAAW,GAAG,GAAG;AAC/C;AAAA,IACF;AAEA,UAAM,eAAe,YAAY,MAAM,gBAAgB;AACvD,QAAI,cAAc;AAChB,uBAAiB,aAAa,CAAC;AAC/B;AAAA,IACF;AAEA,UAAM,UAAU,YAAY,MAAM,yBAAyB;AAC3D,QAAI,SAAS;AACX,YAAM,CAAC,GAAG,KAAK,KAAK,IAAI;AAExB,UAAI,mBAAmB,UA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AAA;AAAA;AAAA;AAAA,QAId,GAAI,KAAK,WAAW,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;AAAA,MACrD;AAAA,MACA,CAAC,WAAW;AAAA,QACV,MAAM,qBAAqB;AAAA,QAC3B,SAAS,MAAM;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export {
8
+ __export
9
+ };
10
+ //# sourceMappingURL=chunk-PZ5AY32C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,435 @@
1
+ import {
2
+ cloneMatchOpts,
3
+ defaultMatchOpts
4
+ } from "./chunk-IADZCZEA.js";
5
+
6
+ // src/eql/v3/columns.ts
7
+ var STORAGE_ONLY = {
8
+ equality: false,
9
+ orderAndRange: false,
10
+ freeTextSearch: false
11
+ };
12
+ var EQUALITY_ONLY = {
13
+ equality: true,
14
+ orderAndRange: false,
15
+ freeTextSearch: false
16
+ };
17
+ var ORDER_AND_RANGE = {
18
+ equality: true,
19
+ orderAndRange: true,
20
+ freeTextSearch: false
21
+ };
22
+ var MATCH_ONLY = {
23
+ equality: false,
24
+ orderAndRange: false,
25
+ freeTextSearch: true
26
+ };
27
+ var TEXT_SEARCH = {
28
+ equality: true,
29
+ orderAndRange: true,
30
+ freeTextSearch: true
31
+ };
32
+ var TEXT_SEARCH_EQL_TYPE = "eql_v3.text_search";
33
+ var INTEGER = {
34
+ eqlType: "eql_v3.integer",
35
+ castAs: "number",
36
+ capabilities: STORAGE_ONLY
37
+ };
38
+ var INTEGER_EQ = {
39
+ eqlType: "eql_v3.integer_eq",
40
+ castAs: "number",
41
+ capabilities: EQUALITY_ONLY
42
+ };
43
+ var INTEGER_ORD_ORE = {
44
+ eqlType: "eql_v3.integer_ord_ore",
45
+ castAs: "number",
46
+ capabilities: ORDER_AND_RANGE
47
+ };
48
+ var INTEGER_ORD = {
49
+ eqlType: "eql_v3.integer_ord",
50
+ castAs: "number",
51
+ capabilities: ORDER_AND_RANGE
52
+ };
53
+ var SMALLINT = {
54
+ eqlType: "eql_v3.smallint",
55
+ castAs: "number",
56
+ capabilities: STORAGE_ONLY
57
+ };
58
+ var SMALLINT_EQ = {
59
+ eqlType: "eql_v3.smallint_eq",
60
+ castAs: "number",
61
+ capabilities: EQUALITY_ONLY
62
+ };
63
+ var SMALLINT_ORD_ORE = {
64
+ eqlType: "eql_v3.smallint_ord_ore",
65
+ castAs: "number",
66
+ capabilities: ORDER_AND_RANGE
67
+ };
68
+ var SMALLINT_ORD = {
69
+ eqlType: "eql_v3.smallint_ord",
70
+ castAs: "number",
71
+ capabilities: ORDER_AND_RANGE
72
+ };
73
+ var DATE = {
74
+ eqlType: "eql_v3.date",
75
+ castAs: "date",
76
+ capabilities: STORAGE_ONLY
77
+ };
78
+ var DATE_EQ = {
79
+ eqlType: "eql_v3.date_eq",
80
+ castAs: "date",
81
+ capabilities: EQUALITY_ONLY
82
+ };
83
+ var DATE_ORD_ORE = {
84
+ eqlType: "eql_v3.date_ord_ore",
85
+ castAs: "date",
86
+ capabilities: ORDER_AND_RANGE
87
+ };
88
+ var DATE_ORD = {
89
+ eqlType: "eql_v3.date_ord",
90
+ castAs: "date",
91
+ capabilities: ORDER_AND_RANGE
92
+ };
93
+ var TIMESTAMP = {
94
+ eqlType: "eql_v3.timestamp",
95
+ castAs: "timestamp",
96
+ capabilities: STORAGE_ONLY
97
+ };
98
+ var TIMESTAMP_EQ = {
99
+ eqlType: "eql_v3.timestamp_eq",
100
+ castAs: "timestamp",
101
+ capabilities: EQUALITY_ONLY
102
+ };
103
+ var TIMESTAMP_ORD_ORE = {
104
+ eqlType: "eql_v3.timestamp_ord_ore",
105
+ castAs: "timestamp",
106
+ capabilities: ORDER_AND_RANGE
107
+ };
108
+ var TIMESTAMP_ORD = {
109
+ eqlType: "eql_v3.timestamp_ord",
110
+ castAs: "timestamp",
111
+ capabilities: ORDER_AND_RANGE
112
+ };
113
+ var NUMERIC = {
114
+ eqlType: "eql_v3.numeric",
115
+ castAs: "number",
116
+ capabilities: STORAGE_ONLY
117
+ };
118
+ var NUMERIC_EQ = {
119
+ eqlType: "eql_v3.numeric_eq",
120
+ castAs: "number",
121
+ capabilities: EQUALITY_ONLY
122
+ };
123
+ var NUMERIC_ORD_ORE = {
124
+ eqlType: "eql_v3.numeric_ord_ore",
125
+ castAs: "number",
126
+ capabilities: ORDER_AND_RANGE
127
+ };
128
+ var NUMERIC_ORD = {
129
+ eqlType: "eql_v3.numeric_ord",
130
+ castAs: "number",
131
+ capabilities: ORDER_AND_RANGE
132
+ };
133
+ var TEXT = {
134
+ eqlType: "eql_v3.text",
135
+ castAs: "string",
136
+ capabilities: STORAGE_ONLY
137
+ };
138
+ var TEXT_EQ = {
139
+ eqlType: "eql_v3.text_eq",
140
+ castAs: "string",
141
+ capabilities: EQUALITY_ONLY
142
+ };
143
+ var TEXT_MATCH = {
144
+ eqlType: "eql_v3.text_match",
145
+ castAs: "string",
146
+ capabilities: MATCH_ONLY
147
+ };
148
+ var TEXT_ORD_ORE = {
149
+ eqlType: "eql_v3.text_ord_ore",
150
+ castAs: "string",
151
+ capabilities: ORDER_AND_RANGE
152
+ };
153
+ var TEXT_ORD = {
154
+ eqlType: "eql_v3.text_ord",
155
+ castAs: "string",
156
+ capabilities: ORDER_AND_RANGE
157
+ };
158
+ var BOOLEAN = {
159
+ eqlType: "eql_v3.boolean",
160
+ castAs: "boolean",
161
+ capabilities: STORAGE_ONLY
162
+ };
163
+ var REAL = {
164
+ eqlType: "eql_v3.real",
165
+ castAs: "number",
166
+ capabilities: STORAGE_ONLY
167
+ };
168
+ var REAL_EQ = {
169
+ eqlType: "eql_v3.real_eq",
170
+ castAs: "number",
171
+ capabilities: EQUALITY_ONLY
172
+ };
173
+ var REAL_ORD_ORE = {
174
+ eqlType: "eql_v3.real_ord_ore",
175
+ castAs: "number",
176
+ capabilities: ORDER_AND_RANGE
177
+ };
178
+ var REAL_ORD = {
179
+ eqlType: "eql_v3.real_ord",
180
+ castAs: "number",
181
+ capabilities: ORDER_AND_RANGE
182
+ };
183
+ var DOUBLE = {
184
+ eqlType: "eql_v3.double",
185
+ castAs: "number",
186
+ capabilities: STORAGE_ONLY
187
+ };
188
+ var DOUBLE_EQ = {
189
+ eqlType: "eql_v3.double_eq",
190
+ castAs: "number",
191
+ capabilities: EQUALITY_ONLY
192
+ };
193
+ var DOUBLE_ORD_ORE = {
194
+ eqlType: "eql_v3.double_ord_ore",
195
+ castAs: "number",
196
+ capabilities: ORDER_AND_RANGE
197
+ };
198
+ var DOUBLE_ORD = {
199
+ eqlType: "eql_v3.double_ord",
200
+ castAs: "number",
201
+ capabilities: ORDER_AND_RANGE
202
+ };
203
+ function indexesForCapabilities(capabilities, castAs) {
204
+ const indexes = {};
205
+ if (capabilities.equality && (!capabilities.orderAndRange || castAs === "string")) {
206
+ indexes.unique = { token_filters: [] };
207
+ }
208
+ if (capabilities.orderAndRange) {
209
+ indexes.ore = {};
210
+ }
211
+ if (capabilities.freeTextSearch) {
212
+ indexes.match = defaultMatchOpts();
213
+ }
214
+ return indexes;
215
+ }
216
+ function isQueryableCapabilities(capabilities) {
217
+ return capabilities.equality || capabilities.orderAndRange || capabilities.freeTextSearch;
218
+ }
219
+ var EncryptedV3Column = class {
220
+ constructor(columnName, definition) {
221
+ this.columnName = columnName;
222
+ this.definition = definition;
223
+ }
224
+ columnName;
225
+ definition;
226
+ getName() {
227
+ return this.columnName;
228
+ }
229
+ /** The concrete EQL v3 domain name. Metadata only; not emitted by `build()`. */
230
+ getEqlType() {
231
+ return this.definition.eqlType;
232
+ }
233
+ /** The semantic query capabilities this domain exposes. Metadata only. */
234
+ getQueryCapabilities() {
235
+ return this.definition.capabilities;
236
+ }
237
+ /** `true` when this domain can produce at least one kind of query term. */
238
+ isQueryable() {
239
+ return isQueryableCapabilities(
240
+ this.definition.capabilities
241
+ );
242
+ }
243
+ /** Emit the encrypt-config column: `cast_as` plus capability-derived indexes. */
244
+ build() {
245
+ return {
246
+ cast_as: this.definition.castAs,
247
+ indexes: indexesForCapabilities(
248
+ this.definition.capabilities,
249
+ this.definition.castAs
250
+ )
251
+ };
252
+ }
253
+ };
254
+ var TEXT_SEARCH_DOMAIN = {
255
+ eqlType: TEXT_SEARCH_EQL_TYPE,
256
+ castAs: "string",
257
+ capabilities: TEXT_SEARCH
258
+ };
259
+ var EncryptedTextSearchColumn = class extends EncryptedV3Column {
260
+ matchOpts;
261
+ constructor(columnName) {
262
+ super(columnName, TEXT_SEARCH_DOMAIN);
263
+ this.matchOpts = defaultMatchOpts();
264
+ }
265
+ /**
266
+ * Tune the match index. Each provided key replaces its default; omitted
267
+ * keys keep the default. This NEVER enables a capability — match is always
268
+ * on for this type. Merge semantics mirror v2's `opts?.x ?? default`.
269
+ */
270
+ freeTextSearch(opts) {
271
+ const defaults = defaultMatchOpts();
272
+ this.matchOpts = cloneMatchOpts({
273
+ tokenizer: opts?.tokenizer ?? defaults.tokenizer,
274
+ token_filters: opts?.token_filters ?? defaults.token_filters,
275
+ k: opts?.k ?? defaults.k,
276
+ m: opts?.m ?? defaults.m,
277
+ include_original: opts?.include_original ?? defaults.include_original
278
+ });
279
+ return this;
280
+ }
281
+ /** Emit the encrypt-config column. Byte-identical to a v2 equality+order+match column. */
282
+ build() {
283
+ return {
284
+ cast_as: "string",
285
+ indexes: {
286
+ unique: { token_filters: [] },
287
+ ore: {},
288
+ match: cloneMatchOpts(this.matchOpts)
289
+ }
290
+ };
291
+ }
292
+ };
293
+ var EncryptedIntegerColumn = class extends EncryptedV3Column {
294
+ };
295
+ var EncryptedIntegerEqColumn = class extends EncryptedV3Column {
296
+ };
297
+ var EncryptedIntegerOrdOreColumn = class extends EncryptedV3Column {
298
+ };
299
+ var EncryptedIntegerOrdColumn = class extends EncryptedV3Column {
300
+ };
301
+ var EncryptedSmallintColumn = class extends EncryptedV3Column {
302
+ };
303
+ var EncryptedSmallintEqColumn = class extends EncryptedV3Column {
304
+ };
305
+ var EncryptedSmallintOrdOreColumn = class extends EncryptedV3Column {
306
+ };
307
+ var EncryptedSmallintOrdColumn = class extends EncryptedV3Column {
308
+ };
309
+ var EncryptedDateColumn = class extends EncryptedV3Column {
310
+ };
311
+ var EncryptedDateEqColumn = class extends EncryptedV3Column {
312
+ };
313
+ var EncryptedDateOrdOreColumn = class extends EncryptedV3Column {
314
+ };
315
+ var EncryptedDateOrdColumn = class extends EncryptedV3Column {
316
+ };
317
+ var EncryptedTimestampColumn = class extends EncryptedV3Column {
318
+ };
319
+ var EncryptedTimestampEqColumn = class extends EncryptedV3Column {
320
+ };
321
+ var EncryptedTimestampOrdOreColumn = class extends EncryptedV3Column {
322
+ };
323
+ var EncryptedTimestampOrdColumn = class extends EncryptedV3Column {
324
+ };
325
+ var EncryptedNumericColumn = class extends EncryptedV3Column {
326
+ };
327
+ var EncryptedNumericEqColumn = class extends EncryptedV3Column {
328
+ };
329
+ var EncryptedNumericOrdOreColumn = class extends EncryptedV3Column {
330
+ };
331
+ var EncryptedNumericOrdColumn = class extends EncryptedV3Column {
332
+ };
333
+ var EncryptedTextColumn = class extends EncryptedV3Column {
334
+ };
335
+ var EncryptedTextEqColumn = class extends EncryptedV3Column {
336
+ };
337
+ var EncryptedTextMatchColumn = class extends EncryptedV3Column {
338
+ };
339
+ var EncryptedTextOrdOreColumn = class extends EncryptedV3Column {
340
+ };
341
+ var EncryptedTextOrdColumn = class extends EncryptedV3Column {
342
+ };
343
+ var EncryptedBooleanColumn = class extends EncryptedV3Column {
344
+ };
345
+ var EncryptedRealColumn = class extends EncryptedV3Column {
346
+ };
347
+ var EncryptedRealEqColumn = class extends EncryptedV3Column {
348
+ };
349
+ var EncryptedRealOrdOreColumn = class extends EncryptedV3Column {
350
+ };
351
+ var EncryptedRealOrdColumn = class extends EncryptedV3Column {
352
+ };
353
+ var EncryptedDoubleColumn = class extends EncryptedV3Column {
354
+ };
355
+ var EncryptedDoubleEqColumn = class extends EncryptedV3Column {
356
+ };
357
+ var EncryptedDoubleOrdOreColumn = class extends EncryptedV3Column {
358
+ };
359
+ var EncryptedDoubleOrdColumn = class extends EncryptedV3Column {
360
+ };
361
+
362
+ export {
363
+ TEXT_SEARCH_EQL_TYPE,
364
+ INTEGER,
365
+ INTEGER_EQ,
366
+ INTEGER_ORD_ORE,
367
+ INTEGER_ORD,
368
+ SMALLINT,
369
+ SMALLINT_EQ,
370
+ SMALLINT_ORD_ORE,
371
+ SMALLINT_ORD,
372
+ DATE,
373
+ DATE_EQ,
374
+ DATE_ORD_ORE,
375
+ DATE_ORD,
376
+ TIMESTAMP,
377
+ TIMESTAMP_EQ,
378
+ TIMESTAMP_ORD_ORE,
379
+ TIMESTAMP_ORD,
380
+ NUMERIC,
381
+ NUMERIC_EQ,
382
+ NUMERIC_ORD_ORE,
383
+ NUMERIC_ORD,
384
+ TEXT,
385
+ TEXT_EQ,
386
+ TEXT_MATCH,
387
+ TEXT_ORD_ORE,
388
+ TEXT_ORD,
389
+ BOOLEAN,
390
+ REAL,
391
+ REAL_EQ,
392
+ REAL_ORD_ORE,
393
+ REAL_ORD,
394
+ DOUBLE,
395
+ DOUBLE_EQ,
396
+ DOUBLE_ORD_ORE,
397
+ DOUBLE_ORD,
398
+ EncryptedV3Column,
399
+ EncryptedTextSearchColumn,
400
+ EncryptedIntegerColumn,
401
+ EncryptedIntegerEqColumn,
402
+ EncryptedIntegerOrdOreColumn,
403
+ EncryptedIntegerOrdColumn,
404
+ EncryptedSmallintColumn,
405
+ EncryptedSmallintEqColumn,
406
+ EncryptedSmallintOrdOreColumn,
407
+ EncryptedSmallintOrdColumn,
408
+ EncryptedDateColumn,
409
+ EncryptedDateEqColumn,
410
+ EncryptedDateOrdOreColumn,
411
+ EncryptedDateOrdColumn,
412
+ EncryptedTimestampColumn,
413
+ EncryptedTimestampEqColumn,
414
+ EncryptedTimestampOrdOreColumn,
415
+ EncryptedTimestampOrdColumn,
416
+ EncryptedNumericColumn,
417
+ EncryptedNumericEqColumn,
418
+ EncryptedNumericOrdOreColumn,
419
+ EncryptedNumericOrdColumn,
420
+ EncryptedTextColumn,
421
+ EncryptedTextEqColumn,
422
+ EncryptedTextMatchColumn,
423
+ EncryptedTextOrdOreColumn,
424
+ EncryptedTextOrdColumn,
425
+ EncryptedBooleanColumn,
426
+ EncryptedRealColumn,
427
+ EncryptedRealEqColumn,
428
+ EncryptedRealOrdOreColumn,
429
+ EncryptedRealOrdColumn,
430
+ EncryptedDoubleColumn,
431
+ EncryptedDoubleEqColumn,
432
+ EncryptedDoubleOrdOreColumn,
433
+ EncryptedDoubleOrdColumn
434
+ };
435
+ //# sourceMappingURL=chunk-U66S7VIF.js.map