@cipherstash/stack 0.18.0 → 1.0.0-rc.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 (111) hide show
  1. package/CHANGELOG.md +704 -0
  2. package/README.md +97 -79
  3. package/dist/adapter-kit.cjs +923 -0
  4. package/dist/adapter-kit.cjs.map +1 -0
  5. package/dist/adapter-kit.d.cts +82 -0
  6. package/dist/adapter-kit.d.ts +82 -0
  7. package/dist/adapter-kit.js +47 -0
  8. package/dist/adapter-kit.js.map +1 -0
  9. package/dist/base-operation-AOAIvsSB.d.cts +32 -0
  10. package/dist/base-operation-FXEzUXIq.d.ts +32 -0
  11. package/dist/{chunk-VPOTNP4K.js → chunk-3B5ZX3IS.js} +3 -1
  12. package/dist/chunk-3B5ZX3IS.js.map +1 -0
  13. package/dist/chunk-7333ZC6L.js +48 -0
  14. package/dist/chunk-7333ZC6L.js.map +1 -0
  15. package/dist/{chunk-XWPGAHBZ.js → chunk-BNO32ZMV.js} +1 -1
  16. package/dist/chunk-BNO32ZMV.js.map +1 -0
  17. package/dist/chunk-CLM7E4I6.js +4439 -0
  18. package/dist/chunk-CLM7E4I6.js.map +1 -0
  19. package/dist/{chunk-LLCCNKDL.js → chunk-HQANMV7R.js} +3 -3
  20. package/dist/{chunk-LLCCNKDL.js.map → chunk-HQANMV7R.js.map} +1 -1
  21. package/dist/chunk-JSG2AMDI.js +17 -0
  22. package/dist/chunk-JSG2AMDI.js.map +1 -0
  23. package/dist/chunk-OFQ555AX.js +191 -0
  24. package/dist/chunk-OFQ555AX.js.map +1 -0
  25. package/dist/chunk-PZ5AY32C.js +10 -0
  26. package/dist/chunk-PZ5AY32C.js.map +1 -0
  27. package/dist/chunk-V2Q3NYIH.js +494 -0
  28. package/dist/chunk-V2Q3NYIH.js.map +1 -0
  29. package/dist/chunk-X3JRXEIB.js +98 -0
  30. package/dist/chunk-X3JRXEIB.js.map +1 -0
  31. package/dist/{chunk-ZYOZHZMJ.js → chunk-ZTP5QJ27.js} +193 -169
  32. package/dist/chunk-ZTP5QJ27.js.map +1 -0
  33. package/dist/client.cjs +4124 -49
  34. package/dist/client.cjs.map +1 -1
  35. package/dist/client.d.cts +6 -5
  36. package/dist/client.d.ts +6 -5
  37. package/dist/client.js +3 -1
  38. package/dist/columns-D2_YzrCX.d.cts +622 -0
  39. package/dist/columns-rZc7fQHI.d.ts +622 -0
  40. package/dist/dynamodb/index.cjs +19 -12
  41. package/dist/dynamodb/index.cjs.map +1 -1
  42. package/dist/dynamodb/index.d.cts +3 -2
  43. package/dist/dynamodb/index.d.ts +3 -2
  44. package/dist/dynamodb/index.js +8 -10
  45. package/dist/dynamodb/index.js.map +1 -1
  46. package/dist/encryption/index.cjs +4496 -222
  47. package/dist/encryption/index.cjs.map +1 -1
  48. package/dist/encryption/index.d.cts +807 -6
  49. package/dist/encryption/index.d.ts +807 -6
  50. package/dist/encryption/index.js +15 -7
  51. package/dist/encryption/v3.cjs +7896 -0
  52. package/dist/encryption/v3.cjs.map +1 -0
  53. package/dist/encryption/v3.d.cts +103 -0
  54. package/dist/encryption/v3.d.ts +103 -0
  55. package/dist/encryption/v3.js +189 -0
  56. package/dist/encryption/v3.js.map +1 -0
  57. package/dist/eql/v3/index.cjs +663 -0
  58. package/dist/eql/v3/index.cjs.map +1 -0
  59. package/dist/eql/v3/index.d.cts +173 -0
  60. package/dist/eql/v3/index.d.ts +173 -0
  61. package/dist/eql/v3/index.js +99 -0
  62. package/dist/eql/v3/index.js.map +1 -0
  63. package/dist/errors/index.js +1 -0
  64. package/dist/identity/index.cjs +55 -35
  65. package/dist/identity/index.cjs.map +1 -1
  66. package/dist/identity/index.d.cts +54 -30
  67. package/dist/identity/index.d.ts +54 -30
  68. package/dist/identity/index.js +9 -177
  69. package/dist/identity/index.js.map +1 -1
  70. package/dist/index-BquA71_Y.d.ts +24 -0
  71. package/dist/index-fhWTOV0K.d.cts +24 -0
  72. package/dist/index.cjs +4547 -243
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.d.cts +18 -19
  75. package/dist/index.d.ts +18 -19
  76. package/dist/index.js +20 -5
  77. package/dist/index.js.map +1 -1
  78. package/dist/schema/index.cjs +4128 -49
  79. package/dist/schema/index.cjs.map +1 -1
  80. package/dist/schema/index.d.cts +1 -1
  81. package/dist/schema/index.d.ts +1 -1
  82. package/dist/schema/index.js +3 -1
  83. package/dist/{types-public-BTxqjmtv.d.cts → types-public-QMjYNfQO.d.cts} +448 -251
  84. package/dist/{types-public-BTxqjmtv.d.ts → types-public-QMjYNfQO.d.ts} +448 -251
  85. package/dist/types-public.cjs.map +1 -1
  86. package/dist/types-public.d.cts +2 -2
  87. package/dist/types-public.d.ts +2 -2
  88. package/dist/types-public.js +2 -1
  89. package/dist/wasm-inline.d.ts +1643 -0
  90. package/dist/wasm-inline.js +4901 -0
  91. package/dist/wasm-inline.js.map +1 -0
  92. package/package.json +74 -52
  93. package/dist/chunk-VPOTNP4K.js.map +0 -1
  94. package/dist/chunk-XWPGAHBZ.js.map +0 -1
  95. package/dist/chunk-YWQXTZ5M.js +0 -383
  96. package/dist/chunk-YWQXTZ5M.js.map +0 -1
  97. package/dist/chunk-ZYOZHZMJ.js.map +0 -1
  98. package/dist/client-CIsfZ2zg.d.ts +0 -692
  99. package/dist/client-Dt98Rugc.d.cts +0 -692
  100. package/dist/drizzle/index.cjs +0 -1558
  101. package/dist/drizzle/index.cjs.map +0 -1
  102. package/dist/drizzle/index.d.cts +0 -358
  103. package/dist/drizzle/index.d.ts +0 -358
  104. package/dist/drizzle/index.js +0 -1215
  105. package/dist/drizzle/index.js.map +0 -1
  106. package/dist/supabase/index.cjs +0 -1526
  107. package/dist/supabase/index.cjs.map +0 -1
  108. package/dist/supabase/index.d.cts +0 -144
  109. package/dist/supabase/index.d.ts +0 -144
  110. package/dist/supabase/index.js +0 -899
  111. package/dist/supabase/index.js.map +0 -1
@@ -1,181 +1,13 @@
1
1
  import {
2
- logger
3
- } from "../chunk-LLCCNKDL.js";
4
- import {
5
- EncryptionErrorTypes
6
- } from "../chunk-LBMC4D6D.js";
7
-
8
- // src/utils/config/index.ts
9
- import fs from "fs";
10
- import path from "path";
11
- function getWorkspaceCrn(tomlString) {
12
- let currentSection = "";
13
- let workspaceCrn;
14
- const lines = tomlString.split(/\r?\n/);
15
- for (const line of lines) {
16
- const trimmedLine = line.trim();
17
- if (!trimmedLine || trimmedLine.startsWith("#")) {
18
- continue;
19
- }
20
- const sectionMatch = trimmedLine.match(/^\[([^\]]+)\]$/);
21
- if (sectionMatch) {
22
- currentSection = sectionMatch[1];
23
- continue;
24
- }
25
- const kvMatch = trimmedLine.match(/^(\w+)\s*=\s*"([^"]+)"$/);
26
- if (kvMatch) {
27
- const [_, key, value] = kvMatch;
28
- if (currentSection === "auth" && key === "workspace_crn") {
29
- workspaceCrn = value;
30
- break;
31
- }
32
- }
33
- }
34
- return workspaceCrn;
35
- }
36
- function extractWorkspaceIdFromCrn(crn) {
37
- const match = crn.match(/crn:[^:]+:([^:]+)$/);
38
- if (!match) {
39
- throw new Error("Invalid CRN format");
40
- }
41
- return match[1];
42
- }
43
- function loadWorkSpaceId(suppliedCrn) {
44
- const configPath = path.join(process.cwd(), "cipherstash.toml");
45
- if (suppliedCrn) {
46
- return extractWorkspaceIdFromCrn(suppliedCrn);
47
- }
48
- if (!fs.existsSync(configPath) && !process.env.CS_WORKSPACE_CRN) {
49
- throw new Error(
50
- "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
51
- );
52
- }
53
- if (process.env.CS_WORKSPACE_CRN) {
54
- return extractWorkspaceIdFromCrn(process.env.CS_WORKSPACE_CRN);
55
- }
56
- if (!fs.existsSync(configPath)) {
57
- throw new Error(
58
- "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
59
- );
60
- }
61
- const tomlString = fs.readFileSync(configPath, "utf8");
62
- const workspaceCrn = getWorkspaceCrn(tomlString);
63
- if (!workspaceCrn) {
64
- throw new Error(
65
- "You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
66
- );
67
- }
68
- return extractWorkspaceIdFromCrn(workspaceCrn);
69
- }
70
-
71
- // src/identity/index.ts
72
- import { withResult } from "@byteslice/result";
73
- var LockContext = class {
74
- ctsToken;
75
- workspaceId;
76
- context;
77
- constructor({
78
- context = { identityClaim: ["sub"] },
79
- ctsToken
80
- } = {}) {
81
- const workspaceId = loadWorkSpaceId();
82
- if (!workspaceId) {
83
- throw new Error(
84
- "You have not defined a workspace ID in your config file, or the CS_WORKSPACE_CRN environment variable."
85
- );
86
- }
87
- if (ctsToken) {
88
- this.ctsToken = ctsToken;
89
- }
90
- this.workspaceId = workspaceId;
91
- this.context = context;
92
- logger.debug("Successfully initialized the EQL lock context.");
93
- }
94
- /**
95
- * Exchange a user's JWT for a CTS token and bind it to this lock context.
96
- *
97
- * @param jwtToken - A valid OIDC / JWT token for the current user.
98
- * @returns A `Result` containing this `LockContext` (now authenticated) or an error.
99
- *
100
- * @example
101
- * ```typescript
102
- * const lc = new LockContext()
103
- * const result = await lc.identify(userJwt)
104
- * if (result.failure) {
105
- * console.error("Auth failed:", result.failure.message)
106
- * }
107
- * ```
108
- */
109
- async identify(jwtToken) {
110
- const workspaceId = this.workspaceId;
111
- const ctsEndpoint = process.env.CS_CTS_ENDPOINT || "https://ap-southeast-2.aws.auth.viturhosted.net";
112
- const ctsFetchResult = await withResult(
113
- () => fetch(`${ctsEndpoint}/api/authorize`, {
114
- method: "POST",
115
- headers: {
116
- "Content-Type": "application/json"
117
- },
118
- body: JSON.stringify({
119
- workspaceId,
120
- oidcToken: jwtToken
121
- })
122
- }),
123
- (error) => ({
124
- type: EncryptionErrorTypes.CtsTokenError,
125
- message: error.message
126
- })
127
- );
128
- if (ctsFetchResult.failure) {
129
- return ctsFetchResult;
130
- }
131
- const identifiedLockContext = await withResult(
132
- async () => {
133
- const ctsToken = await ctsFetchResult.data.json();
134
- if (!ctsToken.accessToken) {
135
- throw new Error(
136
- "The response from the CipherStash API did not contain an access token. Please contact support."
137
- );
138
- }
139
- this.ctsToken = ctsToken;
140
- return this;
141
- },
142
- (error) => ({
143
- type: EncryptionErrorTypes.CtsTokenError,
144
- message: error.message
145
- })
146
- );
147
- return identifiedLockContext;
148
- }
149
- /**
150
- * Retrieve the current CTS token and context for use with encryption operations.
151
- *
152
- * Must be called after {@link identify}. Returns the token/context pair that
153
- * `.withLockContext()` expects.
154
- *
155
- * @returns A `Result` containing the CTS token and identity context, or an error
156
- * if {@link identify} has not been called.
157
- */
158
- getLockContext() {
159
- return withResult(
160
- () => {
161
- if (!this.ctsToken?.accessToken || !this.ctsToken?.expiry) {
162
- throw new Error(
163
- "The CTS token is not set. Please call identify() with a users JWT token, or pass an existing CTS token to the LockContext constructor before calling getLockContext()."
164
- );
165
- }
166
- return {
167
- context: this.context,
168
- ctsToken: this.ctsToken
169
- };
170
- },
171
- (error) => ({
172
- type: EncryptionErrorTypes.CtsTokenError,
173
- message: error.message
174
- })
175
- );
176
- }
177
- };
2
+ LockContext,
3
+ resolveLockContext
4
+ } from "../chunk-OFQ555AX.js";
5
+ import "../chunk-JSG2AMDI.js";
6
+ import "../chunk-HQANMV7R.js";
7
+ import "../chunk-LBMC4D6D.js";
8
+ import "../chunk-PZ5AY32C.js";
178
9
  export {
179
- LockContext
10
+ LockContext,
11
+ resolveLockContext
180
12
  };
181
13
  //# sourceMappingURL=index.js.map
@@ -1 +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 EncryptionError, EncryptionErrorTypes } from '@/errors'\nimport { loadWorkSpaceId } from '@/utils/config'\nimport { logger } from '@/utils/logger'\nimport { type Result, withResult } from '@byteslice/result'\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 * Manages CipherStash lock contexts for row-level access control.\n *\n * A `LockContext` ties encryption/decryption operations to an authenticated\n * user identity via CTS (CipherStash Token Service). Call {@link identify}\n * with a user's JWT to obtain a CTS token, then pass the `LockContext`\n * to `.withLockContext()` on any encrypt/decrypt operation.\n *\n * @example\n * ```typescript\n * import { LockContext } from \"@cipherstash/stack/identity\"\n *\n * const lc = new LockContext()\n * const identified = await lc.identify(userJwt)\n *\n * if (identified.failure) throw new Error(identified.failure.message)\n *\n * const result = await client\n * .encrypt(value, { column: users.email, table: users })\n * .withLockContext(identified.data)\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 * Exchange a user's JWT for a CTS token and bind it to this lock context.\n *\n * @param jwtToken - A valid OIDC / JWT token for the current user.\n * @returns A `Result` containing this `LockContext` (now authenticated) or an error.\n *\n * @example\n * ```typescript\n * const lc = new LockContext()\n * const result = await lc.identify(userJwt)\n * if (result.failure) {\n * console.error(\"Auth failed:\", result.failure.message)\n * }\n * ```\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 current CTS token and context for use with encryption operations.\n *\n * Must be called after {@link identify}. Returns the token/context pair that\n * `.withLockContext()` expects.\n *\n * @returns A `Result` containing the CTS token and identity context, or an error\n * if {@link identify} has not been called.\n */\n getLockContext(): Promise<Result<GetLockContextResponse, EncryptionError>> {\n return withResult(\n () => {\n if (!this.ctsToken?.accessToken || !this.ctsToken?.expiry) {\n throw new Error(\n 'The CTS token is not set. Please call identify() with a users JWT token, or pass an existing CTS token to the LockContext constructor before calling getLockContext().',\n )\n }\n\n return {\n context: this.context,\n ctsToken: this.ctsToken,\n }\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,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A,MACjB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,iBAA2E;AACzE,WAAO;AAAA,MACL,MAAM;AACJ,YAAI,CAAC,KAAK,UAAU,eAAe,CAAC,KAAK,UAAU,QAAQ;AACzD,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,eAAO;AAAA,UACL,SAAS,KAAK;AAAA,UACd,UAAU,KAAK;AAAA,QACjB;AAAA,MACF;AAAA,MACA,CAAC,WAAW;AAAA,QACV,MAAM,qBAAqB;AAAA,QAC3B,SAAS,MAAM;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,24 @@
1
+ import { p as Encrypted } from './types-public-QMjYNfQO.js';
2
+
3
+ type EncryptedPgComposite = {
4
+ data: Encrypted;
5
+ };
6
+ /**
7
+ * Helper function to transform an encrypted payload into a PostgreSQL composite type.
8
+ * Use this when inserting data via Supabase or similar clients.
9
+ */
10
+ declare function encryptedToPgComposite(obj: Encrypted): EncryptedPgComposite;
11
+ /**
12
+ * Helper function to transform a model's encrypted fields into PostgreSQL composite types
13
+ */
14
+ declare function modelToEncryptedPgComposites<T extends Record<string, unknown>>(model: T): T;
15
+ /**
16
+ * Helper function to transform multiple models' encrypted fields into PostgreSQL composite types
17
+ */
18
+ declare function bulkModelsToEncryptedPgComposites<T extends Record<string, unknown>>(models: T[]): T[];
19
+ /**
20
+ * Helper function to check if a value is an encrypted payload
21
+ */
22
+ declare function isEncryptedPayload(value: unknown): value is Encrypted;
23
+
24
+ export { bulkModelsToEncryptedPgComposites as b, encryptedToPgComposite as e, isEncryptedPayload as i, modelToEncryptedPgComposites as m };
@@ -0,0 +1,24 @@
1
+ import { p as Encrypted } from './types-public-QMjYNfQO.cjs';
2
+
3
+ type EncryptedPgComposite = {
4
+ data: Encrypted;
5
+ };
6
+ /**
7
+ * Helper function to transform an encrypted payload into a PostgreSQL composite type.
8
+ * Use this when inserting data via Supabase or similar clients.
9
+ */
10
+ declare function encryptedToPgComposite(obj: Encrypted): EncryptedPgComposite;
11
+ /**
12
+ * Helper function to transform a model's encrypted fields into PostgreSQL composite types
13
+ */
14
+ declare function modelToEncryptedPgComposites<T extends Record<string, unknown>>(model: T): T;
15
+ /**
16
+ * Helper function to transform multiple models' encrypted fields into PostgreSQL composite types
17
+ */
18
+ declare function bulkModelsToEncryptedPgComposites<T extends Record<string, unknown>>(models: T[]): T[];
19
+ /**
20
+ * Helper function to check if a value is an encrypted payload
21
+ */
22
+ declare function isEncryptedPayload(value: unknown): value is Encrypted;
23
+
24
+ export { bulkModelsToEncryptedPgComposites as b, encryptedToPgComposite as e, isEncryptedPayload as i, modelToEncryptedPgComposites as m };