@cipherstash/stack 0.1.0 → 0.2.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 (40) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +10 -12
  3. package/dist/bin/stash.js +27 -12
  4. package/dist/bin/stash.js.map +1 -1
  5. package/dist/{chunk-SJ7JO4ME.js → chunk-5G4F4JJG.js} +1 -1
  6. package/dist/{chunk-SJ7JO4ME.js.map → chunk-5G4F4JJG.js.map} +1 -1
  7. package/dist/{chunk-2GZMIJFO.js → chunk-LHZ6KZIG.js} +29 -14
  8. package/dist/chunk-LHZ6KZIG.js.map +1 -0
  9. package/dist/{client-DtGq9dJp.d.ts → client-BV9pXC-d.d.ts} +30 -15
  10. package/dist/{client-BxJG56Ey.d.cts → client-D-ZH8SB2.d.cts} +30 -15
  11. package/dist/client.d.cts +2 -2
  12. package/dist/client.d.ts +2 -2
  13. package/dist/drizzle/index.cjs.map +1 -1
  14. package/dist/drizzle/index.d.cts +2 -2
  15. package/dist/drizzle/index.d.ts +2 -2
  16. package/dist/drizzle/index.js +1 -1
  17. package/dist/dynamodb/index.d.cts +2 -2
  18. package/dist/dynamodb/index.d.ts +2 -2
  19. package/dist/index.cjs +27 -12
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +3 -3
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.js +2 -2
  24. package/dist/schema/index.d.cts +1 -1
  25. package/dist/schema/index.d.ts +1 -1
  26. package/dist/secrets/index.cjs +27 -12
  27. package/dist/secrets/index.cjs.map +1 -1
  28. package/dist/secrets/index.d.cts +1 -1
  29. package/dist/secrets/index.d.ts +1 -1
  30. package/dist/secrets/index.js +2 -2
  31. package/dist/supabase/index.d.cts +2 -2
  32. package/dist/supabase/index.d.ts +2 -2
  33. package/dist/{types-public-BCj1L4fi.d.ts → types-public-Dfg-hkuQ.d.cts} +35 -11
  34. package/dist/{types-public-BCj1L4fi.d.cts → types-public-Dfg-hkuQ.d.ts} +35 -11
  35. package/dist/types-public.cjs.map +1 -1
  36. package/dist/types-public.d.cts +1 -1
  37. package/dist/types-public.d.ts +1 -1
  38. package/dist/types-public.js +1 -1
  39. package/package.json +1 -1
  40. package/dist/chunk-2GZMIJFO.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { E as EncryptionClient } from './client-BxJG56Ey.cjs';
2
- import { E as EncryptionClientConfig } from './types-public-BCj1L4fi.cjs';
3
- export { c as InferEncrypted, I as InferPlaintext, P as ProtectColumn, d as ProtectTable, f as ProtectTableColumn, g as ProtectValue, a as encryptedColumn, e as encryptedTable, b as encryptedValue } from './types-public-BCj1L4fi.cjs';
1
+ import { E as EncryptionClient } from './client-D-ZH8SB2.cjs';
2
+ import { E as EncryptionClientConfig } from './types-public-Dfg-hkuQ.cjs';
3
+ export { h as EncryptedFromSchema, c as InferEncrypted, I as InferPlaintext, P as ProtectColumn, d as ProtectTable, f as ProtectTableColumn, g as ProtectValue, a as encryptedColumn, e as encryptedTable, b as encryptedValue } from './types-public-Dfg-hkuQ.cjs';
4
4
  export { C as ClientInitError, c as CtsTokenError, D as DecryptionOperationError, a as EncryptionError, E as EncryptionErrorTypes, b as EncryptionOperationError, L as LockContextError, S as StackError, g as getErrorMessage } from './index-9-Ya3fDK.cjs';
5
5
  import '@byteslice/result';
6
6
  import '@cipherstash/protect-ffi';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { E as EncryptionClient } from './client-DtGq9dJp.js';
2
- import { E as EncryptionClientConfig } from './types-public-BCj1L4fi.js';
3
- export { c as InferEncrypted, I as InferPlaintext, P as ProtectColumn, d as ProtectTable, f as ProtectTableColumn, g as ProtectValue, a as encryptedColumn, e as encryptedTable, b as encryptedValue } from './types-public-BCj1L4fi.js';
1
+ import { E as EncryptionClient } from './client-BV9pXC-d.js';
2
+ import { E as EncryptionClientConfig } from './types-public-Dfg-hkuQ.js';
3
+ export { h as EncryptedFromSchema, c as InferEncrypted, I as InferPlaintext, P as ProtectColumn, d as ProtectTable, f as ProtectTableColumn, g as ProtectValue, a as encryptedColumn, e as encryptedTable, b as encryptedValue } from './types-public-Dfg-hkuQ.js';
4
4
  export { C as ClientInitError, c as CtsTokenError, D as DecryptionOperationError, a as EncryptionError, E as EncryptionErrorTypes, b as EncryptionOperationError, L as LockContextError, S as StackError, g as getErrorMessage } from './index-9-Ya3fDK.js';
5
5
  import '@byteslice/result';
6
6
  import '@cipherstash/protect-ffi';
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Encryption
3
- } from "./chunk-2GZMIJFO.js";
3
+ } from "./chunk-LHZ6KZIG.js";
4
4
  import "./chunk-SUYMGQBY.js";
5
- import "./chunk-SJ7JO4ME.js";
5
+ import "./chunk-5G4F4JJG.js";
6
6
  import {
7
7
  EncryptionErrorTypes,
8
8
  getErrorMessage
@@ -1,4 +1,4 @@
1
- export { C as CastAs, v as ColumnSchema, r as EncryptConfig, c as InferEncrypted, I as InferPlaintext, M as MatchIndexOpts, O as OreIndexOpts, P as ProtectColumn, d as ProtectTable, f as ProtectTableColumn, g as ProtectValue, u as SteVecIndexOpts, T as TokenFilter, U as UniqueIndexOpts, w as buildEncryptConfig, s as castAsEnum, t as encryptConfigSchema, a as encryptedColumn, e as encryptedTable, b as encryptedValue } from '../types-public-BCj1L4fi.cjs';
1
+ export { C as CastAs, w as ColumnSchema, s as EncryptConfig, c as InferEncrypted, I as InferPlaintext, M as MatchIndexOpts, O as OreIndexOpts, P as ProtectColumn, d as ProtectTable, f as ProtectTableColumn, g as ProtectValue, v as SteVecIndexOpts, T as TokenFilter, U as UniqueIndexOpts, x as buildEncryptConfig, t as castAsEnum, u as encryptConfigSchema, a as encryptedColumn, e as encryptedTable, b as encryptedValue } from '../types-public-Dfg-hkuQ.cjs';
2
2
  import 'zod';
3
3
  import 'evlog';
4
4
  import '@cipherstash/protect-ffi';
@@ -1,4 +1,4 @@
1
- export { C as CastAs, v as ColumnSchema, r as EncryptConfig, c as InferEncrypted, I as InferPlaintext, M as MatchIndexOpts, O as OreIndexOpts, P as ProtectColumn, d as ProtectTable, f as ProtectTableColumn, g as ProtectValue, u as SteVecIndexOpts, T as TokenFilter, U as UniqueIndexOpts, w as buildEncryptConfig, s as castAsEnum, t as encryptConfigSchema, a as encryptedColumn, e as encryptedTable, b as encryptedValue } from '../types-public-BCj1L4fi.js';
1
+ export { C as CastAs, w as ColumnSchema, s as EncryptConfig, c as InferEncrypted, I as InferPlaintext, M as MatchIndexOpts, O as OreIndexOpts, P as ProtectColumn, d as ProtectTable, f as ProtectTableColumn, g as ProtectValue, v as SteVecIndexOpts, T as TokenFilter, U as UniqueIndexOpts, x as buildEncryptConfig, t as castAsEnum, u as encryptConfigSchema, a as encryptedColumn, e as encryptedTable, b as encryptedValue } from '../types-public-Dfg-hkuQ.js';
2
2
  import 'zod';
3
3
  import 'evlog';
4
4
  import '@cipherstash/protect-ffi';
@@ -2493,10 +2493,10 @@ var EncryptionClient = class {
2493
2493
  this.client = await (0, import_protect_ffi9.newClient)({
2494
2494
  encryptConfig: validated,
2495
2495
  clientOpts: {
2496
- workspaceCrn: config.workspaceCrn,
2497
- accessKey: config.accessKey,
2498
- clientId: config.clientId,
2499
- clientKey: config.clientKey,
2496
+ workspaceCrn: config.workspaceCrn ?? process.env.CS_WORKSPACE_CRN,
2497
+ accessKey: config.accessKey ?? process.env.CS_CLIENT_ACCESS_KEY,
2498
+ clientId: config.clientId ?? process.env.CS_CLIENT_ID,
2499
+ clientKey: config.clientKey ?? process.env.CS_CLIENT_KEY,
2500
2500
  keyset: toFfiKeysetIdentifier(config.keyset)
2501
2501
  }
2502
2502
  });
@@ -2646,10 +2646,16 @@ var EncryptionClient = class {
2646
2646
  * All other fields are passed through unchanged. Returns a thenable operation
2647
2647
  * that supports `.withLockContext()` for identity-aware encryption.
2648
2648
  *
2649
+ * The return type is **schema-aware**: fields matching the table schema are
2650
+ * typed as `Encrypted`, while other fields retain their original types. For
2651
+ * best results, let TypeScript infer the type parameters from the arguments
2652
+ * rather than providing an explicit type argument.
2653
+ *
2649
2654
  * @param input - The model object with plaintext values to encrypt.
2650
2655
  * @param table - The table schema defining which fields to encrypt.
2651
- * @returns An `EncryptModelOperation<T>` that can be awaited to get a `Result`
2652
- * containing the model with encrypted fields, or an `EncryptionError`.
2656
+ * @returns An `EncryptModelOperation` that can be awaited to get a `Result`
2657
+ * containing the model with schema-defined fields typed as `Encrypted`,
2658
+ * or an `EncryptionError`.
2653
2659
  *
2654
2660
  * @example
2655
2661
  * ```typescript
@@ -2664,7 +2670,9 @@ var EncryptionClient = class {
2664
2670
  *
2665
2671
  * const client = await Encryption({ schemas: [usersSchema] })
2666
2672
  *
2667
- * const result = await client.encryptModel<User>(
2673
+ * // Let TypeScript infer the return type from the schema.
2674
+ * // result.data.email is typed as `Encrypted`, result.data.id stays `string`.
2675
+ * const result = await client.encryptModel(
2668
2676
  * { id: "user_123", email: "alice@example.com", createdAt: new Date() },
2669
2677
  * usersSchema,
2670
2678
  * )
@@ -2672,8 +2680,8 @@ var EncryptionClient = class {
2672
2680
  * if (result.failure) {
2673
2681
  * console.error(result.failure.message)
2674
2682
  * } else {
2675
- * // result.data.id is unchanged, result.data.email is encrypted
2676
- * console.log(result.data)
2683
+ * console.log(result.data.id) // string
2684
+ * console.log(result.data.email) // Encrypted
2677
2685
  * }
2678
2686
  * ```
2679
2687
  */
@@ -2718,10 +2726,15 @@ var EncryptionClient = class {
2718
2726
  * while still using a unique key for each encrypted value. Only fields
2719
2727
  * matching the table schema are encrypted; other fields pass through unchanged.
2720
2728
  *
2729
+ * The return type is **schema-aware**: fields matching the table schema are
2730
+ * typed as `Encrypted`, while other fields retain their original types. For
2731
+ * best results, let TypeScript infer the type parameters from the arguments.
2732
+ *
2721
2733
  * @param input - An array of model objects with plaintext values to encrypt.
2722
2734
  * @param table - The table schema defining which fields to encrypt.
2723
- * @returns A `BulkEncryptModelsOperation<T>` that can be awaited to get a `Result`
2724
- * containing an array of models with encrypted fields, or an `EncryptionError`.
2735
+ * @returns A `BulkEncryptModelsOperation` that can be awaited to get a `Result`
2736
+ * containing an array of models with schema-defined fields typed as `Encrypted`,
2737
+ * or an `EncryptionError`.
2725
2738
  *
2726
2739
  * @example
2727
2740
  * ```typescript
@@ -2736,7 +2749,9 @@ var EncryptionClient = class {
2736
2749
  *
2737
2750
  * const client = await Encryption({ schemas: [usersSchema] })
2738
2751
  *
2739
- * const result = await client.bulkEncryptModels<User>(
2752
+ * // Let TypeScript infer the return type from the schema.
2753
+ * // Each item's email is typed as `Encrypted`, id stays `string`.
2754
+ * const result = await client.bulkEncryptModels(
2740
2755
  * [
2741
2756
  * { id: "1", email: "alice@example.com" },
2742
2757
  * { id: "2", email: "bob@example.com" },