@cipherstash/stack 0.9.0 → 0.11.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.
- package/CHANGELOG.md +18 -0
- package/dist/bin/stash.js +101 -137
- package/dist/bin/stash.js.map +1 -1
- package/dist/{chunk-HCL75LXQ.js → chunk-46PDK2Z6.js} +1 -1
- package/dist/chunk-46PDK2Z6.js.map +1 -0
- package/dist/{chunk-3BOJHROP.js → chunk-EHDOOLWU.js} +3 -3
- package/dist/{chunk-Y3KSTOVR.js → chunk-GNLU3I27.js} +14 -3
- package/dist/chunk-GNLU3I27.js.map +1 -0
- package/dist/{chunk-4C52Q5R6.js → chunk-O4MBO4DJ.js} +8 -22
- package/dist/chunk-O4MBO4DJ.js.map +1 -0
- package/dist/{client-_63nbmO7.d.ts → client-CZLBiToT.d.ts} +1 -7
- package/dist/{client-CV7X5Hrt.d.cts → client-bW-5wG9Y.d.cts} +1 -7
- package/dist/client.cjs +13 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/drizzle/index.cjs +13 -2
- package/dist/drizzle/index.cjs.map +1 -1
- package/dist/drizzle/index.d.cts +2 -2
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +2 -2
- package/dist/dynamodb/index.d.cts +2 -2
- package/dist/dynamodb/index.d.ts +2 -2
- package/dist/encryption/index.cjs +22 -96
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +2 -2
- package/dist/encryption/index.d.ts +2 -2
- package/dist/encryption/index.js +3 -4
- package/dist/index.cjs +29 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/schema/index.cjs +13 -2
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/secrets/index.cjs +29 -81
- package/dist/secrets/index.cjs.map +1 -1
- package/dist/secrets/index.d.cts +1 -1
- package/dist/secrets/index.d.ts +1 -1
- package/dist/secrets/index.js +4 -4
- package/dist/supabase/index.cjs +12 -2
- package/dist/supabase/index.cjs.map +1 -1
- package/dist/supabase/index.d.cts +2 -2
- package/dist/supabase/index.d.ts +2 -2
- package/dist/supabase/index.js +1 -1
- package/dist/{types-public-B5YxQhR6.d.cts → types-public-WADaA-TW.d.cts} +119 -1
- package/dist/{types-public-B5YxQhR6.d.ts → types-public-WADaA-TW.d.ts} +119 -1
- package/dist/types-public.cjs.map +1 -1
- package/dist/types-public.d.cts +1 -1
- package/dist/types-public.d.ts +1 -1
- package/dist/types-public.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-4C52Q5R6.js.map +0 -1
- package/dist/chunk-HCL75LXQ.js.map +0 -1
- package/dist/chunk-Y3KSTOVR.js.map +0 -1
- /package/dist/{chunk-3BOJHROP.js.map → chunk-EHDOOLWU.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @cipherstash/stack
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b0e56b8: Upgrade protect-ffi to 0.21.0 and enable array_index_mode for searchable JSON
|
|
8
|
+
|
|
9
|
+
- Upgrade `@cipherstash/protect-ffi` to 0.21.0 across all packages
|
|
10
|
+
- Enable `array_index_mode: 'all'` on STE vec indexes so JSON array operations
|
|
11
|
+
(jsonb_array_elements, jsonb_array_length, array containment) work correctly
|
|
12
|
+
- Delegate credential resolution entirely to protect-ffi's `withEnvCredentials`
|
|
13
|
+
- Download latest EQL at build/runtime instead of bundling hardcoded SQL files
|
|
14
|
+
|
|
15
|
+
## 0.10.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 5245cd7: Improved CLI setup and initialization commands.
|
|
20
|
+
|
|
3
21
|
## 0.9.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/bin/stash.js
CHANGED
|
@@ -104,8 +104,8 @@ var require_package = __commonJS({
|
|
|
104
104
|
var require_main = __commonJS({
|
|
105
105
|
"../../node_modules/.pnpm/dotenv@16.4.7/node_modules/dotenv/lib/main.js"(exports, module) {
|
|
106
106
|
"use strict";
|
|
107
|
-
var
|
|
108
|
-
var
|
|
107
|
+
var fs = __require("fs");
|
|
108
|
+
var path = __require("path");
|
|
109
109
|
var os = __require("os");
|
|
110
110
|
var crypto = __require("crypto");
|
|
111
111
|
var packageJson = require_package();
|
|
@@ -211,7 +211,7 @@ var require_main = __commonJS({
|
|
|
211
211
|
if (options && options.path && options.path.length > 0) {
|
|
212
212
|
if (Array.isArray(options.path)) {
|
|
213
213
|
for (const filepath of options.path) {
|
|
214
|
-
if (
|
|
214
|
+
if (fs.existsSync(filepath)) {
|
|
215
215
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
@@ -219,15 +219,15 @@ var require_main = __commonJS({
|
|
|
219
219
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
220
220
|
}
|
|
221
221
|
} else {
|
|
222
|
-
possibleVaultPath =
|
|
222
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
223
223
|
}
|
|
224
|
-
if (
|
|
224
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
225
225
|
return possibleVaultPath;
|
|
226
226
|
}
|
|
227
227
|
return null;
|
|
228
228
|
}
|
|
229
229
|
function _resolveHome(envPath) {
|
|
230
|
-
return envPath[0] === "~" ?
|
|
230
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
231
231
|
}
|
|
232
232
|
function _configVault(options) {
|
|
233
233
|
_log("Loading env from encrypted .env.vault");
|
|
@@ -240,7 +240,7 @@ var require_main = __commonJS({
|
|
|
240
240
|
return { parsed };
|
|
241
241
|
}
|
|
242
242
|
function configDotenv(options) {
|
|
243
|
-
const dotenvPath =
|
|
243
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
244
244
|
let encoding = "utf8";
|
|
245
245
|
const debug = Boolean(options && options.debug);
|
|
246
246
|
if (options && options.encoding) {
|
|
@@ -263,13 +263,13 @@ var require_main = __commonJS({
|
|
|
263
263
|
}
|
|
264
264
|
let lastError;
|
|
265
265
|
const parsedAll = {};
|
|
266
|
-
for (const
|
|
266
|
+
for (const path2 of optionPaths) {
|
|
267
267
|
try {
|
|
268
|
-
const parsed = DotenvModule.parse(
|
|
268
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
|
|
269
269
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
270
270
|
} catch (e2) {
|
|
271
271
|
if (debug) {
|
|
272
|
-
_debug(`Failed to load ${
|
|
272
|
+
_debug(`Failed to load ${path2} ${e2.message}`);
|
|
273
273
|
}
|
|
274
274
|
lastError = e2;
|
|
275
275
|
}
|
|
@@ -1295,6 +1295,18 @@ function detectPackageManager() {
|
|
|
1295
1295
|
if (existsSync(resolve(cwd, "yarn.lock"))) return "yarn";
|
|
1296
1296
|
return "npm";
|
|
1297
1297
|
}
|
|
1298
|
+
function prodInstallCommand(pm, packageName) {
|
|
1299
|
+
switch (pm) {
|
|
1300
|
+
case "bun":
|
|
1301
|
+
return `bun add ${packageName}`;
|
|
1302
|
+
case "pnpm":
|
|
1303
|
+
return `pnpm add ${packageName}`;
|
|
1304
|
+
case "yarn":
|
|
1305
|
+
return `yarn add ${packageName}`;
|
|
1306
|
+
case "npm":
|
|
1307
|
+
return `npm install ${packageName}`;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1298
1310
|
function devInstallCommand(pm, packageName) {
|
|
1299
1311
|
switch (pm) {
|
|
1300
1312
|
case "bun":
|
|
@@ -1568,44 +1580,50 @@ var buildSchemaStep = {
|
|
|
1568
1580
|
|
|
1569
1581
|
// src/bin/commands/init/steps/install-forge.ts
|
|
1570
1582
|
import { execSync } from "node:child_process";
|
|
1583
|
+
var STACK_PACKAGE = "@cipherstash/stack";
|
|
1571
1584
|
var FORGE_PACKAGE = "@cipherstash/stack-forge";
|
|
1585
|
+
async function installIfNeeded(packageName, buildCommand, depLabel) {
|
|
1586
|
+
if (isPackageInstalled(packageName)) {
|
|
1587
|
+
M2.success(`${packageName} is already installed.`);
|
|
1588
|
+
return true;
|
|
1589
|
+
}
|
|
1590
|
+
const pm = detectPackageManager();
|
|
1591
|
+
const cmd = buildCommand(pm, packageName);
|
|
1592
|
+
const install = await ye({
|
|
1593
|
+
message: `Install ${packageName} as a ${depLabel} dependency? (${cmd})`
|
|
1594
|
+
});
|
|
1595
|
+
if (pD(install)) throw new CancelledError();
|
|
1596
|
+
if (!install) {
|
|
1597
|
+
M2.info(`Skipping ${packageName} installation.`);
|
|
1598
|
+
Me(
|
|
1599
|
+
`You can install it manually later:
|
|
1600
|
+
${cmd}`,
|
|
1601
|
+
"Manual Installation"
|
|
1602
|
+
);
|
|
1603
|
+
return false;
|
|
1604
|
+
}
|
|
1605
|
+
const s = Y2();
|
|
1606
|
+
s.start(`Installing ${packageName}...`);
|
|
1607
|
+
try {
|
|
1608
|
+
execSync(cmd, { cwd: process.cwd(), stdio: "pipe" });
|
|
1609
|
+
s.stop(`${packageName} installed successfully`);
|
|
1610
|
+
return true;
|
|
1611
|
+
} catch (err) {
|
|
1612
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1613
|
+
s.stop(`${packageName} installation failed`);
|
|
1614
|
+
M2.error(message);
|
|
1615
|
+
Me(`You can install it manually:
|
|
1616
|
+
${cmd}`, "Manual Installation");
|
|
1617
|
+
return false;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1572
1620
|
var installForgeStep = {
|
|
1573
1621
|
id: "install-forge",
|
|
1574
|
-
name: "Install stack
|
|
1622
|
+
name: "Install stack dependencies",
|
|
1575
1623
|
async run(state, _provider) {
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
}
|
|
1580
|
-
const pm = detectPackageManager();
|
|
1581
|
-
const cmd = devInstallCommand(pm, FORGE_PACKAGE);
|
|
1582
|
-
const install = await ye({
|
|
1583
|
-
message: `Install ${FORGE_PACKAGE} as a dev dependency? (${cmd})`
|
|
1584
|
-
});
|
|
1585
|
-
if (pD(install)) throw new CancelledError();
|
|
1586
|
-
if (!install) {
|
|
1587
|
-
M2.info(`Skipping ${FORGE_PACKAGE} installation.`);
|
|
1588
|
-
Me(
|
|
1589
|
-
`You can install it manually later:
|
|
1590
|
-
${cmd}`,
|
|
1591
|
-
"Manual Installation"
|
|
1592
|
-
);
|
|
1593
|
-
return { ...state, forgeInstalled: false };
|
|
1594
|
-
}
|
|
1595
|
-
const s = Y2();
|
|
1596
|
-
s.start(`Installing ${FORGE_PACKAGE}...`);
|
|
1597
|
-
try {
|
|
1598
|
-
execSync(cmd, { cwd: process.cwd(), stdio: "pipe" });
|
|
1599
|
-
s.stop(`${FORGE_PACKAGE} installed successfully`);
|
|
1600
|
-
return { ...state, forgeInstalled: true };
|
|
1601
|
-
} catch (err) {
|
|
1602
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
1603
|
-
s.stop(`${FORGE_PACKAGE} installation failed`);
|
|
1604
|
-
M2.error(message);
|
|
1605
|
-
Me(`You can install it manually:
|
|
1606
|
-
${cmd}`, "Manual Installation");
|
|
1607
|
-
return { ...state, forgeInstalled: false };
|
|
1608
|
-
}
|
|
1624
|
+
const stackInstalled = await installIfNeeded(STACK_PACKAGE, prodInstallCommand, "production");
|
|
1625
|
+
const forgeInstalled = await installIfNeeded(FORGE_PACKAGE, devInstallCommand, "dev");
|
|
1626
|
+
return { ...state, forgeInstalled, stackInstalled };
|
|
1609
1627
|
}
|
|
1610
1628
|
};
|
|
1611
1629
|
|
|
@@ -1750,8 +1768,18 @@ var matchIndexOptsSchema = z2.object({
|
|
|
1750
1768
|
m: z2.number().default(2048).optional(),
|
|
1751
1769
|
include_original: z2.boolean().default(false).optional()
|
|
1752
1770
|
});
|
|
1771
|
+
var arrayIndexModeSchema = z2.union([
|
|
1772
|
+
z2.literal("all"),
|
|
1773
|
+
z2.literal("none"),
|
|
1774
|
+
z2.object({
|
|
1775
|
+
item: z2.boolean().optional(),
|
|
1776
|
+
wildcard: z2.boolean().optional(),
|
|
1777
|
+
position: z2.boolean().optional()
|
|
1778
|
+
})
|
|
1779
|
+
]);
|
|
1753
1780
|
var steVecIndexOptsSchema = z2.object({
|
|
1754
|
-
prefix: z2.string()
|
|
1781
|
+
prefix: z2.string(),
|
|
1782
|
+
array_index_mode: arrayIndexModeSchema.optional()
|
|
1755
1783
|
});
|
|
1756
1784
|
var indexesSchema = z2.object({
|
|
1757
1785
|
ore: oreIndexOptsSchema.optional(),
|
|
@@ -1948,7 +1976,7 @@ var EncryptedColumn = class {
|
|
|
1948
1976
|
*/
|
|
1949
1977
|
searchableJson() {
|
|
1950
1978
|
this.castAsValue = "json";
|
|
1951
|
-
this.indexesValue.ste_vec = { prefix: "enabled" };
|
|
1979
|
+
this.indexesValue.ste_vec = { prefix: "enabled", array_index_mode: "all" };
|
|
1952
1980
|
return this;
|
|
1953
1981
|
}
|
|
1954
1982
|
build() {
|
|
@@ -1996,6 +2024,7 @@ var EncryptedTable = class {
|
|
|
1996
2024
|
indexes: {
|
|
1997
2025
|
...builtColumn.indexes,
|
|
1998
2026
|
ste_vec: {
|
|
2027
|
+
...builtColumn.indexes.ste_vec,
|
|
1999
2028
|
prefix: `${this.tableName}/${colName}`
|
|
2000
2029
|
}
|
|
2001
2030
|
}
|
|
@@ -2057,69 +2086,6 @@ var EncryptionErrorTypes = {
|
|
|
2057
2086
|
CtsTokenError: "CtsTokenError"
|
|
2058
2087
|
};
|
|
2059
2088
|
|
|
2060
|
-
// src/utils/config/index.ts
|
|
2061
|
-
import fs from "node:fs";
|
|
2062
|
-
import path from "node:path";
|
|
2063
|
-
function getWorkspaceCrn(tomlString) {
|
|
2064
|
-
let currentSection = "";
|
|
2065
|
-
let workspaceCrn;
|
|
2066
|
-
const lines = tomlString.split(/\r?\n/);
|
|
2067
|
-
for (const line of lines) {
|
|
2068
|
-
const trimmedLine = line.trim();
|
|
2069
|
-
if (!trimmedLine || trimmedLine.startsWith("#")) {
|
|
2070
|
-
continue;
|
|
2071
|
-
}
|
|
2072
|
-
const sectionMatch = trimmedLine.match(/^\[([^\]]+)\]$/);
|
|
2073
|
-
if (sectionMatch) {
|
|
2074
|
-
currentSection = sectionMatch[1];
|
|
2075
|
-
continue;
|
|
2076
|
-
}
|
|
2077
|
-
const kvMatch = trimmedLine.match(/^(\w+)\s*=\s*"([^"]+)"$/);
|
|
2078
|
-
if (kvMatch) {
|
|
2079
|
-
const [_3, key, value] = kvMatch;
|
|
2080
|
-
if (currentSection === "auth" && key === "workspace_crn") {
|
|
2081
|
-
workspaceCrn = value;
|
|
2082
|
-
break;
|
|
2083
|
-
}
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
return workspaceCrn;
|
|
2087
|
-
}
|
|
2088
|
-
function extractWorkspaceIdFromCrn(crn) {
|
|
2089
|
-
const match = crn.match(/crn:[^:]+:([^:]+)$/);
|
|
2090
|
-
if (!match) {
|
|
2091
|
-
throw new Error("Invalid CRN format");
|
|
2092
|
-
}
|
|
2093
|
-
return match[1];
|
|
2094
|
-
}
|
|
2095
|
-
function loadWorkSpaceId(suppliedCrn) {
|
|
2096
|
-
const configPath = path.join(process.cwd(), "cipherstash.toml");
|
|
2097
|
-
if (suppliedCrn) {
|
|
2098
|
-
return extractWorkspaceIdFromCrn(suppliedCrn);
|
|
2099
|
-
}
|
|
2100
|
-
if (!fs.existsSync(configPath) && !process.env.CS_WORKSPACE_CRN) {
|
|
2101
|
-
throw new Error(
|
|
2102
|
-
"You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
|
|
2103
|
-
);
|
|
2104
|
-
}
|
|
2105
|
-
if (process.env.CS_WORKSPACE_CRN) {
|
|
2106
|
-
return extractWorkspaceIdFromCrn(process.env.CS_WORKSPACE_CRN);
|
|
2107
|
-
}
|
|
2108
|
-
if (!fs.existsSync(configPath)) {
|
|
2109
|
-
throw new Error(
|
|
2110
|
-
"You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
|
|
2111
|
-
);
|
|
2112
|
-
}
|
|
2113
|
-
const tomlString = fs.readFileSync(configPath, "utf8");
|
|
2114
|
-
const workspaceCrn = getWorkspaceCrn(tomlString);
|
|
2115
|
-
if (!workspaceCrn) {
|
|
2116
|
-
throw new Error(
|
|
2117
|
-
"You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
|
|
2118
|
-
);
|
|
2119
|
-
}
|
|
2120
|
-
return extractWorkspaceIdFromCrn(workspaceCrn);
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
2089
|
// src/utils/logger/index.ts
|
|
2124
2090
|
import { createRequestLogger, initLogger } from "evlog";
|
|
2125
2091
|
var validLevels = ["debug", "info", "error"];
|
|
@@ -2613,11 +2579,11 @@ import {
|
|
|
2613
2579
|
decryptBulk,
|
|
2614
2580
|
encryptBulk
|
|
2615
2581
|
} from "@cipherstash/protect-ffi";
|
|
2616
|
-
function setNestedValue(obj,
|
|
2582
|
+
function setNestedValue(obj, path, value) {
|
|
2617
2583
|
const FORBIDDEN_KEYS = ["__proto__", "prototype", "constructor"];
|
|
2618
2584
|
let current = obj;
|
|
2619
|
-
for (let i = 0; i <
|
|
2620
|
-
const part =
|
|
2585
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
2586
|
+
const part = path[i];
|
|
2621
2587
|
if (FORBIDDEN_KEYS.includes(part)) {
|
|
2622
2588
|
throw new Error(`[encryption]: Forbidden key "${part}" in field path`);
|
|
2623
2589
|
}
|
|
@@ -2626,7 +2592,7 @@ function setNestedValue(obj, path2, value) {
|
|
|
2626
2592
|
}
|
|
2627
2593
|
current = current[part];
|
|
2628
2594
|
}
|
|
2629
|
-
const lastKey =
|
|
2595
|
+
const lastKey = path[path.length - 1];
|
|
2630
2596
|
if (FORBIDDEN_KEYS.includes(lastKey)) {
|
|
2631
2597
|
throw new Error(`[encryption]: Forbidden key "${lastKey}" in field path`);
|
|
2632
2598
|
}
|
|
@@ -2703,7 +2669,7 @@ function prepareFieldsForEncryption(model, table) {
|
|
|
2703
2669
|
continue;
|
|
2704
2670
|
}
|
|
2705
2671
|
if (typeof value === "object" && !isEncryptedPayload(value) && !columnPaths2.includes(fullKey)) {
|
|
2706
|
-
if (columnPaths2.some((
|
|
2672
|
+
if (columnPaths2.some((path) => path.startsWith(fullKey))) {
|
|
2707
2673
|
processNestedFields(
|
|
2708
2674
|
value,
|
|
2709
2675
|
fullKey,
|
|
@@ -2881,7 +2847,7 @@ function prepareBulkModelsForOperation(models, table) {
|
|
|
2881
2847
|
continue;
|
|
2882
2848
|
}
|
|
2883
2849
|
if (typeof value === "object" && !isEncryptedPayload(value) && !columnPaths.includes(fullKey)) {
|
|
2884
|
-
if (columnPaths.some((
|
|
2850
|
+
if (columnPaths.some((path) => path.startsWith(fullKey))) {
|
|
2885
2851
|
processNestedFields(
|
|
2886
2852
|
value,
|
|
2887
2853
|
fullKey,
|
|
@@ -4056,11 +4022,6 @@ var noClientError = () => new Error(
|
|
|
4056
4022
|
var EncryptionClient = class {
|
|
4057
4023
|
client;
|
|
4058
4024
|
encryptConfig;
|
|
4059
|
-
workspaceId;
|
|
4060
|
-
constructor(workspaceCrn) {
|
|
4061
|
-
const workspaceId = loadWorkSpaceId(workspaceCrn);
|
|
4062
|
-
this.workspaceId = workspaceId;
|
|
4063
|
-
}
|
|
4064
4025
|
/**
|
|
4065
4026
|
* Initializes the EncryptionClient with the provided configuration.
|
|
4066
4027
|
* @internal
|
|
@@ -4082,10 +4043,10 @@ var EncryptionClient = class {
|
|
|
4082
4043
|
this.client = await newClient({
|
|
4083
4044
|
encryptConfig: validated,
|
|
4084
4045
|
clientOpts: {
|
|
4085
|
-
workspaceCrn: config3.workspaceCrn
|
|
4086
|
-
accessKey: config3.accessKey
|
|
4087
|
-
clientId: config3.clientId
|
|
4088
|
-
clientKey: config3.clientKey
|
|
4046
|
+
workspaceCrn: config3.workspaceCrn,
|
|
4047
|
+
accessKey: config3.accessKey,
|
|
4048
|
+
clientId: config3.clientId,
|
|
4049
|
+
clientKey: config3.clientKey,
|
|
4089
4050
|
keyset: toFfiKeysetIdentifier(config3.keyset)
|
|
4090
4051
|
}
|
|
4091
4052
|
});
|
|
@@ -4470,12 +4431,6 @@ var EncryptionClient = class {
|
|
|
4470
4431
|
bulkDecrypt(encryptedPayloads) {
|
|
4471
4432
|
return new BulkDecryptOperation(this.client, encryptedPayloads);
|
|
4472
4433
|
}
|
|
4473
|
-
/** e.g., debugging or environment info */
|
|
4474
|
-
clientInfo() {
|
|
4475
|
-
return {
|
|
4476
|
-
workspaceId: this.workspaceId
|
|
4477
|
-
};
|
|
4478
|
-
}
|
|
4479
4434
|
/**
|
|
4480
4435
|
* Get the encrypt config object.
|
|
4481
4436
|
*
|
|
@@ -4497,7 +4452,7 @@ var Encryption = async (config3) => {
|
|
|
4497
4452
|
"[encryption]: Invalid UUID provided for keyset id. Must be a valid UUID."
|
|
4498
4453
|
);
|
|
4499
4454
|
}
|
|
4500
|
-
const client = new EncryptionClient(
|
|
4455
|
+
const client = new EncryptionClient();
|
|
4501
4456
|
const encryptConfig = buildEncryptConfig(...schemas);
|
|
4502
4457
|
const result = await client.init({
|
|
4503
4458
|
encryptConfig,
|
|
@@ -4509,6 +4464,15 @@ var Encryption = async (config3) => {
|
|
|
4509
4464
|
return result.data;
|
|
4510
4465
|
};
|
|
4511
4466
|
|
|
4467
|
+
// src/utils/config/index.ts
|
|
4468
|
+
function extractWorkspaceIdFromCrn(crn) {
|
|
4469
|
+
const match = crn.match(/crn:[^:]+:([^:]+)$/);
|
|
4470
|
+
if (!match) {
|
|
4471
|
+
throw new Error("Invalid CRN format");
|
|
4472
|
+
}
|
|
4473
|
+
return match[1];
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4512
4476
|
// src/secrets/index.ts
|
|
4513
4477
|
var Secrets = class {
|
|
4514
4478
|
encryptionClient = null;
|
|
@@ -4571,14 +4535,14 @@ var Secrets = class {
|
|
|
4571
4535
|
* For GET requests, `params` are appended as URL query parameters.
|
|
4572
4536
|
* For POST requests, `body` is sent as JSON in the request body.
|
|
4573
4537
|
*/
|
|
4574
|
-
async apiRequest(method,
|
|
4538
|
+
async apiRequest(method, path, options) {
|
|
4575
4539
|
try {
|
|
4576
|
-
let url = `${this.apiBaseUrl}${
|
|
4540
|
+
let url = `${this.apiBaseUrl}${path}`;
|
|
4577
4541
|
if (options?.params) {
|
|
4578
4542
|
const searchParams = new URLSearchParams(options.params);
|
|
4579
4543
|
url = `${url}?${searchParams.toString()}`;
|
|
4580
4544
|
}
|
|
4581
|
-
logger.debug(`Secrets API request: ${method} ${
|
|
4545
|
+
logger.debug(`Secrets API request: ${method} ${path}`);
|
|
4582
4546
|
const headers = {
|
|
4583
4547
|
"Content-Type": "application/json",
|
|
4584
4548
|
Authorization: this.getAuthHeader()
|
|
@@ -4597,7 +4561,7 @@ var Secrets = class {
|
|
|
4597
4561
|
} catch {
|
|
4598
4562
|
errorMessage = errorText || errorMessage;
|
|
4599
4563
|
}
|
|
4600
|
-
logger.error(`Secrets API error on ${method} ${
|
|
4564
|
+
logger.error(`Secrets API error on ${method} ${path}: ${errorMessage}`);
|
|
4601
4565
|
return {
|
|
4602
4566
|
failure: {
|
|
4603
4567
|
type: "ApiError",
|
|
@@ -4605,12 +4569,12 @@ var Secrets = class {
|
|
|
4605
4569
|
}
|
|
4606
4570
|
};
|
|
4607
4571
|
}
|
|
4608
|
-
logger.debug(`Secrets API request successful: ${method} ${
|
|
4572
|
+
logger.debug(`Secrets API request successful: ${method} ${path}`);
|
|
4609
4573
|
const data = await response.json();
|
|
4610
4574
|
return { data };
|
|
4611
4575
|
} catch (error) {
|
|
4612
4576
|
const message = error instanceof Error ? error.message : "Unknown network error occurred";
|
|
4613
|
-
logger.error(`Secrets network error on ${method} ${
|
|
4577
|
+
logger.error(`Secrets network error on ${method} ${path}: ${message}`);
|
|
4614
4578
|
return {
|
|
4615
4579
|
failure: {
|
|
4616
4580
|
type: "NetworkError",
|