@cipherstash/stack 0.14.0 → 0.15.1

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