run402 4.165.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 +73 -64
- 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 +22 -2
- 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
package/lib/app-repo-tokens.mjs
CHANGED
|
@@ -24,14 +24,13 @@ async function create(args) {
|
|
|
24
24
|
if (pos.length === 0) fail({ code: "BAD_USAGE", message: "Missing <name>.", hint: CREATE_USAGE });
|
|
25
25
|
if (pos.length > 1) tooMany("tokens create", pos[1]);
|
|
26
26
|
const access = flagValue(a, "--access");
|
|
27
|
-
if (access !== "read" && access !== "write") fail({ code: "BAD_USAGE", message: "--access must be read or write.", hint: CREATE_USAGE });
|
|
28
27
|
const ttl = flagValue(a, "--ttl");
|
|
29
28
|
const ttlSeconds = ttl === null || ttl === undefined ? undefined : Number(ttl);
|
|
30
29
|
if (ttlSeconds !== undefined && !Number.isInteger(ttlSeconds)) {
|
|
31
30
|
fail({ code: "BAD_USAGE", message: "--ttl must be a whole number of seconds.", hint: "60 to 86400; the default is 3600." });
|
|
32
31
|
}
|
|
33
32
|
const projectId = resolveProjectId(flagValue(a, "--project"));
|
|
34
|
-
await call((ar) => ar.createToken(projectId, pos[0], { access, ...(ttlSeconds !== undefined ? { ttl_seconds: ttlSeconds } : {}) }));
|
|
33
|
+
await call((ar) => ar.createToken(projectId, pos[0], { ...(access !== null ? { access } : {}), ...(ttlSeconds !== undefined ? { ttl_seconds: ttlSeconds } : {}) }));
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
async function revoke(args) {
|
package/lib/app-repos.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import { fileURLToPath } from "node:url";
|
|
|
19
19
|
import { apiBase, activeProfile, findProject, readWallet, resolveProjectId } from "./config.mjs";
|
|
20
20
|
import { getSdk, getProjectAuth } from "./sdk.mjs";
|
|
21
21
|
import { reportSdkError, fail } from "./sdk-errors.mjs";
|
|
22
|
-
import { assertKnownFlags, flagValue, normalizeArgv, positionalArgs,
|
|
22
|
+
import { assertKnownFlags, flagValue, normalizeArgv, positionalArgs, parseIntegerArg, failUnknownSubcommand } from "./argparse.mjs";
|
|
23
23
|
import { resolveOnPath } from "./path-lookup.mjs";
|
|
24
24
|
|
|
25
25
|
const DEFAULT_REPO = "default";
|
|
@@ -215,7 +215,7 @@ async function log(args) {
|
|
|
215
215
|
const path = flagValue(a, "--path");
|
|
216
216
|
const cursor = flagValue(a, "--cursor");
|
|
217
217
|
const rawLimit = flagValue(a, "--limit");
|
|
218
|
-
const limit = rawLimit === null || rawLimit === undefined ? undefined :
|
|
218
|
+
const limit = rawLimit === null || rawLimit === undefined ? undefined : parseIntegerArg("--limit", rawLimit);
|
|
219
219
|
await call((ar) => ar.log(projectId, repoName, {
|
|
220
220
|
...(path ? { path } : {}),
|
|
221
221
|
...(cursor ? { cursor } : {}),
|
package/lib/apps.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { walletAuthHeaders, saveProject } from "./config.mjs";
|
|
2
2
|
import { getSdk } from "./sdk.mjs";
|
|
3
3
|
import { reportSdkError, fail } from "./sdk-errors.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { assertKnownFlags, flagValue, normalizeArgv, positionalArgs, resolveProjectSelector, failUnknownSubcommand } from "./argparse.mjs";
|
|
5
5
|
|
|
6
6
|
const HELP = `run402 apps — Browse and manage the app marketplace
|
|
7
7
|
|
|
@@ -223,7 +223,6 @@ async function publish(projectId, args) {
|
|
|
223
223
|
opts.description = flagValue(parsedArgs, "--description") ?? undefined;
|
|
224
224
|
opts.tags = flagValue(parsedArgs, "--tags")?.split(",");
|
|
225
225
|
opts.visibility = flagValue(parsedArgs, "--visibility") ?? undefined;
|
|
226
|
-
if (opts.visibility) assertAllowedValue(opts.visibility, ["public", "unlisted", "private"], "--visibility");
|
|
227
226
|
if (parsedArgs.includes("--fork-allowed")) opts.forkAllowed = true;
|
|
228
227
|
try {
|
|
229
228
|
const data = await getSdk().apps.publish(resolvedProject, {
|
|
@@ -288,7 +287,6 @@ async function update(projectId, versionId, args) {
|
|
|
288
287
|
opts.description = flagValue(parsedArgs, "--description") ?? undefined;
|
|
289
288
|
opts.tags = flagValue(parsedArgs, "--tags")?.split(",");
|
|
290
289
|
opts.visibility = flagValue(parsedArgs, "--visibility") ?? undefined;
|
|
291
|
-
if (opts.visibility) assertAllowedValue(opts.visibility, ["public", "unlisted", "private"], "--visibility");
|
|
292
290
|
if (parsedArgs.includes("--fork-allowed")) opts.fork_allowed = true;
|
|
293
291
|
if (parsedArgs.includes("--no-fork")) opts.fork_allowed = false;
|
|
294
292
|
try {
|
package/lib/archives.mjs
CHANGED
|
@@ -131,9 +131,6 @@ async function create(rawArgs) {
|
|
|
131
131
|
const scope = flagValue(args, "--scope") ?? "portable-runtime-v1";
|
|
132
132
|
const auth = flagValue(args, "--auth") ?? "stubs";
|
|
133
133
|
const consistency = flagValue(args, "--consistency") ?? "pause-writes";
|
|
134
|
-
assertAllowedValue(scope, ["portable-runtime-v1"], "--scope");
|
|
135
|
-
assertAllowedValue(auth, ["stubs", "none"], "--auth");
|
|
136
|
-
assertAllowedValue(consistency, ["pause-writes", "cloud_write_pause_v1"], "--consistency");
|
|
137
134
|
|
|
138
135
|
const output = flagValue(args, "--output");
|
|
139
136
|
const wait = args.includes("--wait") || Boolean(output);
|
|
@@ -404,9 +401,6 @@ function parseSecrets(args) {
|
|
|
404
401
|
fail({ code: "BAD_FLAG", message: "--secret requires KEY=VALUE", details: { value } });
|
|
405
402
|
}
|
|
406
403
|
const key = value.slice(0, eq);
|
|
407
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
|
|
408
|
-
fail({ code: "BAD_FLAG", message: `Invalid secret env var name: ${key}` });
|
|
409
|
-
}
|
|
410
404
|
out[key] = value.slice(eq + 1);
|
|
411
405
|
i += 1;
|
|
412
406
|
}
|
package/lib/argparse.mjs
CHANGED
|
@@ -119,6 +119,16 @@ export function parseIntegerFlag(name, value, { min = 1, max = Number.POSITIVE_I
|
|
|
119
119
|
return n;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Parse an integer flag whose value the gateway judges: the CLI checks only
|
|
124
|
+
* that it is an integer (the flag's argv type) and passes it on, so any range
|
|
125
|
+
* is the gateway's to refuse. Use `parseIntegerFlag` with `min`/`max` only for
|
|
126
|
+
* a value the CLI itself uses (a local poll interval or timeout).
|
|
127
|
+
*/
|
|
128
|
+
export function parseIntegerArg(name, value, { def } = {}) {
|
|
129
|
+
return parseIntegerFlag(name, value, { min: Number.NEGATIVE_INFINITY, def });
|
|
130
|
+
}
|
|
131
|
+
|
|
122
132
|
export function assertAllowedValue(value, allowed, fieldName) {
|
|
123
133
|
if (!allowed.includes(value)) {
|
|
124
134
|
fail({
|
|
@@ -129,16 +139,6 @@ export function assertAllowedValue(value, allowed, fieldName) {
|
|
|
129
139
|
}
|
|
130
140
|
}
|
|
131
141
|
|
|
132
|
-
export function validateEvmAddress(value, fieldName = "address") {
|
|
133
|
-
if (typeof value !== "string" || !/^0x[a-fA-F0-9]{40}$/.test(value)) {
|
|
134
|
-
fail({
|
|
135
|
-
code: "BAD_FLAG",
|
|
136
|
-
message: `${fieldName} must be a 0x-prefixed 20-byte EVM address`,
|
|
137
|
-
details: { field: fieldName, value },
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
142
|
// A rejected positional could be anything the caller typed or piped in (see
|
|
143
143
|
// core-dist/redact.js's doc comment), so it is never safe to echo verbatim.
|
|
144
144
|
export function failBadProjectId(value) {
|
|
@@ -150,49 +150,6 @@ export function failBadProjectId(value) {
|
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* Validate a webhook URL: parse it locally and reject non-https:// schemes.
|
|
155
|
-
*
|
|
156
|
-
* Scope: scheme-only validation. Reject `javascript:`, `file:`,
|
|
157
|
-
* `http:`, `data:`, `ftp:`, etc. before the request leaves the CLI process.
|
|
158
|
-
* Server-side SSRF defenses (private-IP filtering, DNS rebinding, IMDS
|
|
159
|
-
* blocking) live on the gateway, not here — this helper is the cheap
|
|
160
|
-
* client-side guard against the obvious classes.
|
|
161
|
-
*
|
|
162
|
-
* No-op when `url` is null/undefined/empty so callers can pass optional
|
|
163
|
-
* flag values directly. Required-vs-optional handling stays at the call
|
|
164
|
-
* site (e.g. `webhooks register` does its own missing-flag check first).
|
|
165
|
-
*
|
|
166
|
-
* On failure: `fail()` writes the canonical error envelope and exits 1.
|
|
167
|
-
*
|
|
168
|
-
* @param {string|null|undefined} url - The webhook URL to validate.
|
|
169
|
-
* @param {string} fieldName - The CLI flag name for the error envelope (e.g. "--url", "--webhook").
|
|
170
|
-
*/
|
|
171
|
-
export function validateWebhookUrl(url, fieldName = "--url") {
|
|
172
|
-
if (!url) return;
|
|
173
|
-
let parsed;
|
|
174
|
-
try {
|
|
175
|
-
parsed = new URL(url);
|
|
176
|
-
} catch {
|
|
177
|
-
fail({
|
|
178
|
-
code: "BAD_WEBHOOK_URL",
|
|
179
|
-
message: `${fieldName} is not a valid URL: ${JSON.stringify(url)}`,
|
|
180
|
-
field: fieldName,
|
|
181
|
-
hint: "Webhook URL must be a fully-qualified https:// URL.",
|
|
182
|
-
details: { flag: fieldName, value: url },
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
if (parsed.protocol !== "https:") {
|
|
186
|
-
fail({
|
|
187
|
-
code: "BAD_WEBHOOK_URL",
|
|
188
|
-
message: `${fieldName} must use https://, got ${parsed.protocol}`,
|
|
189
|
-
field: fieldName,
|
|
190
|
-
hint: "Webhook URLs must be https:// for transport security.",
|
|
191
|
-
details: { flag: fieldName, value: url, scheme: parsed.protocol },
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
153
|
/**
|
|
197
154
|
* Validate that a CLI flag pointing at a filesystem path resolves to an
|
|
198
155
|
* existing regular file. Shared by `functions deploy`, `secrets set`,
|
package/lib/assets.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import { pipeline } from "node:stream/promises";
|
|
|
25
25
|
import { resolveProjectIdAllowingLegacyEnv } from "./config.mjs";
|
|
26
26
|
import { getSdk } from "./sdk.mjs";
|
|
27
27
|
import { reportSdkError, fail } from "./sdk-errors.mjs";
|
|
28
|
-
import { assertKnownFlags, hasHelp, normalizeArgv,
|
|
28
|
+
import { assertKnownFlags, hasHelp, normalizeArgv, parseIntegerArg, failUnknownSubcommand } from "./argparse.mjs";
|
|
29
29
|
import { toWireAssetRef } from "./asset-wire.mjs";
|
|
30
30
|
|
|
31
31
|
const HELP = `run402 blob — Direct-to-S3 blob storage
|
|
@@ -272,9 +272,9 @@ function parseArgs(rawArgs) {
|
|
|
272
272
|
else if (a === "--immutable") out.immutable = true;
|
|
273
273
|
else if (a === "--stream") out.stream = true;
|
|
274
274
|
else if (a === "--prefix") out.prefix = args[++i];
|
|
275
|
-
else if (a === "--limit") out.limit =
|
|
275
|
+
else if (a === "--limit") out.limit = parseIntegerArg("--limit", args[++i]);
|
|
276
276
|
else if (a === "--output" || a === "-o") out.output = args[++i];
|
|
277
|
-
else if (a === "--ttl") out.ttl =
|
|
277
|
+
else if (a === "--ttl") out.ttl = parseIntegerArg("--ttl", args[++i]);
|
|
278
278
|
else if (a === "--variant") out.variants = parseVariantFlag(args[++i]);
|
|
279
279
|
// Repeatable --meta key=value (number-coerce on pure digits,
|
|
280
280
|
// comma-split into string[] when value contains ',', "true"/"false"
|
|
@@ -341,26 +341,12 @@ function coerceMetaValue(value) {
|
|
|
341
341
|
return value;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
// --exif-policy and --sort pass through as given; the gateway judges the value.
|
|
344
345
|
function parseExifPolicyFlag(raw) {
|
|
345
|
-
if (raw !== "keep" && raw !== "strip") {
|
|
346
|
-
fail({
|
|
347
|
-
code: "BAD_FLAG",
|
|
348
|
-
message: `--exif-policy must be 'keep' or 'strip', got: ${raw}`,
|
|
349
|
-
details: { flag: "--exif-policy", value: raw },
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
346
|
return raw;
|
|
353
347
|
}
|
|
354
348
|
|
|
355
|
-
const VALID_SORTS = new Set(["key:asc", "createdAt:asc", "createdAt:desc"]);
|
|
356
349
|
function parseSortFlag(raw) {
|
|
357
|
-
if (typeof raw !== "string" || !VALID_SORTS.has(raw)) {
|
|
358
|
-
fail({
|
|
359
|
-
code: "INVALID_SORT",
|
|
360
|
-
message: `--sort must be one of: ${[...VALID_SORTS].join(", ")} — got: ${raw}`,
|
|
361
|
-
details: { flag: "--sort", value: raw },
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
350
|
return raw;
|
|
365
351
|
}
|
|
366
352
|
|
|
@@ -399,20 +385,14 @@ function applyFilterFlag(filter, raw) {
|
|
|
399
385
|
filter[key] = value === "true";
|
|
400
386
|
} else if (key === "min_width" || key === "max_width" || key === "min_height" || key === "max_height") {
|
|
401
387
|
const n = Number(value);
|
|
402
|
-
if (
|
|
388
|
+
if (value.trim() === "" || !Number.isSafeInteger(n)) {
|
|
403
389
|
fail({
|
|
404
390
|
code: "INVALID_FILTER_KEY",
|
|
405
|
-
message: `--filter ${key} must be
|
|
391
|
+
message: `--filter ${key} must be an integer, got: ${value}`,
|
|
406
392
|
});
|
|
407
393
|
}
|
|
408
394
|
filter[key] = n;
|
|
409
395
|
} else {
|
|
410
|
-
if (value.length === 0) {
|
|
411
|
-
fail({
|
|
412
|
-
code: "INVALID_FILTER_KEY",
|
|
413
|
-
message: `--filter ${key} must be a non-empty string`,
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
396
|
filter[key] = value;
|
|
417
397
|
}
|
|
418
398
|
}
|
|
@@ -425,16 +405,7 @@ function parseContentTypeFlag(name, value) {
|
|
|
425
405
|
details: { flag: name },
|
|
426
406
|
});
|
|
427
407
|
}
|
|
428
|
-
|
|
429
|
-
const base = raw.split(";", 1)[0].trim();
|
|
430
|
-
if (!/^[^\s/]+\/[^\s/]+$/.test(base)) {
|
|
431
|
-
fail({
|
|
432
|
-
code: "BAD_FLAG",
|
|
433
|
-
message: `${name} must be a non-empty type/subtype MIME value, got: ${String(value)}`,
|
|
434
|
-
details: { flag: name, value: String(value) },
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
return raw;
|
|
408
|
+
return String(value).trim();
|
|
438
409
|
}
|
|
439
410
|
|
|
440
411
|
// ---------------------------------------------------------------------------
|
|
@@ -652,15 +623,13 @@ async function sign(argv) {
|
|
|
652
623
|
// Shared helpers
|
|
653
624
|
// ---------------------------------------------------------------------------
|
|
654
625
|
|
|
655
|
-
const SIGN_VARIANTS = ["thumb", "medium", "large", "display_jpeg", "video_web", "video_poster", "video_transcript"];
|
|
656
|
-
|
|
657
626
|
function parseVariantFlag(value) {
|
|
658
|
-
const kinds = typeof value === "string" ? value.split(",").map((v) => v.trim()) : [];
|
|
659
|
-
if (kinds.length === 0
|
|
627
|
+
const kinds = typeof value === "string" ? value.split(",").map((v) => v.trim()).filter(Boolean) : [];
|
|
628
|
+
if (kinds.length === 0) {
|
|
660
629
|
fail({
|
|
661
630
|
code: "BAD_FLAG",
|
|
662
|
-
message:
|
|
663
|
-
details: { flag: "--variant"
|
|
631
|
+
message: "--variant requires a value (a variant name, or a comma-separated list)",
|
|
632
|
+
details: { flag: "--variant" },
|
|
664
633
|
});
|
|
665
634
|
}
|
|
666
635
|
return [...new Set(kinds)];
|
package/lib/auth.mjs
CHANGED
|
@@ -481,18 +481,9 @@ async function magicLink(args) {
|
|
|
481
481
|
if (!email) {
|
|
482
482
|
fail({ code: "BAD_USAGE", message: "Missing --email" });
|
|
483
483
|
}
|
|
484
|
-
if (!["link", "code", "both"].includes(delivery)) {
|
|
485
|
-
fail({ code: "BAD_FLAG", message: "--delivery must be link, code, or both" });
|
|
486
|
-
}
|
|
487
|
-
if (delivery !== "code" && !redirect) {
|
|
488
|
-
fail({ code: "BAD_USAGE", message: "Missing --redirect <url> for link/both delivery" });
|
|
489
|
-
}
|
|
490
484
|
|
|
491
485
|
try {
|
|
492
486
|
const intent = parseFlag(args, "--intent");
|
|
493
|
-
if (intent && !["signin", "invite", "claim", "recovery"].includes(intent)) {
|
|
494
|
-
fail({ code: "BAD_FLAG", message: "--intent must be signin, invite, claim, or recovery" });
|
|
495
|
-
}
|
|
496
487
|
const state = parseFlag(args, "--state");
|
|
497
488
|
const locale = parseFlag(args, "--locale");
|
|
498
489
|
const result = await getSdk().auth.requestMagicLink(projectId, {
|
|
@@ -529,9 +520,6 @@ async function createUser(args) {
|
|
|
529
520
|
if (!email) {
|
|
530
521
|
fail({ code: "BAD_USAGE", message: "Missing --email" });
|
|
531
522
|
}
|
|
532
|
-
if (sendInvite && !redirectUrl) {
|
|
533
|
-
fail({ code: "BAD_USAGE", message: "Missing --redirect <url> when --invite is used" });
|
|
534
|
-
}
|
|
535
523
|
|
|
536
524
|
try {
|
|
537
525
|
const data = await getSdk().auth.createUser(projectId, {
|
|
@@ -737,38 +725,6 @@ async function settings(args) {
|
|
|
737
725
|
const idleSeconds = windowFlag("--browser-session-idle-seconds");
|
|
738
726
|
const maxSeconds = windowFlag("--browser-session-max-seconds");
|
|
739
727
|
|
|
740
|
-
if (
|
|
741
|
-
allow === undefined &&
|
|
742
|
-
requireAdminPasskey === undefined &&
|
|
743
|
-
preferredRaw === null &&
|
|
744
|
-
publicSignup === null &&
|
|
745
|
-
domainsRaw === null &&
|
|
746
|
-
clientIdsRaw === null &&
|
|
747
|
-
appleIdsRaw === null &&
|
|
748
|
-
testModeRaw === null &&
|
|
749
|
-
idleSeconds === undefined &&
|
|
750
|
-
maxSeconds === undefined
|
|
751
|
-
) {
|
|
752
|
-
fail({
|
|
753
|
-
code: "BAD_USAGE",
|
|
754
|
-
message: "Set at least one auth setting flag",
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
if (
|
|
758
|
-
preferredRaw !== null &&
|
|
759
|
-
!["password", "magic_link", "oauth_google", "passkey", "null"].includes(preferredRaw)
|
|
760
|
-
) {
|
|
761
|
-
fail({
|
|
762
|
-
code: "BAD_FLAG",
|
|
763
|
-
message: "--preferred must be password, magic_link, oauth_google, passkey, or null",
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
if (publicSignup !== null && !["open", "known_email", "invite_only"].includes(publicSignup)) {
|
|
767
|
-
fail({
|
|
768
|
-
code: "BAD_FLAG",
|
|
769
|
-
message: "--public-signup must be open, known_email, or invite_only",
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
728
|
|
|
773
729
|
// --allowed-email-domains: comma-separated list; the literal `none` clears the
|
|
774
730
|
// restriction (→ []); omitted preserves. Server normalizes + validates each entry.
|
|
@@ -931,8 +887,8 @@ async function testEmails(args) {
|
|
|
931
887
|
const projectId = resolveProjectId(parseFlag(args, "--project"));
|
|
932
888
|
const limitFlag = parseFlag(args, "--limit");
|
|
933
889
|
const limit = limitFlag === undefined || limitFlag === null ? undefined : Number(limitFlag);
|
|
934
|
-
if (limit !== undefined &&
|
|
935
|
-
fail({ code: "BAD_FLAG", message: "--limit must be a whole number
|
|
890
|
+
if (limit !== undefined && !Number.isInteger(limit)) {
|
|
891
|
+
fail({ code: "BAD_FLAG", message: "--limit must be a whole number" });
|
|
936
892
|
}
|
|
937
893
|
try {
|
|
938
894
|
const data = await getSdk().auth.listTestEmails(projectId, {
|
|
@@ -977,8 +933,8 @@ function scaffoldRoles(args) {
|
|
|
977
933
|
const ttlRaw = parseFlag(args, "--cache-ttl");
|
|
978
934
|
if (ttlRaw !== null) {
|
|
979
935
|
const n = Number(ttlRaw);
|
|
980
|
-
if (!Number.isInteger(n)
|
|
981
|
-
fail({ code: "BAD_FLAG", message: "--cache-ttl must be
|
|
936
|
+
if (!Number.isInteger(n)) {
|
|
937
|
+
fail({ code: "BAD_FLAG", message: "--cache-ttl must be a whole number of seconds" });
|
|
982
938
|
}
|
|
983
939
|
cacheTtl = n;
|
|
984
940
|
}
|
package/lib/billing.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSdk } from "./sdk.mjs";
|
|
2
2
|
import { reportSdkError, fail } from "./sdk-errors.mjs";
|
|
3
|
-
import { assertAllowedValue, assertKnownFlags, flagValue, normalizeArgv,
|
|
3
|
+
import { assertAllowedValue, assertKnownFlags, flagValue, normalizeArgv, positionalArgs, failUnknownSubcommand, parseIntegerArg } from "./argparse.mjs";
|
|
4
4
|
import { takeOrgPositional, requireRest } from "./org-context.mjs";
|
|
5
5
|
|
|
6
6
|
const HELP = `run402 billing — Email organizations and org checkouts
|
|
@@ -260,7 +260,7 @@ async function checkout(args) {
|
|
|
260
260
|
}
|
|
261
261
|
checkoutRequest = {
|
|
262
262
|
product: "balance_topup",
|
|
263
|
-
amountUsdMicros:
|
|
263
|
+
amountUsdMicros: parseIntegerArg("--amount", amountRaw),
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
266
|
try {
|
|
@@ -286,8 +286,8 @@ async function topup(args) {
|
|
|
286
286
|
}
|
|
287
287
|
const satsRaw = flagValue(parsedArgs, "--sats");
|
|
288
288
|
const sats = Number(satsRaw);
|
|
289
|
-
if (satsRaw === null || !Number.isSafeInteger(sats)
|
|
290
|
-
fail({ code: "BAD_FLAG", message: "--sats must be a
|
|
289
|
+
if (satsRaw === null || !Number.isSafeInteger(sats)) {
|
|
290
|
+
fail({ code: "BAD_FLAG", message: "--sats must be a whole number of satoshis.", details: { flag: "--sats" } });
|
|
291
291
|
}
|
|
292
292
|
const timeoutRaw = flagValue(parsedArgs, "--timeout");
|
|
293
293
|
const timeoutMs = timeoutRaw === null ? 600_000 : Number(timeoutRaw) * 1000;
|
|
@@ -394,7 +394,7 @@ async function autoRecharge(args) {
|
|
|
394
394
|
// resolution (which may cost a network hop via --project).
|
|
395
395
|
const thresholdStr = flagValue(parsedArgs, "--threshold");
|
|
396
396
|
const threshold = parsedArgs.includes("--threshold")
|
|
397
|
-
?
|
|
397
|
+
? parseIntegerArg("--threshold", thresholdStr)
|
|
398
398
|
: undefined;
|
|
399
399
|
const { orgId, rest } = await takeOrgPositional(parsedArgs, valueFlags, { cmd: "billing" });
|
|
400
400
|
const count = stateFlag ? 0 : 1;
|
|
@@ -435,8 +435,8 @@ function parseUsdFlag(name, raw) {
|
|
|
435
435
|
fail({ code: "BAD_FLAG", message: `${name} must be whole or decimal US dollars (up to 6 decimals), got: ${raw}`, details: { flag: name, value: String(raw) } });
|
|
436
436
|
}
|
|
437
437
|
const micros = Number(m[1]) * 1_000_000 + Number((m[2] ?? "").padEnd(6, "0"));
|
|
438
|
-
if (!Number.isSafeInteger(micros)
|
|
439
|
-
fail({ code: "BAD_FLAG", message: `${name}
|
|
438
|
+
if (!Number.isSafeInteger(micros)) {
|
|
439
|
+
fail({ code: "BAD_FLAG", message: `${name} is too large a US-dollar amount, got: ${raw}`, details: { flag: name, value: String(raw) } });
|
|
440
440
|
}
|
|
441
441
|
return micros;
|
|
442
442
|
}
|
|
@@ -554,7 +554,7 @@ async function history(args) {
|
|
|
554
554
|
});
|
|
555
555
|
}
|
|
556
556
|
const limit = parsedArgs.includes("--limit")
|
|
557
|
-
?
|
|
557
|
+
? parseIntegerArg("--limit", flagValue(parsedArgs, "--limit"))
|
|
558
558
|
: 50;
|
|
559
559
|
const after = flagValue(parsedArgs, "--after");
|
|
560
560
|
try {
|
package/lib/branches.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { getSdk } from "./sdk.mjs";
|
|
2
2
|
import { fail, reportSdkError } from "./sdk-errors.mjs";
|
|
3
3
|
import {
|
|
4
|
-
assertAllowedValue,
|
|
5
4
|
assertKnownFlags,
|
|
6
5
|
flagValue,
|
|
7
6
|
hasHelp,
|
|
8
7
|
normalizeArgv,
|
|
9
|
-
parseIntegerFlag,
|
|
10
8
|
positionalArgs,
|
|
11
9
|
resolveProjectSelector,
|
|
12
10
|
failUnknownSubcommand,
|
|
11
|
+
parseIntegerArg,
|
|
13
12
|
} from "./argparse.mjs";
|
|
14
13
|
|
|
15
14
|
const HELP = `run402 branches — Contained project data branches
|
|
@@ -53,9 +52,8 @@ export async function run(sub, args = []) {
|
|
|
53
52
|
async function create(args) {
|
|
54
53
|
const { projectId } = resolveProjectSelector(args, { valueFlags: FLAG_VALUES });
|
|
55
54
|
const emailMode = flagValue(args, "--email-mode") ?? undefined;
|
|
56
|
-
if (emailMode !== undefined) assertAllowedValue(emailMode, ["sandbox", "off"], "--email-mode");
|
|
57
55
|
const ttlDaysFlag = flagValue(args, "--ttl-days");
|
|
58
|
-
const ttlDays = ttlDaysFlag === null ? undefined :
|
|
56
|
+
const ttlDays = ttlDaysFlag === null ? undefined : parseIntegerArg("--ttl-days", ttlDaysFlag);
|
|
59
57
|
const named = args.flatMap((arg, i) => (arg === "--copy-secret" && args[i + 1] ? [args[i + 1]] : []));
|
|
60
58
|
if (named.length > 0 && args.includes("--copy-secrets")) {
|
|
61
59
|
fail({ code: "BAD_USAGE", message: "--copy-secrets copies every secret; --copy-secret <KEY> copies the named ones. Pass one form." });
|
|
@@ -89,7 +87,7 @@ async function list(args) {
|
|
|
89
87
|
async function renew(args) {
|
|
90
88
|
const { projectId, branchProjectId } = resolveProjectAndBranch(args, "run402 branches renew [project_id] <branch_project_id>");
|
|
91
89
|
const ttlDaysFlag = flagValue(args, "--ttl-days");
|
|
92
|
-
const ttlDays = ttlDaysFlag === null ? undefined :
|
|
90
|
+
const ttlDays = ttlDaysFlag === null ? undefined : parseIntegerArg("--ttl-days", ttlDaysFlag);
|
|
93
91
|
try {
|
|
94
92
|
const branch = await getSdk().branches.renew(projectId, branchProjectId, {
|
|
95
93
|
...(ttlDays !== undefined ? { ttlDays } : {}),
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
positionalArgs,
|
|
18
18
|
requirePositionalCount,
|
|
19
19
|
failUnknownSubcommand,
|
|
20
|
+
parseIntegerArg,
|
|
20
21
|
} from "./argparse.mjs";
|
|
21
22
|
|
|
22
23
|
const HELP = `run402 buzz notifications — route project events into a Buzz community channel
|
|
@@ -133,12 +134,6 @@ function narrateAuthorization(authorization) {
|
|
|
133
134
|
console.error(" Then run `run402 buzz notifications test <buzzper_id> --wait` to verify it landed.");
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
function assertHexPubkey(value, flag) {
|
|
137
|
-
if (!/^[0-9a-f]{64}$/i.test(String(value).trim())) {
|
|
138
|
-
fail({ code: "BAD_FLAG", message: `${flag} must be a 64-hex Buzz pubkey`, details: { flag } });
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
137
|
/**
|
|
143
138
|
* `run402 buzz notifications on-call <buzzper_id> --agent <hex> | --clear` —
|
|
144
139
|
* set or clear the agent a crash or platform incident pages. Reads the route
|
|
@@ -162,7 +157,6 @@ async function onCall(args) {
|
|
|
162
157
|
if (clearing && name !== null) {
|
|
163
158
|
fail({ code: "BAD_FLAG", message: "--name goes with --agent, not --clear", details: { flag: "--name" } });
|
|
164
159
|
}
|
|
165
|
-
if (!clearing) assertHexPubkey(agent, "--agent");
|
|
166
160
|
try {
|
|
167
161
|
const sdk = getSdk();
|
|
168
162
|
const current = await sdk.buzz.notifications.get(routeId);
|
|
@@ -218,9 +212,6 @@ async function projects(args) {
|
|
|
218
212
|
const scope = new Set(current.project_ids ?? []);
|
|
219
213
|
if (add !== null) scope.add(add);
|
|
220
214
|
if (remove !== null) scope.delete(remove);
|
|
221
|
-
if (scope.size === 0) {
|
|
222
|
-
fail({ code: "BAD_FLAG", message: "a route keeps at least one project; revoke the route instead of emptying it", details: { flag: "--remove" } });
|
|
223
|
-
}
|
|
224
215
|
const updated = await sdk.buzz.notifications.update(routeId, { projectIds: Array.from(scope) }, current.revision);
|
|
225
216
|
out(updated);
|
|
226
217
|
console.error(`Route scope is now ${updated.project_ids.length} project(s): ${updated.project_ids.join(", ")}. Only facts occurring from now on are delivered — nothing is replayed.`);
|
|
@@ -249,9 +240,6 @@ async function scope(args) {
|
|
|
249
240
|
fail({ code: "BAD_FLAG", message: "pass exactly one of --org or --listed", details: { flag: "--org" } });
|
|
250
241
|
}
|
|
251
242
|
const projectIds = flagValues(a, "--project");
|
|
252
|
-
if (org && projectIds.length) {
|
|
253
|
-
fail({ code: "BAD_FLAG", message: "--project goes with --listed; an org-wide route needs no list", details: { flag: "--project" } });
|
|
254
|
-
}
|
|
255
243
|
try {
|
|
256
244
|
const sdk = getSdk();
|
|
257
245
|
const current = await sdk.buzz.notifications.get(routeId);
|
|
@@ -276,18 +264,11 @@ async function configure(args) {
|
|
|
276
264
|
const includeOrgEvents = a.includes("--include-org-events");
|
|
277
265
|
const allProjects = a.includes("--all-projects");
|
|
278
266
|
const onCall = flagValue(a, "--on-call");
|
|
279
|
-
if (onCall !== null) assertHexPubkey(onCall, "--on-call");
|
|
280
267
|
const onCallName = flagValue(a, "--on-call-name");
|
|
281
|
-
if (onCallName !== null && onCall === null) {
|
|
282
|
-
fail({ code: "BAD_FLAG", message: "--on-call-name goes with --on-call", details: { flag: "--on-call-name" } });
|
|
283
|
-
}
|
|
284
268
|
requirePositionalCount(positionalArgs(a, valueFlags), valueFlags, {
|
|
285
269
|
min: 0, max: 0, command: "run402 buzz notifications configure", missing: "",
|
|
286
270
|
});
|
|
287
271
|
const projectIds = flagValues(a, "--project");
|
|
288
|
-
if (projectIds.length === 0 && !allProjects) {
|
|
289
|
-
fail({ code: "BAD_FLAG", message: "--project is required at least once, or pass --all-projects to route every project the organization owns", details: { flag: "--project" } });
|
|
290
|
-
}
|
|
291
272
|
const eventTypes = flagValues(a, "--event-type");
|
|
292
273
|
const eventClasses = flagValues(a, "--event-class");
|
|
293
274
|
try {
|
|
@@ -394,7 +375,7 @@ async function deliveries(args) {
|
|
|
394
375
|
try {
|
|
395
376
|
out(await getSdk().buzz.notifications.deliveries(positionals[0], {
|
|
396
377
|
...(flagValue(a, "--limit") != null
|
|
397
|
-
? { limit:
|
|
378
|
+
? { limit: parseIntegerArg("--limit", flagValue(a, "--limit")) }
|
|
398
379
|
: {}),
|
|
399
380
|
...(flagValue(a, "--cursor") ? { cursor: flagValue(a, "--cursor") } : {}),
|
|
400
381
|
...(flagValue(a, "--delivery") ? { deliveryId: flagValue(a, "--delivery") } : {}),
|
package/lib/buzz.mjs
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
failUnknownSubcommand,
|
|
8
8
|
flagValue,
|
|
9
9
|
normalizeArgv,
|
|
10
|
-
parseIntegerFlag,
|
|
11
10
|
requirePositionalCount,
|
|
12
11
|
validateRegularFile,
|
|
12
|
+
parseIntegerArg,
|
|
13
13
|
} from "./argparse.mjs";
|
|
14
14
|
|
|
15
15
|
const HELP = `run402 buzz — Buzz community ↔ Run402 control plane
|
|
@@ -82,7 +82,6 @@ function requiredFlag(args, flag) {
|
|
|
82
82
|
function readJsonFile(path, field) {
|
|
83
83
|
validateRegularFile(path, field);
|
|
84
84
|
const bytes = readFileSync(path);
|
|
85
|
-
if (bytes.byteLength > 256 * 1024) fail({ code: "BAD_FILE", message: `${field} exceeds 262144 bytes`, details: { field, max_bytes: 262144 } });
|
|
86
85
|
try { return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes)); }
|
|
87
86
|
catch { fail({ code: "BAD_FILE", message: `${field} must contain valid UTF-8 JSON`, details: { field } }); }
|
|
88
87
|
}
|
|
@@ -229,7 +228,7 @@ async function install(args) {
|
|
|
229
228
|
if (!["true", "false"].includes(defaultValue)) fail({ code: "BAD_FLAG", message: "--default must be true or false", details: { flag: "--default" } });
|
|
230
229
|
return invoke(() => getSdk().buzz.communityInstallations.update(id, {
|
|
231
230
|
enrollmentPolicy: readJsonFile(requiredFlag(a, "--policy-file"), "--policy-file"),
|
|
232
|
-
policyRevision:
|
|
231
|
+
policyRevision: parseIntegerArg("--policy-revision", requiredFlag(a, "--policy-revision")),
|
|
233
232
|
defaultForEnrollment: defaultValue === "true",
|
|
234
233
|
idempotencyKey: flagValue(a, "--idempotency-key") ?? undefined,
|
|
235
234
|
}));
|
|
@@ -330,8 +329,8 @@ async function approve(args) {
|
|
|
330
329
|
const [id] = requirePositionalCount(a, values, { min: 1, max: 1, command: "run402 buzz approve <buzzae_id> --grants-file <json> --descriptor-revision <n> --policy-revision <n>" });
|
|
331
330
|
return invoke(() => getSdk().buzz.enrollments.approve(id, {
|
|
332
331
|
approvedGrants: readJsonFile(requiredFlag(a, "--grants-file"), "--grants-file"),
|
|
333
|
-
installationDescriptorRevision:
|
|
334
|
-
installationPolicyRevision:
|
|
332
|
+
installationDescriptorRevision: parseIntegerArg("--descriptor-revision", requiredFlag(a, "--descriptor-revision")),
|
|
333
|
+
installationPolicyRevision: parseIntegerArg("--policy-revision", requiredFlag(a, "--policy-revision")),
|
|
335
334
|
idempotencyKey: flagValue(a, "--idempotency-key") ?? undefined,
|
|
336
335
|
}));
|
|
337
336
|
}
|
package/lib/cache.mjs
CHANGED
|
@@ -122,13 +122,6 @@ async function inspect(args) {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
const url = positionals[0];
|
|
125
|
-
if (!url.startsWith("https://") && !url.startsWith("http://")) {
|
|
126
|
-
fail({
|
|
127
|
-
code: "BAD_USAGE",
|
|
128
|
-
message: `URL must be absolute (got: ${url})`,
|
|
129
|
-
next_actions: [editRequestAction("run402 cache inspect https://<host>/<path>", "Use an absolute HTTP(S) URL.")],
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
125
|
|
|
133
126
|
const locale = flagValue(parsed, "--locale");
|
|
134
127
|
const releaseId = flagValue(parsed, "--release-id");
|
|
@@ -183,12 +176,6 @@ async function invalidate(args) {
|
|
|
183
176
|
next_actions: [editRequestAction("run402 cache invalidate --prefix /blog/ --host <hostname>", "Pair prefix invalidation with the owning host.")],
|
|
184
177
|
});
|
|
185
178
|
}
|
|
186
|
-
if (!prefix.startsWith("/")) {
|
|
187
|
-
fail({
|
|
188
|
-
code: "BAD_USAGE",
|
|
189
|
-
message: `prefix must start with '/' (got: ${prefix})`,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
179
|
try {
|
|
193
180
|
const result = await sdk.cache.invalidatePrefix({ host, prefix });
|
|
194
181
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -211,13 +198,6 @@ async function invalidate(args) {
|
|
|
211
198
|
});
|
|
212
199
|
}
|
|
213
200
|
const url = positionals[0];
|
|
214
|
-
if (!url.startsWith("https://") && !url.startsWith("http://")) {
|
|
215
|
-
fail({
|
|
216
|
-
code: "BAD_USAGE",
|
|
217
|
-
message: `URL must be absolute (got: ${url})`,
|
|
218
|
-
next_actions: [editRequestAction("run402 cache invalidate https://<host>/<path>", "Use an absolute HTTP(S) URL.")],
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
201
|
try {
|
|
222
202
|
const result = await sdk.cache.invalidate(url);
|
|
223
203
|
console.log(JSON.stringify(result, null, 2));
|
package/lib/cdn.mjs
CHANGED
|
@@ -97,13 +97,6 @@ async function waitFresh(argv) {
|
|
|
97
97
|
if (opts.positional.length === 0) die("URL required");
|
|
98
98
|
const url = opts.positional[0];
|
|
99
99
|
if (!opts.sha) die("--sha is required");
|
|
100
|
-
if (!/^[a-fA-F0-9]{64}$/.test(opts.sha)) {
|
|
101
|
-
fail({
|
|
102
|
-
code: "BAD_FLAG",
|
|
103
|
-
message: "--sha must be a 64-character hex SHA-256 digest",
|
|
104
|
-
details: { flag: "--sha", value: opts.sha },
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
100
|
|
|
108
101
|
const timeoutMs = (opts.timeout ?? 60) * 1000;
|
|
109
102
|
try {
|
package/lib/claims.mjs
CHANGED
|
@@ -13,12 +13,11 @@ import {
|
|
|
13
13
|
normalizeArgv,
|
|
14
14
|
hasHelp,
|
|
15
15
|
assertKnownFlags,
|
|
16
|
-
assertAllowedValue,
|
|
17
|
-
parseIntegerFlag,
|
|
18
16
|
flagValue,
|
|
19
17
|
positionalArgs,
|
|
20
18
|
requirePositionalCount,
|
|
21
19
|
failUnknownSubcommand,
|
|
20
|
+
parseIntegerArg,
|
|
22
21
|
} from "./argparse.mjs";
|
|
23
22
|
import { resolveRoom, withPresenceRetry } from "./rooms-context.mjs";
|
|
24
23
|
|
|
@@ -80,7 +79,6 @@ async function create(args) {
|
|
|
80
79
|
min: 1, max: 1, command: "run402 claims create <resource>", missing: "<resource>",
|
|
81
80
|
});
|
|
82
81
|
const mode = flagValue(a, "--mode") ?? "exclusive";
|
|
83
|
-
assertAllowedValue(mode, MODES, "--mode");
|
|
84
82
|
const ttl = flagValue(a, "--ttl");
|
|
85
83
|
const room = await resolveRoom({
|
|
86
84
|
org: flagValue(a, "--org"), room: flagValue(a, "--room"), project: flagValue(a, "--project"),
|
|
@@ -90,7 +88,7 @@ async function create(args) {
|
|
|
90
88
|
getSdk().rooms.createClaim(room.orgId, room.roomKey, {
|
|
91
89
|
resource: positionals[0],
|
|
92
90
|
mode,
|
|
93
|
-
ttlSeconds: ttl != null ?
|
|
91
|
+
ttlSeconds: ttl != null ? parseIntegerArg("--ttl", ttl) : undefined,
|
|
94
92
|
note: flagValue(a, "--note") ?? undefined,
|
|
95
93
|
presenceId: presenceId ?? undefined,
|
|
96
94
|
sessionKey,
|