stitchkit 0.136.7 → 0.136.8
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 +15 -0
- package/dist/entrypoints/cli/publish.d.ts +4 -4
- package/dist/entrypoints/cli/publish.d.ts.map +1 -1
- package/dist/entrypoints/cli/publish.js +154 -46
- package/dist/entrypoints/cli.d.ts +1 -1
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +3 -1
- package/dist/entrypoints/postgres.d.ts +3 -1
- package/dist/entrypoints/postgres.d.ts.map +1 -1
- package/dist/entrypoints/postgres.js +246 -0
- package/dist/{index-f103md2v.js → index-3zt0r4y0.js} +84 -19
- package/dist/postgres/connection-config.d.ts +54 -0
- package/dist/postgres/connection-config.d.ts.map +1 -0
- package/dist/tools/cli/distribution-config.d.ts +39 -1
- package/dist/tools/cli/distribution-config.d.ts.map +1 -1
- package/dist/tools/cli/distribution-routes.d.ts +4 -2
- package/dist/tools/cli/distribution-routes.d.ts.map +1 -1
- package/dist/tools/cli/publication-contract.d.ts +9 -2
- package/dist/tools/cli/publication-contract.d.ts.map +1 -1
- package/dist/tools/cli/publication.d.ts.map +1 -1
- package/dist/tools/cli/signature.d.ts +23 -9
- package/dist/tools/cli/signature.d.ts.map +1 -1
- package/dist/tools/cli/update.d.ts +6 -1
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/llms/cli-publish.txt +4 -1
- package/llms/cli.2.txt +32 -43
- package/llms/cli.3.txt +32 -1
- package/llms/postgres.txt +13 -3
- package/llms/stitchkit.txt +3 -3
- package/llms-full.txt +53 -20
- package/llms.txt +4 -4
- package/package.json +3 -3
|
@@ -1,3 +1,248 @@
|
|
|
1
|
+
// src/postgres/connection-config.ts
|
|
2
|
+
var CONTROL_CHAR_PATTERN = /[\u0000-\u001f\u007f]/;
|
|
3
|
+
var ALLOWED_PROTOCOLS = new Set(["postgres:", "postgresql:", "socket:"]);
|
|
4
|
+
var EMPTY_HOST_WITH_CREDS = /^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/?#]*@)\//;
|
|
5
|
+
var TIME_ZONE_PATTERN = /^[A-Za-z0-9_+-][A-Za-z0-9_./+:,-]{0,127}$/;
|
|
6
|
+
var SEARCH_PATH_ITEM_PATTERN = /^(?:\$user|"\$user"|[A-Za-z_][A-Za-z0-9_$]{0,62}|"(?:[^"\\\s]|""){1,63}")$/;
|
|
7
|
+
var PARAMETER_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,62}(?:\.[A-Za-z_][A-Za-z0-9_]{0,62})?$/;
|
|
8
|
+
var RESERVED_PARAMETERS = new Set(["timezone", "search_path"]);
|
|
9
|
+
function isPlainObject(value) {
|
|
10
|
+
if (typeof value !== "object" || value === null)
|
|
11
|
+
return false;
|
|
12
|
+
const proto = Object.getPrototypeOf(value);
|
|
13
|
+
return proto === Object.prototype || proto === null;
|
|
14
|
+
}
|
|
15
|
+
function parseAndStripConnectionString(raw) {
|
|
16
|
+
if (typeof raw !== "string" || raw.length === 0 || raw !== raw.trim() || CONTROL_CHAR_PATTERN.test(raw)) {
|
|
17
|
+
throw new TypeError("postgresConnectionConfig received an invalid PostgreSQL connectionString");
|
|
18
|
+
}
|
|
19
|
+
if (raw.startsWith("/")) {
|
|
20
|
+
return { connectionString: raw, urlOptions: [] };
|
|
21
|
+
}
|
|
22
|
+
const candidateUrl = EMPTY_HOST_WITH_CREDS.test(raw) ? raw.replace(EMPTY_HOST_WITH_CREDS, "$1___stitchkit_empty_host___/") : raw;
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = new URL(candidateUrl);
|
|
26
|
+
} catch {
|
|
27
|
+
throw new TypeError("postgresConnectionConfig received an invalid PostgreSQL connectionString");
|
|
28
|
+
}
|
|
29
|
+
if (!ALLOWED_PROTOCOLS.has(parsed.protocol)) {
|
|
30
|
+
throw new TypeError("postgresConnectionConfig connectionString must use postgres://, postgresql://, or socket:");
|
|
31
|
+
}
|
|
32
|
+
if (parsed.protocol === "socket:") {
|
|
33
|
+
if (parsed.pathname.length === 0) {
|
|
34
|
+
throw new TypeError("postgresConnectionConfig socket: connectionString must include a socket path");
|
|
35
|
+
}
|
|
36
|
+
} else if (!raw.slice(parsed.protocol.length).startsWith("//")) {
|
|
37
|
+
throw new TypeError("postgresConnectionConfig connectionString must use an authority-form postgres:// or postgresql:// URL");
|
|
38
|
+
}
|
|
39
|
+
const hashIndex = raw.indexOf("#");
|
|
40
|
+
const withoutHash = hashIndex === -1 ? raw : raw.slice(0, hashIndex);
|
|
41
|
+
const hashPart = hashIndex === -1 ? "" : raw.slice(hashIndex);
|
|
42
|
+
const queryIndex = withoutHash.indexOf("?");
|
|
43
|
+
if (queryIndex === -1) {
|
|
44
|
+
return { connectionString: raw, urlOptions: [] };
|
|
45
|
+
}
|
|
46
|
+
const beforeQuery = withoutHash.slice(0, queryIndex);
|
|
47
|
+
const rawQuery = withoutHash.slice(queryIndex + 1);
|
|
48
|
+
const segments = rawQuery.split("&");
|
|
49
|
+
const keptSegments = [];
|
|
50
|
+
const urlOptions = [];
|
|
51
|
+
let strippedAny = false;
|
|
52
|
+
for (const segment of segments) {
|
|
53
|
+
const params = new URLSearchParams(`&${segment}`);
|
|
54
|
+
if (params.has("options")) {
|
|
55
|
+
strippedAny = true;
|
|
56
|
+
for (const value of params.getAll("options")) {
|
|
57
|
+
urlOptions.push(value);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
keptSegments.push(segment);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!strippedAny) {
|
|
64
|
+
return { connectionString: raw, urlOptions: [] };
|
|
65
|
+
}
|
|
66
|
+
const remaining = keptSegments.filter((segment) => segment.length > 0);
|
|
67
|
+
const connectionString = remaining.length > 0 ? `${beforeQuery}?${remaining.join("&")}${hashPart}` : `${beforeQuery}${hashPart}`;
|
|
68
|
+
return { connectionString, urlOptions };
|
|
69
|
+
}
|
|
70
|
+
function normalizeRawOptionFragment(raw, source) {
|
|
71
|
+
if (CONTROL_CHAR_PATTERN.test(raw)) {
|
|
72
|
+
throw new TypeError(`postgresConnectionConfig ${source} must not contain control characters`);
|
|
73
|
+
}
|
|
74
|
+
const tokens = [];
|
|
75
|
+
let current = "";
|
|
76
|
+
let inToken = false;
|
|
77
|
+
let escaping = false;
|
|
78
|
+
let start = -1;
|
|
79
|
+
let end = -1;
|
|
80
|
+
for (let i = 0;i < raw.length; i += 1) {
|
|
81
|
+
const ch = raw[i];
|
|
82
|
+
if (ch === undefined)
|
|
83
|
+
break;
|
|
84
|
+
if (escaping) {
|
|
85
|
+
current += ch;
|
|
86
|
+
escaping = false;
|
|
87
|
+
end = i + 1;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (ch === "\\") {
|
|
91
|
+
if (!inToken) {
|
|
92
|
+
inToken = true;
|
|
93
|
+
if (start === -1)
|
|
94
|
+
start = i;
|
|
95
|
+
}
|
|
96
|
+
escaping = true;
|
|
97
|
+
end = i + 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (ch === " ") {
|
|
101
|
+
if (inToken) {
|
|
102
|
+
tokens.push(current);
|
|
103
|
+
current = "";
|
|
104
|
+
inToken = false;
|
|
105
|
+
}
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (/\s/.test(ch)) {
|
|
109
|
+
throw new TypeError(`postgresConnectionConfig ${source} contains unsupported whitespace characters`);
|
|
110
|
+
}
|
|
111
|
+
if (!inToken) {
|
|
112
|
+
inToken = true;
|
|
113
|
+
if (start === -1)
|
|
114
|
+
start = i;
|
|
115
|
+
}
|
|
116
|
+
current += ch;
|
|
117
|
+
end = i + 1;
|
|
118
|
+
}
|
|
119
|
+
if (escaping) {
|
|
120
|
+
throw new TypeError(`postgresConnectionConfig ${source} must not end with an unescaped backslash`);
|
|
121
|
+
}
|
|
122
|
+
if (inToken) {
|
|
123
|
+
tokens.push(current);
|
|
124
|
+
}
|
|
125
|
+
if (tokens.length === 0)
|
|
126
|
+
return;
|
|
127
|
+
if (tokens.includes("--")) {
|
|
128
|
+
throw new TypeError(`postgresConnectionConfig ${source} must not contain a standalone "--" option terminator`);
|
|
129
|
+
}
|
|
130
|
+
if (tokens[tokens.length - 1] === "-c") {
|
|
131
|
+
throw new TypeError(`postgresConnectionConfig ${source} must not end with an incomplete "-c" flag`);
|
|
132
|
+
}
|
|
133
|
+
return raw.slice(start, end);
|
|
134
|
+
}
|
|
135
|
+
function formatTimeZoneFlag(value) {
|
|
136
|
+
if (value === null)
|
|
137
|
+
return;
|
|
138
|
+
const timeZone = value === undefined ? "UTC" : value;
|
|
139
|
+
if (typeof timeZone !== "string" || timeZone.includes("..") || !TIME_ZONE_PATTERN.test(timeZone)) {
|
|
140
|
+
throw new TypeError("postgresConnectionConfig options.timeZone must be a valid PostgreSQL time zone name, UTC offset, or null");
|
|
141
|
+
}
|
|
142
|
+
return `-c TimeZone=${timeZone}`;
|
|
143
|
+
}
|
|
144
|
+
function formatSearchPathFlag(value) {
|
|
145
|
+
if (value === undefined)
|
|
146
|
+
return;
|
|
147
|
+
let items;
|
|
148
|
+
if (typeof value === "string") {
|
|
149
|
+
if (CONTROL_CHAR_PATTERN.test(value)) {
|
|
150
|
+
throw new TypeError("postgresConnectionConfig options.searchPath must not contain control characters");
|
|
151
|
+
}
|
|
152
|
+
items = value.split(",").map((part) => part.trim());
|
|
153
|
+
} else if (Array.isArray(value)) {
|
|
154
|
+
if (value.length === 0) {
|
|
155
|
+
throw new TypeError("postgresConnectionConfig options.searchPath must not be empty");
|
|
156
|
+
}
|
|
157
|
+
items = [];
|
|
158
|
+
for (const entry of value) {
|
|
159
|
+
if (typeof entry !== "string" || entry.length === 0 || entry !== entry.trim() || entry.includes(",") || CONTROL_CHAR_PATTERN.test(entry)) {
|
|
160
|
+
throw new TypeError("postgresConnectionConfig options.searchPath entries must be valid trimmed schema names without commas");
|
|
161
|
+
}
|
|
162
|
+
items.push(entry);
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
throw new TypeError("postgresConnectionConfig options.searchPath must be a string or an array of schema names");
|
|
166
|
+
}
|
|
167
|
+
for (const item of items) {
|
|
168
|
+
if (item.length === 0 || CONTROL_CHAR_PATTERN.test(item) || !SEARCH_PATH_ITEM_PATTERN.test(item)) {
|
|
169
|
+
throw new TypeError(`postgresConnectionConfig options.searchPath contains an invalid schema identifier: ${item}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return `-c search_path=${items.join(",")}`;
|
|
173
|
+
}
|
|
174
|
+
function formatParameterFlags(value) {
|
|
175
|
+
if (value === undefined)
|
|
176
|
+
return [];
|
|
177
|
+
if (!isPlainObject(value)) {
|
|
178
|
+
throw new TypeError("postgresConnectionConfig options.parameters must be a plain object");
|
|
179
|
+
}
|
|
180
|
+
const seen = new Set;
|
|
181
|
+
const flags = [];
|
|
182
|
+
for (const [name, paramValue] of Object.entries(value)) {
|
|
183
|
+
if (!PARAMETER_NAME_PATTERN.test(name)) {
|
|
184
|
+
throw new TypeError(`postgresConnectionConfig options.parameters contains an invalid parameter name: ${name}`);
|
|
185
|
+
}
|
|
186
|
+
const normalized = name.toLowerCase();
|
|
187
|
+
if (RESERVED_PARAMETERS.has(normalized)) {
|
|
188
|
+
throw new TypeError(`postgresConnectionConfig options.parameters forbids "${name}"; use the dedicated timeZone or searchPath option`);
|
|
189
|
+
}
|
|
190
|
+
if (seen.has(normalized)) {
|
|
191
|
+
throw new TypeError(`postgresConnectionConfig options.parameters contains duplicate parameter "${name}"`);
|
|
192
|
+
}
|
|
193
|
+
seen.add(normalized);
|
|
194
|
+
if (typeof paramValue !== "string" || paramValue.length === 0 || CONTROL_CHAR_PATTERN.test(paramValue) || /\s/.test(paramValue) || paramValue.includes("\\")) {
|
|
195
|
+
throw new TypeError(`postgresConnectionConfig options.parameters.${name} must be a non-empty string without whitespace, backslashes, or control characters`);
|
|
196
|
+
}
|
|
197
|
+
flags.push(`-c ${name}=${paramValue}`);
|
|
198
|
+
}
|
|
199
|
+
return flags;
|
|
200
|
+
}
|
|
201
|
+
function resolveConnectionConfig(rest, rawConnectionString, rawConfigOptions, options) {
|
|
202
|
+
if (options !== undefined && !isPlainObject(options)) {
|
|
203
|
+
throw new TypeError("postgresConnectionConfig options must be a plain object");
|
|
204
|
+
}
|
|
205
|
+
const { connectionString, urlOptions } = parseAndStripConnectionString(rawConnectionString);
|
|
206
|
+
const parts = [];
|
|
207
|
+
for (const fragment of urlOptions) {
|
|
208
|
+
const normalized = normalizeRawOptionFragment(fragment, "URL options");
|
|
209
|
+
if (normalized !== undefined)
|
|
210
|
+
parts.push(normalized);
|
|
211
|
+
}
|
|
212
|
+
if (rawConfigOptions !== undefined) {
|
|
213
|
+
if (typeof rawConfigOptions !== "string") {
|
|
214
|
+
throw new TypeError("postgresConnectionConfig config.options must be a string");
|
|
215
|
+
}
|
|
216
|
+
const normalized = normalizeRawOptionFragment(rawConfigOptions, "config.options");
|
|
217
|
+
if (normalized !== undefined)
|
|
218
|
+
parts.push(normalized);
|
|
219
|
+
}
|
|
220
|
+
for (const flag of formatParameterFlags(options?.parameters)) {
|
|
221
|
+
parts.push(flag);
|
|
222
|
+
}
|
|
223
|
+
const searchPathFlag = formatSearchPathFlag(options?.searchPath);
|
|
224
|
+
if (searchPathFlag !== undefined)
|
|
225
|
+
parts.push(searchPathFlag);
|
|
226
|
+
const timeZoneFlag = formatTimeZoneFlag(options?.timeZone);
|
|
227
|
+
if (timeZoneFlag !== undefined)
|
|
228
|
+
parts.push(timeZoneFlag);
|
|
229
|
+
const mergedOptions = parts.length > 0 ? parts.join(" ") : undefined;
|
|
230
|
+
return {
|
|
231
|
+
...rest,
|
|
232
|
+
connectionString,
|
|
233
|
+
...mergedOptions !== undefined && { options: mergedOptions }
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function postgresConnectionConfig(input, options) {
|
|
237
|
+
if (typeof input === "string") {
|
|
238
|
+
return resolveConnectionConfig(undefined, input, undefined, options);
|
|
239
|
+
}
|
|
240
|
+
if (!isPlainObject(input)) {
|
|
241
|
+
throw new TypeError("postgresConnectionConfig expects a connection string or a plain config object");
|
|
242
|
+
}
|
|
243
|
+
const { connectionString: rawUrl, options: rawConfigOptions, ...rest } = input;
|
|
244
|
+
return resolveConnectionConfig(rest, rawUrl, rawConfigOptions, options);
|
|
245
|
+
}
|
|
1
246
|
// src/postgres/serialize-prisma.ts
|
|
2
247
|
var CONNECT_FACTORY_METHODS = new Set([
|
|
3
248
|
"connect",
|
|
@@ -130,5 +375,6 @@ function withSerializedPrismaTransactions(adapter) {
|
|
|
130
375
|
return proxy;
|
|
131
376
|
}
|
|
132
377
|
export {
|
|
378
|
+
postgresConnectionConfig,
|
|
133
379
|
withSerializedPrismaTransactions
|
|
134
380
|
};
|
|
@@ -159,6 +159,72 @@ var CliBuildSignatureSchema2 = z.object({
|
|
|
159
159
|
keyId: z.string().min(1),
|
|
160
160
|
signature: z.string().min(1)
|
|
161
161
|
});
|
|
162
|
+
var UNSAFE_TRUST_KEY_IDS = new Set(["__proto__", "constructor", "prototype"]);
|
|
163
|
+
var CANONICAL_RAW_ED25519_BASE64 = /^[A-Za-z0-9+/]{43}=?$/;
|
|
164
|
+
var STRICT_SPKI_PUBLIC_KEY_PEM = /^-----BEGIN PUBLIC KEY-----\r?\n[A-Za-z0-9+/\r\n]+=*\r?\n-----END PUBLIC KEY-----$/;
|
|
165
|
+
function publicKeyOf(material) {
|
|
166
|
+
const trimmed = material.trim();
|
|
167
|
+
if (trimmed.includes("BEGIN ") || trimmed.includes("END ")) {
|
|
168
|
+
if (!STRICT_SPKI_PUBLIC_KEY_PEM.test(trimmed)) {
|
|
169
|
+
throw new Error("[stitchkit] an Ed25519 SPKI public key PEM is required");
|
|
170
|
+
}
|
|
171
|
+
const key = createPublicKey(trimmed);
|
|
172
|
+
if (key.asymmetricKeyType !== "ed25519") {
|
|
173
|
+
throw new Error("[stitchkit] an Ed25519 public key is required");
|
|
174
|
+
}
|
|
175
|
+
return key;
|
|
176
|
+
}
|
|
177
|
+
if (!CANONICAL_RAW_ED25519_BASE64.test(trimmed)) {
|
|
178
|
+
throw new Error("[stitchkit] an Ed25519 public key is 32 bytes or SPKI PEM");
|
|
179
|
+
}
|
|
180
|
+
const raw = Buffer.from(trimmed, "base64");
|
|
181
|
+
const canonical = raw.toString("base64");
|
|
182
|
+
if (raw.length !== 32 || trimmed !== canonical && trimmed !== canonical.slice(0, -1)) {
|
|
183
|
+
throw new Error("[stitchkit] an Ed25519 public key is 32 bytes or SPKI PEM");
|
|
184
|
+
}
|
|
185
|
+
const spki = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]);
|
|
186
|
+
return createPublicKey({ key: spki, format: "der", type: "spki" });
|
|
187
|
+
}
|
|
188
|
+
var trustKeyIdSchema = z.string().min(1, "trust key id must not be empty").refine((id) => id === id.trim(), "trust key id must not have leading or trailing whitespace").refine((id) => !UNSAFE_TRUST_KEY_IDS.has(id), "trust key id must not be a prototype property");
|
|
189
|
+
var trustPublicKeySchema = z.string().min(1, "trust public key must not be empty").refine((material) => {
|
|
190
|
+
if (material.trim().length === 0)
|
|
191
|
+
return false;
|
|
192
|
+
try {
|
|
193
|
+
publicKeyOf(material);
|
|
194
|
+
return true;
|
|
195
|
+
} catch {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}, "trust public key must be an Ed25519 SPKI PEM or 32-byte base64 key");
|
|
199
|
+
function hasOwnUnsafeTrustKeyId(value) {
|
|
200
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
201
|
+
return false;
|
|
202
|
+
return Object.getOwnPropertyNames(value).some((key) => UNSAFE_TRUST_KEY_IDS.has(key));
|
|
203
|
+
}
|
|
204
|
+
var trustKeysRecordSchema = z.record(trustKeyIdSchema, trustPublicKeySchema).readonly().refine((keys) => Object.keys(keys).length > 0, "trust.keys must contain at least one signing key");
|
|
205
|
+
var CliTrustRootSchema2 = z.strictObject({
|
|
206
|
+
keys: z.unknown().refine((value) => !hasOwnUnsafeTrustKeyId(value), "trust key id must not be a prototype property").pipe(trustKeysRecordSchema)
|
|
207
|
+
});
|
|
208
|
+
function isUnsafeTrustKeyId(keyId) {
|
|
209
|
+
return UNSAFE_TRUST_KEY_IDS.has(keyId);
|
|
210
|
+
}
|
|
211
|
+
function isUnenforcedEmptyTrustRoot(trust) {
|
|
212
|
+
if (typeof trust !== "object" || trust === null)
|
|
213
|
+
return false;
|
|
214
|
+
const keys = Reflect.get(trust, "keys");
|
|
215
|
+
if (typeof keys !== "object" || keys === null || Array.isArray(keys))
|
|
216
|
+
return false;
|
|
217
|
+
if (hasOwnUnsafeTrustKeyId(keys))
|
|
218
|
+
return false;
|
|
219
|
+
return Object.keys(keys).length === 0;
|
|
220
|
+
}
|
|
221
|
+
function freezeTrustRoot(trust) {
|
|
222
|
+
const keys = Object.create(null);
|
|
223
|
+
for (const [keyId, material] of Object.entries(trust.keys)) {
|
|
224
|
+
keys[keyId] = material;
|
|
225
|
+
}
|
|
226
|
+
return Object.freeze({ keys: Object.freeze(keys) });
|
|
227
|
+
}
|
|
162
228
|
function cliManifestSigningPayload2(manifest) {
|
|
163
229
|
return serializeCanonicalJson({
|
|
164
230
|
name: manifest.name,
|
|
@@ -174,17 +240,6 @@ function cliManifestSigningPayload2(manifest) {
|
|
|
174
240
|
}))
|
|
175
241
|
});
|
|
176
242
|
}
|
|
177
|
-
function publicKeyOf(material) {
|
|
178
|
-
const trimmed = material.trim();
|
|
179
|
-
if (trimmed.includes("BEGIN PUBLIC KEY"))
|
|
180
|
-
return createPublicKey(trimmed);
|
|
181
|
-
const raw = Buffer.from(trimmed, "base64");
|
|
182
|
-
if (raw.length !== 32) {
|
|
183
|
-
throw new Error("[stitchkit] an Ed25519 public key is 32 bytes or SPKI PEM");
|
|
184
|
-
}
|
|
185
|
-
const spki = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]);
|
|
186
|
-
return createPublicKey({ key: spki, format: "der", type: "spki" });
|
|
187
|
-
}
|
|
188
243
|
function signCliManifest2(manifest, options) {
|
|
189
244
|
const signature = cryptoSign(null, Buffer.from(cliManifestSigningPayload2(manifest), "utf8"), createPrivateKey(typeof options.privateKey === "string" ? options.privateKey : { key: Buffer.from(options.privateKey), format: "der", type: "pkcs8" }));
|
|
190
245
|
return {
|
|
@@ -570,14 +625,19 @@ var DEFAULT_DOWNLOAD_IDLE_TIMEOUT_MS = 30000;
|
|
|
570
625
|
var DEFAULT_VERIFY_TIMEOUT_MS = 30000;
|
|
571
626
|
var MANIFEST_MAX_BYTES = 256 * 1024;
|
|
572
627
|
var DEFAULT_MAX_ASSET_BYTES = 256 * 1024 * 1024;
|
|
628
|
+
var SEMVER_PATTERN = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
|
|
573
629
|
function parseVersion(value) {
|
|
574
|
-
const match =
|
|
630
|
+
const match = SEMVER_PATTERN.exec(value.trim());
|
|
575
631
|
if (!match)
|
|
576
632
|
return;
|
|
577
633
|
const numbers = [match[1], match[2], match[3]].map((part) => Number(part));
|
|
578
|
-
if (numbers.some((part) => !Number.
|
|
634
|
+
if (numbers.some((part) => !Number.isSafeInteger(part)))
|
|
635
|
+
return;
|
|
636
|
+
const prerelease = match[4];
|
|
637
|
+
if (prerelease?.split(".").some((part) => /^0\d+$/.test(part))) {
|
|
579
638
|
return;
|
|
580
|
-
|
|
639
|
+
}
|
|
640
|
+
return { numbers, prerelease };
|
|
581
641
|
}
|
|
582
642
|
function compareCliVersions2(left, right) {
|
|
583
643
|
const a = parseVersion(left);
|
|
@@ -682,15 +742,20 @@ async function applyCliUpdate2(config) {
|
|
|
682
742
|
assertTimerMs("[stitchkit] update: timeoutMs", config.timeoutMs);
|
|
683
743
|
assertTimerMs("[stitchkit] update: idleTimeoutMs", config.idleTimeoutMs);
|
|
684
744
|
assertTimerMs("[stitchkit] update: verifyTimeoutMs", config.verifyTimeoutMs);
|
|
685
|
-
if (config.trust) {
|
|
745
|
+
if (config.trust !== undefined && !isUnenforcedEmptyTrustRoot(config.trust)) {
|
|
746
|
+
const parsedTrust = CliTrustRootSchema2.safeParse(config.trust);
|
|
747
|
+
if (!parsedTrust.success) {
|
|
748
|
+
throw new Error("[stitchkit] update: refusing to install — trust root must contain valid Ed25519 keys", { cause: parsedTrust.error });
|
|
749
|
+
}
|
|
686
750
|
if (!config.manifest) {
|
|
687
751
|
throw new Error("[stitchkit] update: a trust root needs the manifest the asset came from");
|
|
688
752
|
}
|
|
689
|
-
const
|
|
690
|
-
|
|
753
|
+
const trust = freezeTrustRoot(parsedTrust.data);
|
|
754
|
+
const verdict = verifyCliManifest2(config.manifest, config.manifest.signature, trust);
|
|
755
|
+
if (verdict !== "valid") {
|
|
691
756
|
throw new Error(`[stitchkit] update: refusing to install — manifest signature ${verdict}`);
|
|
692
757
|
}
|
|
693
|
-
if (!config.manifest.assets.some((asset) => asset.sha256 === config.asset.sha256)) {
|
|
758
|
+
if (!config.manifest.assets.some((asset) => asset.sha256 === config.asset.sha256 && asset.size === config.asset.size && asset.compression === config.asset.compression && asset.platform === config.asset.platform && asset.arch === config.asset.arch)) {
|
|
694
759
|
throw new Error("[stitchkit] update: the asset is not one the signed manifest names");
|
|
695
760
|
}
|
|
696
761
|
}
|
|
@@ -767,4 +832,4 @@ function rollbackCliUpdate2(config) {
|
|
|
767
832
|
return { path: target, bytes: bytes.length, sha256 };
|
|
768
833
|
}
|
|
769
834
|
|
|
770
|
-
export { renderCliInstaller2, CliBuildSignatureSchema2, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|
|
835
|
+
export { renderCliInstaller2, CliBuildSignatureSchema2, CliTrustRootSchema2, isUnsafeTrustKeyId, freezeTrustRoot, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peer-free PostgreSQL connection configuration helper (`stitchkit/postgres`).
|
|
3
|
+
*
|
|
4
|
+
* `pg`'s `ConnectionParameters` merges parsed `connectionString` query parameters on top of
|
|
5
|
+
* `config`, so any `?options=...` (including an empty `?options=`) in `DATABASE_URL` silently
|
|
6
|
+
* overwrites `config.options` and erases required `-c TimeZone=UTC` / `-c search_path=...` flags.
|
|
7
|
+
*
|
|
8
|
+
* This module surgically removes `options` query parameters from the raw `connectionString`
|
|
9
|
+
* (without rewriting unrelated query segments or credentials), validates raw option fragments
|
|
10
|
+
* against PostgreSQL `pg_split_opts` boundaries, and appends structured `parameters`,
|
|
11
|
+
* `searchPath`, and `timeZone` (defaulting to `'UTC'`) at the end so later startup options win.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Minimal PostgreSQL connection configuration accepted and returned by
|
|
15
|
+
* {@link postgresConnectionConfig}, structurally compatible with `pg.PoolConfig`
|
|
16
|
+
* and `PrismaPg` without importing `pg`.
|
|
17
|
+
*/
|
|
18
|
+
export interface PostgresConnectionConfig {
|
|
19
|
+
/** PostgreSQL connection URL (with any `?options=` stripped) or raw Unix socket path. */
|
|
20
|
+
connectionString: string;
|
|
21
|
+
/** Merged PostgreSQL startup `options` string (`-c key=value ...`), omitted when empty. */
|
|
22
|
+
options?: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Structured session parameters appended after any URL or config `options` by
|
|
26
|
+
* {@link postgresConnectionConfig}.
|
|
27
|
+
*/
|
|
28
|
+
export interface PostgresConnectionOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Session `TimeZone` enforced via `-c TimeZone=<value>`. Defaults to `'UTC'`.
|
|
31
|
+
* Pass `null` to omit setting `TimeZone`.
|
|
32
|
+
*/
|
|
33
|
+
timeZone?: string | null | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Session `search_path` enforced via `-c search_path=<schemas>`, as a comma-separated
|
|
36
|
+
* string or an array of schema identifiers (including `$user` or double-quoted names).
|
|
37
|
+
*/
|
|
38
|
+
searchPath?: string | readonly string[] | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Additional PostgreSQL session parameters appended as `-c <name>=<value>` before
|
|
41
|
+
* `searchPath` and `timeZone`. `timezone` and `search_path` (case-insensitive) are
|
|
42
|
+
* rejected here so callers use the dedicated fields.
|
|
43
|
+
*/
|
|
44
|
+
parameters?: Readonly<Record<string, string>> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build a `pg.PoolConfig` / `PrismaPg` connection object that preserves user `?options=` from
|
|
48
|
+
* `connectionString`, strips `options` from the URL so `pg` cannot overwrite `config.options`,
|
|
49
|
+
* and appends structured session parameters (`parameters`, `searchPath`, and `timeZone`,
|
|
50
|
+
* defaulting to `'UTC'`) at the end.
|
|
51
|
+
*/
|
|
52
|
+
export declare function postgresConnectionConfig(connectionString: string, options?: PostgresConnectionOptions): PostgresConnectionConfig;
|
|
53
|
+
export declare function postgresConnectionConfig<T extends PostgresConnectionConfig>(config: T, options?: PostgresConnectionOptions): Omit<T, 'connectionString' | 'options'> & PostgresConnectionConfig;
|
|
54
|
+
//# sourceMappingURL=connection-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-config.d.ts","sourceRoot":"","sources":["../../src/postgres/connection-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,yFAAyF;IACzF,gBAAgB,EAAE,MAAM,CAAC;IACzB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACpD;;;;OAIG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CAC3D;AAuTD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,yBAAyB,GAClC,wBAAwB,CAAC;AAC5B,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,wBAAwB,EACzE,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,yBAAyB,GAClC,IAAI,CAAC,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC,GAAG,wBAAwB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration validation and safe path matching for `createCliDistributionRoutes`.
|
|
3
3
|
*/
|
|
4
|
-
import type
|
|
4
|
+
import { type CliSignatureVerdict, type CliTrustRoot } from './signature.js';
|
|
5
5
|
export declare const SAFE_ASSET_SEGMENT: RegExp;
|
|
6
6
|
/** Diagnostic event emitted when a CLI distribution route responds with 503 or 404. */
|
|
7
7
|
export interface CliDistributionUnavailableEvent {
|
|
@@ -52,5 +52,43 @@ export interface ResolvedDistributionConfig {
|
|
|
52
52
|
readonly onUnavailable: ((event: CliDistributionUnavailableEvent) => void) | undefined;
|
|
53
53
|
}
|
|
54
54
|
export declare function resolveDistributionConfig(options: CliDistributionRoutesOptions): ResolvedDistributionConfig;
|
|
55
|
+
export declare const DISTRIBUTION_STATE_HEADER = "x-stitchkit-cli-distribution-state";
|
|
56
|
+
export declare const UNPUBLISHED_STATE = "unpublished";
|
|
57
|
+
export declare const UNAVAILABLE_STATE = "unavailable";
|
|
58
|
+
export declare const UNPUBLISHED_BODY = "No verified CLI build is published";
|
|
59
|
+
export declare const UNAVAILABLE_BODY = "CLI distribution is unavailable";
|
|
60
|
+
/**
|
|
61
|
+
* Wire contract returned by {@link createCliDistributionRoutes} on channel manifest and installer
|
|
62
|
+
* routes when a channel has no published manifest yet (`reason: 'missing'`).
|
|
63
|
+
*
|
|
64
|
+
* Integrity, signature, path, I/O and configuration failures deliberately return a distinct `503`
|
|
65
|
+
* response without `headerValue: 'unpublished'` so external probes and gates never mistake a
|
|
66
|
+
* broken or tampered channel for an empty one.
|
|
67
|
+
*/
|
|
68
|
+
export interface CliDistributionUnpublishedResponse {
|
|
69
|
+
readonly status: 503;
|
|
70
|
+
readonly header: 'x-stitchkit-cli-distribution-state';
|
|
71
|
+
readonly headerValue: 'unpublished';
|
|
72
|
+
readonly body: 'No verified CLI build is published';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Canonical HTTP response contract for an unpublished (empty) CLI distribution channel.
|
|
76
|
+
*/
|
|
77
|
+
export declare const CLI_DISTRIBUTION_UNPUBLISHED_RESPONSE: CliDistributionUnpublishedResponse;
|
|
78
|
+
/**
|
|
79
|
+
* True when an HTTP response carries the exact status and state header emitted by
|
|
80
|
+
* {@link createCliDistributionRoutes} for a genuinely empty (not yet published) CLI channel.
|
|
81
|
+
*
|
|
82
|
+
* Synchronous and body-free: never consumes `response.body`, and returns `false` for all
|
|
83
|
+
* integrity, signature, path, configuration, proxy or generic `503` responses.
|
|
84
|
+
*/
|
|
85
|
+
export declare function isCliDistributionUnpublishedResponse(response: {
|
|
86
|
+
readonly status: number;
|
|
87
|
+
readonly headers: {
|
|
88
|
+
get(name: string): string | null;
|
|
89
|
+
};
|
|
90
|
+
}): boolean;
|
|
91
|
+
/** True when `trust` passes {@link CliTrustRootSchema} (non-empty valid Ed25519 keys). */
|
|
92
|
+
export declare function hasUsableTrustKeys(trust: CliTrustRoot): boolean;
|
|
55
93
|
export declare function assetMatchesUrl(entryUrl: string, asset: string): boolean;
|
|
56
94
|
//# sourceMappingURL=distribution-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution-config.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/distribution-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"distribution-config.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/distribution-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AASrB,eAAO,MAAM,kBAAkB,QAAiC,CAAC;AAKjE,uFAAuF;AACvF,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,GAAG,OAAO,GAAG,WAAW,CAAC;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EACX,mBAAmB,GACnB,kBAAkB,GAClB,SAAS,GACT,aAAa,GACb,WAAW,GACX,kBAAkB,GAClB,mBAAmB,GACnB,qBAAqB,GACrB,gBAAgB,GAChB,UAAU,CAAC;IACf,QAAQ,CAAC,OAAO,CAAC,E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CAexE"}
|
|
@@ -13,8 +13,10 @@ import { type CliDistributionRoutesOptions } from './distribution-config.js';
|
|
|
13
13
|
/**
|
|
14
14
|
* Create portable `RawRoute[]` handlers serving signed CLI channel manifests, immutable
|
|
15
15
|
* versioned manifests and binary assets, and `install.sh` (`GET` only, full-body descriptor
|
|
16
|
-
* streaming).
|
|
17
|
-
*
|
|
16
|
+
* streaming). Returns {@link CLI_DISTRIBUTION_UNPUBLISHED_RESPONSE} (`503` with
|
|
17
|
+
* `x-stitchkit-cli-distribution-state: unpublished`) only when a channel has no published
|
|
18
|
+
* manifest yet (`reason: 'missing'`); all configuration, path, integrity and signature
|
|
19
|
+
* failures fail closed with a distinct `503` (`x-stitchkit-cli-distribution-state: unavailable`).
|
|
18
20
|
*/
|
|
19
21
|
export declare function createCliDistributionRoutes(options: CliDistributionRoutesOptions): RawRoute[];
|
|
20
22
|
//# sourceMappingURL=distribution-routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution-routes.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/distribution-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"distribution-routes.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/distribution-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAGL,KAAK,4BAA4B,EASlC,MAAM,uBAAuB,CAAC;AAsX/B;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,QAAQ,EAAE,CAwCZ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { type CliBuildStamp, type CliBuildTarget } from './manifest.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type CliSigningKey, type CliTrustRoot } from './signature.js';
|
|
4
4
|
export declare const PublicationTargetSchema: z.ZodObject<{
|
|
5
5
|
platform: z.ZodString;
|
|
6
6
|
arch: z.ZodString;
|
|
@@ -75,7 +75,14 @@ export type CliPublicationOptions = Omit<z.input<typeof dataSchema>, 'limits' |
|
|
|
75
75
|
};
|
|
76
76
|
trust?: CliTrustRoot;
|
|
77
77
|
};
|
|
78
|
-
export
|
|
78
|
+
export interface PublicationSigningSnapshot {
|
|
79
|
+
readonly keyId: string;
|
|
80
|
+
readonly privateKey: CliSigningKey;
|
|
81
|
+
}
|
|
82
|
+
export type PublicationData = z.infer<typeof dataSchema> & {
|
|
83
|
+
readonly trust?: CliTrustRoot;
|
|
84
|
+
readonly signing?: PublicationSigningSnapshot;
|
|
85
|
+
};
|
|
79
86
|
export declare function publicationData(options: CliPublicationOptions): PublicationData;
|
|
80
87
|
export declare function assetFilename(name: string, target: CliBuildTarget): string;
|
|
81
88
|
export declare function assetUrl(baseUrl: string, version: string, filename: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publication-contract.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/publication-contract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EAEpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"publication-contract.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/publication-contract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EAEpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EAIlB,MAAM,aAAa,CAAC;AAKrB,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC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AAE,aAAa,CAAA;KAAE,CAAC;IACvD,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,CAAC;AACF,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;CACpC;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,GAAG;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,0BAA0B,CAAC;CAC/C,CAAC;AA+BF,wBAAgB,eAAe,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAuB/E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAE1E;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publication.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/publication.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,OAAO,EAGL,KAAK,qBAAqB,EAI3B,MAAM,wBAAwB,CAAC;AAoBhC,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhB,CAAC;AACH;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"publication.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/publication.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,OAAO,EAGL,KAAK,qBAAqB,EAI3B,MAAM,wBAAwB,CAAC;AAoBhC,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhB,CAAC;AACH;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAwThE;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAU/B"}
|
|
@@ -31,15 +31,29 @@ export type CliBuildSignature = z.infer<typeof CliBuildSignatureSchema>;
|
|
|
31
31
|
* to remove.
|
|
32
32
|
*/
|
|
33
33
|
export type CliSignatureVerdict = 'valid' | 'unenforced' | 'missing' | 'unknown-key' | 'invalid';
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
keys:
|
|
42
|
-
}
|
|
34
|
+
/**
|
|
35
|
+
* Schema for the keys a build trusts, by id.
|
|
36
|
+
*
|
|
37
|
+
* Requires at least one valid Ed25519 SPKI PEM or 32-byte base64 public key and rejects
|
|
38
|
+
* empty, padded, or prototype-polluting key ids.
|
|
39
|
+
*/
|
|
40
|
+
export declare const CliTrustRootSchema: z.ZodObject<{
|
|
41
|
+
keys: z.ZodPipe<z.ZodUnknown, z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
/** The keys a build trusts, by id. Enforce non-empty keys with {@link CliTrustRootSchema}. */
|
|
44
|
+
export type CliTrustRoot = z.infer<typeof CliTrustRootSchema>;
|
|
45
|
+
/** True when a trust key id is a prototype property name that must be refused. */
|
|
46
|
+
export declare function isUnsafeTrustKeyId(keyId: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* True when `trust` is an explicit empty `{ keys: {} }` root with no own prototype-polluting
|
|
49
|
+
* keys — the documented ADR 0193 unenforced update posture.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isUnenforcedEmptyTrustRoot(trust: unknown): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Return an immutable null-prototype snapshot of a trust root so caller mutation
|
|
54
|
+
* after validation cannot alter signature checks mid-operation.
|
|
55
|
+
*/
|
|
56
|
+
export declare function freezeTrustRoot(trust: CliTrustRoot): CliTrustRoot;
|
|
43
57
|
/**
|
|
44
58
|
* The exact bytes a signature covers.
|
|
45
59
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,iFAAiF;AACjF,eAAO,MAAM,uBAAuB;;;;iBAMlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,YAAY,GACZ,SAAS,GACT,aAAa,GACb,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,iFAAiF;AACjF,eAAO,MAAM,uBAAuB;;;;iBAMlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,u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85
|
+
/**
|
|
86
|
+
* Keys this build trusts. When `trust.keys` is non-empty, the trust root is validated with
|
|
87
|
+
* {@link CliTrustRootSchema}, frozen, and the manifest signature plus every signed asset field
|
|
88
|
+
* (`sha256`, `size`, `compression`, `platform`, `arch`) are verified before the fetch. An
|
|
89
|
+
* explicit empty `{ keys: {} }` retains the documented `'unenforced'` behaviour (ADR 0193).
|
|
90
|
+
*/
|
|
86
91
|
trust?: CliTrustRoot;
|
|
87
92
|
/**
|
|
88
93
|
* Keep the bytes being replaced, here, so there is something to go back to.
|