run402 4.11.2 → 4.12.1
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/cli.mjs +6 -0
- package/lib/auth.mjs +55 -22
- package/lib/command-manifest.mjs +6 -0
- package/lib/delegates.mjs +189 -0
- package/lib/deploy-v2.mjs +10 -0
- package/package.json +1 -1
- package/sdk/dist/delegate-credentials.d.ts +37 -0
- package/sdk/dist/delegate-credentials.d.ts.map +1 -0
- package/sdk/dist/delegate-credentials.js +41 -0
- package/sdk/dist/delegate-credentials.js.map +1 -0
- package/sdk/dist/index.d.ts +12 -0
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +11 -0
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/namespaces/auth.d.ts +43 -6
- package/sdk/dist/namespaces/auth.d.ts.map +1 -1
- package/sdk/dist/namespaces/auth.js +46 -5
- package/sdk/dist/namespaces/auth.js.map +1 -1
- package/sdk/dist/namespaces/delegates.d.ts +50 -0
- package/sdk/dist/namespaces/delegates.d.ts.map +1 -0
- package/sdk/dist/namespaces/delegates.js +99 -0
- package/sdk/dist/namespaces/delegates.js.map +1 -0
- package/sdk/dist/namespaces/delegates.types.d.ts +88 -0
- package/sdk/dist/namespaces/delegates.types.d.ts.map +1 -0
- package/sdk/dist/namespaces/delegates.types.js +10 -0
- package/sdk/dist/namespaces/delegates.types.js.map +1 -0
- package/sdk/dist/namespaces/deploy.d.ts.map +1 -1
- package/sdk/dist/namespaces/deploy.js +9 -1
- package/sdk/dist/namespaces/deploy.js.map +1 -1
- package/sdk/dist/node/credentials.d.ts +17 -1
- package/sdk/dist/node/credentials.d.ts.map +1 -1
- package/sdk/dist/node/credentials.js +28 -0
- package/sdk/dist/node/credentials.js.map +1 -1
- package/sdk/dist/node/index.d.ts +8 -1
- package/sdk/dist/node/index.d.ts.map +1 -1
- package/sdk/dist/node/index.js +2 -1
- package/sdk/dist/node/index.js.map +1 -1
- package/sdk/dist/scoped.d.ts +15 -2
- package/sdk/dist/scoped.d.ts.map +1 -1
- package/sdk/dist/scoped.js +26 -0
- package/sdk/dist/scoped.js.map +1 -1
package/cli.mjs
CHANGED
|
@@ -41,6 +41,7 @@ Commands:
|
|
|
41
41
|
transfer Two-party project transfer (init, preview, list, accept, cancel)
|
|
42
42
|
org Org membership, invites & audit (whoami, list, member, invite, audit)
|
|
43
43
|
grants Per-project capability grants for agent/CI principals (create, revoke)
|
|
44
|
+
delegates Scoped deploy credentials for agents (create, list, revoke, rotate)
|
|
44
45
|
events What happened to your project since you last looked (cursored feed)
|
|
45
46
|
errors Grouped error fingerprints + a promote/revert verdict (release-baselined)
|
|
46
47
|
jobs Submit and inspect platform-managed jobs
|
|
@@ -250,6 +251,11 @@ switch (cmd) {
|
|
|
250
251
|
await run(sub, rest);
|
|
251
252
|
break;
|
|
252
253
|
}
|
|
254
|
+
case "delegates": {
|
|
255
|
+
const { run } = await import("./lib/delegates.mjs");
|
|
256
|
+
await run(sub, rest);
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
253
259
|
case "events": {
|
|
254
260
|
const { run } = await import("./lib/events.mjs");
|
|
255
261
|
await run(sub, rest);
|
package/lib/auth.mjs
CHANGED
|
@@ -9,11 +9,11 @@ Usage:
|
|
|
9
9
|
run402 auth <subcommand> [args...]
|
|
10
10
|
|
|
11
11
|
Subcommands:
|
|
12
|
-
magic-link --email <addr> --redirect <url> [--project <id>]
|
|
13
|
-
|
|
12
|
+
magic-link --email <addr> [--delivery link|code|both] [--redirect <url>] [--project <id>]
|
|
13
|
+
Request passwordless email authentication. Link remains the default.
|
|
14
14
|
|
|
15
|
-
verify --token <token> [--project <id>]
|
|
16
|
-
Exchange
|
|
15
|
+
verify (--token <token> | --challenge-id <id> --code <6 digits>) [--project <id>]
|
|
16
|
+
Exchange one email credential for access_token + refresh_token.
|
|
17
17
|
|
|
18
18
|
create-user --email <addr> [--admin <true|false>] [--invite] [--redirect <url>] [--project <id>]
|
|
19
19
|
Create or update a project auth user with the service key.
|
|
@@ -53,7 +53,7 @@ Subcommands:
|
|
|
53
53
|
|
|
54
54
|
Examples:
|
|
55
55
|
run402 auth magic-link --email user@example.com --redirect https://myapp.run402.com/cb
|
|
56
|
-
run402 auth verify --
|
|
56
|
+
run402 auth verify --challenge-id 123e4567-e89b-42d3-a456-426614174000 --code 042731
|
|
57
57
|
run402 auth invite-user --email admin@example.com --redirect https://myapp.run402.com/cb --admin true
|
|
58
58
|
run402 auth set-password --token eyJ... --new "new-pass" --current "old-pass"
|
|
59
59
|
run402 auth settings --preferred passkey --require-admin-passkey true
|
|
@@ -62,20 +62,23 @@ Examples:
|
|
|
62
62
|
`;
|
|
63
63
|
|
|
64
64
|
const SUB_HELP = {
|
|
65
|
-
"magic-link": `run402 auth magic-link —
|
|
65
|
+
"magic-link": `run402 auth magic-link — Request passwordless email authentication
|
|
66
66
|
|
|
67
67
|
Usage:
|
|
68
|
-
run402 auth magic-link --email <addr>
|
|
68
|
+
run402 auth magic-link --email <addr> [options]
|
|
69
69
|
|
|
70
70
|
Options:
|
|
71
71
|
--email <addr> Required: recipient email address
|
|
72
|
-
--
|
|
72
|
+
--delivery <mode> link (default), code, or both
|
|
73
|
+
--redirect <url> Required for link/both; optional for code
|
|
73
74
|
--intent <intent> signin (default), invite, claim, or recovery
|
|
74
75
|
--state <value> Optional client_state preserved through verification
|
|
75
76
|
--project <id> Project ID (defaults to active project)
|
|
76
77
|
|
|
77
78
|
Notes:
|
|
78
|
-
|
|
79
|
+
Acceptance does not prove delivery or disclose whether an account exists.
|
|
80
|
+
Code/both returns an opaque challenge_id; the six-digit code is sent by email.
|
|
81
|
+
Uses the project's anon_key (invite intent uses the service key).
|
|
79
82
|
|
|
80
83
|
Examples:
|
|
81
84
|
run402 auth magic-link --email user@example.com \\
|
|
@@ -111,13 +114,16 @@ Options:
|
|
|
111
114
|
--state <value> Optional client_state for the invite
|
|
112
115
|
--project <id> Project ID (defaults to active project)
|
|
113
116
|
`,
|
|
114
|
-
verify: `run402 auth verify — Exchange
|
|
117
|
+
verify: `run402 auth verify — Exchange an email credential for session tokens
|
|
115
118
|
|
|
116
119
|
Usage:
|
|
117
120
|
run402 auth verify --token <token> [options]
|
|
121
|
+
run402 auth verify --challenge-id <id> --code <6 digits> [options]
|
|
118
122
|
|
|
119
123
|
Options:
|
|
120
124
|
--token <token> Required: the one-time magic-link token
|
|
125
|
+
--challenge-id <id> Required with --code: opaque handle from magic-link request
|
|
126
|
+
--code <digits> Required with --challenge-id: six-digit email code
|
|
121
127
|
--project <id> Project ID (defaults to active project)
|
|
122
128
|
|
|
123
129
|
Notes:
|
|
@@ -125,6 +131,7 @@ Notes:
|
|
|
125
131
|
|
|
126
132
|
Examples:
|
|
127
133
|
run402 auth verify --token abc123def456
|
|
134
|
+
run402 auth verify --challenge-id 123e4567-e89b-42d3-a456-426614174000 --code 042731
|
|
128
135
|
`,
|
|
129
136
|
"set-password": `run402 auth set-password — Change, reset, or set a user's password
|
|
130
137
|
|
|
@@ -267,8 +274,8 @@ Notes:
|
|
|
267
274
|
|
|
268
275
|
const AUTH_FLAGS = {
|
|
269
276
|
"magic-link": {
|
|
270
|
-
known: ["--email", "--redirect", "--intent", "--state", "--project", "--help", "-h"],
|
|
271
|
-
values: ["--email", "--redirect", "--intent", "--state", "--project"],
|
|
277
|
+
known: ["--email", "--delivery", "--redirect", "--intent", "--state", "--project", "--help", "-h"],
|
|
278
|
+
values: ["--email", "--delivery", "--redirect", "--intent", "--state", "--project"],
|
|
272
279
|
},
|
|
273
280
|
"create-user": {
|
|
274
281
|
known: ["--email", "--admin", "--invite", "--redirect", "--state", "--project", "--help", "-h"],
|
|
@@ -279,8 +286,8 @@ const AUTH_FLAGS = {
|
|
|
279
286
|
values: ["--email", "--redirect", "--admin", "--state", "--project"],
|
|
280
287
|
},
|
|
281
288
|
verify: {
|
|
282
|
-
known: ["--token", "--project", "--help", "-h"],
|
|
283
|
-
values: ["--token", "--project"],
|
|
289
|
+
known: ["--token", "--challenge-id", "--code", "--project", "--help", "-h"],
|
|
290
|
+
values: ["--token", "--challenge-id", "--code", "--project"],
|
|
284
291
|
},
|
|
285
292
|
"set-password": {
|
|
286
293
|
known: ["--token", "--new", "--current", "--project", "--help", "-h"],
|
|
@@ -368,13 +375,17 @@ function parseJsonFlag(args, flag) {
|
|
|
368
375
|
async function magicLink(args) {
|
|
369
376
|
const email = parseFlag(args, "--email");
|
|
370
377
|
const redirect = parseFlag(args, "--redirect");
|
|
378
|
+
const delivery = parseFlag(args, "--delivery") || "link";
|
|
371
379
|
const projectId = resolveProjectId(parseFlag(args, "--project"));
|
|
372
380
|
|
|
373
381
|
if (!email) {
|
|
374
382
|
fail({ code: "BAD_USAGE", message: "Missing --email" });
|
|
375
383
|
}
|
|
376
|
-
if (!
|
|
377
|
-
fail({ code: "
|
|
384
|
+
if (!["link", "code", "both"].includes(delivery)) {
|
|
385
|
+
fail({ code: "BAD_FLAG", message: "--delivery must be link, code, or both" });
|
|
386
|
+
}
|
|
387
|
+
if (delivery !== "code" && !redirect) {
|
|
388
|
+
fail({ code: "BAD_USAGE", message: "Missing --redirect <url> for link/both delivery" });
|
|
378
389
|
}
|
|
379
390
|
|
|
380
391
|
try {
|
|
@@ -383,13 +394,23 @@ async function magicLink(args) {
|
|
|
383
394
|
fail({ code: "BAD_FLAG", message: "--intent must be signin, invite, claim, or recovery" });
|
|
384
395
|
}
|
|
385
396
|
const state = parseFlag(args, "--state");
|
|
386
|
-
await getSdk().auth.requestMagicLink(projectId, {
|
|
397
|
+
const result = await getSdk().auth.requestMagicLink(projectId, {
|
|
387
398
|
email,
|
|
388
|
-
|
|
399
|
+
delivery,
|
|
400
|
+
redirectUrl: redirect ?? undefined,
|
|
389
401
|
intent: intent ?? undefined,
|
|
390
402
|
clientState: state ?? undefined,
|
|
391
403
|
});
|
|
392
|
-
console.log(JSON.stringify({
|
|
404
|
+
console.log(JSON.stringify({
|
|
405
|
+
email,
|
|
406
|
+
delivery,
|
|
407
|
+
...(redirect ? { redirect_url: redirect } : {}),
|
|
408
|
+
intent: intent || "signin",
|
|
409
|
+
accepted: true,
|
|
410
|
+
message: result.message,
|
|
411
|
+
...(result.warnings ? { warnings: result.warnings } : {}),
|
|
412
|
+
...(result.challengeId ? { challenge_id: result.challengeId } : {}),
|
|
413
|
+
}));
|
|
393
414
|
} catch (err) {
|
|
394
415
|
reportSdkError(err);
|
|
395
416
|
}
|
|
@@ -453,14 +474,26 @@ async function inviteUser(args) {
|
|
|
453
474
|
|
|
454
475
|
async function verify(args) {
|
|
455
476
|
const token = parseFlag(args, "--token");
|
|
477
|
+
const challengeId = parseFlag(args, "--challenge-id");
|
|
478
|
+
const code = parseFlag(args, "--code");
|
|
456
479
|
const projectId = resolveProjectId(parseFlag(args, "--project"));
|
|
457
480
|
|
|
458
|
-
|
|
459
|
-
|
|
481
|
+
const hasLink = token !== null;
|
|
482
|
+
const hasCodePart = challengeId !== null || code !== null;
|
|
483
|
+
if (hasLink === hasCodePart) {
|
|
484
|
+
fail({
|
|
485
|
+
code: "BAD_USAGE",
|
|
486
|
+
message: "Provide either --token, or --challenge-id with --code (not both)",
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
if (hasCodePart && (!challengeId || !code)) {
|
|
490
|
+
fail({ code: "BAD_USAGE", message: "--challenge-id and --code must be provided together" });
|
|
460
491
|
}
|
|
461
492
|
|
|
462
493
|
try {
|
|
463
|
-
const data =
|
|
494
|
+
const data = hasLink
|
|
495
|
+
? await getSdk().auth.verifyMagicLink(projectId, token)
|
|
496
|
+
: await getSdk().auth.verifyEmailCode(projectId, { challengeId, code });
|
|
464
497
|
console.log(JSON.stringify(data));
|
|
465
498
|
} catch (err) {
|
|
466
499
|
reportSdkError(err);
|
package/lib/command-manifest.mjs
CHANGED
|
@@ -175,6 +175,12 @@ export const COMMAND_MANIFEST = [
|
|
|
175
175
|
{ path: ["grants", "create"], positionals: [p("wallet")], projectScoped: true, legacyPositionalProject: true, minimalArgs: ["0x1111111111111111111111111111111111111111", "--capability", "deploy"] },
|
|
176
176
|
{ path: ["grants", "revoke"], positionals: [p("grant_id")], projectScoped: true, legacyPositionalProject: true, minimalArgs: ["grt_gate1"] },
|
|
177
177
|
|
|
178
|
+
// ── delegates ────────────────────────────────────────────────────────────
|
|
179
|
+
{ path: ["delegates", "create"], legacyPositionalProject: false, positionals: [], projectScoped: true, minimalArgs: ["--grant", "11111111-1111-1111-1111-111111111111"] },
|
|
180
|
+
{ path: ["delegates", "list"], legacyPositionalProject: false, positionals: [], projectScoped: true, minimalArgs: [] },
|
|
181
|
+
{ path: ["delegates", "revoke"], legacyPositionalProject: false, positionals: [p("delegate_id")], projectScoped: true, minimalArgs: ["dlg_gate1"] },
|
|
182
|
+
{ path: ["delegates", "rotate"], legacyPositionalProject: false, positionals: [p("delegate_id")], projectScoped: true, minimalArgs: ["dlg_gate1"] },
|
|
183
|
+
|
|
178
184
|
// ── events / errors (flat, merged runners) ───────────────────────────────
|
|
179
185
|
{ path: ["events"], positionals: [], projectScoped: true, legacyPositionalProject: false, minimalArgs: [], runStyle: "merged" },
|
|
180
186
|
{ path: ["errors"], positionals: [p("fingerprint_id", { required: false })], projectScoped: true, legacyPositionalProject: false, minimalArgs: [], runStyle: "merged" },
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { getSdk } from "./sdk.mjs";
|
|
2
|
+
import { reportSdkError, parseFlagJson } from "./sdk-errors.mjs";
|
|
3
|
+
import {
|
|
4
|
+
normalizeArgv,
|
|
5
|
+
assertKnownFlags,
|
|
6
|
+
flagValue,
|
|
7
|
+
requirePositionalCount,
|
|
8
|
+
resolveProjectSelector,
|
|
9
|
+
failUnknownSubcommand,
|
|
10
|
+
} from "./argparse.mjs";
|
|
11
|
+
|
|
12
|
+
const HELP = `run402 delegates — scoped deploy credentials an owner mints for an agent
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
run402 delegates <subcommand> [args...]
|
|
16
|
+
|
|
17
|
+
Subcommands:
|
|
18
|
+
create --grant <grant_id> [--project <id>] [--capability <cap>] [--kind <kind>]
|
|
19
|
+
[--scope <json>] [--expires <iso8601>]
|
|
20
|
+
Mint a delegate. The bearer is printed ONCE.
|
|
21
|
+
list [--project <id>] List delegates (never shows tokens)
|
|
22
|
+
revoke <delegate_id> [--project <id>]
|
|
23
|
+
Revoke immediately
|
|
24
|
+
rotate <delegate_id> [--project <id>]
|
|
25
|
+
Revoke + reissue; new bearer printed ONCE
|
|
26
|
+
|
|
27
|
+
Notes:
|
|
28
|
+
- A delegate NARROWS an existing grant, so mint the grant first:
|
|
29
|
+
run402 grants create <agent-wallet> --capability deploy --project <id>
|
|
30
|
+
then pass the returned grant_id to 'delegates create'.
|
|
31
|
+
- Mutations require you to be an owner of the project's org (wallet SIWX).
|
|
32
|
+
- A delegate can never be an owner, and is revocable and expiring.
|
|
33
|
+
- The token is shown ONCE and is not recoverable. Store it immediately;
|
|
34
|
+
if you lose it, 'rotate' issues a new one.
|
|
35
|
+
- Use it with: RUN402_DELEGATE_TOKEN=<token> run402 deploy apply ...
|
|
36
|
+
- JSON in, JSON out.
|
|
37
|
+
|
|
38
|
+
Why this exists:
|
|
39
|
+
Project API keys are issued once at project-create and are never re-issued.
|
|
40
|
+
An agent that loses local state therefore cannot deploy to its own project.
|
|
41
|
+
You still hold the wallet, so SIWX is enough to mint a fresh credential.
|
|
42
|
+
|
|
43
|
+
Examples:
|
|
44
|
+
run402 grants create 0x90F3eB...F80a --capability deploy --project prj_abc
|
|
45
|
+
run402 delegates create --grant 1d86452e-... --project prj_abc
|
|
46
|
+
run402 delegates list --project prj_abc
|
|
47
|
+
run402 delegates revoke 5845f17b-... --project prj_abc
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const SUB_HELP = {
|
|
51
|
+
create: `run402 delegates create — mint a scoped deploy credential
|
|
52
|
+
|
|
53
|
+
Usage:
|
|
54
|
+
run402 delegates create --grant <grant_id> [--project <id>] [--capability <cap>]
|
|
55
|
+
[--kind <kind>] [--scope <json>] [--expires <iso8601>]
|
|
56
|
+
|
|
57
|
+
--capability defaults to "deploy". --kind defaults to "run402_agent_key" (the
|
|
58
|
+
only kind that returns a bearer). --scope, if given, overrides --capability and
|
|
59
|
+
must be a JSON object like {"v":1,"capabilities":["deploy"]}.
|
|
60
|
+
|
|
61
|
+
The bearer is printed ONCE and cannot be read back. Store it immediately.
|
|
62
|
+
Requires owner of the project's org.
|
|
63
|
+
`,
|
|
64
|
+
list: `run402 delegates list — list a project's delegates
|
|
65
|
+
|
|
66
|
+
Usage:
|
|
67
|
+
run402 delegates list [--project <id>]
|
|
68
|
+
|
|
69
|
+
Never returns tokens or secret material — id, kind, scope, expiry, revocation.
|
|
70
|
+
`,
|
|
71
|
+
revoke: `run402 delegates revoke — revoke a delegate immediately
|
|
72
|
+
|
|
73
|
+
Usage:
|
|
74
|
+
run402 delegates revoke <delegate_id> [--project <id>]
|
|
75
|
+
|
|
76
|
+
Takes effect for every subsequent request. Requires owner of the project's org.
|
|
77
|
+
`,
|
|
78
|
+
rotate: `run402 delegates rotate — revoke and reissue in one step
|
|
79
|
+
|
|
80
|
+
Usage:
|
|
81
|
+
run402 delegates rotate <delegate_id> [--project <id>]
|
|
82
|
+
|
|
83
|
+
Keeps the same principal, grant, kind, scope, cap and expiry. The NEW bearer is
|
|
84
|
+
printed once. Use this when a token is lost or possibly exposed.
|
|
85
|
+
`,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const CREATE_VALUE_FLAGS = ["--project", "--grant", "--capability", "--kind", "--scope", "--expires"];
|
|
89
|
+
|
|
90
|
+
async function create(args) {
|
|
91
|
+
const a = normalizeArgv(args);
|
|
92
|
+
assertKnownFlags(a, [...CREATE_VALUE_FLAGS, "--help", "-h"], CREATE_VALUE_FLAGS);
|
|
93
|
+
const grantId = flagValue(a, "--grant");
|
|
94
|
+
const capability = flagValue(a, "--capability") || "deploy";
|
|
95
|
+
const kind = flagValue(a, "--kind") || undefined;
|
|
96
|
+
const scopeRaw = flagValue(a, "--scope");
|
|
97
|
+
const expiresAt = flagValue(a, "--expires");
|
|
98
|
+
const { projectId, rest } = resolveProjectSelector(a, { valueFlags: CREATE_VALUE_FLAGS });
|
|
99
|
+
requirePositionalCount(rest, CREATE_VALUE_FLAGS, {
|
|
100
|
+
min: 0,
|
|
101
|
+
max: 0,
|
|
102
|
+
command: "run402 delegates create --grant <grant_id> [--project <id>]",
|
|
103
|
+
missing: "",
|
|
104
|
+
});
|
|
105
|
+
if (!grantId) {
|
|
106
|
+
console.error("Missing --grant <grant_id>. Mint one first:");
|
|
107
|
+
console.error(" run402 grants create <agent-wallet> --capability deploy --project <id>");
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
const scope = scopeRaw != null
|
|
111
|
+
? parseFlagJson("--scope", scopeRaw)
|
|
112
|
+
: { v: 1, capabilities: [capability], projects: [projectId] };
|
|
113
|
+
try {
|
|
114
|
+
const res = await getSdk().delegates.create(projectId, {
|
|
115
|
+
grantId,
|
|
116
|
+
kind,
|
|
117
|
+
scope,
|
|
118
|
+
expiresAt: expiresAt || undefined,
|
|
119
|
+
});
|
|
120
|
+
console.log(JSON.stringify(res, null, 2));
|
|
121
|
+
if (res?.token) {
|
|
122
|
+
console.error("");
|
|
123
|
+
console.error("The token above is shown ONCE and cannot be read back.");
|
|
124
|
+
console.error("Store it now, then use it as: RUN402_DELEGATE_TOKEN=<token>");
|
|
125
|
+
}
|
|
126
|
+
} catch (err) {
|
|
127
|
+
reportSdkError(err);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function list(args) {
|
|
132
|
+
const a = normalizeArgv(args);
|
|
133
|
+
assertKnownFlags(a, ["--project", "--help", "-h"], ["--project"]);
|
|
134
|
+
const { projectId, rest } = resolveProjectSelector(a, { valueFlags: ["--project"] });
|
|
135
|
+
requirePositionalCount(rest, ["--project"], {
|
|
136
|
+
min: 0,
|
|
137
|
+
max: 0,
|
|
138
|
+
command: "run402 delegates list [--project <id>]",
|
|
139
|
+
missing: "",
|
|
140
|
+
});
|
|
141
|
+
try {
|
|
142
|
+
console.log(JSON.stringify(await getSdk().delegates.list(projectId), null, 2));
|
|
143
|
+
} catch (err) {
|
|
144
|
+
reportSdkError(err);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function oneIdCommand(name) {
|
|
149
|
+
return async (args) => {
|
|
150
|
+
const a = normalizeArgv(args);
|
|
151
|
+
assertKnownFlags(a, ["--project", "--help", "-h"], ["--project"]);
|
|
152
|
+
const { projectId, rest } = resolveProjectSelector(a, { valueFlags: ["--project"] });
|
|
153
|
+
const [delegateId] = requirePositionalCount(rest, ["--project"], {
|
|
154
|
+
min: 1,
|
|
155
|
+
max: 1,
|
|
156
|
+
command: `run402 delegates ${name} <delegate_id> [--project <id>]`,
|
|
157
|
+
missing: "Missing <delegate_id>.",
|
|
158
|
+
});
|
|
159
|
+
try {
|
|
160
|
+
const res = await getSdk().delegates[name](projectId, delegateId);
|
|
161
|
+
console.log(JSON.stringify(res, null, 2));
|
|
162
|
+
if (res?.token) {
|
|
163
|
+
console.error("");
|
|
164
|
+
console.error("The token above is shown ONCE and cannot be read back.");
|
|
165
|
+
}
|
|
166
|
+
} catch (err) {
|
|
167
|
+
reportSdkError(err);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export async function run(sub, args) {
|
|
173
|
+
if (!sub || sub === "--help" || sub === "-h") {
|
|
174
|
+
console.log(HELP);
|
|
175
|
+
process.exit(0);
|
|
176
|
+
}
|
|
177
|
+
if (Array.isArray(args) && (args.includes("--help") || args.includes("-h"))) {
|
|
178
|
+
console.log(SUB_HELP[sub] || HELP);
|
|
179
|
+
process.exit(0);
|
|
180
|
+
}
|
|
181
|
+
switch (sub) {
|
|
182
|
+
case "create": await create(args); break;
|
|
183
|
+
case "list": await list(args); break;
|
|
184
|
+
case "revoke": await oneIdCommand("revoke")(args); break;
|
|
185
|
+
case "rotate": await oneIdCommand("rotate")(args); break;
|
|
186
|
+
default:
|
|
187
|
+
failUnknownSubcommand("delegates", sub);
|
|
188
|
+
}
|
|
189
|
+
}
|
package/lib/deploy-v2.mjs
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
import { getSdk } from "./sdk.mjs";
|
|
35
35
|
import { reportSdkError, fail } from "./sdk-errors.mjs";
|
|
36
36
|
import { API, allowanceAuthHeaders, getActiveProjectId, resolveProjectId, isCoreApiTarget } from "./config.mjs";
|
|
37
|
+
import { delegateTokenFromEnv } from "#sdk/node";
|
|
37
38
|
import { flagValue, normalizeArgv } from "./argparse.mjs";
|
|
38
39
|
import { loadLiveControlPlaneSession } from "../core-dist/control-plane-session.js";
|
|
39
40
|
import { withAutoApprove } from "./operator.mjs";
|
|
@@ -1146,11 +1147,20 @@ async function applyCmd(args) {
|
|
|
1146
1147
|
}
|
|
1147
1148
|
|
|
1148
1149
|
let sdkOpts;
|
|
1150
|
+
const delegateToken = delegateTokenFromEnv();
|
|
1149
1151
|
if (useGithubActionsOidc) {
|
|
1150
1152
|
sdkOpts = {
|
|
1151
1153
|
credentials: githubActionsCredentials({ projectId: releaseSpec.project, apiBase: API }),
|
|
1152
1154
|
disablePaidFetch: true,
|
|
1153
1155
|
};
|
|
1156
|
+
} else if (delegateToken) {
|
|
1157
|
+
// A delegate is a complete, self-contained deploy credential: the owner
|
|
1158
|
+
// minted it with their wallet and handed it over, so this process needs no
|
|
1159
|
+
// allowance of its own. Skipping the guard is the point — an agent that
|
|
1160
|
+
// lost its local state (or never had a wallet) can still deploy. Paid fetch
|
|
1161
|
+
// is disabled for the same reason it is under CI: a delegate authorizes
|
|
1162
|
+
// deploys, not spending.
|
|
1163
|
+
sdkOpts = { delegateToken, disablePaidFetch: true };
|
|
1154
1164
|
} else if (!isCoreApiTarget() && !loadLiveControlPlaneSession()) {
|
|
1155
1165
|
// Aggressive early exit when no allowance is configured — unless a
|
|
1156
1166
|
// wallet-less human is deploying via their operator (control-plane) session
|
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegate-credential helpers.
|
|
3
|
+
*
|
|
4
|
+
* A delegate is a scoped, revocable, expiring bearer an OWNER mints for an
|
|
5
|
+
* agent (gateway `cryptographic-delegates`, v1.79). It authenticates the same
|
|
6
|
+
* routes a CI session does — including the apikey-gated `/content/v1/*` CAS
|
|
7
|
+
* routes — so from the client's perspective it behaves exactly like the CI
|
|
8
|
+
* session path: the bearer rides `Authorization`, and helpers that would
|
|
9
|
+
* otherwise attach a project `apikey` must stand down so the two credential
|
|
10
|
+
* families never mix on one request.
|
|
11
|
+
*
|
|
12
|
+
* Why this exists at all: project API keys are stateless JWTs issued once at
|
|
13
|
+
* project-create and never re-issued. An agent that loses local state (fresh
|
|
14
|
+
* container, new sandbox) therefore has no cached apikey and no way to deploy
|
|
15
|
+
* to a project it owns. The owner still holds the wallet, so they can mint a
|
|
16
|
+
* delegate with SIWX and hand it to the agent. See kychee-com/run402-private#624.
|
|
17
|
+
*/
|
|
18
|
+
import type { CredentialsProvider } from "./credentials.js";
|
|
19
|
+
export declare const DELEGATE_CREDENTIALS: unique symbol;
|
|
20
|
+
export interface DelegateMarkedCredentialsProvider extends CredentialsProvider {
|
|
21
|
+
readonly [DELEGATE_CREDENTIALS]: true;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* True when this provider is presenting a delegate bearer for the current
|
|
25
|
+
* request family. Consumers use it the same way they use
|
|
26
|
+
* `isCiSessionCredentials` — to suppress apikey attachment.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isDelegateCredentials(credentials: CredentialsProvider): boolean;
|
|
29
|
+
/** Environment variable carrying a delegate bearer for non-interactive runs. */
|
|
30
|
+
export declare const DELEGATE_TOKEN_ENV = "RUN402_DELEGATE_TOKEN";
|
|
31
|
+
/**
|
|
32
|
+
* Read a delegate bearer from the environment. Whitespace-trimmed; an empty or
|
|
33
|
+
* whitespace-only value is treated as absent so `RUN402_DELEGATE_TOKEN=` in a
|
|
34
|
+
* shell profile does not silently disable every other credential class.
|
|
35
|
+
*/
|
|
36
|
+
export declare function delegateTokenFromEnv(env?: NodeJS.ProcessEnv): string | undefined;
|
|
37
|
+
//# sourceMappingURL=delegate-credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-credentials.d.ts","sourceRoot":"","sources":["../src/delegate-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,eAAiD,CAAC;AAEnF,MAAM,WAAW,iCAAkC,SAAQ,mBAAmB;IAC5E,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAE/E;AAED,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,GAAG,SAAS,CAKpB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegate-credential helpers.
|
|
3
|
+
*
|
|
4
|
+
* A delegate is a scoped, revocable, expiring bearer an OWNER mints for an
|
|
5
|
+
* agent (gateway `cryptographic-delegates`, v1.79). It authenticates the same
|
|
6
|
+
* routes a CI session does — including the apikey-gated `/content/v1/*` CAS
|
|
7
|
+
* routes — so from the client's perspective it behaves exactly like the CI
|
|
8
|
+
* session path: the bearer rides `Authorization`, and helpers that would
|
|
9
|
+
* otherwise attach a project `apikey` must stand down so the two credential
|
|
10
|
+
* families never mix on one request.
|
|
11
|
+
*
|
|
12
|
+
* Why this exists at all: project API keys are stateless JWTs issued once at
|
|
13
|
+
* project-create and never re-issued. An agent that loses local state (fresh
|
|
14
|
+
* container, new sandbox) therefore has no cached apikey and no way to deploy
|
|
15
|
+
* to a project it owns. The owner still holds the wallet, so they can mint a
|
|
16
|
+
* delegate with SIWX and hand it to the agent. See kychee-com/run402-private#624.
|
|
17
|
+
*/
|
|
18
|
+
export const DELEGATE_CREDENTIALS = Symbol.for("@run402/sdk/delegate-credentials");
|
|
19
|
+
/**
|
|
20
|
+
* True when this provider is presenting a delegate bearer for the current
|
|
21
|
+
* request family. Consumers use it the same way they use
|
|
22
|
+
* `isCiSessionCredentials` — to suppress apikey attachment.
|
|
23
|
+
*/
|
|
24
|
+
export function isDelegateCredentials(credentials) {
|
|
25
|
+
return Boolean(credentials[DELEGATE_CREDENTIALS]);
|
|
26
|
+
}
|
|
27
|
+
/** Environment variable carrying a delegate bearer for non-interactive runs. */
|
|
28
|
+
export const DELEGATE_TOKEN_ENV = "RUN402_DELEGATE_TOKEN";
|
|
29
|
+
/**
|
|
30
|
+
* Read a delegate bearer from the environment. Whitespace-trimmed; an empty or
|
|
31
|
+
* whitespace-only value is treated as absent so `RUN402_DELEGATE_TOKEN=` in a
|
|
32
|
+
* shell profile does not silently disable every other credential class.
|
|
33
|
+
*/
|
|
34
|
+
export function delegateTokenFromEnv(env = process.env) {
|
|
35
|
+
const raw = env[DELEGATE_TOKEN_ENV];
|
|
36
|
+
if (typeof raw !== "string")
|
|
37
|
+
return undefined;
|
|
38
|
+
const trimmed = raw.trim();
|
|
39
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=delegate-credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-credentials.js","sourceRoot":"","sources":["../src/delegate-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAMnF;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAgC;IACpE,OAAO,OAAO,CAAE,WAA0D,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACpG,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,GAAG,GAAG,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACpC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC9C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC"}
|
package/sdk/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { Branches } from "./namespaces/branches.js";
|
|
|
37
37
|
import { Operator } from "./namespaces/operator.js";
|
|
38
38
|
import { Orgs, ScopedOrg } from "./namespaces/org.js";
|
|
39
39
|
import { Grants } from "./namespaces/grants.js";
|
|
40
|
+
import { Delegates } from "./namespaces/delegates.js";
|
|
40
41
|
import { Events } from "./namespaces/events.js";
|
|
41
42
|
import { Errors } from "./namespaces/errors.js";
|
|
42
43
|
import { Pay, type PayExecutor } from "./namespaces/pay.js";
|
|
@@ -119,6 +120,13 @@ export declare class Run402 {
|
|
|
119
120
|
* project-scoped as `r.project(id).grants`.
|
|
120
121
|
*/
|
|
121
122
|
readonly grants: Grants;
|
|
123
|
+
/**
|
|
124
|
+
* Scoped, revocable deploy credentials an owner mints for an agent. The
|
|
125
|
+
* supported way back in when a project's API keys are lost (they are issued
|
|
126
|
+
* once at create and never re-issued). Also project-scoped as
|
|
127
|
+
* `r.project(id).delegates`.
|
|
128
|
+
*/
|
|
129
|
+
readonly delegates: Delegates;
|
|
122
130
|
/**
|
|
123
131
|
* Cursored project events feed — "what happened since I last looked".
|
|
124
132
|
* Also available project-scoped as `r.project(id).events`.
|
|
@@ -244,6 +252,8 @@ export { PROJECT_OPERATION_AUTH_CLASSIFICATIONS, projectOperationAuthClassificat
|
|
|
244
252
|
export type * from "./project-auth-classification.js";
|
|
245
253
|
export { CI_SESSION_CREDENTIALS, createCiSessionCredentials, githubActionsCredentials, isCiSessionCredentials, } from "./ci-credentials.js";
|
|
246
254
|
export type * from "./ci-credentials.js";
|
|
255
|
+
export { DELEGATE_CREDENTIALS, DELEGATE_TOKEN_ENV, delegateTokenFromEnv, isDelegateCredentials, } from "./delegate-credentials.js";
|
|
256
|
+
export type * from "./delegate-credentials.js";
|
|
247
257
|
export * from "./app-up.js";
|
|
248
258
|
export { CONTROL_PLANE_SESSION_CREDENTIALS, controlPlaneSessionCredentials, isControlPlaneSessionCredentials, } from "./control-plane-credentials.js";
|
|
249
259
|
export type * from "./control-plane-credentials.js";
|
|
@@ -278,6 +288,8 @@ export { Orgs, ScopedOrg, OrgMembers, OrgInvites } from "./namespaces/org.js";
|
|
|
278
288
|
export type * from "./namespaces/org.types.js";
|
|
279
289
|
export { Grants } from "./namespaces/grants.js";
|
|
280
290
|
export type * from "./namespaces/grants.types.js";
|
|
291
|
+
export { Delegates } from "./namespaces/delegates.js";
|
|
292
|
+
export type * from "./namespaces/delegates.types.js";
|
|
281
293
|
export { Events } from "./namespaces/events.js";
|
|
282
294
|
export type * from "./namespaces/events.types.js";
|
|
283
295
|
export { Errors } from "./namespaces/errors.js";
|
package/sdk/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA+C,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CA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AAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,mBAAmB,8BAA8B,CAAC;AAClD,OAAO,EACL,GAAG,EACH,iBAAiB,EACjB,kBAAkB,EAClB,8BAA8B,EAC9B,mCAAmC,EACnC,sBAAsB,EACtB,oCAAoC,EACpC,oBAAoB,EACpB,+BAA+B,EAC/B,qBAAqB,EACrB,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,mBAAmB,qBAAqB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,mBAAmB,gCAAgC,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,mBAAmB,iCAAiC,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,+BAA+B,CAAC;AACnD,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,sBAAsB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,mBAAmB,yBAAyB,CAAC"}
|
package/sdk/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ import { Branches } from "./namespaces/branches.js";
|
|
|
36
36
|
import { Operator } from "./namespaces/operator.js";
|
|
37
37
|
import { Orgs, ScopedOrg } from "./namespaces/org.js";
|
|
38
38
|
import { Grants } from "./namespaces/grants.js";
|
|
39
|
+
import { Delegates } from "./namespaces/delegates.js";
|
|
39
40
|
import { Events } from "./namespaces/events.js";
|
|
40
41
|
import { Errors } from "./namespaces/errors.js";
|
|
41
42
|
import { Pay } from "./namespaces/pay.js";
|
|
@@ -96,6 +97,13 @@ export class Run402 {
|
|
|
96
97
|
* project-scoped as `r.project(id).grants`.
|
|
97
98
|
*/
|
|
98
99
|
grants;
|
|
100
|
+
/**
|
|
101
|
+
* Scoped, revocable deploy credentials an owner mints for an agent. The
|
|
102
|
+
* supported way back in when a project's API keys are lost (they are issued
|
|
103
|
+
* once at create and never re-issued). Also project-scoped as
|
|
104
|
+
* `r.project(id).delegates`.
|
|
105
|
+
*/
|
|
106
|
+
delegates;
|
|
99
107
|
/**
|
|
100
108
|
* Cursored project events feed — "what happened since I last looked".
|
|
101
109
|
* Also available project-scoped as `r.project(id).events`.
|
|
@@ -172,6 +180,7 @@ export class Run402 {
|
|
|
172
180
|
this.operator = new Operator(client);
|
|
173
181
|
this.orgs = new Orgs(client);
|
|
174
182
|
this.grants = new Grants(client);
|
|
183
|
+
this.delegates = new Delegates(client);
|
|
175
184
|
this.events = new Events(client);
|
|
176
185
|
this.pay = new Pay(client, opts.payExecutor);
|
|
177
186
|
this.errors = new Errors(client);
|
|
@@ -312,6 +321,7 @@ export { Run402Action } from "./actions.js";
|
|
|
312
321
|
export { defineConfig, dir, emailTrigger, file, nodeFunction, scheduleTrigger, sqlFile, } from "./config.js";
|
|
313
322
|
export { PROJECT_OPERATION_AUTH_CLASSIFICATIONS, projectOperationAuthClassification, } from "./project-auth-classification.js";
|
|
314
323
|
export { CI_SESSION_CREDENTIALS, createCiSessionCredentials, githubActionsCredentials, isCiSessionCredentials, } from "./ci-credentials.js";
|
|
324
|
+
export { DELEGATE_CREDENTIALS, DELEGATE_TOKEN_ENV, delegateTokenFromEnv, isDelegateCredentials, } from "./delegate-credentials.js";
|
|
315
325
|
export * from "./app-up.js";
|
|
316
326
|
export { CONTROL_PLANE_SESSION_CREDENTIALS, controlPlaneSessionCredentials, isControlPlaneSessionCredentials, } from "./control-plane-credentials.js";
|
|
317
327
|
export { EMPTY_STATIC_MANIFEST_METADATA, ROUTE_HTTP_METHODS, buildDeployResolveSummary, isDeployResolveRouteHit, isDeployResolveStaticHit, normalizeDeployResolveRequest, normalizeStaticManifestMetadata, summarizeDeployResult, } from "./namespaces/deploy.types.js";
|
|
@@ -323,6 +333,7 @@ export { FunctionRunTerminalError, FunctionRuns } from "./namespaces/functions.j
|
|
|
323
333
|
export { OperatorSession } from "./namespaces/operator-session.js";
|
|
324
334
|
export { Orgs, ScopedOrg, OrgMembers, OrgInvites } from "./namespaces/org.js";
|
|
325
335
|
export { Grants } from "./namespaces/grants.js";
|
|
336
|
+
export { Delegates } from "./namespaces/delegates.js";
|
|
326
337
|
export { Events } from "./namespaces/events.js";
|
|
327
338
|
export { Errors } from "./namespaces/errors.js";
|
|
328
339
|
export { Pay, PaymentBuyerError, PaymentPolicyError, DEFAULT_PAYMENT_MAX_USD_MICROS, X402_COMMERCE_RESULT_SCHEMA_VERSION, X402_EVIDENCE_STATUSES, X402_GATEWAY_AVAILABILITY_ERROR_CODE, X402_MUTATION_STATES, X402_PAYMENT_POLICY_ERROR_CODES, X402_RECOVERY_ACTIONS, RUN402_PENDING_CLASSIFIER_VERSION, isPaymentBuyerError, isPaymentPolicyError, isTrustedRun402PaymentUrl, isTrustedRun402PendingResponse, payFetchResultToJson, } from "./namespaces/pay.js";
|