@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.
- package/CHANGELOG.md +17 -0
- package/dist/drizzle/index.cjs +4 -2
- package/dist/drizzle/index.cjs.map +1 -1
- package/dist/drizzle/index.js +4 -2
- package/dist/drizzle/index.js.map +1 -1
- package/dist/identity/index.js +63 -3
- package/dist/identity/index.js.map +1 -1
- package/dist/index.cjs +6 -365
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -5
- package/package.json +1 -1
- package/dist/chunk-GXGEW6T4.js +0 -68
- package/dist/chunk-GXGEW6T4.js.map +0 -1
- package/dist/chunk-XTKLRDGJ.js +0 -357
- package/dist/chunk-XTKLRDGJ.js.map +0 -1
- package/dist/secrets/index.cjs +0 -3143
- package/dist/secrets/index.cjs.map +0 -1
- package/dist/secrets/index.d.cts +0 -225
- package/dist/secrets/index.d.ts +0 -225
- package/dist/secrets/index.js +0 -14
- package/dist/secrets/index.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { E as Encrypted } from './types-public-DX3mGqoi.cjs';
|
|
2
2
|
export { e as encryptedColumn, a as encryptedField, b as encryptedTable } from './types-public-DX3mGqoi.cjs';
|
|
3
3
|
export { E as Encryption } from './client-DQyqn0oT.cjs';
|
|
4
|
-
export { Secrets } from './secrets/index.cjs';
|
|
5
4
|
import 'zod';
|
|
6
5
|
import '@cipherstash/protect-ffi';
|
|
7
6
|
import './errors/index.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { E as Encrypted } from './types-public-DX3mGqoi.js';
|
|
2
2
|
export { e as encryptedColumn, a as encryptedField, b as encryptedTable } from './types-public-DX3mGqoi.js';
|
|
3
3
|
export { E as Encryption } from './client-Dv60lAyy.js';
|
|
4
|
-
export { Secrets } from './secrets/index.js';
|
|
5
4
|
import 'zod';
|
|
6
5
|
import '@cipherstash/protect-ffi';
|
|
7
6
|
import './errors/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Secrets
|
|
3
|
-
} from "./chunk-XTKLRDGJ.js";
|
|
4
1
|
import {
|
|
5
2
|
Encryption
|
|
6
3
|
} from "./chunk-YPAPL3IC.js";
|
|
@@ -14,12 +11,10 @@ import {
|
|
|
14
11
|
encryptedTable
|
|
15
12
|
} from "./chunk-GNLU3I27.js";
|
|
16
13
|
import "./chunk-MD6742R6.js";
|
|
17
|
-
import "./chunk-GXGEW6T4.js";
|
|
18
14
|
import "./chunk-Q5FTQLYG.js";
|
|
19
15
|
import "./chunk-LBMC4D6D.js";
|
|
20
16
|
export {
|
|
21
17
|
Encryption,
|
|
22
|
-
Secrets,
|
|
23
18
|
encryptedColumn,
|
|
24
19
|
encryptedField,
|
|
25
20
|
encryptedTable,
|
package/package.json
CHANGED
package/dist/chunk-GXGEW6T4.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// src/utils/config/index.ts
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
function getWorkspaceCrn(tomlString) {
|
|
5
|
-
let currentSection = "";
|
|
6
|
-
let workspaceCrn;
|
|
7
|
-
const lines = tomlString.split(/\r?\n/);
|
|
8
|
-
for (const line of lines) {
|
|
9
|
-
const trimmedLine = line.trim();
|
|
10
|
-
if (!trimmedLine || trimmedLine.startsWith("#")) {
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
const sectionMatch = trimmedLine.match(/^\[([^\]]+)\]$/);
|
|
14
|
-
if (sectionMatch) {
|
|
15
|
-
currentSection = sectionMatch[1];
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
const kvMatch = trimmedLine.match(/^(\w+)\s*=\s*"([^"]+)"$/);
|
|
19
|
-
if (kvMatch) {
|
|
20
|
-
const [_, key, value] = kvMatch;
|
|
21
|
-
if (currentSection === "auth" && key === "workspace_crn") {
|
|
22
|
-
workspaceCrn = value;
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return workspaceCrn;
|
|
28
|
-
}
|
|
29
|
-
function extractWorkspaceIdFromCrn(crn) {
|
|
30
|
-
const match = crn.match(/crn:[^:]+:([^:]+)$/);
|
|
31
|
-
if (!match) {
|
|
32
|
-
throw new Error("Invalid CRN format");
|
|
33
|
-
}
|
|
34
|
-
return match[1];
|
|
35
|
-
}
|
|
36
|
-
function loadWorkSpaceId(suppliedCrn) {
|
|
37
|
-
const configPath = path.join(process.cwd(), "cipherstash.toml");
|
|
38
|
-
if (suppliedCrn) {
|
|
39
|
-
return extractWorkspaceIdFromCrn(suppliedCrn);
|
|
40
|
-
}
|
|
41
|
-
if (!fs.existsSync(configPath) && !process.env.CS_WORKSPACE_CRN) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
"You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
if (process.env.CS_WORKSPACE_CRN) {
|
|
47
|
-
return extractWorkspaceIdFromCrn(process.env.CS_WORKSPACE_CRN);
|
|
48
|
-
}
|
|
49
|
-
if (!fs.existsSync(configPath)) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
"You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
const tomlString = fs.readFileSync(configPath, "utf8");
|
|
55
|
-
const workspaceCrn = getWorkspaceCrn(tomlString);
|
|
56
|
-
if (!workspaceCrn) {
|
|
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
|
-
return extractWorkspaceIdFromCrn(workspaceCrn);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export {
|
|
65
|
-
extractWorkspaceIdFromCrn,
|
|
66
|
-
loadWorkSpaceId
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=chunk-GXGEW6T4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/config/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"],"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,UAAM,cAAc,KAAK,KAAK;AAE9B,QAAI,CAAC,eAAe,YAAY,WAAW,GAAG,GAAG;AAC/C;AAAA,IACF;AAEA,UAAM,eAAe,YAAY,MAAM,gBAAgB;AACvD,QAAI,cAAc;AAChB,uBAAiB,aAAa,CAAC;AAC/B;AAAA,IACF;AAEA,UAAM,UAAU,YAAY,MAAM,yBAAyB;AAC3D,QAAI,SAAS;AACX,YAAM,CAAC,GAAG,KAAK,KAAK,IAAI;AAExB,UAAI,mBAAmB,UAAU,QAAQ,iBAAiB;AACxD,uBAAe;AACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AASO,SAAS,0BAA0B,KAAqB;AAC7D,QAAM,QAAQ,IAAI,MAAM,oBAAoB;AAC5C,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AACA,SAAO,MAAM,CAAC;AAChB;AAEO,SAAS,gBAAgB,aAA8B;AAC5D,QAAM,aAAa,KAAK,KAAK,QAAQ,IAAI,GAAG,kBAAkB;AAE9D,MAAI,aAAa;AACf,WAAO,0BAA0B,WAAW;AAAA,EAC9C;AAEA,MAAI,CAAC,GAAG,WAAW,UAAU,KAAK,CAAC,QAAQ,IAAI,kBAAkB;AAC/D,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAGA,MAAI,QAAQ,IAAI,kBAAkB;AAChC,WAAO,0BAA0B,QAAQ,IAAI,gBAAgB;AAAA,EAC/D;AAEA,MAAI,CAAC,GAAG,WAAW,UAAU,GAAG;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa,GAAG,aAAa,YAAY,MAAM;AACrD,QAAM,eAAe,gBAAgB,UAAU;AAE/C,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO,0BAA0B,YAAY;AAC/C;","names":[]}
|
package/dist/chunk-XTKLRDGJ.js
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Encryption
|
|
3
|
-
} from "./chunk-YPAPL3IC.js";
|
|
4
|
-
import {
|
|
5
|
-
encryptedToPgComposite
|
|
6
|
-
} from "./chunk-4RNBI3UH.js";
|
|
7
|
-
import {
|
|
8
|
-
encryptedColumn,
|
|
9
|
-
encryptedTable
|
|
10
|
-
} from "./chunk-GNLU3I27.js";
|
|
11
|
-
import {
|
|
12
|
-
extractWorkspaceIdFromCrn
|
|
13
|
-
} from "./chunk-GXGEW6T4.js";
|
|
14
|
-
import {
|
|
15
|
-
logger
|
|
16
|
-
} from "./chunk-Q5FTQLYG.js";
|
|
17
|
-
|
|
18
|
-
// src/secrets/index.ts
|
|
19
|
-
var Secrets = class {
|
|
20
|
-
encryptionClient = null;
|
|
21
|
-
config;
|
|
22
|
-
apiBaseUrl = process.env.STASH_API_URL || "https://dashboard.cipherstash.com/api/secrets";
|
|
23
|
-
secretsSchema = encryptedTable("secrets", {
|
|
24
|
-
value: encryptedColumn("value")
|
|
25
|
-
});
|
|
26
|
-
constructor(config) {
|
|
27
|
-
const workspaceCRN = config.workspaceCRN ?? process.env.CS_WORKSPACE_CRN;
|
|
28
|
-
const clientId = config.clientId ?? process.env.CS_CLIENT_ID;
|
|
29
|
-
const clientKey = config.clientKey ?? process.env.CS_CLIENT_KEY;
|
|
30
|
-
const accessKey = config.accessKey ?? process.env.CS_CLIENT_ACCESS_KEY;
|
|
31
|
-
if (!workspaceCRN || !clientId || !clientKey || !accessKey) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
"Missing required configuration or environment variables."
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
this.config = {
|
|
37
|
-
environment: config.environment,
|
|
38
|
-
workspaceCRN,
|
|
39
|
-
clientId,
|
|
40
|
-
clientKey,
|
|
41
|
-
accessKey
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
initPromise = null;
|
|
45
|
-
/**
|
|
46
|
-
* Initialize the Secrets client and underlying Encryption client
|
|
47
|
-
*/
|
|
48
|
-
async ensureInitialized() {
|
|
49
|
-
if (!this.initPromise) {
|
|
50
|
-
this.initPromise = this._doInit();
|
|
51
|
-
}
|
|
52
|
-
return this.initPromise;
|
|
53
|
-
}
|
|
54
|
-
async _doInit() {
|
|
55
|
-
logger.debug("Initializing the Secrets client.");
|
|
56
|
-
this.encryptionClient = await Encryption({
|
|
57
|
-
schemas: [this.secretsSchema],
|
|
58
|
-
config: {
|
|
59
|
-
workspaceCrn: this.config.workspaceCRN,
|
|
60
|
-
clientId: this.config.clientId,
|
|
61
|
-
clientKey: this.config.clientKey,
|
|
62
|
-
accessKey: this.config.accessKey,
|
|
63
|
-
keyset: { name: this.config.environment }
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
logger.debug("Successfully initialized the Secrets client.");
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get the authorization header for API requests
|
|
70
|
-
*/
|
|
71
|
-
getAuthHeader() {
|
|
72
|
-
return `Bearer ${this.config.accessKey}`;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Make an API request with error handling.
|
|
76
|
-
*
|
|
77
|
-
* For GET requests, `params` are appended as URL query parameters.
|
|
78
|
-
* For POST requests, `body` is sent as JSON in the request body.
|
|
79
|
-
*/
|
|
80
|
-
async apiRequest(method, path, options) {
|
|
81
|
-
try {
|
|
82
|
-
let url = `${this.apiBaseUrl}${path}`;
|
|
83
|
-
if (options?.params) {
|
|
84
|
-
const searchParams = new URLSearchParams(options.params);
|
|
85
|
-
url = `${url}?${searchParams.toString()}`;
|
|
86
|
-
}
|
|
87
|
-
logger.debug(`Secrets API request: ${method} ${path}`);
|
|
88
|
-
const headers = {
|
|
89
|
-
"Content-Type": "application/json",
|
|
90
|
-
Authorization: this.getAuthHeader()
|
|
91
|
-
};
|
|
92
|
-
const response = await fetch(url, {
|
|
93
|
-
method,
|
|
94
|
-
headers,
|
|
95
|
-
body: options?.body ? JSON.stringify(options.body) : void 0
|
|
96
|
-
});
|
|
97
|
-
if (!response.ok) {
|
|
98
|
-
const errorText = await response.text();
|
|
99
|
-
let errorMessage = `API request failed with status ${response.status}`;
|
|
100
|
-
try {
|
|
101
|
-
const errorJson = JSON.parse(errorText);
|
|
102
|
-
errorMessage = errorJson.message || errorJson.error || errorMessage;
|
|
103
|
-
} catch {
|
|
104
|
-
errorMessage = errorText || errorMessage;
|
|
105
|
-
}
|
|
106
|
-
logger.error(`Secrets API error on ${method} ${path}: ${errorMessage}`);
|
|
107
|
-
return {
|
|
108
|
-
failure: {
|
|
109
|
-
type: "ApiError",
|
|
110
|
-
message: errorMessage
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
logger.debug(`Secrets API request successful: ${method} ${path}`);
|
|
115
|
-
const data = await response.json();
|
|
116
|
-
return { data };
|
|
117
|
-
} catch (error) {
|
|
118
|
-
const message = error instanceof Error ? error.message : "Unknown network error occurred";
|
|
119
|
-
logger.error(`Secrets network error on ${method} ${path}: ${message}`);
|
|
120
|
-
return {
|
|
121
|
-
failure: {
|
|
122
|
-
type: "NetworkError",
|
|
123
|
-
message
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Store an encrypted secret in the vault.
|
|
130
|
-
* The value is encrypted locally before being sent to the API.
|
|
131
|
-
*
|
|
132
|
-
* API: POST /api/secrets/set
|
|
133
|
-
*
|
|
134
|
-
* @param name - The name of the secret
|
|
135
|
-
* @param value - The plaintext value to encrypt and store
|
|
136
|
-
* @returns A Result containing the API response or an error
|
|
137
|
-
*/
|
|
138
|
-
async set(name, value) {
|
|
139
|
-
logger.debug("Setting secret");
|
|
140
|
-
await this.ensureInitialized();
|
|
141
|
-
if (!this.encryptionClient) {
|
|
142
|
-
return {
|
|
143
|
-
failure: {
|
|
144
|
-
type: "ClientError",
|
|
145
|
-
message: "Failed to initialize Encryption client"
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const encryptResult = await this.encryptionClient.encrypt(value, {
|
|
150
|
-
column: this.secretsSchema.value,
|
|
151
|
-
table: this.secretsSchema
|
|
152
|
-
});
|
|
153
|
-
if (encryptResult.failure) {
|
|
154
|
-
logger.error("Failed to encrypt secret");
|
|
155
|
-
return {
|
|
156
|
-
failure: {
|
|
157
|
-
type: "EncryptionError",
|
|
158
|
-
message: encryptResult.failure.message
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN);
|
|
163
|
-
return await this.apiRequest("POST", "/set", {
|
|
164
|
-
body: {
|
|
165
|
-
workspaceId,
|
|
166
|
-
environment: this.config.environment,
|
|
167
|
-
name,
|
|
168
|
-
encryptedValue: encryptedToPgComposite(encryptResult.data)
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Retrieve and decrypt a secret from the vault.
|
|
174
|
-
* The secret is decrypted locally after retrieval.
|
|
175
|
-
*
|
|
176
|
-
* API: GET /api/secrets/get?workspaceId=...&environment=...&name=...
|
|
177
|
-
*
|
|
178
|
-
* @param name - The name of the secret to retrieve
|
|
179
|
-
* @returns A Result containing the decrypted value or an error
|
|
180
|
-
*/
|
|
181
|
-
async get(name) {
|
|
182
|
-
logger.debug("Getting secret");
|
|
183
|
-
await this.ensureInitialized();
|
|
184
|
-
if (!this.encryptionClient) {
|
|
185
|
-
return {
|
|
186
|
-
failure: {
|
|
187
|
-
type: "ClientError",
|
|
188
|
-
message: "Failed to initialize Encryption client"
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN);
|
|
193
|
-
const apiResult = await this.apiRequest("GET", "/get", {
|
|
194
|
-
params: {
|
|
195
|
-
workspaceId,
|
|
196
|
-
environment: this.config.environment,
|
|
197
|
-
name
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
if (apiResult.failure) {
|
|
201
|
-
return apiResult;
|
|
202
|
-
}
|
|
203
|
-
const decryptResult = await this.encryptionClient.decrypt(
|
|
204
|
-
apiResult.data.encryptedValue.data
|
|
205
|
-
);
|
|
206
|
-
if (decryptResult.failure) {
|
|
207
|
-
logger.error("Failed to decrypt secret");
|
|
208
|
-
return {
|
|
209
|
-
failure: {
|
|
210
|
-
type: "DecryptionError",
|
|
211
|
-
message: decryptResult.failure.message
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
if (typeof decryptResult.data !== "string") {
|
|
216
|
-
logger.error("Decrypted secret value is not a string");
|
|
217
|
-
return {
|
|
218
|
-
failure: {
|
|
219
|
-
type: "DecryptionError",
|
|
220
|
-
message: "Decrypted value is not a string"
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
return { data: decryptResult.data };
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Retrieve and decrypt many secrets from the vault.
|
|
228
|
-
* The secrets are decrypted locally after retrieval.
|
|
229
|
-
* This method only triggers a single network request to the ZeroKMS.
|
|
230
|
-
*
|
|
231
|
-
* API: GET /api/secrets/get-many?workspaceId=...&environment=...&names=name1,name2,...
|
|
232
|
-
*
|
|
233
|
-
* Constraints:
|
|
234
|
-
* - Minimum 2 secret names required
|
|
235
|
-
* - Maximum 100 secret names per request
|
|
236
|
-
*
|
|
237
|
-
* @param names - The names of the secrets to retrieve (min 2, max 100)
|
|
238
|
-
* @returns A Result containing an object mapping secret names to their decrypted values
|
|
239
|
-
*/
|
|
240
|
-
async getMany(names) {
|
|
241
|
-
logger.debug(`Getting ${names.length} secrets.`);
|
|
242
|
-
await this.ensureInitialized();
|
|
243
|
-
if (!this.encryptionClient) {
|
|
244
|
-
return {
|
|
245
|
-
failure: {
|
|
246
|
-
type: "ClientError",
|
|
247
|
-
message: "Failed to initialize Encryption client"
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
if (names.length < 2) {
|
|
252
|
-
return {
|
|
253
|
-
failure: {
|
|
254
|
-
type: "ClientError",
|
|
255
|
-
message: "At least 2 secret names are required for getMany"
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
if (names.length > 100) {
|
|
260
|
-
return {
|
|
261
|
-
failure: {
|
|
262
|
-
type: "ClientError",
|
|
263
|
-
message: "Maximum 100 secret names per request"
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN);
|
|
268
|
-
const apiResult = await this.apiRequest(
|
|
269
|
-
"GET",
|
|
270
|
-
"/get-many",
|
|
271
|
-
{
|
|
272
|
-
params: {
|
|
273
|
-
workspaceId,
|
|
274
|
-
environment: this.config.environment,
|
|
275
|
-
names: names.join(",")
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
);
|
|
279
|
-
if (apiResult.failure) {
|
|
280
|
-
return apiResult;
|
|
281
|
-
}
|
|
282
|
-
const dataToDecrypt = apiResult.data.map((item) => ({
|
|
283
|
-
name: item.name,
|
|
284
|
-
value: item.encryptedValue.data
|
|
285
|
-
}));
|
|
286
|
-
const decryptResult = await this.encryptionClient.bulkDecryptModels(dataToDecrypt);
|
|
287
|
-
if (decryptResult.failure) {
|
|
288
|
-
logger.error(
|
|
289
|
-
`Failed to decrypt secrets: ${decryptResult.failure.message}`
|
|
290
|
-
);
|
|
291
|
-
return {
|
|
292
|
-
failure: {
|
|
293
|
-
type: "DecryptionError",
|
|
294
|
-
message: decryptResult.failure.message
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
const decryptedSecrets = decryptResult.data;
|
|
299
|
-
const secretsMap = {};
|
|
300
|
-
for (const secret of decryptedSecrets) {
|
|
301
|
-
if (secret.name && secret.value) {
|
|
302
|
-
secretsMap[secret.name] = secret.value;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return { data: secretsMap };
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* List all secrets in the environment.
|
|
309
|
-
* Only names and metadata are returned; values remain encrypted.
|
|
310
|
-
*
|
|
311
|
-
* API: GET /api/secrets/list?workspaceId=...&environment=...
|
|
312
|
-
*
|
|
313
|
-
* @returns A Result containing the list of secrets or an error
|
|
314
|
-
*/
|
|
315
|
-
async list() {
|
|
316
|
-
logger.debug("Listing secrets.");
|
|
317
|
-
const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN);
|
|
318
|
-
const apiResult = await this.apiRequest(
|
|
319
|
-
"GET",
|
|
320
|
-
"/list",
|
|
321
|
-
{
|
|
322
|
-
params: {
|
|
323
|
-
workspaceId,
|
|
324
|
-
environment: this.config.environment
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
);
|
|
328
|
-
if (apiResult.failure) {
|
|
329
|
-
return apiResult;
|
|
330
|
-
}
|
|
331
|
-
return { data: apiResult.data.secrets };
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Delete a secret from the vault.
|
|
335
|
-
*
|
|
336
|
-
* API: POST /api/secrets/delete
|
|
337
|
-
*
|
|
338
|
-
* @param name - The name of the secret to delete
|
|
339
|
-
* @returns A Result containing the API response or an error
|
|
340
|
-
*/
|
|
341
|
-
async delete(name) {
|
|
342
|
-
logger.debug("Deleting secret");
|
|
343
|
-
const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN);
|
|
344
|
-
return await this.apiRequest("POST", "/delete", {
|
|
345
|
-
body: {
|
|
346
|
-
workspaceId,
|
|
347
|
-
environment: this.config.environment,
|
|
348
|
-
name
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
export {
|
|
355
|
-
Secrets
|
|
356
|
-
};
|
|
357
|
-
//# sourceMappingURL=chunk-XTKLRDGJ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/secrets/index.ts"],"sourcesContent":["/**\n * Placeholder: Corrected Secrets client interface\n *\n * This file reflects the actual dashboard API endpoints as implemented in:\n * apps/dashboard/src/app/api/secrets/{get,set,list,get-many,delete}/route.ts\n *\n * Key corrections from the original interface:\n * 1. get, list, get-many are GET endpoints (not POST) with query params\n * 2. get-many takes a comma-separated `names` string (not a JSON array)\n * 3. set and delete return { success, message } (not void)\n * 4. SecretMetadata fields (id, createdAt, updatedAt) are non-optional\n * 5. GetSecretResponse fields (createdAt, updatedAt) are non-optional\n * 6. get-many enforces min 2 names (comma required) and max 100 names\n */\n\nimport { encryptedToPgComposite } from '@/encryption/helpers'\nimport type { EncryptionClient } from '@/encryption/index.js'\nimport { Encryption } from '@/index'\nimport { encryptedColumn, encryptedTable } from '@/schema'\nimport type { Encrypted } from '@/types'\nimport { logger } from '@/utils/logger'\nimport type { Result } from '@byteslice/result'\nimport { extractWorkspaceIdFromCrn } from '../utils/config/index.js'\n\nexport type SecretName = string\nexport type SecretValue = string\n\n/**\n * Discriminated error type for secrets operations.\n */\nexport type SecretsErrorType =\n | 'ApiError'\n | 'NetworkError'\n | 'ClientError'\n | 'EncryptionError'\n | 'DecryptionError'\n\n/**\n * Error returned by secrets operations.\n */\nexport interface SecretsError {\n type: SecretsErrorType\n message: string\n}\n\n/**\n * Configuration options for initializing the Stash client\n */\nexport interface SecretsConfig {\n environment: string\n workspaceCRN?: string\n clientId?: string\n clientKey?: string\n accessKey?: string\n}\n\n/**\n * Secret metadata returned from the API (list endpoint).\n * All fields are always present in API responses.\n */\nexport interface SecretMetadata {\n id: string\n name: string\n environment: string\n createdAt: string\n updatedAt: string\n}\n\n/**\n * API response for listing secrets.\n * GET /api/secrets/list?workspaceId=...&environment=...\n */\nexport interface ListSecretsResponse {\n environment: string\n secrets: SecretMetadata[]\n}\n\n/**\n * API response for getting a single secret.\n * GET /api/secrets/get?workspaceId=...&environment=...&name=...\n *\n * The `encryptedValue` is the raw value stored in the vault's `value` column,\n * which is the `{ data: Encrypted }` object that was passed to the set endpoint.\n */\nexport interface GetSecretResponse {\n name: string\n environment: string\n encryptedValue: {\n data: Encrypted\n }\n createdAt: string\n updatedAt: string\n}\n\n/**\n * API response for getting multiple secrets.\n * GET /api/secrets/get-many?workspaceId=...&environment=...&names=name1,name2,...\n *\n * Returns an array of GetSecretResponse objects.\n * Constraints:\n * - `names` must be comma-separated (minimum 2 names)\n * - Maximum 100 names per request\n */\nexport type GetManySecretsResponse = GetSecretResponse[]\n\n/**\n * API response for setting a secret.\n * POST /api/secrets/set\n */\nexport interface SetSecretResponse {\n success: true\n message: string\n}\n\n/**\n * API request body for setting a secret.\n * POST /api/secrets/set\n */\nexport interface SetSecretRequest {\n workspaceId: string\n environment: string\n name: string\n encryptedValue: {\n data: Encrypted\n }\n}\n\n/**\n * API response for deleting a secret.\n * POST /api/secrets/delete\n */\nexport interface DeleteSecretResponse {\n success: true\n message: string\n}\n\n/**\n * API request body for deleting a secret.\n * POST /api/secrets/delete\n */\nexport interface DeleteSecretRequest {\n workspaceId: string\n environment: string\n name: string\n}\n\n/**\n * API error response for plan limit violations (403).\n * Returned by POST /api/secrets/set when the workspace has reached its secret limit.\n */\nexport interface PlanLimitError {\n error: string\n code: 'PLAN_LIMIT_REACHED'\n}\n\nexport interface DecryptedSecretResponse {\n name: string\n environment: string\n value: string\n createdAt: string\n updatedAt: string\n}\n\n/**\n * The Secrets client provides a high-level API for managing encrypted secrets\n * stored in CipherStash. Secrets are encrypted locally before being sent to\n * the API, ensuring end-to-end encryption.\n */\nexport class Secrets {\n private encryptionClient: EncryptionClient | null = null\n private config: Required<SecretsConfig>\n private readonly apiBaseUrl =\n process.env.STASH_API_URL || 'https://dashboard.cipherstash.com/api/secrets'\n private readonly secretsSchema = encryptedTable('secrets', {\n value: encryptedColumn('value'),\n })\n\n constructor(config: SecretsConfig) {\n const workspaceCRN = config.workspaceCRN ?? process.env.CS_WORKSPACE_CRN\n const clientId = config.clientId ?? process.env.CS_CLIENT_ID\n const clientKey = config.clientKey ?? process.env.CS_CLIENT_KEY\n const accessKey = config.accessKey ?? process.env.CS_CLIENT_ACCESS_KEY\n\n if (!workspaceCRN || !clientId || !clientKey || !accessKey) {\n throw new Error(\n 'Missing required configuration or environment variables.',\n )\n }\n\n this.config = {\n environment: config.environment,\n workspaceCRN,\n clientId,\n clientKey,\n accessKey,\n }\n }\n\n private initPromise: Promise<void> | null = null\n\n /**\n * Initialize the Secrets client and underlying Encryption client\n */\n private async ensureInitialized(): Promise<void> {\n if (!this.initPromise) {\n this.initPromise = this._doInit()\n }\n return this.initPromise\n }\n\n private async _doInit(): Promise<void> {\n logger.debug('Initializing the Secrets client.')\n\n this.encryptionClient = await Encryption({\n schemas: [this.secretsSchema],\n config: {\n workspaceCrn: this.config.workspaceCRN,\n clientId: this.config.clientId,\n clientKey: this.config.clientKey,\n accessKey: this.config.accessKey,\n keyset: { name: this.config.environment },\n },\n })\n\n logger.debug('Successfully initialized the Secrets client.')\n }\n\n /**\n * Get the authorization header for API requests\n */\n private getAuthHeader(): string {\n return `Bearer ${this.config.accessKey}`\n }\n\n /**\n * Make an API request with error handling.\n *\n * For GET requests, `params` are appended as URL query parameters.\n * For POST requests, `body` is sent as JSON in the request body.\n */\n private async apiRequest<T>(\n method: 'GET' | 'POST',\n path: string,\n options?: {\n body?: unknown\n params?: Record<string, string>\n },\n ): Promise<Result<T, SecretsError>> {\n try {\n let url = `${this.apiBaseUrl}${path}`\n\n if (options?.params) {\n const searchParams = new URLSearchParams(options.params)\n url = `${url}?${searchParams.toString()}`\n }\n\n logger.debug(`Secrets API request: ${method} ${path}`)\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Authorization: this.getAuthHeader(),\n }\n\n const response = await fetch(url, {\n method,\n headers,\n body: options?.body ? JSON.stringify(options.body) : undefined,\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = `API request failed with status ${response.status}`\n try {\n const errorJson = JSON.parse(errorText)\n errorMessage = errorJson.message || errorJson.error || errorMessage\n } catch {\n errorMessage = errorText || errorMessage\n }\n\n logger.error(`Secrets API error on ${method} ${path}: ${errorMessage}`)\n\n return {\n failure: {\n type: 'ApiError',\n message: errorMessage,\n },\n }\n }\n\n logger.debug(`Secrets API request successful: ${method} ${path}`)\n\n const data = await response.json()\n return { data }\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : 'Unknown network error occurred'\n\n logger.error(`Secrets network error on ${method} ${path}: ${message}`)\n\n return {\n failure: {\n type: 'NetworkError',\n message,\n },\n }\n }\n }\n\n /**\n * Store an encrypted secret in the vault.\n * The value is encrypted locally before being sent to the API.\n *\n * API: POST /api/secrets/set\n *\n * @param name - The name of the secret\n * @param value - The plaintext value to encrypt and store\n * @returns A Result containing the API response or an error\n */\n async set(\n name: SecretName,\n value: SecretValue,\n ): Promise<Result<SetSecretResponse, SecretsError>> {\n logger.debug('Setting secret')\n\n await this.ensureInitialized()\n\n if (!this.encryptionClient) {\n return {\n failure: {\n type: 'ClientError',\n message: 'Failed to initialize Encryption client',\n },\n }\n }\n\n // Encrypt the value locally\n const encryptResult = await this.encryptionClient.encrypt(value, {\n column: this.secretsSchema.value,\n table: this.secretsSchema,\n })\n\n if (encryptResult.failure) {\n logger.error('Failed to encrypt secret')\n return {\n failure: {\n type: 'EncryptionError',\n message: encryptResult.failure.message,\n },\n }\n }\n\n // Extract workspaceId from CRN\n const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN)\n\n // Send encrypted value to API\n return await this.apiRequest<SetSecretResponse>('POST', '/set', {\n body: {\n workspaceId,\n environment: this.config.environment,\n name,\n encryptedValue: encryptedToPgComposite(encryptResult.data),\n },\n })\n }\n\n /**\n * Retrieve and decrypt a secret from the vault.\n * The secret is decrypted locally after retrieval.\n *\n * API: GET /api/secrets/get?workspaceId=...&environment=...&name=...\n *\n * @param name - The name of the secret to retrieve\n * @returns A Result containing the decrypted value or an error\n */\n async get(name: SecretName): Promise<Result<SecretValue, SecretsError>> {\n logger.debug('Getting secret')\n\n await this.ensureInitialized()\n\n if (!this.encryptionClient) {\n return {\n failure: {\n type: 'ClientError',\n message: 'Failed to initialize Encryption client',\n },\n }\n }\n\n // Extract workspaceId from CRN\n const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN)\n\n // Fetch encrypted value from API via GET with query params\n const apiResult = await this.apiRequest<GetSecretResponse>('GET', '/get', {\n params: {\n workspaceId,\n environment: this.config.environment,\n name,\n },\n })\n\n if (apiResult.failure) {\n return apiResult\n }\n\n // Decrypt the value locally\n const decryptResult = await this.encryptionClient.decrypt(\n apiResult.data.encryptedValue.data,\n )\n\n if (decryptResult.failure) {\n logger.error('Failed to decrypt secret')\n return {\n failure: {\n type: 'DecryptionError',\n message: decryptResult.failure.message,\n },\n }\n }\n\n if (typeof decryptResult.data !== 'string') {\n logger.error('Decrypted secret value is not a string')\n return {\n failure: {\n type: 'DecryptionError',\n message: 'Decrypted value is not a string',\n },\n }\n }\n\n return { data: decryptResult.data }\n }\n\n /**\n * Retrieve and decrypt many secrets from the vault.\n * The secrets are decrypted locally after retrieval.\n * This method only triggers a single network request to the ZeroKMS.\n *\n * API: GET /api/secrets/get-many?workspaceId=...&environment=...&names=name1,name2,...\n *\n * Constraints:\n * - Minimum 2 secret names required\n * - Maximum 100 secret names per request\n *\n * @param names - The names of the secrets to retrieve (min 2, max 100)\n * @returns A Result containing an object mapping secret names to their decrypted values\n */\n async getMany(\n names: SecretName[],\n ): Promise<Result<Record<SecretName, SecretValue>, SecretsError>> {\n logger.debug(`Getting ${names.length} secrets.`)\n\n await this.ensureInitialized()\n\n if (!this.encryptionClient) {\n return {\n failure: {\n type: 'ClientError',\n message: 'Failed to initialize Encryption client',\n },\n }\n }\n\n if (names.length < 2) {\n return {\n failure: {\n type: 'ClientError',\n message: 'At least 2 secret names are required for getMany',\n },\n }\n }\n\n if (names.length > 100) {\n return {\n failure: {\n type: 'ClientError',\n message: 'Maximum 100 secret names per request',\n },\n }\n }\n\n // Extract workspaceId from CRN\n const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN)\n\n // Fetch encrypted values from API via GET with comma-separated names\n const apiResult = await this.apiRequest<GetManySecretsResponse>(\n 'GET',\n '/get-many',\n {\n params: {\n workspaceId,\n environment: this.config.environment,\n names: names.join(','),\n },\n },\n )\n\n if (apiResult.failure) {\n return apiResult\n }\n\n const dataToDecrypt = apiResult.data.map((item) => ({\n name: item.name,\n value: item.encryptedValue.data,\n }))\n\n const decryptResult =\n await this.encryptionClient.bulkDecryptModels(dataToDecrypt)\n\n if (decryptResult.failure) {\n logger.error(\n `Failed to decrypt secrets: ${decryptResult.failure.message}`,\n )\n return {\n failure: {\n type: 'DecryptionError',\n message: decryptResult.failure.message,\n },\n }\n }\n\n // Transform array of decrypted secrets into an object keyed by secret name\n const decryptedSecrets =\n decryptResult.data as unknown as DecryptedSecretResponse[]\n const secretsMap: Record<SecretName, SecretValue> = {}\n\n for (const secret of decryptedSecrets) {\n if (secret.name && secret.value) {\n secretsMap[secret.name] = secret.value\n }\n }\n\n return { data: secretsMap }\n }\n\n /**\n * List all secrets in the environment.\n * Only names and metadata are returned; values remain encrypted.\n *\n * API: GET /api/secrets/list?workspaceId=...&environment=...\n *\n * @returns A Result containing the list of secrets or an error\n */\n async list(): Promise<Result<SecretMetadata[], SecretsError>> {\n logger.debug('Listing secrets.')\n\n // Extract workspaceId from CRN\n const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN)\n\n const apiResult = await this.apiRequest<ListSecretsResponse>(\n 'GET',\n '/list',\n {\n params: {\n workspaceId,\n environment: this.config.environment,\n },\n },\n )\n\n if (apiResult.failure) {\n return apiResult\n }\n\n return { data: apiResult.data.secrets }\n }\n\n /**\n * Delete a secret from the vault.\n *\n * API: POST /api/secrets/delete\n *\n * @param name - The name of the secret to delete\n * @returns A Result containing the API response or an error\n */\n async delete(\n name: SecretName,\n ): Promise<Result<DeleteSecretResponse, SecretsError>> {\n logger.debug('Deleting secret')\n\n // Extract workspaceId from CRN\n const workspaceId = extractWorkspaceIdFromCrn(this.config.workspaceCRN)\n\n return await this.apiRequest<DeleteSecretResponse>('POST', '/delete', {\n body: {\n workspaceId,\n environment: this.config.environment,\n name,\n },\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwKO,IAAM,UAAN,MAAc;AAAA,EACX,mBAA4C;AAAA,EAC5C;AAAA,EACS,aACf,QAAQ,IAAI,iBAAiB;AAAA,EACd,gBAAgB,eAAe,WAAW;AAAA,IACzD,OAAO,gBAAgB,OAAO;AAAA,EAChC,CAAC;AAAA,EAED,YAAY,QAAuB;AACjC,UAAM,eAAe,OAAO,gBAAgB,QAAQ,IAAI;AACxD,UAAM,WAAW,OAAO,YAAY,QAAQ,IAAI;AAChD,UAAM,YAAY,OAAO,aAAa,QAAQ,I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