@cipherstash/stack 0.10.0 → 0.12.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 (61) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +38 -18
  3. package/dist/bin/stash.js +160 -117
  4. package/dist/bin/stash.js.map +1 -1
  5. package/dist/{chunk-HCL75LXQ.js → chunk-46PDK2Z6.js} +1 -1
  6. package/dist/chunk-46PDK2Z6.js.map +1 -0
  7. package/dist/{chunk-3BOJHROP.js → chunk-EHDOOLWU.js} +3 -3
  8. package/dist/{chunk-Y3KSTOVR.js → chunk-GNLU3I27.js} +14 -3
  9. package/dist/chunk-GNLU3I27.js.map +1 -0
  10. package/dist/{chunk-4C52Q5R6.js → chunk-O4MBO4DJ.js} +8 -22
  11. package/dist/chunk-O4MBO4DJ.js.map +1 -0
  12. package/dist/{client-_63nbmO7.d.ts → client-CZLBiToT.d.ts} +1 -7
  13. package/dist/{client-CV7X5Hrt.d.cts → client-bW-5wG9Y.d.cts} +1 -7
  14. package/dist/client.cjs +13 -2
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.d.cts +2 -2
  17. package/dist/client.d.ts +2 -2
  18. package/dist/client.js +1 -1
  19. package/dist/drizzle/index.cjs +13 -2
  20. package/dist/drizzle/index.cjs.map +1 -1
  21. package/dist/drizzle/index.d.cts +2 -2
  22. package/dist/drizzle/index.d.ts +2 -2
  23. package/dist/drizzle/index.js +2 -2
  24. package/dist/dynamodb/index.d.cts +2 -2
  25. package/dist/dynamodb/index.d.ts +2 -2
  26. package/dist/encryption/index.cjs +22 -96
  27. package/dist/encryption/index.cjs.map +1 -1
  28. package/dist/encryption/index.d.cts +2 -2
  29. package/dist/encryption/index.d.ts +2 -2
  30. package/dist/encryption/index.js +3 -4
  31. package/dist/index.cjs +29 -81
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +3 -3
  34. package/dist/index.d.ts +3 -3
  35. package/dist/index.js +4 -4
  36. package/dist/schema/index.cjs +13 -2
  37. package/dist/schema/index.cjs.map +1 -1
  38. package/dist/schema/index.d.cts +1 -1
  39. package/dist/schema/index.d.ts +1 -1
  40. package/dist/schema/index.js +1 -1
  41. package/dist/secrets/index.cjs +29 -81
  42. package/dist/secrets/index.cjs.map +1 -1
  43. package/dist/secrets/index.d.cts +1 -1
  44. package/dist/secrets/index.d.ts +1 -1
  45. package/dist/secrets/index.js +4 -4
  46. package/dist/supabase/index.cjs +12 -2
  47. package/dist/supabase/index.cjs.map +1 -1
  48. package/dist/supabase/index.d.cts +2 -2
  49. package/dist/supabase/index.d.ts +2 -2
  50. package/dist/supabase/index.js +1 -1
  51. package/dist/{types-public-B5YxQhR6.d.cts → types-public-WADaA-TW.d.cts} +119 -1
  52. package/dist/{types-public-B5YxQhR6.d.ts → types-public-WADaA-TW.d.ts} +119 -1
  53. package/dist/types-public.cjs.map +1 -1
  54. package/dist/types-public.d.cts +1 -1
  55. package/dist/types-public.d.ts +1 -1
  56. package/dist/types-public.js +1 -1
  57. package/package.json +6 -5
  58. package/dist/chunk-4C52Q5R6.js.map +0 -1
  59. package/dist/chunk-HCL75LXQ.js.map +0 -1
  60. package/dist/chunk-Y3KSTOVR.js.map +0 -1
  61. /package/dist/{chunk-3BOJHROP.js.map → chunk-EHDOOLWU.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import '../errors/index.cjs';
2
- import '../types-public-B5YxQhR6.cjs';
2
+ import '../types-public-WADaA-TW.cjs';
3
3
  import '@byteslice/result';
4
4
  import '@cipherstash/protect-ffi';
5
- export { E as Encryption, a as EncryptionClient, n as noClientError } from '../client-CV7X5Hrt.cjs';
5
+ export { E as Encryption, a as EncryptionClient, n as noClientError } from '../client-bW-5wG9Y.cjs';
6
6
  import 'zod';
7
7
  import '../identity/index.cjs';
@@ -1,7 +1,7 @@
1
1
  import '../errors/index.js';
2
- import '../types-public-B5YxQhR6.js';
2
+ import '../types-public-WADaA-TW.js';
3
3
  import '@byteslice/result';
4
4
  import '@cipherstash/protect-ffi';
5
- export { E as Encryption, a as EncryptionClient, n as noClientError } from '../client-_63nbmO7.js';
5
+ export { E as Encryption, a as EncryptionClient, n as noClientError } from '../client-CZLBiToT.js';
6
6
  import 'zod';
7
7
  import '../identity/index.js';
@@ -2,11 +2,10 @@ import {
2
2
  Encryption,
3
3
  EncryptionClient,
4
4
  noClientError
5
- } from "../chunk-4C52Q5R6.js";
5
+ } from "../chunk-O4MBO4DJ.js";
6
6
  import "../chunk-4RNBI3UH.js";
7
- import "../chunk-Y3KSTOVR.js";
8
- import "../chunk-HCL75LXQ.js";
9
- import "../chunk-GXGEW6T4.js";
7
+ import "../chunk-GNLU3I27.js";
8
+ import "../chunk-46PDK2Z6.js";
10
9
  import "../chunk-Q5FTQLYG.js";
11
10
  import "../chunk-LBMC4D6D.js";
12
11
  export {
package/dist/index.cjs CHANGED
@@ -77,8 +77,18 @@ var matchIndexOptsSchema = import_zod.z.object({
77
77
  m: import_zod.z.number().default(2048).optional(),
78
78
  include_original: import_zod.z.boolean().default(false).optional()
79
79
  });
80
+ var arrayIndexModeSchema = import_zod.z.union([
81
+ import_zod.z.literal("all"),
82
+ import_zod.z.literal("none"),
83
+ import_zod.z.object({
84
+ item: import_zod.z.boolean().optional(),
85
+ wildcard: import_zod.z.boolean().optional(),
86
+ position: import_zod.z.boolean().optional()
87
+ })
88
+ ]);
80
89
  var steVecIndexOptsSchema = import_zod.z.object({
81
- prefix: import_zod.z.string()
90
+ prefix: import_zod.z.string(),
91
+ array_index_mode: arrayIndexModeSchema.optional()
82
92
  });
83
93
  var indexesSchema = import_zod.z.object({
84
94
  ore: oreIndexOptsSchema.optional(),
@@ -275,7 +285,7 @@ var EncryptedColumn = class {
275
285
  */
276
286
  searchableJson() {
277
287
  this.castAsValue = "json";
278
- this.indexesValue.ste_vec = { prefix: "enabled" };
288
+ this.indexesValue.ste_vec = { prefix: "enabled", array_index_mode: "all" };
279
289
  return this;
280
290
  }
281
291
  build() {
@@ -323,6 +333,7 @@ var EncryptedTable = class {
323
333
  indexes: {
324
334
  ...builtColumn.indexes,
325
335
  ste_vec: {
336
+ ...builtColumn.indexes.ste_vec,
326
337
  prefix: `${this.tableName}/${colName}`
327
338
  }
328
339
  }
@@ -387,69 +398,6 @@ var EncryptionErrorTypes = {
387
398
  CtsTokenError: "CtsTokenError"
388
399
  };
389
400
 
390
- // src/utils/config/index.ts
391
- var import_node_fs = __toESM(require("fs"), 1);
392
- var import_node_path = __toESM(require("path"), 1);
393
- function getWorkspaceCrn(tomlString) {
394
- let currentSection = "";
395
- let workspaceCrn;
396
- const lines = tomlString.split(/\r?\n/);
397
- for (const line of lines) {
398
- const trimmedLine = line.trim();
399
- if (!trimmedLine || trimmedLine.startsWith("#")) {
400
- continue;
401
- }
402
- const sectionMatch = trimmedLine.match(/^\[([^\]]+)\]$/);
403
- if (sectionMatch) {
404
- currentSection = sectionMatch[1];
405
- continue;
406
- }
407
- const kvMatch = trimmedLine.match(/^(\w+)\s*=\s*"([^"]+)"$/);
408
- if (kvMatch) {
409
- const [_, key, value] = kvMatch;
410
- if (currentSection === "auth" && key === "workspace_crn") {
411
- workspaceCrn = value;
412
- break;
413
- }
414
- }
415
- }
416
- return workspaceCrn;
417
- }
418
- function extractWorkspaceIdFromCrn(crn) {
419
- const match = crn.match(/crn:[^:]+:([^:]+)$/);
420
- if (!match) {
421
- throw new Error("Invalid CRN format");
422
- }
423
- return match[1];
424
- }
425
- function loadWorkSpaceId(suppliedCrn) {
426
- const configPath = import_node_path.default.join(process.cwd(), "cipherstash.toml");
427
- if (suppliedCrn) {
428
- return extractWorkspaceIdFromCrn(suppliedCrn);
429
- }
430
- if (!import_node_fs.default.existsSync(configPath) && !process.env.CS_WORKSPACE_CRN) {
431
- throw new Error(
432
- "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
433
- );
434
- }
435
- if (process.env.CS_WORKSPACE_CRN) {
436
- return extractWorkspaceIdFromCrn(process.env.CS_WORKSPACE_CRN);
437
- }
438
- if (!import_node_fs.default.existsSync(configPath)) {
439
- throw new Error(
440
- "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
441
- );
442
- }
443
- const tomlString = import_node_fs.default.readFileSync(configPath, "utf8");
444
- const workspaceCrn = getWorkspaceCrn(tomlString);
445
- if (!workspaceCrn) {
446
- throw new Error(
447
- "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
448
- );
449
- }
450
- return extractWorkspaceIdFromCrn(workspaceCrn);
451
- }
452
-
453
401
  // src/utils/logger/index.ts
454
402
  var import_evlog = require("evlog");
455
403
  var validLevels = ["debug", "info", "error"];
@@ -2409,11 +2357,6 @@ var noClientError = () => new Error(
2409
2357
  var EncryptionClient = class {
2410
2358
  client;
2411
2359
  encryptConfig;
2412
- workspaceId;
2413
- constructor(workspaceCrn) {
2414
- const workspaceId = loadWorkSpaceId(workspaceCrn);
2415
- this.workspaceId = workspaceId;
2416
- }
2417
2360
  /**
2418
2361
  * Initializes the EncryptionClient with the provided configuration.
2419
2362
  * @internal
@@ -2435,10 +2378,10 @@ var EncryptionClient = class {
2435
2378
  this.client = await (0, import_protect_ffi9.newClient)({
2436
2379
  encryptConfig: validated,
2437
2380
  clientOpts: {
2438
- workspaceCrn: config.workspaceCrn ?? process.env.CS_WORKSPACE_CRN,
2439
- accessKey: config.accessKey ?? process.env.CS_CLIENT_ACCESS_KEY,
2440
- clientId: config.clientId ?? process.env.CS_CLIENT_ID,
2441
- clientKey: config.clientKey ?? process.env.CS_CLIENT_KEY,
2381
+ workspaceCrn: config.workspaceCrn,
2382
+ accessKey: config.accessKey,
2383
+ clientId: config.clientId,
2384
+ clientKey: config.clientKey,
2442
2385
  keyset: toFfiKeysetIdentifier(config.keyset)
2443
2386
  }
2444
2387
  });
@@ -2823,12 +2766,6 @@ var EncryptionClient = class {
2823
2766
  bulkDecrypt(encryptedPayloads) {
2824
2767
  return new BulkDecryptOperation(this.client, encryptedPayloads);
2825
2768
  }
2826
- /** e.g., debugging or environment info */
2827
- clientInfo() {
2828
- return {
2829
- workspaceId: this.workspaceId
2830
- };
2831
- }
2832
2769
  /**
2833
2770
  * Get the encrypt config object.
2834
2771
  *
@@ -2850,7 +2787,7 @@ var Encryption = async (config) => {
2850
2787
  "[encryption]: Invalid UUID provided for keyset id. Must be a valid UUID."
2851
2788
  );
2852
2789
  }
2853
- const client = new EncryptionClient(clientConfig?.workspaceCrn);
2790
+ const client = new EncryptionClient();
2854
2791
  const encryptConfig = buildEncryptConfig(...schemas);
2855
2792
  const result = await client.init({
2856
2793
  encryptConfig,
@@ -2862,6 +2799,17 @@ var Encryption = async (config) => {
2862
2799
  return result.data;
2863
2800
  };
2864
2801
 
2802
+ // src/utils/config/index.ts
2803
+ var import_node_fs = __toESM(require("fs"), 1);
2804
+ var import_node_path = __toESM(require("path"), 1);
2805
+ function extractWorkspaceIdFromCrn(crn) {
2806
+ const match = crn.match(/crn:[^:]+:([^:]+)$/);
2807
+ if (!match) {
2808
+ throw new Error("Invalid CRN format");
2809
+ }
2810
+ return match[1];
2811
+ }
2812
+
2865
2813
  // src/secrets/index.ts
2866
2814
  var Secrets = class {
2867
2815
  encryptionClient = null;