run402 4.166.0 → 4.167.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/lib/app-repo-tokens.mjs +1 -2
- package/lib/app-repos.mjs +2 -2
- package/lib/apps.mjs +1 -3
- package/lib/archives.mjs +0 -6
- package/lib/argparse.mjs +10 -53
- package/lib/assets.mjs +11 -42
- package/lib/auth.mjs +4 -48
- package/lib/billing.mjs +8 -8
- package/lib/branches.mjs +3 -5
- package/lib/buzz-notifications.mjs +2 -21
- package/lib/buzz.mjs +4 -5
- package/lib/cache.mjs +0 -20
- package/lib/cdn.mjs +0 -7
- package/lib/claims.mjs +2 -4
- package/lib/contacts.mjs +3 -9
- package/lib/contracts.mjs +0 -28
- package/lib/credentials.mjs +2 -5
- package/lib/deliveries.mjs +0 -1
- package/lib/deploy-v2.mjs +20 -102
- package/lib/domains.mjs +6 -73
- package/lib/email.mjs +19 -62
- package/lib/errors.mjs +6 -13
- package/lib/escalations.mjs +2 -4
- package/lib/events.mjs +1 -3
- package/lib/feedback.mjs +1 -34
- package/lib/functions.mjs +12 -26
- package/lib/grants.mjs +0 -7
- package/lib/identity.mjs +1 -7
- package/lib/image.mjs +1 -2
- package/lib/init.mjs +0 -3
- package/lib/jobs.mjs +2 -2
- package/lib/logs.mjs +2 -5
- package/lib/messages.mjs +3 -3
- package/lib/orgs.mjs +3 -3
- package/lib/projects.mjs +3 -50
- package/lib/remote-helper-session.mjs +1 -2
- package/lib/repos.mjs +7 -39
- package/lib/rooms.mjs +2 -3
- package/lib/snapshots.mjs +2 -7
- package/lib/stripe.mjs +9 -16
- package/lib/subscriptions.mjs +0 -3
- package/lib/transfer.mjs +16 -67
- package/lib/up.mjs +0 -16
- package/lib/webhooks.mjs +1 -13
- package/lib/whoami.mjs +0 -8
- package/package.json +1 -1
- package/sdk/dist/app-up.js +1 -0
- package/sdk/dist/app-up.js.map +1 -1
- package/sdk/dist/ci-credentials.d.ts.map +1 -1
- package/sdk/dist/ci-credentials.js +6 -0
- package/sdk/dist/ci-credentials.js.map +1 -1
- package/sdk/dist/control-plane-credentials.d.ts.map +1 -1
- package/sdk/dist/control-plane-credentials.js +2 -0
- package/sdk/dist/control-plane-credentials.js.map +1 -1
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +7 -0
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/jcs.d.ts.map +1 -1
- package/sdk/dist/jcs.js +1 -0
- package/sdk/dist/jcs.js.map +1 -1
- package/sdk/dist/namespaces/admin.d.ts +1 -1
- package/sdk/dist/namespaces/admin.d.ts.map +1 -1
- package/sdk/dist/namespaces/admin.js +0 -5
- package/sdk/dist/namespaces/admin.js.map +1 -1
- package/sdk/dist/namespaces/agent.d.ts.map +1 -1
- package/sdk/dist/namespaces/agent.js +1 -0
- package/sdk/dist/namespaces/agent.js.map +1 -1
- package/sdk/dist/namespaces/ai.d.ts.map +1 -1
- package/sdk/dist/namespaces/ai.js +1 -0
- package/sdk/dist/namespaces/ai.js.map +1 -1
- package/sdk/dist/namespaces/app-repos.d.ts.map +1 -1
- package/sdk/dist/namespaces/app-repos.js +5 -4
- package/sdk/dist/namespaces/app-repos.js.map +1 -1
- package/sdk/dist/namespaces/archives.d.ts.map +1 -1
- package/sdk/dist/namespaces/archives.js +6 -3
- package/sdk/dist/namespaces/archives.js.map +1 -1
- package/sdk/dist/namespaces/assets-validation.d.ts +14 -19
- package/sdk/dist/namespaces/assets-validation.d.ts.map +1 -1
- package/sdk/dist/namespaces/assets-validation.js +27 -50
- package/sdk/dist/namespaces/assets-validation.js.map +1 -1
- package/sdk/dist/namespaces/assets.d.ts.map +1 -1
- package/sdk/dist/namespaces/assets.js +11 -28
- package/sdk/dist/namespaces/assets.js.map +1 -1
- package/sdk/dist/namespaces/assets.types.d.ts +0 -2
- package/sdk/dist/namespaces/assets.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/assets.types.js +0 -2
- package/sdk/dist/namespaces/assets.types.js.map +1 -1
- package/sdk/dist/namespaces/auth.d.ts.map +1 -1
- package/sdk/dist/namespaces/auth.js +30 -51
- package/sdk/dist/namespaces/auth.js.map +1 -1
- package/sdk/dist/namespaces/billing.d.ts.map +1 -1
- package/sdk/dist/namespaces/billing.js +12 -41
- package/sdk/dist/namespaces/billing.js.map +1 -1
- package/sdk/dist/namespaces/branches.js +1 -0
- package/sdk/dist/namespaces/branches.js.map +1 -1
- package/sdk/dist/namespaces/buzz.d.ts.map +1 -1
- package/sdk/dist/namespaces/buzz.js +3 -6
- package/sdk/dist/namespaces/buzz.js.map +1 -1
- package/sdk/dist/namespaces/cache.d.ts.map +1 -1
- package/sdk/dist/namespaces/cache.js +0 -4
- package/sdk/dist/namespaces/cache.js.map +1 -1
- package/sdk/dist/namespaces/ci.d.ts.map +1 -1
- package/sdk/dist/namespaces/ci.js +24 -90
- package/sdk/dist/namespaces/ci.js.map +1 -1
- package/sdk/dist/namespaces/contracts.d.ts.map +1 -1
- package/sdk/dist/namespaces/contracts.js +10 -32
- package/sdk/dist/namespaces/contracts.js.map +1 -1
- package/sdk/dist/namespaces/credentials.d.ts.map +1 -1
- package/sdk/dist/namespaces/credentials.js +13 -8
- package/sdk/dist/namespaces/credentials.js.map +1 -1
- package/sdk/dist/namespaces/deploy.d.ts.map +1 -1
- package/sdk/dist/namespaces/deploy.js +156 -649
- package/sdk/dist/namespaces/deploy.js.map +1 -1
- package/sdk/dist/namespaces/domains.d.ts.map +1 -1
- package/sdk/dist/namespaces/domains.js +1 -0
- package/sdk/dist/namespaces/domains.js.map +1 -1
- package/sdk/dist/namespaces/email.d.ts +6 -1
- package/sdk/dist/namespaces/email.d.ts.map +1 -1
- package/sdk/dist/namespaces/email.js +23 -78
- package/sdk/dist/namespaces/email.js.map +1 -1
- package/sdk/dist/namespaces/errors.d.ts.map +1 -1
- package/sdk/dist/namespaces/errors.js +9 -0
- package/sdk/dist/namespaces/errors.js.map +1 -1
- package/sdk/dist/namespaces/escalations.d.ts.map +1 -1
- package/sdk/dist/namespaces/escalations.js +15 -0
- package/sdk/dist/namespaces/escalations.js.map +1 -1
- package/sdk/dist/namespaces/events.d.ts.map +1 -1
- package/sdk/dist/namespaces/events.js +2 -0
- package/sdk/dist/namespaces/events.js.map +1 -1
- package/sdk/dist/namespaces/functions.d.ts +2 -2
- package/sdk/dist/namespaces/functions.d.ts.map +1 -1
- package/sdk/dist/namespaces/functions.js +39 -154
- package/sdk/dist/namespaces/functions.js.map +1 -1
- package/sdk/dist/namespaces/grants.d.ts.map +1 -1
- package/sdk/dist/namespaces/grants.js +12 -0
- package/sdk/dist/namespaces/grants.js.map +1 -1
- package/sdk/dist/namespaces/identity-links.d.ts.map +1 -1
- package/sdk/dist/namespaces/identity-links.js +7 -3
- package/sdk/dist/namespaces/identity-links.js.map +1 -1
- package/sdk/dist/namespaces/identity-links.protocol.d.ts.map +1 -1
- package/sdk/dist/namespaces/identity-links.protocol.js +1 -0
- package/sdk/dist/namespaces/identity-links.protocol.js.map +1 -1
- package/sdk/dist/namespaces/live.js +2 -0
- package/sdk/dist/namespaces/live.js.map +1 -1
- package/sdk/dist/namespaces/org.d.ts.map +1 -1
- package/sdk/dist/namespaces/org.js +22 -9
- package/sdk/dist/namespaces/org.js.map +1 -1
- package/sdk/dist/namespaces/projects.d.ts.map +1 -1
- package/sdk/dist/namespaces/projects.js +3 -0
- package/sdk/dist/namespaces/projects.js.map +1 -1
- package/sdk/dist/namespaces/push.d.ts.map +1 -1
- package/sdk/dist/namespaces/push.js +6 -0
- package/sdk/dist/namespaces/push.js.map +1 -1
- package/sdk/dist/namespaces/repos.d.ts +7 -37
- package/sdk/dist/namespaces/repos.d.ts.map +1 -1
- package/sdk/dist/namespaces/repos.js +61 -63
- package/sdk/dist/namespaces/repos.js.map +1 -1
- package/sdk/dist/namespaces/rooms.d.ts.map +1 -1
- package/sdk/dist/namespaces/rooms.js +4 -0
- package/sdk/dist/namespaces/rooms.js.map +1 -1
- package/sdk/dist/namespaces/secrets.d.ts.map +1 -1
- package/sdk/dist/namespaces/secrets.js +1 -12
- package/sdk/dist/namespaces/secrets.js.map +1 -1
- package/sdk/dist/namespaces/snapshots.d.ts.map +1 -1
- package/sdk/dist/namespaces/snapshots.js +5 -0
- package/sdk/dist/namespaces/snapshots.js.map +1 -1
- package/sdk/dist/namespaces/subdomains.d.ts.map +1 -1
- package/sdk/dist/namespaces/subdomains.js +1 -0
- package/sdk/dist/namespaces/subdomains.js.map +1 -1
- package/sdk/dist/namespaces/transfers.d.ts.map +1 -1
- package/sdk/dist/namespaces/transfers.js +17 -28
- package/sdk/dist/namespaces/transfers.js.map +1 -1
- package/sdk/dist/namespaces/vault.crypto.d.ts.map +1 -1
- package/sdk/dist/namespaces/vault.crypto.js +1 -0
- package/sdk/dist/namespaces/vault.crypto.js.map +1 -1
- package/sdk/dist/namespaces/wallets.d.ts.map +1 -1
- package/sdk/dist/namespaces/wallets.js +6 -0
- package/sdk/dist/namespaces/wallets.js.map +1 -1
- package/sdk/dist/node/actions-node.d.ts.map +1 -1
- package/sdk/dist/node/actions-node.js +16 -0
- package/sdk/dist/node/actions-node.js.map +1 -1
- package/sdk/dist/node/archives-node.d.ts.map +1 -1
- package/sdk/dist/node/archives-node.js +17 -0
- package/sdk/dist/node/archives-node.js.map +1 -1
- package/sdk/dist/node/assets-node.d.ts.map +1 -1
- package/sdk/dist/node/assets-node.js +5 -3
- package/sdk/dist/node/assets-node.js.map +1 -1
- package/sdk/dist/node/bearer-redeem-key.d.ts.map +1 -1
- package/sdk/dist/node/bearer-redeem-key.js +1 -0
- package/sdk/dist/node/bearer-redeem-key.js.map +1 -1
- package/sdk/dist/node/buzz-doctor.d.ts.map +1 -1
- package/sdk/dist/node/buzz-doctor.js +3 -0
- package/sdk/dist/node/buzz-doctor.js.map +1 -1
- package/sdk/dist/node/ci.d.ts.map +1 -1
- package/sdk/dist/node/ci.js +1 -0
- package/sdk/dist/node/ci.js.map +1 -1
- package/sdk/dist/node/credentials.d.ts.map +1 -1
- package/sdk/dist/node/credentials.js +1 -0
- package/sdk/dist/node/credentials.js.map +1 -1
- package/sdk/dist/node/deploy-manifest.d.ts.map +1 -1
- package/sdk/dist/node/deploy-manifest.js +90 -222
- package/sdk/dist/node/deploy-manifest.js.map +1 -1
- package/sdk/dist/node/dev-session.d.ts.map +1 -1
- package/sdk/dist/node/dev-session.js +4 -0
- package/sdk/dist/node/dev-session.js.map +1 -1
- package/sdk/dist/node/doctor.d.ts.map +1 -1
- package/sdk/dist/node/doctor.js +1 -0
- package/sdk/dist/node/doctor.js.map +1 -1
- package/sdk/dist/node/files.d.ts.map +1 -1
- package/sdk/dist/node/files.js +5 -0
- package/sdk/dist/node/files.js.map +1 -1
- package/sdk/dist/node/index.d.ts.map +1 -1
- package/sdk/dist/node/index.js +1 -0
- package/sdk/dist/node/index.js.map +1 -1
- package/sdk/dist/node/init.d.ts.map +1 -1
- package/sdk/dist/node/init.js +2 -0
- package/sdk/dist/node/init.js.map +1 -1
- package/sdk/dist/node/lightning-wallet.d.ts.map +1 -1
- package/sdk/dist/node/lightning-wallet.js +1 -0
- package/sdk/dist/node/lightning-wallet.js.map +1 -1
- package/sdk/dist/node/manifest-export.d.ts.map +1 -1
- package/sdk/dist/node/manifest-export.js +1 -0
- package/sdk/dist/node/manifest-export.js.map +1 -1
- package/sdk/dist/node/mpp-pay-executor.d.ts.map +1 -1
- package/sdk/dist/node/mpp-pay-executor.js +1 -0
- package/sdk/dist/node/mpp-pay-executor.js.map +1 -1
- package/sdk/dist/node/org-adopt.d.ts.map +1 -1
- package/sdk/dist/node/org-adopt.js +4 -0
- package/sdk/dist/node/org-adopt.js.map +1 -1
- package/sdk/dist/node/org-context.d.ts.map +1 -1
- package/sdk/dist/node/org-context.js +5 -0
- package/sdk/dist/node/org-context.js.map +1 -1
- package/sdk/dist/node/paid-fetch.d.ts.map +1 -1
- package/sdk/dist/node/paid-fetch.js +2 -0
- package/sdk/dist/node/paid-fetch.js.map +1 -1
- package/sdk/dist/node/payment-attempts.d.ts.map +1 -1
- package/sdk/dist/node/payment-attempts.js +4 -0
- package/sdk/dist/node/payment-attempts.js.map +1 -1
- package/sdk/dist/node/signers/index.d.ts.map +1 -1
- package/sdk/dist/node/signers/index.js +2 -0
- package/sdk/dist/node/signers/index.js.map +1 -1
- package/sdk/dist/node/signers/kms.d.ts.map +1 -1
- package/sdk/dist/node/signers/kms.js +7 -0
- package/sdk/dist/node/signers/kms.js.map +1 -1
- package/sdk/dist/node/target-profile.d.ts.map +1 -1
- package/sdk/dist/node/target-profile.js +4 -0
- package/sdk/dist/node/target-profile.js.map +1 -1
- package/sdk/dist/node/vault-apply.d.ts.map +1 -1
- package/sdk/dist/node/vault-apply.js +6 -0
- package/sdk/dist/node/vault-apply.js.map +1 -1
- package/sdk/dist/node/vault-byo-config.d.ts.map +1 -1
- package/sdk/dist/node/vault-byo-config.js +1 -0
- package/sdk/dist/node/vault-byo-config.js.map +1 -1
- package/sdk/dist/node/vault-byo-probe.d.ts.map +1 -1
- package/sdk/dist/node/vault-byo-probe.js +1 -0
- package/sdk/dist/node/vault-byo-probe.js.map +1 -1
- package/sdk/dist/node/vault-creation-journal.d.ts.map +1 -1
- package/sdk/dist/node/vault-creation-journal.js +1 -0
- package/sdk/dist/node/vault-creation-journal.js.map +1 -1
- package/sdk/dist/node/vault-deploy.d.ts.map +1 -1
- package/sdk/dist/node/vault-deploy.js +7 -0
- package/sdk/dist/node/vault-deploy.js.map +1 -1
- package/sdk/dist/node/vault-handoff.d.ts.map +1 -1
- package/sdk/dist/node/vault-handoff.js +1 -0
- package/sdk/dist/node/vault-handoff.js.map +1 -1
- package/sdk/dist/node/vault-keystore.d.ts.map +1 -1
- package/sdk/dist/node/vault-keystore.js +2 -0
- package/sdk/dist/node/vault-keystore.js.map +1 -1
- package/sdk/dist/node/vault-member-bundle.d.ts.map +1 -1
- package/sdk/dist/node/vault-member-bundle.js +1 -0
- package/sdk/dist/node/vault-member-bundle.js.map +1 -1
- package/sdk/dist/node/vault-mirror-backend.d.ts.map +1 -1
- package/sdk/dist/node/vault-mirror-backend.js +1 -0
- package/sdk/dist/node/vault-mirror-backend.js.map +1 -1
- package/sdk/dist/node/vault-mirror-config.d.ts.map +1 -1
- package/sdk/dist/node/vault-mirror-config.js +1 -0
- package/sdk/dist/node/vault-mirror-config.js.map +1 -1
- package/sdk/dist/node/vault-mirror.d.ts.map +1 -1
- package/sdk/dist/node/vault-mirror.js +1 -0
- package/sdk/dist/node/vault-mirror.js.map +1 -1
- package/sdk/dist/node/vault-prune.d.ts.map +1 -1
- package/sdk/dist/node/vault-prune.js +1 -0
- package/sdk/dist/node/vault-prune.js.map +1 -1
- package/sdk/dist/node/vault-publication.d.ts +1 -2
- package/sdk/dist/node/vault-publication.d.ts.map +1 -1
- package/sdk/dist/node/vault-publication.js +2 -0
- package/sdk/dist/node/vault-publication.js.map +1 -1
- package/sdk/dist/node/vault-recover.d.ts.map +1 -1
- package/sdk/dist/node/vault-recover.js +1 -0
- package/sdk/dist/node/vault-recover.js.map +1 -1
- package/sdk/dist/node/vault-restore.d.ts.map +1 -1
- package/sdk/dist/node/vault-restore.js +3 -0
- package/sdk/dist/node/vault-restore.js.map +1 -1
- package/sdk/dist/node/vault-snapshot.d.ts.map +1 -1
- package/sdk/dist/node/vault-snapshot.js +6 -0
- package/sdk/dist/node/vault-snapshot.js.map +1 -1
- package/sdk/dist/node/vault-writer-state.d.ts.map +1 -1
- package/sdk/dist/node/vault-writer-state.js +1 -0
- package/sdk/dist/node/vault-writer-state.js.map +1 -1
- package/sdk/dist/node/wallets-send.d.ts.map +1 -1
- package/sdk/dist/node/wallets-send.js +4 -0
- package/sdk/dist/node/wallets-send.js.map +1 -1
- package/sdk/dist/node/wallets.d.ts.map +1 -1
- package/sdk/dist/node/wallets.js +17 -0
- package/sdk/dist/node/wallets.js.map +1 -1
- package/sdk/dist/project-id.d.ts.map +1 -1
- package/sdk/dist/project-id.js +1 -0
- package/sdk/dist/project-id.js.map +1 -1
- package/sdk/dist/validation.d.ts +0 -5
- package/sdk/dist/validation.d.ts.map +1 -1
- package/sdk/dist/validation.js +2 -40
- package/sdk/dist/validation.js.map +1 -1
- package/vault-surface.json +1 -1
|
@@ -71,13 +71,10 @@ async function nodeOnly(load, verb) {
|
|
|
71
71
|
return await load();
|
|
72
72
|
}
|
|
73
73
|
catch (e) {
|
|
74
|
+
// local-check: local_state — vault methods need the Node runtime
|
|
74
75
|
throw new LocalError(`\`r.repos.${verb}\` needs the Node runtime (keystore + git); import it from a Node process, or use the read-only vault methods in a browser.`, `running vault ${verb}`, { code: "VAULT_NODE_ONLY", details: { cause: e instanceof Error ? e.message : String(e) } });
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
|
-
/** Byte counts in the refusal text read as MiB — the unit an operator's tier is quoted in. */
|
|
78
|
-
function mib(bytes) {
|
|
79
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`;
|
|
80
|
-
}
|
|
81
78
|
/**
|
|
82
79
|
* A client-generated handoff id (RFC 4122 v4), minted BEFORE the mint call
|
|
83
80
|
* (kygit-handoff design D3): `auth_secret`/`wrap_key` derive off it, so it
|
|
@@ -253,6 +250,7 @@ export async function computeByoPresenceOutcome(input) {
|
|
|
253
250
|
const report = await input.verifyPresence();
|
|
254
251
|
if (report.missing.length > 0) {
|
|
255
252
|
const missing = report.missing.slice(0, VAULT_BYO_OBJECT_MISSING_LIST_CAP);
|
|
253
|
+
// local-check: sdk_normalization — BYO destination misses objects the signed chain names
|
|
256
254
|
throw new LocalError(`the BYO destination for ${input.repoId} (${report.destination}) is missing ${report.missing.length} object(s) run402's own signed chain says should exist`, "running vault fsck", {
|
|
257
255
|
code: "VAULT_BYO_OBJECT_MISSING",
|
|
258
256
|
details: {
|
|
@@ -476,12 +474,14 @@ export class Repos {
|
|
|
476
474
|
const { VaultKeystore } = await this.#keystore();
|
|
477
475
|
const keystore = new VaultKeystore(options.keystore_root !== undefined ? { rootDir: options.keystore_root } : {});
|
|
478
476
|
const repo = keystore.readRepo(repoId);
|
|
477
|
+
// local-check: local_state — keystore holds no repo state
|
|
479
478
|
if (!repo)
|
|
480
479
|
throw new LocalError("this keystore holds no repo state for the vault — only a key-holder can accept a recipient's key change", "accepting a recipient key change", { code: "VAULT_REPO_STATE_MISSING", details: { repo_id: repoId } });
|
|
481
480
|
const record = await this.get(repoId);
|
|
482
481
|
const directory = await this.#client.request(`/orgs/v1/${encodeURIComponent(record.org_id)}/encryption-keys`, { context: "reading the org encryption-key directory" });
|
|
483
482
|
const served = directory.keys.find((k) => k.principal_id === options.principal_id)?.ek_fingerprint ?? null;
|
|
484
483
|
if (served !== options.new_fingerprint) {
|
|
484
|
+
// local-check: sdk_normalization — refuse to pin a fingerprint the directory does not serve
|
|
485
485
|
throw new LocalError(`the org directory currently serves ${served ?? "no key"} for principal ${options.principal_id}, not ${options.new_fingerprint} — refusing to pin a fingerprint the directory does not vouch for`, "accepting a recipient key change", { code: "PIN_CHANGE_UNCONFIRMED", details: { repo_id: repoId, principal_id: options.principal_id, directory_fingerprint: served, requested_fingerprint: options.new_fingerprint } });
|
|
486
486
|
}
|
|
487
487
|
const pins = { ...(repo.envelope_recipient_pins ?? {}) };
|
|
@@ -727,6 +727,7 @@ export class Repos {
|
|
|
727
727
|
return { outcome: "skipped_not_enrollable", ek_fingerprint: identity?.encryption_fingerprint ?? null, signing_fingerprint: identity?.signing_fingerprint ?? null };
|
|
728
728
|
}
|
|
729
729
|
if (identity?.enrolled_principal_id && identity.enrolled_principal_id !== whoami.principal.id) {
|
|
730
|
+
// local-check: local_state — keystore identity enrolled under another principal
|
|
730
731
|
throw new LocalError(`this keystore identity enrolled as principal ${identity.enrolled_principal_id}, but the active credential resolves to ${whoami.principal.id} — refusing cross-profile reuse of a custody identity`, "enrolling the keystore encryption key", { code: "VAULT_IDENTITY_PROFILE_MISMATCH", details: { enrolled_principal_id: identity.enrolled_principal_id, principal_id: whoami.principal.id, keystore_root: keystore.rootDir } });
|
|
731
732
|
}
|
|
732
733
|
const current = whoami.encryption_key ?? null;
|
|
@@ -740,6 +741,7 @@ export class Repos {
|
|
|
740
741
|
if (!identity && !current)
|
|
741
742
|
identity = keystore.ensureIdentity();
|
|
742
743
|
if (!identity) {
|
|
744
|
+
// local-check: local_state — keystore holds no identity for the published key
|
|
743
745
|
throw new LocalError(`this principal has a published encryption key (${current.ek_fingerprint}) but this keystore holds no identity — the keystore that enrolled it is not this one; rotation is never automatic`, "enrolling the keystore encryption key", {
|
|
744
746
|
code: "VAULT_KEY_ROTATION_REQUIRED",
|
|
745
747
|
details: { current_ek_fingerprint: current.ek_fingerprint, current_state: current.state, local_ek_fingerprint: null, keystore_root: keystore.rootDir },
|
|
@@ -751,6 +753,7 @@ export class Repos {
|
|
|
751
753
|
});
|
|
752
754
|
}
|
|
753
755
|
if (current && current.ek_fingerprint !== identity.encryption_fingerprint) {
|
|
756
|
+
// local-check: local_state — published key is not this keystore's key
|
|
754
757
|
throw new LocalError(`this principal's published encryption key (${current.ek_fingerprint}) is not this keystore's key (${identity.encryption_fingerprint}); rotation is never automatic`, "enrolling the keystore encryption key", {
|
|
755
758
|
code: "VAULT_KEY_ROTATION_REQUIRED",
|
|
756
759
|
details: { current_ek_fingerprint: current.ek_fingerprint, current_state: current.state, local_ek_fingerprint: identity.encryption_fingerprint, keystore_root: keystore.rootDir },
|
|
@@ -775,6 +778,7 @@ export class Repos {
|
|
|
775
778
|
}
|
|
776
779
|
const keypair = keystore.encryptionKeypair(identity);
|
|
777
780
|
if (!keypair) {
|
|
781
|
+
// local-check: local_state — keystore identity has no X25519 private key
|
|
778
782
|
throw new LocalError("the keystore identity has no X25519 private key — it cannot enroll or open envelopes", "enrolling the keystore encryption key", { code: "VAULT_UNRECOVERABLE", details: { statement: VAULT_TERMINAL_LOSS_STATEMENT } });
|
|
779
783
|
}
|
|
780
784
|
// The signing half rides the SAME publish call as the encryption half
|
|
@@ -800,6 +804,7 @@ export class Repos {
|
|
|
800
804
|
const published = await this.#client.request("/agent/v1/whoami/encryption-key", { method: "POST", body: { public_key: identity.encryption_pubkey, ek_fingerprint: identity.encryption_fingerprint, custody_scheme: "keystore_v1", ...signingFields }, context: "publishing the keystore encryption key" });
|
|
801
805
|
if (published.state !== "active") {
|
|
802
806
|
if (!published.activation) {
|
|
807
|
+
// local-check: sdk_normalization — pending key response without an activation challenge
|
|
803
808
|
throw new LocalError("the gateway published the key as pending without an activation challenge", "enrolling the keystore encryption key", { code: "KEY_NOT_PENDING", details: { state: published.state } });
|
|
804
809
|
}
|
|
805
810
|
const proof = computeKeystorePossessionProof({
|
|
@@ -860,6 +865,7 @@ export class Repos {
|
|
|
860
865
|
*/
|
|
861
866
|
async openOrCreate(options) {
|
|
862
867
|
if (!options.repo_id && !options.project_id) {
|
|
868
|
+
// local-check: argument — repo_id or project_id picks the vault
|
|
863
869
|
throw new LocalError("pass repo_id, or project_id to resolve it from the control plane", "opening the vault", { code: "VAULT_UNRESOLVED" });
|
|
864
870
|
}
|
|
865
871
|
// An explicit repo_id addresses the vault directly — there is nothing to
|
|
@@ -1626,6 +1632,7 @@ export class Repos {
|
|
|
1626
1632
|
const repoDir = options.repo_dir ?? process.cwd();
|
|
1627
1633
|
const repoFile = handle.keystore.readRepo(handle.repo_id);
|
|
1628
1634
|
if (!repoFile) {
|
|
1635
|
+
// local-check: local_state — keystore holds no key material for the vault
|
|
1629
1636
|
throw new LocalError(`no local key material for ${handle.repo_id} — this principal is not yet a member with a materialized envelope (push once first)`, "minting a handoff", { code: "VAULT_UNRESOLVED" });
|
|
1630
1637
|
}
|
|
1631
1638
|
const kRepo = hexToBytes(repoFile.k_repo_hex);
|
|
@@ -1641,6 +1648,7 @@ export class Repos {
|
|
|
1641
1648
|
const identity = handle.keystore.readIdentity();
|
|
1642
1649
|
const localWriterKeyId = identity?.signing_fingerprint ?? null;
|
|
1643
1650
|
if (!localWriterKeyId || !repoFile.writer_set_pin?.writers.some((w) => w.writer_key_id === localWriterKeyId)) {
|
|
1651
|
+
// local-check: local_state — keystore signing key not in the local writer-set pin
|
|
1644
1652
|
throw new LocalError("this keystore's signing key is not an admitted writer of this vault — minting a handoff requires an ACTIVE writer (design D4); an existing writer must add this key first (`run402 orgs members add` / repos access sync), or push once to reconcile if a pending admission already exists", "minting a handoff", { code: "VAULT_WRITER_NOT_ADMITTED" });
|
|
1645
1653
|
}
|
|
1646
1654
|
// The grant's `minted_role` must EXACTLY predict what the gateway's own
|
|
@@ -1654,6 +1662,7 @@ export class Repos {
|
|
|
1654
1662
|
const who = await this.#client.request("/agent/v1/whoami", { context: "resolving this principal's org role for the handoff grant" });
|
|
1655
1663
|
const membership = who.memberships.find((m) => m.org_id === vaultRecord.org_id && m.status === "active");
|
|
1656
1664
|
if (!membership) {
|
|
1665
|
+
// local-check: sdk_normalization — the SDK needs the minter's role to build the grant
|
|
1657
1666
|
throw new LocalError(`this principal has no active membership on ${vaultRecord.org_id} — an active writer must also be an active org member to mint a handoff`, "minting a handoff", { code: "VAULT_ACCESS_DENIED" });
|
|
1658
1667
|
}
|
|
1659
1668
|
const grantMintedRole = predictMintedRole(options.role, membership.role);
|
|
@@ -1711,6 +1720,7 @@ export class Repos {
|
|
|
1711
1720
|
// call actually sealed, independent of anything the gateway could alter.
|
|
1712
1721
|
const signingKeypair = handle.keystore.signingKeypair(identity); // non-null: the writer precheck above already required identity.signing_fingerprint
|
|
1713
1722
|
if (!signingKeypair) {
|
|
1723
|
+
// local-check: local_state — keystore holds no signing seed
|
|
1714
1724
|
throw new LocalError("this keystore has no local signing seed — it can read the vault's writer identity but cannot sign a writer_admission_grant from here (a read-only recovery identity); mint from a checkout that holds the full signing seed", "minting a handoff", { code: "VAULT_UNRECOVERABLE" });
|
|
1715
1725
|
}
|
|
1716
1726
|
const handoffAdmissionSeed = deriveWriterAdmissionSeed(handoff_id_bytes, master_secret);
|
|
@@ -1767,6 +1777,7 @@ export class Repos {
|
|
|
1767
1777
|
context: "minting a handoff key",
|
|
1768
1778
|
});
|
|
1769
1779
|
if (response.handoff_id !== handoffId) {
|
|
1780
|
+
// local-check: sdk_normalization — minted handoff_id differs from the one the key embeds
|
|
1770
1781
|
throw new LocalError(`the gateway minted a different handoff_id (${response.handoff_id}) than requested (${handoffId}) — the assembled key would not match; retry`, "minting a handoff key", { code: "HANDOFF_ID_MISMATCH", details: { requested: handoffId, minted: response.handoff_id } });
|
|
1771
1782
|
}
|
|
1772
1783
|
// The gateway names back the SHA-256 of the EXACT writer_admission_grant
|
|
@@ -1774,6 +1785,7 @@ export class Repos {
|
|
|
1774
1785
|
// (never the other way around) so a gateway that silently altered the
|
|
1775
1786
|
// grant is caught here, before the key is ever handed to a recipient.
|
|
1776
1787
|
if (response.writer_admission_grant_sha256 !== grantSha256Local) {
|
|
1788
|
+
// local-check: sdk_normalization — echoed grant hash differs from the grant signed here
|
|
1777
1789
|
throw new LocalError(`the gateway echoed a writer_admission_grant_sha256 (${response.writer_admission_grant_sha256}) that does not match what this call sent (${grantSha256Local}) — the stored grant may not be the one this call signed; do not distribute this handoff key`, "minting a handoff key", { code: "HANDOFF_MINT_GRANT_MISMATCH", details: { expected: grantSha256Local, received: response.writer_admission_grant_sha256 } });
|
|
1778
1790
|
}
|
|
1779
1791
|
return {
|
|
@@ -1837,6 +1849,7 @@ export class Repos {
|
|
|
1837
1849
|
const repoDir = options.repo_dir ?? process.cwd();
|
|
1838
1850
|
const repoFile = handle.keystore.readRepo(handle.repo_id);
|
|
1839
1851
|
if (!repoFile) {
|
|
1852
|
+
// local-check: local_state — keystore holds no key material for the vault
|
|
1840
1853
|
throw new LocalError(`no local key material for ${handle.repo_id} — this principal is not yet a member with a materialized envelope (push once first)`, "minting an invite", { code: "VAULT_UNRESOLVED" });
|
|
1841
1854
|
}
|
|
1842
1855
|
const kRepo = hexToBytes(repoFile.k_repo_hex);
|
|
@@ -1851,6 +1864,7 @@ export class Repos {
|
|
|
1851
1864
|
const identity = handle.keystore.readIdentity();
|
|
1852
1865
|
const localWriterKeyId = identity?.signing_fingerprint ?? null;
|
|
1853
1866
|
if (!localWriterKeyId || !repoFile.writer_set_pin?.writers.some((w) => w.writer_key_id === localWriterKeyId)) {
|
|
1867
|
+
// local-check: local_state — keystore signing key not in the local writer-set pin
|
|
1854
1868
|
throw new LocalError("this keystore's signing key is not an admitted writer of this vault — minting an invite requires an ACTIVE writer (the gateway's own refusal is INVITE_MINT_REQUIRES_WRITER); run `run402 repos access sync` from a live writer, or push once to reconcile if a pending admission already exists", "minting an invite", { code: "VAULT_WRITER_NOT_ADMITTED", details: { next_action: "request_writer_sync", command: "run402 repos access sync" } });
|
|
1855
1869
|
}
|
|
1856
1870
|
// The grant's `minted_role` must EXACTLY predict what the gateway's own
|
|
@@ -1863,6 +1877,7 @@ export class Repos {
|
|
|
1863
1877
|
const whoMints = await this.#client.request("/agent/v1/whoami", { context: "resolving this principal's org role for the invite grant" });
|
|
1864
1878
|
const inviterMembership = whoMints.memberships.find((m) => m.org_id === vaultRecord.org_id && m.status === "active");
|
|
1865
1879
|
if (!inviterMembership) {
|
|
1880
|
+
// local-check: sdk_normalization — the SDK needs the inviter's role to build the grant
|
|
1866
1881
|
throw new LocalError(`this principal has no active membership on ${vaultRecord.org_id} — an active writer must also be an active org member to mint an invite`, "minting an invite", { code: "VAULT_ACCESS_DENIED" });
|
|
1867
1882
|
}
|
|
1868
1883
|
const grantMintedRole = predictMintedRole(options.role ?? INVITE_DEFAULT_ROLE, inviterMembership.role);
|
|
@@ -1938,6 +1953,7 @@ export class Repos {
|
|
|
1938
1953
|
// the INVITE id in `handoff_id`. One admission door, two product doors.
|
|
1939
1954
|
const signingKeypair = handle.keystore.signingKeypair(identity); // non-null: the writer precheck above already required identity.signing_fingerprint
|
|
1940
1955
|
if (!signingKeypair) {
|
|
1956
|
+
// local-check: local_state — keystore holds no signing seed
|
|
1941
1957
|
throw new LocalError("this keystore has no local signing seed — it can read the vault's writer identity but cannot sign a writer_admission_grant from here (a read-only recovery identity); mint from a checkout that holds the full signing seed", "minting an invite", { code: "VAULT_UNRECOVERABLE" });
|
|
1942
1958
|
}
|
|
1943
1959
|
const inviteAdmissionSeed = deriveInviteWriterAdmissionSeed(invite_id_bytes, master_secret);
|
|
@@ -1994,6 +2010,7 @@ export class Repos {
|
|
|
1994
2010
|
context: "minting an invite key",
|
|
1995
2011
|
});
|
|
1996
2012
|
if (response.invite_id !== inviteId) {
|
|
2013
|
+
// local-check: sdk_normalization — minted invite_id differs from the one the key embeds
|
|
1997
2014
|
throw new LocalError(`the gateway minted a different invite_id (${response.invite_id}) than requested (${inviteId}) — the assembled key would not match; retry`, "minting an invite key", { code: "INVITE_ID_MISMATCH", details: { requested: inviteId, minted: response.invite_id } });
|
|
1998
2015
|
}
|
|
1999
2016
|
// The gateway names back the SHA-256 of the EXACT writer_admission_grant
|
|
@@ -2001,6 +2018,7 @@ export class Repos {
|
|
|
2001
2018
|
// (never the other way around) so a gateway that silently altered the
|
|
2002
2019
|
// grant is caught here, before the key is ever handed to a joiner.
|
|
2003
2020
|
if (response.writer_admission_grant_sha256 !== grantSha256Local) {
|
|
2021
|
+
// local-check: sdk_normalization — echoed grant hash differs from the grant signed here
|
|
2004
2022
|
throw new LocalError(`the gateway echoed a writer_admission_grant_sha256 (${response.writer_admission_grant_sha256}) that does not match what this call sent (${grantSha256Local}) — the stored grant may not be the one this call signed; do not distribute this invite key`, "minting an invite key", { code: "INVITE_MINT_GRANT_MISMATCH", details: { expected: grantSha256Local, received: response.writer_admission_grant_sha256 } });
|
|
2005
2023
|
}
|
|
2006
2024
|
// design D4: post the message AFTER the mint succeeds — a mint refusal must
|
|
@@ -2142,6 +2160,7 @@ export class Repos {
|
|
|
2142
2160
|
const identity = keystore.ensureIdentity();
|
|
2143
2161
|
const signingKeypair = keystore.signingKeypair(identity);
|
|
2144
2162
|
if (!signingKeypair) {
|
|
2163
|
+
// local-check: local_state — keystore holds no signing seed
|
|
2145
2164
|
throw new LocalError("this keystore has no local signing seed — resuming a vault-multi-writer handoff requires signing writer_acceptance with a full Ed25519 seed, which a read-only recovery identity does not hold", "resuming a handoff", { code: "VAULT_UNRECOVERABLE" });
|
|
2146
2165
|
}
|
|
2147
2166
|
const redeemerEncryptionPubkeyRaw = fromBase64url(identity.encryption_pubkey, "identity.encryption_pubkey");
|
|
@@ -2184,6 +2203,7 @@ export class Repos {
|
|
|
2184
2203
|
grantBytes = fromBase64url(redeem.writer_admission_grant, "writer_admission_grant");
|
|
2185
2204
|
}
|
|
2186
2205
|
catch {
|
|
2206
|
+
// local-check: sdk_normalization — malformed writer_admission_grant in the redeem response
|
|
2187
2207
|
throw new LocalError("the redeem response's writer_admission_grant is not valid base64url", "resuming a handoff", { code: "VALIDATION_FAILED", details: { field: "writer_admission_grant" } });
|
|
2188
2208
|
}
|
|
2189
2209
|
let grant;
|
|
@@ -2191,9 +2211,11 @@ export class Repos {
|
|
|
2191
2211
|
grant = JSON.parse(new TextDecoder().decode(grantBytes));
|
|
2192
2212
|
}
|
|
2193
2213
|
catch {
|
|
2214
|
+
// local-check: sdk_normalization — malformed writer_admission_grant in the redeem response
|
|
2194
2215
|
throw new LocalError("the redeem response's writer_admission_grant does not decode to valid JSON", "resuming a handoff", { code: "VALIDATION_FAILED", details: { field: "writer_admission_grant" } });
|
|
2195
2216
|
}
|
|
2196
2217
|
if (grant.handoff_id !== parsed.handoff_id || grant.auth_hash !== secrets.auth_hash_hex || grant.repo_id !== vault.vault_id) {
|
|
2218
|
+
// local-check: sdk_normalization — redeem grant does not bind this handoff
|
|
2197
2219
|
throw new LocalError("the redeem response's writer_admission_grant does not bind this handoff — refusing", "resuming a handoff", { code: "VALIDATION_FAILED", details: { field: "writer_admission_grant" } });
|
|
2198
2220
|
}
|
|
2199
2221
|
const grantSha256 = sha256Hex(grantBytes);
|
|
@@ -2203,6 +2225,7 @@ export class Repos {
|
|
|
2203
2225
|
// pre-vault-multi-writer mint's envelope outright.
|
|
2204
2226
|
const payload = openHandoffEnvelopeV2(parsed.handoff_id_bytes, secrets.wrap_key, redeem.sealed_envelope, redeem.envelope_kind);
|
|
2205
2227
|
if (payload.repo_id !== vault.vault_id) {
|
|
2228
|
+
// local-check: sdk_normalization — sealed envelope names a different vault
|
|
2206
2229
|
throw new LocalError("the opened envelope's repo_id does not match the redeem response's vault — refusing", "resuming a handoff", { code: "HANDOFF_ENVELOPE_INVALID" });
|
|
2207
2230
|
}
|
|
2208
2231
|
// check the grant hash — design D4's own integrity binding: the SEALED
|
|
@@ -2211,6 +2234,7 @@ export class Repos {
|
|
|
2211
2234
|
// grant doesn't match, something between mint and redeem substituted a
|
|
2212
2235
|
// different one — refuse before spending anything on this handoff.
|
|
2213
2236
|
if (payload.writer_admission_grant_sha256 !== grantSha256) {
|
|
2237
|
+
// local-check: sdk_normalization — redeem grant differs from the hash sealed at mint
|
|
2214
2238
|
throw new LocalError(`the redeem response's writer_admission_grant (sha256 ${grantSha256}) does not match the hash sealed into the envelope at mint time (${payload.writer_admission_grant_sha256}) — refusing to activate under a substituted grant`, "resuming a handoff", { code: "HANDOFF_REDEEM_WRITER_KEY_MISMATCH", details: { expected: payload.writer_admission_grant_sha256, received: grantSha256 } });
|
|
2215
2239
|
}
|
|
2216
2240
|
// Genesis must be pinned before ANY materialize call can succeed
|
|
@@ -2221,10 +2245,12 @@ export class Repos {
|
|
|
2221
2245
|
const transport = createVaultHttpTransport(this.#client);
|
|
2222
2246
|
const genesisBytes = await transport.getGenesis({ repo_id: vault.vault_id });
|
|
2223
2247
|
if (!genesisBytes) {
|
|
2248
|
+
// local-check: sdk_normalization — vault chain has no admitted genesis
|
|
2224
2249
|
throw new LocalError("the vault has no admitted genesis", "resuming a handoff", { code: "CHAIN_BROKEN", details: { repo_id: vault.vault_id } });
|
|
2225
2250
|
}
|
|
2226
2251
|
const genesis = parseVaultStrict(new TextDecoder().decode(genesisBytes));
|
|
2227
2252
|
if (!verifyVaultObject(genesis, genesis.creator_signing_pubkey)) {
|
|
2253
|
+
// local-check: sdk_normalization — genesis signature does not verify
|
|
2228
2254
|
throw new LocalError("vault_genesis signature does not verify", "resuming a handoff", { code: "VAULT_SIGNATURE_INVALID", details: { repo_id: vault.vault_id } });
|
|
2229
2255
|
}
|
|
2230
2256
|
const genesisSha = sha256Hex(genesisBytes);
|
|
@@ -2394,6 +2420,7 @@ export class Repos {
|
|
|
2394
2420
|
const identity = keystore.ensureIdentity();
|
|
2395
2421
|
const signingKeypair = keystore.signingKeypair(identity);
|
|
2396
2422
|
if (!signingKeypair) {
|
|
2423
|
+
// local-check: local_state — keystore holds no signing seed
|
|
2397
2424
|
throw new LocalError("this keystore has no local signing seed — joining an invite requires signing writer_acceptance with a full Ed25519 seed, which a read-only recovery identity does not hold", "joining an invite", { code: "VAULT_UNRECOVERABLE" });
|
|
2398
2425
|
}
|
|
2399
2426
|
const redeemerEncryptionPubkeyRaw = fromBase64url(identity.encryption_pubkey, "identity.encryption_pubkey");
|
|
@@ -2433,6 +2460,7 @@ export class Repos {
|
|
|
2433
2460
|
grantBytes = fromBase64url(redeem.writer_admission_grant, "writer_admission_grant");
|
|
2434
2461
|
}
|
|
2435
2462
|
catch {
|
|
2463
|
+
// local-check: sdk_normalization — malformed writer_admission_grant in the redeem response
|
|
2436
2464
|
throw new LocalError("the redeem response's writer_admission_grant is not valid base64url", "joining an invite", { code: "VALIDATION_FAILED", details: { field: "writer_admission_grant" } });
|
|
2437
2465
|
}
|
|
2438
2466
|
let grant;
|
|
@@ -2440,16 +2468,19 @@ export class Repos {
|
|
|
2440
2468
|
grant = JSON.parse(new TextDecoder().decode(grantBytes));
|
|
2441
2469
|
}
|
|
2442
2470
|
catch {
|
|
2471
|
+
// local-check: sdk_normalization — malformed writer_admission_grant in the redeem response
|
|
2443
2472
|
throw new LocalError("the redeem response's writer_admission_grant does not decode to valid JSON", "joining an invite", { code: "VALIDATION_FAILED", details: { field: "writer_admission_grant" } });
|
|
2444
2473
|
}
|
|
2445
2474
|
// `handoff_id` is the frozen protocol spelling of the key id (D11) —
|
|
2446
2475
|
// for an invite it carries the INVITE id.
|
|
2447
2476
|
if (grant.handoff_id !== parsed.invite_id || grant.auth_hash !== secrets.auth_hash_hex || grant.repo_id !== vault.vault_id) {
|
|
2477
|
+
// local-check: sdk_normalization — redeem grant does not bind this invite
|
|
2448
2478
|
throw new LocalError("the redeem response's writer_admission_grant does not bind this invite — refusing", "joining an invite", { code: "VALIDATION_FAILED", details: { field: "writer_admission_grant" } });
|
|
2449
2479
|
}
|
|
2450
2480
|
const grantSha256 = sha256Hex(grantBytes);
|
|
2451
2481
|
const payload = openInviteEnvelope(parsed.invite_id_bytes, secrets.wrap_key, redeem.sealed_envelope, redeem.envelope_kind);
|
|
2452
2482
|
if (payload.repo_id !== vault.vault_id) {
|
|
2483
|
+
// local-check: sdk_normalization — sealed envelope names a different vault
|
|
2453
2484
|
throw new LocalError("the opened envelope's repo_id does not match the redeem response's vault — refusing", "joining an invite", { code: "INVITE_ENVELOPE_INVALID" });
|
|
2454
2485
|
}
|
|
2455
2486
|
// design D5's own integrity binding: the SEALED envelope
|
|
@@ -2458,6 +2489,7 @@ export class Repos {
|
|
|
2458
2489
|
// this comparison LOCALLY, before anything is written to disk or the
|
|
2459
2490
|
// keystore.
|
|
2460
2491
|
if (payload.writer_admission_grant_sha256 !== grantSha256) {
|
|
2492
|
+
// local-check: sdk_normalization — redeem grant differs from the hash sealed at mint
|
|
2461
2493
|
throw new LocalError(`the redeem response's writer_admission_grant (sha256 ${grantSha256}) does not match the hash sealed into the envelope at mint time (${payload.writer_admission_grant_sha256}) — refusing to activate under a substituted grant`, "joining an invite", { code: "INVITE_REDEEM_WRITER_KEY_MISMATCH", details: { expected: payload.writer_admission_grant_sha256, received: grantSha256 } });
|
|
2462
2494
|
}
|
|
2463
2495
|
// Genesis must be pinned before ANY materialize call can succeed — the
|
|
@@ -2466,10 +2498,12 @@ export class Repos {
|
|
|
2466
2498
|
const transport = createVaultHttpTransport(this.#client);
|
|
2467
2499
|
const genesisBytes = await transport.getGenesis({ repo_id: vault.vault_id });
|
|
2468
2500
|
if (!genesisBytes) {
|
|
2501
|
+
// local-check: sdk_normalization — vault chain has no admitted genesis
|
|
2469
2502
|
throw new LocalError("the vault has no admitted genesis", "joining an invite", { code: "CHAIN_BROKEN", details: { repo_id: vault.vault_id } });
|
|
2470
2503
|
}
|
|
2471
2504
|
const genesis = parseVaultStrict(new TextDecoder().decode(genesisBytes));
|
|
2472
2505
|
if (!verifyVaultObject(genesis, genesis.creator_signing_pubkey)) {
|
|
2506
|
+
// local-check: sdk_normalization — genesis signature does not verify
|
|
2473
2507
|
throw new LocalError("vault_genesis signature does not verify", "joining an invite", { code: "VAULT_SIGNATURE_INVALID", details: { repo_id: vault.vault_id } });
|
|
2474
2508
|
}
|
|
2475
2509
|
const genesisSha = sha256Hex(genesisBytes);
|
|
@@ -2725,6 +2759,7 @@ export class Repos {
|
|
|
2725
2759
|
nextActions.push({ action: "run402 repos access revoke-key <principal_id>", why: "an org membership removal or key revocation is outstanding for this vault; a surviving writer's push completes a membership removal automatically (reason member_removed), so this push was refused because that rotation could not run here — an owner can rotate explicitly with this command (owner + step-up)" });
|
|
2726
2760
|
if (details.exposure_outstanding)
|
|
2727
2761
|
nextActions.push({ action: "run402 repos access declare-exposure", why: "this vault's own epoch secret has been declared exposed (owner + step-up)" });
|
|
2762
|
+
// local-check: sdk_normalization — enriches the gateway's EPOCH_ROTATION_REQUIRED refusal
|
|
2728
2763
|
return new LocalError(`this vault requires a rotate_epoch admission before an ordinary push is admissible (repo_id ${repoId})`, "pushing to vault", { code: "EPOCH_ROTATION_REQUIRED", details, next_actions: nextActions.length > 0 ? nextActions : undefined, cause: e });
|
|
2729
2764
|
}
|
|
2730
2765
|
/**
|
|
@@ -2871,28 +2906,9 @@ export class Repos {
|
|
|
2871
2906
|
const plan = await handle.vault.planPush(push);
|
|
2872
2907
|
return { ...plan, allocation_needed: false, snapshot, vault_commit: snapshot.oid, vault_commit_line: line };
|
|
2873
2908
|
}
|
|
2874
|
-
/**
|
|
2875
|
-
* Compaction's transient-storage preflight
|
|
2876
|
-
* (vault-compaction-headroom-preflight, design D1/D2).
|
|
2877
|
-
*
|
|
2878
|
-
* Three postures, in order of information quality:
|
|
2879
|
-
* 1. the check answers "won't fit" → typed refusal, before any upload;
|
|
2880
|
-
* 2. the caller passed the override → proceed, marked `overridden`;
|
|
2881
|
-
* 3. the check CANNOT be answered → proceed after one stderr note.
|
|
2882
|
-
*
|
|
2883
|
-
* (3) is deliberate: failing closed on ignorance would make compaction's
|
|
2884
|
-
* availability depend on an ADVISORY read, which is wrong for a maintenance
|
|
2885
|
-
* verb whose refusals must come from the authority that owns the quota.
|
|
2886
|
-
*
|
|
2887
|
-
* The size proxy is the vault's billed `source_bytes` (D1). The true
|
|
2888
|
-
* checkpoint-pack size is unknowable before packing, but it is bounded above
|
|
2889
|
-
* by — and usually near — the vault's live content. Deliberately
|
|
2890
|
-
* conservative when history exceeds live content; the override exists
|
|
2891
|
-
* precisely because a proxy can overestimate.
|
|
2892
|
-
*/
|
|
2893
2909
|
/**
|
|
2894
2910
|
* Read compaction's transient-storage arithmetic WITHOUT compacting — the
|
|
2895
|
-
* same figures `compact`
|
|
2911
|
+
* same figures `compact` discloses. `repos gc`
|
|
2896
2912
|
* uses it to disclose headroom on the `--submit` half, where no compaction
|
|
2897
2913
|
* runs but the numbers are just as worth showing. `null` when the pooled
|
|
2898
2914
|
* figures cannot be read.
|
|
@@ -2962,7 +2978,7 @@ export class Repos {
|
|
|
2962
2978
|
// The grant's byte fields arrive as STRINGS on the wire (gateway BIGINT
|
|
2963
2979
|
// serialization, verified live) — coerce BEFORE the finiteness gate, or
|
|
2964
2980
|
// `Number.isFinite("472697418")` (false, no coercion) silently discards
|
|
2965
|
-
// an opened grant and the
|
|
2981
|
+
// an opened grant and the disclosure shows the unraised limit.
|
|
2966
2982
|
const overrideNum = effectiveLimitOverride === undefined ? Number.NaN : Number(effectiveLimitOverride);
|
|
2967
2983
|
const effectiveLimit = Number.isFinite(overrideNum) && overrideNum > 0 ? overrideNum : poolLimit;
|
|
2968
2984
|
const projected = poolUsed + sourceBytes;
|
|
@@ -2972,35 +2988,9 @@ export class Repos {
|
|
|
2972
2988
|
vault_source_bytes: sourceBytes,
|
|
2973
2989
|
projected_transient_bytes: projected,
|
|
2974
2990
|
ok: projected <= effectiveLimit,
|
|
2975
|
-
overridden: false,
|
|
2976
2991
|
...(effectiveLimit !== poolLimit ? { effective_pool_limit_bytes: effectiveLimit } : {}),
|
|
2977
2992
|
};
|
|
2978
2993
|
}
|
|
2979
|
-
/** The reader plus compaction's policy (refuse / override / proceed). */
|
|
2980
|
-
async #compactHeadroomPreflight(repoId, ignore, effectiveLimitOverride) {
|
|
2981
|
-
const headroom = await this.#readCompactHeadroom(repoId, effectiveLimitOverride);
|
|
2982
|
-
if (headroom === null)
|
|
2983
|
-
return null;
|
|
2984
|
-
const { pool_used_bytes: poolUsed, pool_limit_bytes: poolLimit, vault_source_bytes: sourceBytes, projected_transient_bytes: projected, ok, effective_pool_limit_bytes: effectiveLimit } = headroom;
|
|
2985
|
-
if (!ok && !ignore) {
|
|
2986
|
-
const limitForMessage = effectiveLimit ?? poolLimit;
|
|
2987
|
-
throw new LocalError(`compaction needs about ${mib(sourceBytes)} of transient headroom and the org's pooled storage has ${mib(Math.max(limitForMessage - poolUsed, 0))} free ` +
|
|
2988
|
-
`(${mib(poolUsed)} used of ${mib(limitForMessage)}${effectiveLimit !== undefined ? ` — includes an active compaction grant raising the ${mib(poolLimit)} tier limit` : ""}; projected ${mib(projected)}). Compaction transiently holds BOTH the new checkpoint and the ` +
|
|
2989
|
-
`not-yet-pruned history — roughly 2x source_bytes — until a prune completes. Free storage, raise the tier, or re-run with --force-headroom ` +
|
|
2990
|
-
`(the platform's own quota enforcement stays authoritative either way).`, "preflighting vault compaction storage headroom", {
|
|
2991
|
-
code: "VAULT_COMPACT_INSUFFICIENT_HEADROOM",
|
|
2992
|
-
details: {
|
|
2993
|
-
pool_used_bytes: poolUsed,
|
|
2994
|
-
pool_limit_bytes: poolLimit,
|
|
2995
|
-
vault_source_bytes: sourceBytes,
|
|
2996
|
-
projected_transient_bytes: projected,
|
|
2997
|
-
...(effectiveLimit !== undefined ? { effective_pool_limit_bytes: effectiveLimit } : {}),
|
|
2998
|
-
override: "--force-headroom",
|
|
2999
|
-
},
|
|
3000
|
-
});
|
|
3001
|
-
}
|
|
3002
|
-
return { ...headroom, overridden: !ok && ignore };
|
|
3003
|
-
}
|
|
3004
2994
|
/** A 409 `VAULT_COMPACTION_GRANT_ACTIVE` refusal — another compaction already holds this project's grant. */
|
|
3005
2995
|
#isCompactionGrantActive(e) {
|
|
3006
2996
|
const err = e;
|
|
@@ -3031,6 +3021,7 @@ export class Repos {
|
|
|
3031
3021
|
}
|
|
3032
3022
|
catch (e) {
|
|
3033
3023
|
if (this.#isCompactionGrantActive(e)) {
|
|
3024
|
+
// local-check: sdk_normalization — rewraps the gateway's active-compaction-grant refusal
|
|
3034
3025
|
throw new LocalError(`another compaction is already in progress for this vault (its headroom grant expires ${e.details?.expires_at ?? "soon"}) — refusing to race it.`, context, { code: "VAULT_COMPACTION_IN_PROGRESS", details: { expires_at: e.details?.expires_at ?? null } });
|
|
3035
3026
|
}
|
|
3036
3027
|
// 404/absent-route or any other failure: proceed ungranted.
|
|
@@ -3050,15 +3041,13 @@ export class Repos {
|
|
|
3050
3041
|
async compact(options = {}) {
|
|
3051
3042
|
const handle = await this.open(options);
|
|
3052
3043
|
// vault-checkpoint-cadence design D3: open the compaction headroom
|
|
3053
|
-
// grant BEFORE the
|
|
3054
|
-
// any checkpoint is built or uploaded
|
|
3055
|
-
// preflight itself. Outcomes are documented on
|
|
3044
|
+
// grant BEFORE the headroom read (which discloses its raised limit) and
|
|
3045
|
+
// before any checkpoint is built or uploaded. Outcomes are documented on
|
|
3056
3046
|
// {@link VaultNamespace.#openMaintenanceGrantOrConflict}.
|
|
3057
3047
|
const grant = await this.#openMaintenanceGrantOrConflict(handle, "opening the vault compaction headroom grant");
|
|
3058
|
-
// Everything from here on is bracketed by the grant's own lifetime
|
|
3059
|
-
//
|
|
3060
|
-
//
|
|
3061
|
-
// opened rather than leaking it until the gateway's hourly sweep.
|
|
3048
|
+
// Everything from here on is bracketed by the grant's own lifetime, so a
|
|
3049
|
+
// refusal still closes a grant this call opened rather than leaking it
|
|
3050
|
+
// until the gateway's hourly sweep.
|
|
3062
3051
|
try {
|
|
3063
3052
|
return await this.#compactAfterGrant(handle, options, grant);
|
|
3064
3053
|
}
|
|
@@ -3067,11 +3056,10 @@ export class Repos {
|
|
|
3067
3056
|
await handle.vault.closeCompactionGrant().catch(() => undefined);
|
|
3068
3057
|
}
|
|
3069
3058
|
}
|
|
3070
|
-
/** The rest of `compact()`, run under an already-opened-or-skipped grant — split out so the grant's `finally` above covers every exit path
|
|
3059
|
+
/** The rest of `compact()`, run under an already-opened-or-skipped grant — split out so the grant's `finally` above covers every exit path. */
|
|
3071
3060
|
async #compactAfterGrant(handle, options, grant) {
|
|
3072
|
-
//
|
|
3073
|
-
|
|
3074
|
-
const headroom = await this.#compactHeadroomPreflight(handle.repo_id, options.ignoreHeadroom === true, grant?.effective_pool_limit_bytes);
|
|
3061
|
+
// Disclosure only (see VaultCompactHeadroom): the gateway's quota refuses.
|
|
3062
|
+
const headroom = await this.#readCompactHeadroom(handle.repo_id, grant?.effective_pool_limit_bytes);
|
|
3075
3063
|
const base = await handle.vault.materialize();
|
|
3076
3064
|
let lease = null;
|
|
3077
3065
|
if (options.lease !== false) {
|
|
@@ -3117,7 +3105,7 @@ export class Repos {
|
|
|
3117
3105
|
}
|
|
3118
3106
|
// The compaction headroom grant (if one was opened) is closed by the
|
|
3119
3107
|
// caller — `compact()`'s own `finally`, which wraps this ENTIRE
|
|
3120
|
-
// method so
|
|
3108
|
+
// method so any refusal closes it too. Design D3's rationale
|
|
3121
3109
|
// for closing promptly (prune only ever REMOVES objects, so nothing
|
|
3122
3110
|
// past the checkpoint publish needs the raised limit) lives there.
|
|
3123
3111
|
}
|
|
@@ -3373,6 +3361,7 @@ export class Repos {
|
|
|
3373
3361
|
}
|
|
3374
3362
|
const existing = await handle.vault.transport.getObject({ repo_id: handle.repo_id, path: o.path });
|
|
3375
3363
|
const existingSha256 = existing ? sha256Hex(existing) : null;
|
|
3364
|
+
// local-check: sdk_normalization — reused receipt id holds different bytes
|
|
3376
3365
|
if (existing && existingSha256 === o.sha256)
|
|
3377
3366
|
continue; // identical bytes already landed — nothing to do
|
|
3378
3367
|
throw new LocalError(existing
|
|
@@ -3469,6 +3458,7 @@ export class Repos {
|
|
|
3469
3458
|
const before = await this.status(options);
|
|
3470
3459
|
const repoId = before.repo_id;
|
|
3471
3460
|
if (!repoId) {
|
|
3461
|
+
// local-check: argument — repo_id or project_id picks the vault
|
|
3472
3462
|
throw new LocalError(options.repo_id || options.project_id
|
|
3473
3463
|
? "no vault is allocated for this project yet — nothing to fsck"
|
|
3474
3464
|
: "pass repo_id, or project_id to resolve it from the control plane", "running vault fsck", { code: "VAULT_UNRESOLVED", details: { project_id: options.project_id ?? null } });
|
|
@@ -3705,9 +3695,11 @@ export class Repos {
|
|
|
3705
3695
|
const before = await read();
|
|
3706
3696
|
const h = before.vault_handover ?? null;
|
|
3707
3697
|
if (!h) {
|
|
3698
|
+
// local-check: sdk_normalization — transfer response carries no vault handover
|
|
3708
3699
|
throw new LocalError("this transfer's project has no vault, so there is nothing to hand over", "handing over the transfer's vault", { code: "TRANSFER_HAS_NO_VAULT", details: { transfer_id: transferId } });
|
|
3709
3700
|
}
|
|
3710
3701
|
if (!h.recipient) {
|
|
3702
|
+
// local-check: sdk_normalization — handover response names no recipient yet
|
|
3711
3703
|
throw new LocalError("the recipient has not named the principal that receives the source yet; they do that by running `run402 transfer accept`", "handing over the transfer's vault", { code: "TRANSFER_VAULT_RECIPIENT_NOT_NOMINATED", details: { transfer_id: transferId, state: h.state } });
|
|
3712
3704
|
}
|
|
3713
3705
|
const recipient = h.recipient;
|
|
@@ -3772,6 +3764,7 @@ export class Repos {
|
|
|
3772
3764
|
#enrichEpochRotationRequiredForPinManifest(e, repoId) {
|
|
3773
3765
|
if (!isRun402Error(e) || e.code !== "EPOCH_ROTATION_REQUIRED")
|
|
3774
3766
|
return e;
|
|
3767
|
+
// local-check: sdk_normalization — enriches the gateway's EPOCH_ROTATION_REQUIRED refusal
|
|
3775
3768
|
return new LocalError(`this vault requires a rotate_epoch admission before an ordinary pin-manifest publish is admissible (repo_id ${repoId}) — fold this SAME receipt into rotateEpoch({..., pending_confirmations: [{principal_id, ek_fingerprint, receipt}]}) instead of retrying this call`, "publishing a recipient_pin_manifest update", { code: "EPOCH_ROTATION_REQUIRED", details: e.details, next_actions: [{ action: "r.repos.rotateEpoch({..., pending_confirmations: [{principal_id, ek_fingerprint, receipt}]})", why: "the manifest publish rides the SAME head as the required rotation, which is EPOCH_ROTATION_REQUIRED's own escape valve — a standalone publish never is" }], cause: e });
|
|
3776
3769
|
}
|
|
3777
3770
|
/**
|
|
@@ -4181,6 +4174,7 @@ export class Repos {
|
|
|
4181
4174
|
const repoId = await this.#resolveRepoId(options);
|
|
4182
4175
|
const keystore = new VaultKeystore(options.keystore_root !== undefined ? { rootDir: options.keystore_root } : {});
|
|
4183
4176
|
const config = readMirrorConfig(keystore, repoId);
|
|
4177
|
+
// local-check: local_state — no mirror configured in the keystore
|
|
4184
4178
|
if (!config)
|
|
4185
4179
|
throw new LocalError(`no mirror is configured for ${repoId}`, "verifying vault mirror", { code: "VAULT_MIRROR_NOT_CONFIGURED", details: { repo_id: repoId }, next_actions: [{ action: "run402 repos mirror <destination>" }] });
|
|
4186
4180
|
const backend = openVaultMirrorBackend(config.destination, repoId, config.credential);
|
|
@@ -4209,8 +4203,10 @@ export class Repos {
|
|
|
4209
4203
|
let repoId = options.repo_id;
|
|
4210
4204
|
if (!repoId) {
|
|
4211
4205
|
const found = await discoverMirroredRepoIds(destination, options.credential);
|
|
4206
|
+
// local-check: local_state — the client-held mirror holds no vault
|
|
4212
4207
|
if (found.length === 0)
|
|
4213
4208
|
throw new LocalError(`${options.source} holds no mirrored vault (no source/<repo_id>/ prefix found)`, "recovering vault", { code: "VAULT_MIRROR_EMPTY", details: { source: options.source } });
|
|
4209
|
+
// local-check: local_state — the client-held mirror holds several vaults
|
|
4214
4210
|
if (found.length > 1)
|
|
4215
4211
|
throw new LocalError(`${options.source} holds ${found.length} mirrored vaults; pass repo_id to pick one`, "recovering vault", { code: "VAULT_MIRROR_AMBIGUOUS", details: { source: options.source, repo_ids: found }, next_actions: found.map((id) => ({ action: `recover --repo ${id}` })) });
|
|
4216
4212
|
repoId = found[0];
|
|
@@ -4244,6 +4240,7 @@ export class Repos {
|
|
|
4244
4240
|
return options.repo_id;
|
|
4245
4241
|
if (options.project_id)
|
|
4246
4242
|
return (await this.forProject(options.project_id)).repo_id;
|
|
4243
|
+
// local-check: argument — repo_id or project_id picks the vault
|
|
4247
4244
|
throw new LocalError("pass repo_id, or project_id to resolve it from the control plane", "opening the vault", { code: "VAULT_UNRESOLVED" });
|
|
4248
4245
|
}
|
|
4249
4246
|
#publication() {
|
|
@@ -4512,6 +4509,7 @@ export function parseVaultRemoteUrl(url) {
|
|
|
4512
4509
|
return { org_id: m[1], project_id: m[2] };
|
|
4513
4510
|
const other = /^([A-Za-z][A-Za-z0-9+.-]*)::/.exec(trimmed);
|
|
4514
4511
|
if (other && other[1] !== "run402") {
|
|
4512
|
+
// local-check: sdk_normalization — the SDK parses the vault remote URL itself
|
|
4515
4513
|
throw new LocalError(`remote scheme '${other[1]}::' is not supported; the one vault remote scheme is run402::<org>/<name>`, "parsing a vault remote address", { code: "REMOTE_SCHEME_UNSUPPORTED", details: { scheme: other[1] } });
|
|
4516
4514
|
}
|
|
4517
4515
|
return null;
|