@cipherstash/stack 0.1.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 (76) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +670 -0
  4. package/dist/bin/stash.js +5049 -0
  5. package/dist/bin/stash.js.map +1 -0
  6. package/dist/chunk-2GZMIJFO.js +2400 -0
  7. package/dist/chunk-2GZMIJFO.js.map +1 -0
  8. package/dist/chunk-5DCT6YU2.js +138 -0
  9. package/dist/chunk-5DCT6YU2.js.map +1 -0
  10. package/dist/chunk-7XRPN2KX.js +336 -0
  11. package/dist/chunk-7XRPN2KX.js.map +1 -0
  12. package/dist/chunk-SJ7JO4ME.js +28 -0
  13. package/dist/chunk-SJ7JO4ME.js.map +1 -0
  14. package/dist/chunk-SUYMGQBY.js +67 -0
  15. package/dist/chunk-SUYMGQBY.js.map +1 -0
  16. package/dist/client-BxJG56Ey.d.cts +647 -0
  17. package/dist/client-DtGq9dJp.d.ts +647 -0
  18. package/dist/client.cjs +347 -0
  19. package/dist/client.cjs.map +1 -0
  20. package/dist/client.d.cts +7 -0
  21. package/dist/client.d.ts +7 -0
  22. package/dist/client.js +11 -0
  23. package/dist/client.js.map +1 -0
  24. package/dist/drizzle/index.cjs +1528 -0
  25. package/dist/drizzle/index.cjs.map +1 -0
  26. package/dist/drizzle/index.d.cts +350 -0
  27. package/dist/drizzle/index.d.ts +350 -0
  28. package/dist/drizzle/index.js +1212 -0
  29. package/dist/drizzle/index.js.map +1 -0
  30. package/dist/dynamodb/index.cjs +382 -0
  31. package/dist/dynamodb/index.cjs.map +1 -0
  32. package/dist/dynamodb/index.d.cts +125 -0
  33. package/dist/dynamodb/index.d.ts +125 -0
  34. package/dist/dynamodb/index.js +355 -0
  35. package/dist/dynamodb/index.js.map +1 -0
  36. package/dist/identity/index.cjs +271 -0
  37. package/dist/identity/index.cjs.map +1 -0
  38. package/dist/identity/index.d.cts +3 -0
  39. package/dist/identity/index.d.ts +3 -0
  40. package/dist/identity/index.js +117 -0
  41. package/dist/identity/index.js.map +1 -0
  42. package/dist/index-9-Ya3fDK.d.cts +169 -0
  43. package/dist/index-9-Ya3fDK.d.ts +169 -0
  44. package/dist/index.cjs +2915 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.d.cts +22 -0
  47. package/dist/index.d.ts +22 -0
  48. package/dist/index.js +23 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/schema/index.cjs +368 -0
  51. package/dist/schema/index.cjs.map +1 -0
  52. package/dist/schema/index.d.cts +4 -0
  53. package/dist/schema/index.d.ts +4 -0
  54. package/dist/schema/index.js +23 -0
  55. package/dist/schema/index.js.map +1 -0
  56. package/dist/secrets/index.cjs +3207 -0
  57. package/dist/secrets/index.cjs.map +1 -0
  58. package/dist/secrets/index.d.cts +227 -0
  59. package/dist/secrets/index.d.ts +227 -0
  60. package/dist/secrets/index.js +323 -0
  61. package/dist/secrets/index.js.map +1 -0
  62. package/dist/supabase/index.cjs +1113 -0
  63. package/dist/supabase/index.cjs.map +1 -0
  64. package/dist/supabase/index.d.cts +144 -0
  65. package/dist/supabase/index.d.ts +144 -0
  66. package/dist/supabase/index.js +864 -0
  67. package/dist/supabase/index.js.map +1 -0
  68. package/dist/types-public-BCj1L4fi.d.cts +1013 -0
  69. package/dist/types-public-BCj1L4fi.d.ts +1013 -0
  70. package/dist/types-public.cjs +40 -0
  71. package/dist/types-public.cjs.map +1 -0
  72. package/dist/types-public.d.cts +4 -0
  73. package/dist/types-public.d.ts +4 -0
  74. package/dist/types-public.js +7 -0
  75. package/dist/types-public.js.map +1 -0
  76. package/package.json +202 -0
@@ -0,0 +1,227 @@
1
+ import { h as Encrypted } from '../types-public-BCj1L4fi.cjs';
2
+ import { Result } from '@byteslice/result';
3
+ import 'zod';
4
+ import 'evlog';
5
+ import '@cipherstash/protect-ffi';
6
+
7
+ /**
8
+ * Placeholder: Corrected Secrets client interface
9
+ *
10
+ * This file reflects the actual dashboard API endpoints as implemented in:
11
+ * apps/dashboard/src/app/api/secrets/{get,set,list,get-many,delete}/route.ts
12
+ *
13
+ * Key corrections from the original interface:
14
+ * 1. get, list, get-many are GET endpoints (not POST) with query params
15
+ * 2. get-many takes a comma-separated `names` string (not a JSON array)
16
+ * 3. set and delete return { success, message } (not void)
17
+ * 4. SecretMetadata fields (id, createdAt, updatedAt) are non-optional
18
+ * 5. GetSecretResponse fields (createdAt, updatedAt) are non-optional
19
+ * 6. get-many enforces min 2 names (comma required) and max 100 names
20
+ */
21
+
22
+ type SecretName = string;
23
+ type SecretValue = string;
24
+ /**
25
+ * Discriminated error type for secrets operations.
26
+ */
27
+ type SecretsErrorType = 'ApiError' | 'NetworkError' | 'ClientError' | 'EncryptionError' | 'DecryptionError';
28
+ /**
29
+ * Error returned by secrets operations.
30
+ */
31
+ interface SecretsError {
32
+ type: SecretsErrorType;
33
+ message: string;
34
+ }
35
+ /**
36
+ * Configuration options for initializing the Stash client
37
+ */
38
+ interface SecretsConfig {
39
+ workspaceCRN: string;
40
+ clientId: string;
41
+ clientKey: string;
42
+ environment: string;
43
+ apiKey: string;
44
+ accessKey?: string;
45
+ }
46
+ /**
47
+ * Secret metadata returned from the API (list endpoint).
48
+ * All fields are always present in API responses.
49
+ */
50
+ interface SecretMetadata {
51
+ id: string;
52
+ name: string;
53
+ environment: string;
54
+ createdAt: string;
55
+ updatedAt: string;
56
+ }
57
+ /**
58
+ * API response for listing secrets.
59
+ * GET /api/secrets/list?workspaceId=...&environment=...
60
+ */
61
+ interface ListSecretsResponse {
62
+ environment: string;
63
+ secrets: SecretMetadata[];
64
+ }
65
+ /**
66
+ * API response for getting a single secret.
67
+ * GET /api/secrets/get?workspaceId=...&environment=...&name=...
68
+ *
69
+ * The `encryptedValue` is the raw value stored in the vault's `value` column,
70
+ * which is the `{ data: Encrypted }` object that was passed to the set endpoint.
71
+ */
72
+ interface GetSecretResponse {
73
+ name: string;
74
+ environment: string;
75
+ encryptedValue: {
76
+ data: Encrypted;
77
+ };
78
+ createdAt: string;
79
+ updatedAt: string;
80
+ }
81
+ /**
82
+ * API response for getting multiple secrets.
83
+ * GET /api/secrets/get-many?workspaceId=...&environment=...&names=name1,name2,...
84
+ *
85
+ * Returns an array of GetSecretResponse objects.
86
+ * Constraints:
87
+ * - `names` must be comma-separated (minimum 2 names)
88
+ * - Maximum 100 names per request
89
+ */
90
+ type GetManySecretsResponse = GetSecretResponse[];
91
+ /**
92
+ * API response for setting a secret.
93
+ * POST /api/secrets/set
94
+ */
95
+ interface SetSecretResponse {
96
+ success: true;
97
+ message: string;
98
+ }
99
+ /**
100
+ * API request body for setting a secret.
101
+ * POST /api/secrets/set
102
+ */
103
+ interface SetSecretRequest {
104
+ workspaceId: string;
105
+ environment: string;
106
+ name: string;
107
+ encryptedValue: {
108
+ data: Encrypted;
109
+ };
110
+ }
111
+ /**
112
+ * API response for deleting a secret.
113
+ * POST /api/secrets/delete
114
+ */
115
+ interface DeleteSecretResponse {
116
+ success: true;
117
+ message: string;
118
+ }
119
+ /**
120
+ * API request body for deleting a secret.
121
+ * POST /api/secrets/delete
122
+ */
123
+ interface DeleteSecretRequest {
124
+ workspaceId: string;
125
+ environment: string;
126
+ name: string;
127
+ }
128
+ /**
129
+ * API error response for plan limit violations (403).
130
+ * Returned by POST /api/secrets/set when the workspace has reached its secret limit.
131
+ */
132
+ interface PlanLimitError {
133
+ error: string;
134
+ code: 'PLAN_LIMIT_REACHED';
135
+ }
136
+ interface DecryptedSecretResponse {
137
+ name: string;
138
+ environment: string;
139
+ value: string;
140
+ createdAt: string;
141
+ updatedAt: string;
142
+ }
143
+ /**
144
+ * The Secrets client provides a high-level API for managing encrypted secrets
145
+ * stored in CipherStash. Secrets are encrypted locally before being sent to
146
+ * the API, ensuring end-to-end encryption.
147
+ */
148
+ declare class Secrets {
149
+ private encryptionClient;
150
+ private config;
151
+ private readonly apiBaseUrl;
152
+ private readonly secretsSchema;
153
+ constructor(config: SecretsConfig);
154
+ private initPromise;
155
+ /**
156
+ * Initialize the Secrets client and underlying Encryption client
157
+ */
158
+ private ensureInitialized;
159
+ private _doInit;
160
+ /**
161
+ * Get the authorization header for API requests
162
+ */
163
+ private getAuthHeader;
164
+ /**
165
+ * Make an API request with error handling.
166
+ *
167
+ * For GET requests, `params` are appended as URL query parameters.
168
+ * For POST requests, `body` is sent as JSON in the request body.
169
+ */
170
+ private apiRequest;
171
+ /**
172
+ * Store an encrypted secret in the vault.
173
+ * The value is encrypted locally before being sent to the API.
174
+ *
175
+ * API: POST /api/secrets/set
176
+ *
177
+ * @param name - The name of the secret
178
+ * @param value - The plaintext value to encrypt and store
179
+ * @returns A Result containing the API response or an error
180
+ */
181
+ set(name: SecretName, value: SecretValue): Promise<Result<SetSecretResponse, SecretsError>>;
182
+ /**
183
+ * Retrieve and decrypt a secret from the vault.
184
+ * The secret is decrypted locally after retrieval.
185
+ *
186
+ * API: GET /api/secrets/get?workspaceId=...&environment=...&name=...
187
+ *
188
+ * @param name - The name of the secret to retrieve
189
+ * @returns A Result containing the decrypted value or an error
190
+ */
191
+ get(name: SecretName): Promise<Result<SecretValue, SecretsError>>;
192
+ /**
193
+ * Retrieve and decrypt many secrets from the vault.
194
+ * The secrets are decrypted locally after retrieval.
195
+ * This method only triggers a single network request to the ZeroKMS.
196
+ *
197
+ * API: GET /api/secrets/get-many?workspaceId=...&environment=...&names=name1,name2,...
198
+ *
199
+ * Constraints:
200
+ * - Minimum 2 secret names required
201
+ * - Maximum 100 secret names per request
202
+ *
203
+ * @param names - The names of the secrets to retrieve (min 2, max 100)
204
+ * @returns A Result containing an object mapping secret names to their decrypted values
205
+ */
206
+ getMany(names: SecretName[]): Promise<Result<Record<SecretName, SecretValue>, SecretsError>>;
207
+ /**
208
+ * List all secrets in the environment.
209
+ * Only names and metadata are returned; values remain encrypted.
210
+ *
211
+ * API: GET /api/secrets/list?workspaceId=...&environment=...
212
+ *
213
+ * @returns A Result containing the list of secrets or an error
214
+ */
215
+ list(): Promise<Result<SecretMetadata[], SecretsError>>;
216
+ /**
217
+ * Delete a secret from the vault.
218
+ *
219
+ * API: POST /api/secrets/delete
220
+ *
221
+ * @param name - The name of the secret to delete
222
+ * @returns A Result containing the API response or an error
223
+ */
224
+ delete(name: SecretName): Promise<Result<DeleteSecretResponse, SecretsError>>;
225
+ }
226
+
227
+ export { type DecryptedSecretResponse, type DeleteSecretRequest, type DeleteSecretResponse, type GetManySecretsResponse, type GetSecretResponse, type ListSecretsResponse, type PlanLimitError, type SecretMetadata, type SecretName, type SecretValue, Secrets, type SecretsConfig, type SecretsError, type SecretsErrorType, type SetSecretRequest, type SetSecretResponse };
@@ -0,0 +1,227 @@
1
+ import { h as Encrypted } from '../types-public-BCj1L4fi.js';
2
+ import { Result } from '@byteslice/result';
3
+ import 'zod';
4
+ import 'evlog';
5
+ import '@cipherstash/protect-ffi';
6
+
7
+ /**
8
+ * Placeholder: Corrected Secrets client interface
9
+ *
10
+ * This file reflects the actual dashboard API endpoints as implemented in:
11
+ * apps/dashboard/src/app/api/secrets/{get,set,list,get-many,delete}/route.ts
12
+ *
13
+ * Key corrections from the original interface:
14
+ * 1. get, list, get-many are GET endpoints (not POST) with query params
15
+ * 2. get-many takes a comma-separated `names` string (not a JSON array)
16
+ * 3. set and delete return { success, message } (not void)
17
+ * 4. SecretMetadata fields (id, createdAt, updatedAt) are non-optional
18
+ * 5. GetSecretResponse fields (createdAt, updatedAt) are non-optional
19
+ * 6. get-many enforces min 2 names (comma required) and max 100 names
20
+ */
21
+
22
+ type SecretName = string;
23
+ type SecretValue = string;
24
+ /**
25
+ * Discriminated error type for secrets operations.
26
+ */
27
+ type SecretsErrorType = 'ApiError' | 'NetworkError' | 'ClientError' | 'EncryptionError' | 'DecryptionError';
28
+ /**
29
+ * Error returned by secrets operations.
30
+ */
31
+ interface SecretsError {
32
+ type: SecretsErrorType;
33
+ message: string;
34
+ }
35
+ /**
36
+ * Configuration options for initializing the Stash client
37
+ */
38
+ interface SecretsConfig {
39
+ workspaceCRN: string;
40
+ clientId: string;
41
+ clientKey: string;
42
+ environment: string;
43
+ apiKey: string;
44
+ accessKey?: string;
45
+ }
46
+ /**
47
+ * Secret metadata returned from the API (list endpoint).
48
+ * All fields are always present in API responses.
49
+ */
50
+ interface SecretMetadata {
51
+ id: string;
52
+ name: string;
53
+ environment: string;
54
+ createdAt: string;
55
+ updatedAt: string;
56
+ }
57
+ /**
58
+ * API response for listing secrets.
59
+ * GET /api/secrets/list?workspaceId=...&environment=...
60
+ */
61
+ interface ListSecretsResponse {
62
+ environment: string;
63
+ secrets: SecretMetadata[];
64
+ }
65
+ /**
66
+ * API response for getting a single secret.
67
+ * GET /api/secrets/get?workspaceId=...&environment=...&name=...
68
+ *
69
+ * The `encryptedValue` is the raw value stored in the vault's `value` column,
70
+ * which is the `{ data: Encrypted }` object that was passed to the set endpoint.
71
+ */
72
+ interface GetSecretResponse {
73
+ name: string;
74
+ environment: string;
75
+ encryptedValue: {
76
+ data: Encrypted;
77
+ };
78
+ createdAt: string;
79
+ updatedAt: string;
80
+ }
81
+ /**
82
+ * API response for getting multiple secrets.
83
+ * GET /api/secrets/get-many?workspaceId=...&environment=...&names=name1,name2,...
84
+ *
85
+ * Returns an array of GetSecretResponse objects.
86
+ * Constraints:
87
+ * - `names` must be comma-separated (minimum 2 names)
88
+ * - Maximum 100 names per request
89
+ */
90
+ type GetManySecretsResponse = GetSecretResponse[];
91
+ /**
92
+ * API response for setting a secret.
93
+ * POST /api/secrets/set
94
+ */
95
+ interface SetSecretResponse {
96
+ success: true;
97
+ message: string;
98
+ }
99
+ /**
100
+ * API request body for setting a secret.
101
+ * POST /api/secrets/set
102
+ */
103
+ interface SetSecretRequest {
104
+ workspaceId: string;
105
+ environment: string;
106
+ name: string;
107
+ encryptedValue: {
108
+ data: Encrypted;
109
+ };
110
+ }
111
+ /**
112
+ * API response for deleting a secret.
113
+ * POST /api/secrets/delete
114
+ */
115
+ interface DeleteSecretResponse {
116
+ success: true;
117
+ message: string;
118
+ }
119
+ /**
120
+ * API request body for deleting a secret.
121
+ * POST /api/secrets/delete
122
+ */
123
+ interface DeleteSecretRequest {
124
+ workspaceId: string;
125
+ environment: string;
126
+ name: string;
127
+ }
128
+ /**
129
+ * API error response for plan limit violations (403).
130
+ * Returned by POST /api/secrets/set when the workspace has reached its secret limit.
131
+ */
132
+ interface PlanLimitError {
133
+ error: string;
134
+ code: 'PLAN_LIMIT_REACHED';
135
+ }
136
+ interface DecryptedSecretResponse {
137
+ name: string;
138
+ environment: string;
139
+ value: string;
140
+ createdAt: string;
141
+ updatedAt: string;
142
+ }
143
+ /**
144
+ * The Secrets client provides a high-level API for managing encrypted secrets
145
+ * stored in CipherStash. Secrets are encrypted locally before being sent to
146
+ * the API, ensuring end-to-end encryption.
147
+ */
148
+ declare class Secrets {
149
+ private encryptionClient;
150
+ private config;
151
+ private readonly apiBaseUrl;
152
+ private readonly secretsSchema;
153
+ constructor(config: SecretsConfig);
154
+ private initPromise;
155
+ /**
156
+ * Initialize the Secrets client and underlying Encryption client
157
+ */
158
+ private ensureInitialized;
159
+ private _doInit;
160
+ /**
161
+ * Get the authorization header for API requests
162
+ */
163
+ private getAuthHeader;
164
+ /**
165
+ * Make an API request with error handling.
166
+ *
167
+ * For GET requests, `params` are appended as URL query parameters.
168
+ * For POST requests, `body` is sent as JSON in the request body.
169
+ */
170
+ private apiRequest;
171
+ /**
172
+ * Store an encrypted secret in the vault.
173
+ * The value is encrypted locally before being sent to the API.
174
+ *
175
+ * API: POST /api/secrets/set
176
+ *
177
+ * @param name - The name of the secret
178
+ * @param value - The plaintext value to encrypt and store
179
+ * @returns A Result containing the API response or an error
180
+ */
181
+ set(name: SecretName, value: SecretValue): Promise<Result<SetSecretResponse, SecretsError>>;
182
+ /**
183
+ * Retrieve and decrypt a secret from the vault.
184
+ * The secret is decrypted locally after retrieval.
185
+ *
186
+ * API: GET /api/secrets/get?workspaceId=...&environment=...&name=...
187
+ *
188
+ * @param name - The name of the secret to retrieve
189
+ * @returns A Result containing the decrypted value or an error
190
+ */
191
+ get(name: SecretName): Promise<Result<SecretValue, SecretsError>>;
192
+ /**
193
+ * Retrieve and decrypt many secrets from the vault.
194
+ * The secrets are decrypted locally after retrieval.
195
+ * This method only triggers a single network request to the ZeroKMS.
196
+ *
197
+ * API: GET /api/secrets/get-many?workspaceId=...&environment=...&names=name1,name2,...
198
+ *
199
+ * Constraints:
200
+ * - Minimum 2 secret names required
201
+ * - Maximum 100 secret names per request
202
+ *
203
+ * @param names - The names of the secrets to retrieve (min 2, max 100)
204
+ * @returns A Result containing an object mapping secret names to their decrypted values
205
+ */
206
+ getMany(names: SecretName[]): Promise<Result<Record<SecretName, SecretValue>, SecretsError>>;
207
+ /**
208
+ * List all secrets in the environment.
209
+ * Only names and metadata are returned; values remain encrypted.
210
+ *
211
+ * API: GET /api/secrets/list?workspaceId=...&environment=...
212
+ *
213
+ * @returns A Result containing the list of secrets or an error
214
+ */
215
+ list(): Promise<Result<SecretMetadata[], SecretsError>>;
216
+ /**
217
+ * Delete a secret from the vault.
218
+ *
219
+ * API: POST /api/secrets/delete
220
+ *
221
+ * @param name - The name of the secret to delete
222
+ * @returns A Result containing the API response or an error
223
+ */
224
+ delete(name: SecretName): Promise<Result<DeleteSecretResponse, SecretsError>>;
225
+ }
226
+
227
+ export { type DecryptedSecretResponse, type DeleteSecretRequest, type DeleteSecretResponse, type GetManySecretsResponse, type GetSecretResponse, type ListSecretsResponse, type PlanLimitError, type SecretMetadata, type SecretName, type SecretValue, Secrets, type SecretsConfig, type SecretsError, type SecretsErrorType, type SetSecretRequest, type SetSecretResponse };