@calimero-network/mero-js 35.0.0 → 35.2.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/README.md +20 -9
- package/dist/client/recovery-key.d.ts +2 -0
- package/dist/client/recovery-key.js +2 -2
- package/dist/generated/api.d.ts +83 -1
- package/dist/generated/methods.d.ts +7 -0
- package/dist/generated/methods.js +7 -0
- package/dist/index.browser.mjs +3 -3
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.cjs +311 -2
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +311 -2
- package/dist/index.mjs.map +4 -4
- package/dist/package/pack.d.ts +93 -0
- package/dist/package/pack.js +370 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,3 +5,5 @@ export type { DirectorySource, HttpMethod, NodeTransportOptions, QueryValue, Req
|
|
|
5
5
|
export * from './sealed/index.js';
|
|
6
6
|
export * from './agent-gate/index.js';
|
|
7
7
|
export * from './recovery/backup-files.js';
|
|
8
|
+
export { MAX_ARCHIVE_BYTES, MAX_MANIFEST_BYTES, MAX_MPK_BYTES, MAX_PIPELINE_BYTES, MAX_PIPELINES_PER_PACKAGE, canonicalizeManifest, exportPublisherKey, generatePublisherKey, importPublisherKey, isDevPublisherKey, packComputePackage, signerIdOf, signingPayload, webCryptoPublisherKey, } from './package/pack.js';
|
|
9
|
+
export type { ComputePackageInput, PackKey, PackageMetadata, PublisherKey, WebCryptoPublisherKey, } from './package/pack.js';
|
package/dist/index.js
CHANGED
|
@@ -24,3 +24,5 @@ export * from './sealed/index.js';
|
|
|
24
24
|
export * from './agent-gate/index.js';
|
|
25
25
|
// The recovery disk's files as their holder's device opens them.
|
|
26
26
|
export * from './recovery/backup-files.js';
|
|
27
|
+
// Building and signing a compute-only pipeline package (.mpk), byte-compatible with core.
|
|
28
|
+
export { MAX_ARCHIVE_BYTES, MAX_MANIFEST_BYTES, MAX_MPK_BYTES, MAX_PIPELINE_BYTES, MAX_PIPELINES_PER_PACKAGE, canonicalizeManifest, exportPublisherKey, generatePublisherKey, importPublisherKey, isDevPublisherKey, packComputePackage, signerIdOf, signingPayload, webCryptoPublisherKey, } from './package/pack.js';
|
package/dist/index.mjs
CHANGED
|
@@ -2999,6 +2999,13 @@ function createRoutes(api) {
|
|
|
2999
2999
|
* A `421 WRONG_NODE` moves the client to the next node of the cluster.
|
|
3000
3000
|
*/
|
|
3001
3001
|
run: (args, options) => route(api, { "method": "GET", "path": "/apps/{app}/runs/{run}", "pathParams": ["app", "run"], "query": [], "body": "none", "optionalBody": false, "reply": "json" }, args, options),
|
|
3002
|
+
/**
|
|
3003
|
+
* A compute run's attempt logs.
|
|
3004
|
+
*
|
|
3005
|
+
* `GET /apps/{app}/runs/{run}/logs` (`app_run_logs`). **Who:** signed in (a session or an API key).
|
|
3006
|
+
* A `421 WRONG_NODE` moves the client to the next node of the cluster.
|
|
3007
|
+
*/
|
|
3008
|
+
runLogs: (args, options) => route(api, { "method": "GET", "path": "/apps/{app}/runs/{run}/logs", "pathParams": ["app", "run"], "query": [], "body": "none", "optionalBody": false, "reply": "json" }, args, options),
|
|
3002
3009
|
/**
|
|
3003
3010
|
* An app's compute runs.
|
|
3004
3011
|
*
|
|
@@ -4856,9 +4863,9 @@ function newRecoverySeed() {
|
|
|
4856
4863
|
}
|
|
4857
4864
|
function recoverySeedText(seed) {
|
|
4858
4865
|
checkSeed(seed);
|
|
4859
|
-
const
|
|
4866
|
+
const hex3 = Array.from(seed, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
4860
4867
|
const groups = [];
|
|
4861
|
-
for (let i = 0; i <
|
|
4868
|
+
for (let i = 0; i < hex3.length; i += 8) groups.push(hex3.slice(i, i + 8));
|
|
4862
4869
|
return groups.join("-");
|
|
4863
4870
|
}
|
|
4864
4871
|
function parseRecoverySeed(text) {
|
|
@@ -6266,6 +6273,294 @@ async function verifyRecoveryAttestation(header, verifyQuote) {
|
|
|
6266
6273
|
const ok = await verifyQuote({ quoteB64: doc.quote, nonce: nonce2, reportDataSuffix });
|
|
6267
6274
|
if (!ok) throw new Error("the quote was not accepted");
|
|
6268
6275
|
}
|
|
6276
|
+
|
|
6277
|
+
// src/package/pack.ts
|
|
6278
|
+
var MAX_MANIFEST_BYTES = 1024 * 1024;
|
|
6279
|
+
var MAX_PIPELINES_PER_PACKAGE = 16;
|
|
6280
|
+
var MAX_PIPELINE_BYTES = 64 * 1024;
|
|
6281
|
+
var MAX_ARCHIVE_BYTES = 512 * 1024 * 1024;
|
|
6282
|
+
var MAX_MPK_BYTES = (64 * 1024 * 1024 - 1024 * 1024) / 4 * 3;
|
|
6283
|
+
var DEV_SIGNER_ID = "did:key:z6MknF3p5L5FDHJQ7FREUapuX4Wmp4MtF6WrHYaXS2B3eZQd";
|
|
6284
|
+
var MANIFEST_SIGNING_DOMAIN = new TextEncoder().encode("calimero.bundle.manifest.v1\0");
|
|
6285
|
+
var MIN_RUNTIME_VERSION = "0.1.0";
|
|
6286
|
+
var ED25519_PUB_MULTICODEC = [237, 1];
|
|
6287
|
+
var BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
6288
|
+
var COMPONENT_HEADER = [0, 97, 115, 109, 13, 0, 1, 0];
|
|
6289
|
+
var PIPELINE_PATH = /^pipelines\/[A-Za-z0-9._-]+\.yaml$/;
|
|
6290
|
+
var SEED_B64URL = /^[A-Za-z0-9_-]{43}$/;
|
|
6291
|
+
var SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
6292
|
+
var utf86 = (s) => new TextEncoder().encode(s);
|
|
6293
|
+
var hex2 = (b) => Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
|
|
6294
|
+
var concat2 = (...parts) => {
|
|
6295
|
+
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
6296
|
+
let off = 0;
|
|
6297
|
+
for (const p of parts) out.set(p, off), off += p.length;
|
|
6298
|
+
return out;
|
|
6299
|
+
};
|
|
6300
|
+
async function requireEd25519() {
|
|
6301
|
+
const unsupported = new Error("this runtime cannot sign Ed25519 packages (WebCrypto Ed25519 is missing)");
|
|
6302
|
+
if (!globalThis.crypto?.subtle) throw unsupported;
|
|
6303
|
+
try {
|
|
6304
|
+
await privateKey(new Uint8Array(32), false);
|
|
6305
|
+
} catch {
|
|
6306
|
+
throw unsupported;
|
|
6307
|
+
}
|
|
6308
|
+
}
|
|
6309
|
+
async function keyOfSeed(seed) {
|
|
6310
|
+
await requireEd25519();
|
|
6311
|
+
if (seed.length !== 32) throw new Error("a publisher seed is 32 bytes");
|
|
6312
|
+
const publicKey = fromB64url(await recoveryPublicKey(seed));
|
|
6313
|
+
return { seed: Uint8Array.from(seed), publicKey };
|
|
6314
|
+
}
|
|
6315
|
+
async function generatePublisherKey() {
|
|
6316
|
+
await requireEd25519();
|
|
6317
|
+
return keyOfSeed(crypto.getRandomValues(new Uint8Array(32)));
|
|
6318
|
+
}
|
|
6319
|
+
async function webCryptoPublisherKey(key) {
|
|
6320
|
+
await requireEd25519();
|
|
6321
|
+
return { privateKey: await privateKey(Uint8Array.from(key.seed), false), publicKey: Uint8Array.from(key.publicKey) };
|
|
6322
|
+
}
|
|
6323
|
+
function base58(bytes) {
|
|
6324
|
+
let n = 0n;
|
|
6325
|
+
for (const b of bytes) n = n << 8n | BigInt(b);
|
|
6326
|
+
let out = "";
|
|
6327
|
+
for (; n > 0n; n /= 58n) out = BASE58[Number(n % 58n)] + out;
|
|
6328
|
+
return "1".repeat(bytes.findIndex((b) => b !== 0) === -1 ? bytes.length : bytes.findIndex((b) => b !== 0)) + out;
|
|
6329
|
+
}
|
|
6330
|
+
function signerIdOf(key) {
|
|
6331
|
+
return `did:key:z${base58(concat2(Uint8Array.from(ED25519_PUB_MULTICODEC), key.publicKey))}`;
|
|
6332
|
+
}
|
|
6333
|
+
function isDevPublisherKey(key) {
|
|
6334
|
+
return signerIdOf(key) === DEV_SIGNER_ID;
|
|
6335
|
+
}
|
|
6336
|
+
function exportPublisherKey(key) {
|
|
6337
|
+
return utf86(
|
|
6338
|
+
JSON.stringify({ private_key: b64url(key.seed), public_key: b64url(key.publicKey), signer_id: signerIdOf(key) }, null, 2)
|
|
6339
|
+
);
|
|
6340
|
+
}
|
|
6341
|
+
async function importPublisherKey(bytes) {
|
|
6342
|
+
let file;
|
|
6343
|
+
try {
|
|
6344
|
+
file = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
6345
|
+
} catch {
|
|
6346
|
+
throw new Error("a publisher key backup is a JSON document");
|
|
6347
|
+
}
|
|
6348
|
+
const seed = file?.private_key;
|
|
6349
|
+
if (typeof seed !== "string" || !SEED_B64URL.test(seed) || b64url(fromB64url(seed)) !== seed) {
|
|
6350
|
+
throw new Error("the backup private_key is not an unpadded base64url 32-byte seed");
|
|
6351
|
+
}
|
|
6352
|
+
const key = await keyOfSeed(fromB64url(seed));
|
|
6353
|
+
if (file.public_key !== void 0 && file.public_key !== b64url(key.publicKey)) {
|
|
6354
|
+
throw new Error("the backup public_key is not the seed's");
|
|
6355
|
+
}
|
|
6356
|
+
if (file.signer_id !== void 0 && file.signer_id !== signerIdOf(key)) {
|
|
6357
|
+
throw new Error("the backup signer_id is not the seed's");
|
|
6358
|
+
}
|
|
6359
|
+
return key;
|
|
6360
|
+
}
|
|
6361
|
+
function canonicalizeManifest(manifest) {
|
|
6362
|
+
const signed = Object.fromEntries(Object.entries(manifest).filter(([k]) => k !== "signature" && !k.startsWith("_")));
|
|
6363
|
+
return utf86(jcs(signed));
|
|
6364
|
+
}
|
|
6365
|
+
function jcs(value) {
|
|
6366
|
+
if (typeof value === "string") {
|
|
6367
|
+
if (/[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/.test(value)) {
|
|
6368
|
+
throw new Error("a lone surrogate cannot be canonicalized");
|
|
6369
|
+
}
|
|
6370
|
+
return JSON.stringify(value);
|
|
6371
|
+
}
|
|
6372
|
+
if (typeof value === "number") {
|
|
6373
|
+
if (!Number.isSafeInteger(value)) throw new Error("only safe integers can be canonicalized");
|
|
6374
|
+
return String(value);
|
|
6375
|
+
}
|
|
6376
|
+
if (value === null || typeof value === "boolean") return String(value);
|
|
6377
|
+
if (Array.isArray(value)) return `[${value.map(jcs).join(",")}]`;
|
|
6378
|
+
return `{${Object.keys(value).sort().map((k) => `${jcs(k)}:${jcs(value[k])}`).join(",")}}`;
|
|
6379
|
+
}
|
|
6380
|
+
async function signingPayload(manifest) {
|
|
6381
|
+
return sha2562(concat2(MANIFEST_SIGNING_DOMAIN, canonicalizeManifest(manifest)));
|
|
6382
|
+
}
|
|
6383
|
+
async function verifyManifestSignature(manifest) {
|
|
6384
|
+
await requireEd25519();
|
|
6385
|
+
const sig = manifest.signature;
|
|
6386
|
+
if (!sig) throw new Error("manifest is missing required 'signature' field");
|
|
6387
|
+
if (sig.algorithm !== "ed25519") throw new Error(`unsupported signature algorithm: '${sig.algorithm}'`);
|
|
6388
|
+
const publicKey = fromB64url(sig.publicKey ?? "");
|
|
6389
|
+
const signature = fromB64url(sig.signature ?? "");
|
|
6390
|
+
if (publicKey.length !== 32 || signature.length !== 64) throw new Error("malformed signature field");
|
|
6391
|
+
const key = await crypto.subtle.importKey("raw", buf2(publicKey), { name: "Ed25519" }, false, ["verify"]);
|
|
6392
|
+
const ok = await crypto.subtle.verify("Ed25519", key, buf2(signature), buf2(await signingPayload(manifest)));
|
|
6393
|
+
if (!ok) throw new Error("Ed25519 signature verification failed");
|
|
6394
|
+
const derived = signerIdOf({ publicKey });
|
|
6395
|
+
if (manifest.signerId !== derived) {
|
|
6396
|
+
throw new Error(`signerId mismatch: manifest declares '${manifest.signerId}' but signature public key derives to '${derived}'`);
|
|
6397
|
+
}
|
|
6398
|
+
return derived;
|
|
6399
|
+
}
|
|
6400
|
+
function checkPathComponent(value, field) {
|
|
6401
|
+
if (!value) throw new Error(`${field} is empty`);
|
|
6402
|
+
if (value.includes("..")) throw new Error(`${field} contains path traversal sequence '..'`);
|
|
6403
|
+
if (value.includes("/") || value.includes("\\")) throw new Error(`${field} contains directory separator`);
|
|
6404
|
+
if (value.includes("\0")) throw new Error(`${field} contains null byte`);
|
|
6405
|
+
if (value.length >= 2 && value[1] === ":") throw new Error(`${field} appears to be an absolute path`);
|
|
6406
|
+
}
|
|
6407
|
+
function checkPipelinePath(value, field) {
|
|
6408
|
+
if (!value) throw new Error(`${field} is empty`);
|
|
6409
|
+
if (value.includes("\0")) throw new Error(`${field} contains null byte`);
|
|
6410
|
+
if (value.includes("\\")) throw new Error(`${field} contains backslash (use forward slashes)`);
|
|
6411
|
+
if (value.startsWith("/")) throw new Error(`${field} is an absolute path`);
|
|
6412
|
+
if (value[1] === ":") throw new Error(`${field} appears to be an absolute Windows path`);
|
|
6413
|
+
if (value.split("/").includes("..")) throw new Error(`${field} contains path traversal component '..'`);
|
|
6414
|
+
if (!PIPELINE_PATH.test(value) || utf86(value).length > 100) {
|
|
6415
|
+
throw new Error(`${field} must be pipelines/<name>.yaml (A-Z a-z 0-9 . _ -), at most 100 bytes`);
|
|
6416
|
+
}
|
|
6417
|
+
}
|
|
6418
|
+
var METADATA_STRINGS = ["name", "description", "author", "icon", "license", "category", "guide"];
|
|
6419
|
+
function normalizeMetadata(m) {
|
|
6420
|
+
const bad = (what) => new Error(`metadata ${what}`);
|
|
6421
|
+
if (typeof m !== "object" || m === null || Array.isArray(m)) throw bad("must be an object");
|
|
6422
|
+
const known = /* @__PURE__ */ new Set([...METADATA_STRINGS, "tags"]);
|
|
6423
|
+
const unknown = Object.keys(m).find((k) => !known.has(k));
|
|
6424
|
+
if (unknown !== void 0) throw bad(`has an unknown field '${unknown}'`);
|
|
6425
|
+
const out = {};
|
|
6426
|
+
for (const k of METADATA_STRINGS) {
|
|
6427
|
+
const v = m[k];
|
|
6428
|
+
if (v === void 0) continue;
|
|
6429
|
+
if (typeof v !== "string") throw bad(`${k} must be a string`);
|
|
6430
|
+
out[k] = v;
|
|
6431
|
+
}
|
|
6432
|
+
if (typeof out.name !== "string") throw bad("name is required");
|
|
6433
|
+
if (m.tags !== void 0) {
|
|
6434
|
+
if (!Array.isArray(m.tags) || m.tags.some((t) => typeof t !== "string")) throw bad("tags must be an array of strings");
|
|
6435
|
+
out.tags = [...m.tags];
|
|
6436
|
+
}
|
|
6437
|
+
return out;
|
|
6438
|
+
}
|
|
6439
|
+
var artifact = (path, bytes) => ({ path, hash: hex2(sha2562(bytes)), size: bytes.length });
|
|
6440
|
+
var padded = (n) => 512 + Math.ceil(n / 512) * 512;
|
|
6441
|
+
function tarEntry(name, data) {
|
|
6442
|
+
const header = new Uint8Array(512);
|
|
6443
|
+
const put = (off, text) => header.set(utf86(text), off);
|
|
6444
|
+
put(0, name);
|
|
6445
|
+
put(100, "0000644\0");
|
|
6446
|
+
put(108, "0000000\0");
|
|
6447
|
+
put(116, "0000000\0");
|
|
6448
|
+
put(124, `${data.length.toString(8).padStart(11, "0")}\0`);
|
|
6449
|
+
put(136, "00000000000\0");
|
|
6450
|
+
put(148, " ");
|
|
6451
|
+
put(156, "0");
|
|
6452
|
+
put(257, "ustar\0");
|
|
6453
|
+
put(263, "00");
|
|
6454
|
+
put(148, `${header.reduce((n, b) => n + b, 0).toString(8).padStart(6, "0")}\0 `);
|
|
6455
|
+
return concat2(header, data, new Uint8Array((512 - data.length % 512) % 512));
|
|
6456
|
+
}
|
|
6457
|
+
function readTar(tar) {
|
|
6458
|
+
const out = /* @__PURE__ */ new Map();
|
|
6459
|
+
const text = (a, b) => new TextDecoder().decode(tar.subarray(a, b)).replace(/\0.*$/s, "");
|
|
6460
|
+
for (let off = 0; off + 512 <= tar.length && tar[off] !== 0; ) {
|
|
6461
|
+
const name = text(off, off + 100);
|
|
6462
|
+
const size = parseInt(text(off + 124, off + 136).trim(), 8);
|
|
6463
|
+
if (out.has(name)) throw new Error(`the archive has more than one entry at '${name}'`);
|
|
6464
|
+
out.set(name, tar.subarray(off + 512, off + 512 + size));
|
|
6465
|
+
off += padded(size);
|
|
6466
|
+
}
|
|
6467
|
+
return out;
|
|
6468
|
+
}
|
|
6469
|
+
async function checkPackage(tar, publicKey) {
|
|
6470
|
+
const entries = readTar(tar);
|
|
6471
|
+
const raw = entries.get("manifest.json");
|
|
6472
|
+
if (!raw) throw new Error("manifest.json not found in bundle");
|
|
6473
|
+
const manifest = JSON.parse(new TextDecoder().decode(raw));
|
|
6474
|
+
await verifyManifestSignature(manifest);
|
|
6475
|
+
if (manifest.signature.publicKey !== b64url(publicKey)) throw new Error("the manifest is not signed by the publisher key");
|
|
6476
|
+
const declared = [manifest.compute, ...manifest.pipelines ?? []];
|
|
6477
|
+
const names = ["manifest.json", ...declared.map((a) => a.path)];
|
|
6478
|
+
if (names.length !== entries.size || names.some((n) => !entries.has(n))) {
|
|
6479
|
+
throw new Error("the archive does not hold exactly the files its manifest declares");
|
|
6480
|
+
}
|
|
6481
|
+
for (const a of declared) {
|
|
6482
|
+
const bytes = entries.get(a.path);
|
|
6483
|
+
if (!bytes || bytes.length !== a.size || hex2(sha2562(bytes)) !== a.hash) {
|
|
6484
|
+
throw new Error(`bundle artifact '${a.path}' failed its integrity check`);
|
|
6485
|
+
}
|
|
6486
|
+
}
|
|
6487
|
+
}
|
|
6488
|
+
async function gzip(bytes) {
|
|
6489
|
+
if (typeof CompressionStream === "undefined") throw new Error("this runtime cannot gzip packages (no CompressionStream)");
|
|
6490
|
+
const stream = new Blob([buf2(bytes)]).stream().pipeThrough(new CompressionStream("gzip"));
|
|
6491
|
+
return new Uint8Array(await new Response(stream).arrayBuffer());
|
|
6492
|
+
}
|
|
6493
|
+
async function signerOf(key, seed, publicKey) {
|
|
6494
|
+
if (seed) {
|
|
6495
|
+
const derived = fromB64url(await recoveryPublicKey(seed));
|
|
6496
|
+
if (hex2(derived) !== hex2(publicKey)) throw new Error("the publisher key's publicKey is not its seed's");
|
|
6497
|
+
return { signing: await privateKey(seed, false), publicKey: derived };
|
|
6498
|
+
}
|
|
6499
|
+
const k = key.privateKey;
|
|
6500
|
+
if (k?.algorithm?.name !== "Ed25519" || k.type !== "private" || !k.usages.includes("sign")) {
|
|
6501
|
+
throw new Error("the publisher key is not an Ed25519 signing key");
|
|
6502
|
+
}
|
|
6503
|
+
return { signing: k, publicKey };
|
|
6504
|
+
}
|
|
6505
|
+
async function packComputePackage(input, key) {
|
|
6506
|
+
const seed = "seed" in key && key.seed ? Uint8Array.from(key.seed) : void 0;
|
|
6507
|
+
const publicKey = Uint8Array.from(key.publicKey);
|
|
6508
|
+
const job = prepare(input);
|
|
6509
|
+
await requireEd25519();
|
|
6510
|
+
const { signing, publicKey: pub } = await signerOf(key, seed, publicKey);
|
|
6511
|
+
const manifest = { ...job.manifest, signerId: signerIdOf({ publicKey: pub }) };
|
|
6512
|
+
const signature = await crypto.subtle.sign("Ed25519", signing, buf2(await signingPayload(manifest)));
|
|
6513
|
+
manifest.signature = { algorithm: "ed25519", publicKey: b64url(pub), signature: b64url(new Uint8Array(signature)) };
|
|
6514
|
+
const manifestBytes = utf86(jcs(manifest));
|
|
6515
|
+
if (manifestBytes.length > MAX_MANIFEST_BYTES) {
|
|
6516
|
+
throw new Error(`bundle manifest.json exceeds the ${MAX_MANIFEST_BYTES} byte cap`);
|
|
6517
|
+
}
|
|
6518
|
+
const files = [["manifest.json", manifestBytes], ["compute.wasm", job.compute], ...job.files];
|
|
6519
|
+
checkArchiveSize(files.map(([, b]) => b.length));
|
|
6520
|
+
const tar = concat2(...files.map(([n, b]) => tarEntry(n, b)), new Uint8Array(1024));
|
|
6521
|
+
await checkPackage(tar, pub);
|
|
6522
|
+
const mpk = await gzip(tar);
|
|
6523
|
+
if (mpk.length > MAX_MPK_BYTES) throw new Error(`a package is limited to ${MAX_MPK_BYTES >> 20} MiB`);
|
|
6524
|
+
return mpk;
|
|
6525
|
+
}
|
|
6526
|
+
function checkArchiveSize(sizes) {
|
|
6527
|
+
if (sizes.reduce((n, s) => n + padded(s), 1024) > MAX_ARCHIVE_BYTES) {
|
|
6528
|
+
throw new Error(`bundle archive exceeds the ${MAX_ARCHIVE_BYTES} byte decompressed cap`);
|
|
6529
|
+
}
|
|
6530
|
+
}
|
|
6531
|
+
function prepare(input) {
|
|
6532
|
+
checkPathComponent(input.package, "package");
|
|
6533
|
+
checkPathComponent(input.version, "appVersion");
|
|
6534
|
+
if (!SEMVER.test(input.version)) throw new Error(`appVersion '${input.version}' is not a semantic version`);
|
|
6535
|
+
if (!input.compute?.length) throw new Error("the package ships no WASM");
|
|
6536
|
+
if (input.pipelines.length > MAX_PIPELINES_PER_PACKAGE) {
|
|
6537
|
+
throw new Error(`bundle declares ${input.pipelines.length} pipelines, at most ${MAX_PIPELINES_PER_PACKAGE} are allowed`);
|
|
6538
|
+
}
|
|
6539
|
+
checkArchiveSize([input.compute.length]);
|
|
6540
|
+
const compute = Uint8Array.from(input.compute);
|
|
6541
|
+
if (COMPONENT_HEADER.some((b, i) => compute[i] !== b)) {
|
|
6542
|
+
throw new Error("compute: not a WASM component (an SDK 0.12 core module is refused by the node)");
|
|
6543
|
+
}
|
|
6544
|
+
const files = input.pipelines.map((p, i) => {
|
|
6545
|
+
checkPipelinePath(p.path, `pipelines[${i}].path`);
|
|
6546
|
+
return [p.path, utf86(p.source)];
|
|
6547
|
+
});
|
|
6548
|
+
const big = files.find(([, b]) => b.length > MAX_PIPELINE_BYTES);
|
|
6549
|
+
if (big) throw new Error(`pipeline '${big[0]}' exceeds the ${MAX_PIPELINE_BYTES} byte cap`);
|
|
6550
|
+
const lower = files.map(([n]) => n.toLowerCase());
|
|
6551
|
+
if (new Set(lower).size !== files.length) throw new Error("two pipelines have the same path");
|
|
6552
|
+
const metadata = input.metadata === void 0 ? void 0 : normalizeMetadata(input.metadata);
|
|
6553
|
+
const manifest = {
|
|
6554
|
+
version: "1.0",
|
|
6555
|
+
package: input.package,
|
|
6556
|
+
appVersion: input.version,
|
|
6557
|
+
minRuntimeVersion: MIN_RUNTIME_VERSION,
|
|
6558
|
+
...metadata ? { metadata } : {},
|
|
6559
|
+
compute: artifact("compute.wasm", compute),
|
|
6560
|
+
...files.length ? { pipelines: files.map(([n, b]) => artifact(n, b)) } : {}
|
|
6561
|
+
};
|
|
6562
|
+
return { manifest, compute, files };
|
|
6563
|
+
}
|
|
6269
6564
|
export {
|
|
6270
6565
|
AGENT_ATTEST_DOMAIN,
|
|
6271
6566
|
AGENT_PROVISION_INFO_DOMAIN,
|
|
@@ -6297,6 +6592,11 @@ export {
|
|
|
6297
6592
|
IdempotencyMismatch,
|
|
6298
6593
|
KMS_RELEASE_SIGNER,
|
|
6299
6594
|
LoginRequired,
|
|
6595
|
+
MAX_ARCHIVE_BYTES,
|
|
6596
|
+
MAX_MANIFEST_BYTES,
|
|
6597
|
+
MAX_MPK_BYTES,
|
|
6598
|
+
MAX_PIPELINES_PER_PACKAGE,
|
|
6599
|
+
MAX_PIPELINE_BYTES,
|
|
6300
6600
|
MAX_RECOVERY_NONCE_BYTES,
|
|
6301
6601
|
MAX_REPORT_PAGE,
|
|
6302
6602
|
MOCK_QUOTE_HEADER,
|
|
@@ -6333,6 +6633,7 @@ export {
|
|
|
6333
6633
|
b64url,
|
|
6334
6634
|
backupPublicKey,
|
|
6335
6635
|
browserPasskey,
|
|
6636
|
+
canonicalizeManifest,
|
|
6336
6637
|
checkOwner,
|
|
6337
6638
|
claimedRelease,
|
|
6338
6639
|
cloudNodeReleaseUrl,
|
|
@@ -6350,6 +6651,7 @@ export {
|
|
|
6350
6651
|
deployerKey,
|
|
6351
6652
|
directoryTransport,
|
|
6352
6653
|
errorFrom,
|
|
6654
|
+
exportPublisherKey,
|
|
6353
6655
|
fetchAttestedKey,
|
|
6354
6656
|
fetchGithubNodeRelease,
|
|
6355
6657
|
fetchNodeRelease,
|
|
@@ -6357,8 +6659,11 @@ export {
|
|
|
6357
6659
|
fromB64url,
|
|
6358
6660
|
frontendManifest,
|
|
6359
6661
|
generateOwnerKey,
|
|
6662
|
+
generatePublisherKey,
|
|
6360
6663
|
holderKey,
|
|
6361
6664
|
holderRecoveryBody,
|
|
6665
|
+
importPublisherKey,
|
|
6666
|
+
isDevPublisherKey,
|
|
6362
6667
|
leaveOrgConsent,
|
|
6363
6668
|
newBackupKeyPair,
|
|
6364
6669
|
newIdempotencyKey,
|
|
@@ -6366,6 +6671,7 @@ export {
|
|
|
6366
6671
|
openDataKey,
|
|
6367
6672
|
orgCapabilities,
|
|
6368
6673
|
ownerPublicKey,
|
|
6674
|
+
packComputePackage,
|
|
6369
6675
|
pageDeployment,
|
|
6370
6676
|
pageQuery,
|
|
6371
6677
|
parseRecoverySeed,
|
|
@@ -6397,6 +6703,8 @@ export {
|
|
|
6397
6703
|
setMemberRoleConsent,
|
|
6398
6704
|
setMemberTeamsConsent,
|
|
6399
6705
|
signRecovery,
|
|
6706
|
+
signerIdOf,
|
|
6707
|
+
signingPayload,
|
|
6400
6708
|
sseFrames,
|
|
6401
6709
|
stalledBy,
|
|
6402
6710
|
transportKeyBinding,
|
|
@@ -6409,6 +6717,7 @@ export {
|
|
|
6409
6717
|
verifyReleaseUrl,
|
|
6410
6718
|
verifySignedAgentPolicy,
|
|
6411
6719
|
verifySignedNodeRelease,
|
|
6720
|
+
webCryptoPublisherKey,
|
|
6412
6721
|
withdrawConsent,
|
|
6413
6722
|
withoutConsentReturn
|
|
6414
6723
|
};
|