@cipherstash/stack 0.10.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 +12 -0
- package/dist/bin/stash.js +49 -103
- 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/dist/drizzle/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
2
2
|
import { PgTable, PgCustomColumn } from 'drizzle-orm/pg-core';
|
|
3
|
-
import { c as EncryptedTable, f as EncryptedColumn, C as CastAs, M as MatchIndexOpts, T as TokenFilter } from '../types-public-
|
|
4
|
-
import { a as EncryptionClient } from '../client-
|
|
3
|
+
import { c as EncryptedTable, f as EncryptedColumn, C as CastAs, M as MatchIndexOpts, T as TokenFilter } from '../types-public-WADaA-TW.cjs';
|
|
4
|
+
import { a as EncryptionClient } from '../client-bW-5wG9Y.cjs';
|
|
5
5
|
import { SQLWrapper, SQL, exists, notExists, isNull, isNotNull, not, arrayContains, arrayContained, arrayOverlaps } from 'drizzle-orm';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import '@cipherstash/protect-ffi';
|
package/dist/drizzle/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
2
2
|
import { PgTable, PgCustomColumn } from 'drizzle-orm/pg-core';
|
|
3
|
-
import { c as EncryptedTable, f as EncryptedColumn, C as CastAs, M as MatchIndexOpts, T as TokenFilter } from '../types-public-
|
|
4
|
-
import { a as EncryptionClient } from '../client-
|
|
3
|
+
import { c as EncryptedTable, f as EncryptedColumn, C as CastAs, M as MatchIndexOpts, T as TokenFilter } from '../types-public-WADaA-TW.js';
|
|
4
|
+
import { a as EncryptionClient } from '../client-CZLBiToT.js';
|
|
5
5
|
import { SQLWrapper, SQL, exists, notExists, isNull, isNotNull, not, arrayContains, arrayContained, arrayOverlaps } from 'drizzle-orm';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import '@cipherstash/protect-ffi';
|
package/dist/drizzle/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
encryptedColumn,
|
|
3
3
|
encryptedTable
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-GNLU3I27.js";
|
|
5
5
|
import {
|
|
6
6
|
queryTypes
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-46PDK2Z6.js";
|
|
8
8
|
|
|
9
9
|
// src/drizzle/index.ts
|
|
10
10
|
import { customType } from "drizzle-orm/pg-core";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as EncryptionClient } from '../client-
|
|
2
|
-
import { D as Decrypted, g as EncryptedValue, c as EncryptedTable, d as EncryptedTableColumn } from '../types-public-
|
|
1
|
+
import { a as EncryptionClient } from '../client-bW-5wG9Y.cjs';
|
|
2
|
+
import { D as Decrypted, g as EncryptedValue, c as EncryptedTable, d as EncryptedTableColumn } from '../types-public-WADaA-TW.cjs';
|
|
3
3
|
import { ProtectErrorCode } from '@cipherstash/protect-ffi';
|
|
4
4
|
import { Result } from '@byteslice/result';
|
|
5
5
|
import '../errors/index.cjs';
|
package/dist/dynamodb/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as EncryptionClient } from '../client-
|
|
2
|
-
import { D as Decrypted, g as EncryptedValue, c as EncryptedTable, d as EncryptedTableColumn } from '../types-public-
|
|
1
|
+
import { a as EncryptionClient } from '../client-CZLBiToT.js';
|
|
2
|
+
import { D as Decrypted, g as EncryptedValue, c as EncryptedTable, d as EncryptedTableColumn } from '../types-public-WADaA-TW.js';
|
|
3
3
|
import { ProtectErrorCode } from '@cipherstash/protect-ffi';
|
|
4
4
|
import { Result } from '@byteslice/result';
|
|
5
5
|
import '../errors/index.js';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/encryption/index.ts
|
|
@@ -82,8 +72,18 @@ var matchIndexOptsSchema = import_zod.z.object({
|
|
|
82
72
|
m: import_zod.z.number().default(2048).optional(),
|
|
83
73
|
include_original: import_zod.z.boolean().default(false).optional()
|
|
84
74
|
});
|
|
75
|
+
var arrayIndexModeSchema = import_zod.z.union([
|
|
76
|
+
import_zod.z.literal("all"),
|
|
77
|
+
import_zod.z.literal("none"),
|
|
78
|
+
import_zod.z.object({
|
|
79
|
+
item: import_zod.z.boolean().optional(),
|
|
80
|
+
wildcard: import_zod.z.boolean().optional(),
|
|
81
|
+
position: import_zod.z.boolean().optional()
|
|
82
|
+
})
|
|
83
|
+
]);
|
|
85
84
|
var steVecIndexOptsSchema = import_zod.z.object({
|
|
86
|
-
prefix: import_zod.z.string()
|
|
85
|
+
prefix: import_zod.z.string(),
|
|
86
|
+
array_index_mode: arrayIndexModeSchema.optional()
|
|
87
87
|
});
|
|
88
88
|
var indexesSchema = import_zod.z.object({
|
|
89
89
|
ore: oreIndexOptsSchema.optional(),
|
|
@@ -113,69 +113,6 @@ function buildEncryptConfig(...protectTables) {
|
|
|
113
113
|
return config;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
// src/utils/config/index.ts
|
|
117
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
118
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
119
|
-
function getWorkspaceCrn(tomlString) {
|
|
120
|
-
let currentSection = "";
|
|
121
|
-
let workspaceCrn;
|
|
122
|
-
const lines = tomlString.split(/\r?\n/);
|
|
123
|
-
for (const line of lines) {
|
|
124
|
-
const trimmedLine = line.trim();
|
|
125
|
-
if (!trimmedLine || trimmedLine.startsWith("#")) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
const sectionMatch = trimmedLine.match(/^\[([^\]]+)\]$/);
|
|
129
|
-
if (sectionMatch) {
|
|
130
|
-
currentSection = sectionMatch[1];
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
const kvMatch = trimmedLine.match(/^(\w+)\s*=\s*"([^"]+)"$/);
|
|
134
|
-
if (kvMatch) {
|
|
135
|
-
const [_, key, value] = kvMatch;
|
|
136
|
-
if (currentSection === "auth" && key === "workspace_crn") {
|
|
137
|
-
workspaceCrn = value;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return workspaceCrn;
|
|
143
|
-
}
|
|
144
|
-
function extractWorkspaceIdFromCrn(crn) {
|
|
145
|
-
const match = crn.match(/crn:[^:]+:([^:]+)$/);
|
|
146
|
-
if (!match) {
|
|
147
|
-
throw new Error("Invalid CRN format");
|
|
148
|
-
}
|
|
149
|
-
return match[1];
|
|
150
|
-
}
|
|
151
|
-
function loadWorkSpaceId(suppliedCrn) {
|
|
152
|
-
const configPath = import_node_path.default.join(process.cwd(), "cipherstash.toml");
|
|
153
|
-
if (suppliedCrn) {
|
|
154
|
-
return extractWorkspaceIdFromCrn(suppliedCrn);
|
|
155
|
-
}
|
|
156
|
-
if (!import_node_fs.default.existsSync(configPath) && !process.env.CS_WORKSPACE_CRN) {
|
|
157
|
-
throw new Error(
|
|
158
|
-
"You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
if (process.env.CS_WORKSPACE_CRN) {
|
|
162
|
-
return extractWorkspaceIdFromCrn(process.env.CS_WORKSPACE_CRN);
|
|
163
|
-
}
|
|
164
|
-
if (!import_node_fs.default.existsSync(configPath)) {
|
|
165
|
-
throw new Error(
|
|
166
|
-
"You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
const tomlString = import_node_fs.default.readFileSync(configPath, "utf8");
|
|
170
|
-
const workspaceCrn = getWorkspaceCrn(tomlString);
|
|
171
|
-
if (!workspaceCrn) {
|
|
172
|
-
throw new Error(
|
|
173
|
-
"You have not defined a workspace CRN in your config file, or the CS_WORKSPACE_CRN environment variable."
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
return extractWorkspaceIdFromCrn(workspaceCrn);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
116
|
// src/utils/logger/index.ts
|
|
180
117
|
var import_evlog = require("evlog");
|
|
181
118
|
var validLevels = ["debug", "info", "error"];
|
|
@@ -693,11 +630,11 @@ var import_result3 = require("@byteslice/result");
|
|
|
693
630
|
|
|
694
631
|
// src/encryption/helpers/model-helpers.ts
|
|
695
632
|
var import_protect_ffi4 = require("@cipherstash/protect-ffi");
|
|
696
|
-
function setNestedValue(obj,
|
|
633
|
+
function setNestedValue(obj, path, value) {
|
|
697
634
|
const FORBIDDEN_KEYS = ["__proto__", "prototype", "constructor"];
|
|
698
635
|
let current = obj;
|
|
699
|
-
for (let i = 0; i <
|
|
700
|
-
const part =
|
|
636
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
637
|
+
const part = path[i];
|
|
701
638
|
if (FORBIDDEN_KEYS.includes(part)) {
|
|
702
639
|
throw new Error(`[encryption]: Forbidden key "${part}" in field path`);
|
|
703
640
|
}
|
|
@@ -706,7 +643,7 @@ function setNestedValue(obj, path2, value) {
|
|
|
706
643
|
}
|
|
707
644
|
current = current[part];
|
|
708
645
|
}
|
|
709
|
-
const lastKey =
|
|
646
|
+
const lastKey = path[path.length - 1];
|
|
710
647
|
if (FORBIDDEN_KEYS.includes(lastKey)) {
|
|
711
648
|
throw new Error(`[encryption]: Forbidden key "${lastKey}" in field path`);
|
|
712
649
|
}
|
|
@@ -783,7 +720,7 @@ function prepareFieldsForEncryption(model, table) {
|
|
|
783
720
|
continue;
|
|
784
721
|
}
|
|
785
722
|
if (typeof value === "object" && !isEncryptedPayload(value) && !columnPaths2.includes(fullKey)) {
|
|
786
|
-
if (columnPaths2.some((
|
|
723
|
+
if (columnPaths2.some((path) => path.startsWith(fullKey))) {
|
|
787
724
|
processNestedFields(
|
|
788
725
|
value,
|
|
789
726
|
fullKey,
|
|
@@ -961,7 +898,7 @@ function prepareBulkModelsForOperation(models, table) {
|
|
|
961
898
|
continue;
|
|
962
899
|
}
|
|
963
900
|
if (typeof value === "object" && !isEncryptedPayload(value) && !columnPaths.includes(fullKey)) {
|
|
964
|
-
if (columnPaths.some((
|
|
901
|
+
if (columnPaths.some((path) => path.startsWith(fullKey))) {
|
|
965
902
|
processNestedFields(
|
|
966
903
|
value,
|
|
967
904
|
fullKey,
|
|
@@ -2130,11 +2067,6 @@ var noClientError = () => new Error(
|
|
|
2130
2067
|
var EncryptionClient = class {
|
|
2131
2068
|
client;
|
|
2132
2069
|
encryptConfig;
|
|
2133
|
-
workspaceId;
|
|
2134
|
-
constructor(workspaceCrn) {
|
|
2135
|
-
const workspaceId = loadWorkSpaceId(workspaceCrn);
|
|
2136
|
-
this.workspaceId = workspaceId;
|
|
2137
|
-
}
|
|
2138
2070
|
/**
|
|
2139
2071
|
* Initializes the EncryptionClient with the provided configuration.
|
|
2140
2072
|
* @internal
|
|
@@ -2156,10 +2088,10 @@ var EncryptionClient = class {
|
|
|
2156
2088
|
this.client = await (0, import_protect_ffi9.newClient)({
|
|
2157
2089
|
encryptConfig: validated,
|
|
2158
2090
|
clientOpts: {
|
|
2159
|
-
workspaceCrn: config.workspaceCrn
|
|
2160
|
-
accessKey: config.accessKey
|
|
2161
|
-
clientId: config.clientId
|
|
2162
|
-
clientKey: config.clientKey
|
|
2091
|
+
workspaceCrn: config.workspaceCrn,
|
|
2092
|
+
accessKey: config.accessKey,
|
|
2093
|
+
clientId: config.clientId,
|
|
2094
|
+
clientKey: config.clientKey,
|
|
2163
2095
|
keyset: toFfiKeysetIdentifier(config.keyset)
|
|
2164
2096
|
}
|
|
2165
2097
|
});
|
|
@@ -2544,12 +2476,6 @@ var EncryptionClient = class {
|
|
|
2544
2476
|
bulkDecrypt(encryptedPayloads) {
|
|
2545
2477
|
return new BulkDecryptOperation(this.client, encryptedPayloads);
|
|
2546
2478
|
}
|
|
2547
|
-
/** e.g., debugging or environment info */
|
|
2548
|
-
clientInfo() {
|
|
2549
|
-
return {
|
|
2550
|
-
workspaceId: this.workspaceId
|
|
2551
|
-
};
|
|
2552
|
-
}
|
|
2553
2479
|
/**
|
|
2554
2480
|
* Get the encrypt config object.
|
|
2555
2481
|
*
|
|
@@ -2571,7 +2497,7 @@ var Encryption = async (config) => {
|
|
|
2571
2497
|
"[encryption]: Invalid UUID provided for keyset id. Must be a valid UUID."
|
|
2572
2498
|
);
|
|
2573
2499
|
}
|
|
2574
|
-
const client = new EncryptionClient(
|
|
2500
|
+
const client = new EncryptionClient();
|
|
2575
2501
|
const encryptConfig = buildEncryptConfig(...schemas);
|
|
2576
2502
|
const result = await client.init({
|
|
2577
2503
|
encryptConfig,
|