run402-mcp 2.39.4 → 2.41.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/core/dist/control-plane-session.d.ts +53 -0
- package/core/dist/control-plane-session.d.ts.map +1 -0
- package/core/dist/control-plane-session.js +114 -0
- package/core/dist/control-plane-session.js.map +1 -0
- package/dist/tools/orgs.js +4 -4
- package/dist/tools/orgs.js.map +1 -1
- package/package.json +1 -1
- package/sdk/README.md +1 -1
- package/sdk/core-dist/control-plane-session.d.ts +53 -0
- package/sdk/core-dist/control-plane-session.js +114 -0
- package/sdk/dist/control-plane-credentials.d.ts +45 -0
- package/sdk/dist/control-plane-credentials.d.ts.map +1 -0
- package/sdk/dist/control-plane-credentials.js +57 -0
- package/sdk/dist/control-plane-credentials.js.map +1 -0
- package/sdk/dist/errors.d.ts +31 -1
- package/sdk/dist/errors.d.ts.map +1 -1
- package/sdk/dist/errors.js +59 -0
- package/sdk/dist/errors.js.map +1 -1
- package/sdk/dist/index.d.ts +6 -2
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +4 -2
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/kernel.d.ts.map +1 -1
- package/sdk/dist/kernel.js +4 -1
- package/sdk/dist/kernel.js.map +1 -1
- package/sdk/dist/namespaces/operator-session.d.ts +223 -0
- package/sdk/dist/namespaces/operator-session.d.ts.map +1 -0
- package/sdk/dist/namespaces/operator-session.js +230 -0
- package/sdk/dist/namespaces/operator-session.js.map +1 -0
- package/sdk/dist/namespaces/operator.d.ts +63 -0
- package/sdk/dist/namespaces/operator.d.ts.map +1 -1
- package/sdk/dist/namespaces/operator.js +51 -0
- package/sdk/dist/namespaces/operator.js.map +1 -1
- package/sdk/dist/namespaces/org.d.ts +55 -23
- package/sdk/dist/namespaces/org.d.ts.map +1 -1
- package/sdk/dist/namespaces/org.js +117 -52
- package/sdk/dist/namespaces/org.js.map +1 -1
- package/sdk/dist/namespaces/org.types.d.ts +37 -1
- package/sdk/dist/namespaces/org.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/transfers.d.ts +58 -0
- package/sdk/dist/namespaces/transfers.d.ts.map +1 -1
- package/sdk/dist/namespaces/transfers.js +40 -0
- package/sdk/dist/namespaces/transfers.js.map +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A cached **control-plane session** — the human principal's *write-capable*
|
|
3
|
+
* bearer, minted by the loopback-PKCE flow (`run402 operator login --loopback`).
|
|
4
|
+
* Distinct from the device-flow {@link OperatorSession} (read-only): this one
|
|
5
|
+
* carries `provenance` (`loopback_pkce`) and `amr`, and is accepted everywhere a
|
|
6
|
+
* SIWX wallet is. Cached at the BASE config dir (email/principal-scoped, shared
|
|
7
|
+
* across local named wallets), mode 0600 — the token is as sensitive as the
|
|
8
|
+
* allowance key.
|
|
9
|
+
*
|
|
10
|
+
* Stored shape vs the gateway payload: the gateway returns a relative
|
|
11
|
+
* `expires_in` (seconds); we persist the absolute `expires_at` (epoch ms) so a
|
|
12
|
+
* cached session can be expiry-checked without knowing when it was written.
|
|
13
|
+
*/
|
|
14
|
+
export interface ControlPlaneSessionCache {
|
|
15
|
+
control_plane_session_token: string;
|
|
16
|
+
token_type: string;
|
|
17
|
+
provenance: string;
|
|
18
|
+
principal_id: string;
|
|
19
|
+
amr: string[];
|
|
20
|
+
/** Epoch ms when the session expires (issued_at + expires_in). */
|
|
21
|
+
expires_at: number;
|
|
22
|
+
}
|
|
23
|
+
/** The token payload returned by `POST /agent/v1/control-plane/cli/token`. */
|
|
24
|
+
export interface ControlPlaneSessionTokenResponse {
|
|
25
|
+
control_plane_session_token: string;
|
|
26
|
+
token_type?: string;
|
|
27
|
+
provenance?: string;
|
|
28
|
+
principal_id?: string;
|
|
29
|
+
amr?: string[];
|
|
30
|
+
expires_in?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Path to the cached control-plane session: `{base}/control-plane-session.json`.
|
|
34
|
+
* `RUN402_CONTROL_PLANE_SESSION_PATH` overrides for testing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getControlPlaneSessionPath(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Load the cached control-plane session. Returns `null` for the "no session"
|
|
39
|
+
* cases (absent, unreadable, unparseable). Throws when the file parses as JSON
|
|
40
|
+
* but the shape is wrong, so a corrupted cache surfaces a clear fix-it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readControlPlaneSession(path?: string): ControlPlaneSessionCache | null;
|
|
43
|
+
/** Persist a control-plane session atomically (temp-file + rename), mode 0600. */
|
|
44
|
+
export declare function saveControlPlaneSession(data: ControlPlaneSessionCache, path?: string): void;
|
|
45
|
+
/** Delete the cached control-plane session — local half of `operator logout`. Idempotent. */
|
|
46
|
+
export declare function clearControlPlaneSession(path?: string): void;
|
|
47
|
+
/** Whether a cached session is past its usable life (with a small skew buffer). */
|
|
48
|
+
export declare function isControlPlaneSessionExpired(session: ControlPlaneSessionCache, nowMs?: number, skewMs?: number): boolean;
|
|
49
|
+
/** Read the cached session and return it only if still usable; `null` if absent or expired. */
|
|
50
|
+
export declare function loadLiveControlPlaneSession(path?: string, nowMs?: number): ControlPlaneSessionCache | null;
|
|
51
|
+
/** Map a gateway token payload (relative `expires_in`) into the cached shape (absolute `expires_at`). */
|
|
52
|
+
export declare function controlPlaneSessionFromTokenResponse(resp: ControlPlaneSessionTokenResponse, nowMs?: number): ControlPlaneSessionCache;
|
|
53
|
+
//# sourceMappingURL=control-plane-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-plane-session.d.ts","sourceRoot":"","sources":["../src/control-plane-session.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,wBAAwB;IACvC,2BAA2B,EAAE,MAAM,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,8EAA8E;AAC9E,MAAM,WAAW,gCAAgC;IAC/C,2BAA2B,EAAE,MAAM,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAKnD;AAkBD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,wBAAwB,GAAG,IAAI,CA2CtF;AAED,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAQ3F;AAED,6FAA6F;AAC7F,wBAAgB,wBAAwB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAO5D;AAED,mFAAmF;AACnF,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,wBAAwB,EACjC,KAAK,GAAE,MAAmB,EAC1B,MAAM,SAAS,GACd,OAAO,CAET;AAED,+FAA+F;AAC/F,wBAAgB,2BAA2B,CACzC,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,GAAE,MAAmB,GACzB,wBAAwB,GAAG,IAAI,CAIjC;AAED,yGAAyG;AACzG,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,gCAAgC,EACtC,KAAK,GAAE,MAAmB,GACzB,wBAAwB,CAS1B"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, chmodSync, renameSync, statSync, rmSync, } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { randomBytes } from "node:crypto";
|
|
4
|
+
import { getConfigBaseDir } from "./config.js";
|
|
5
|
+
/**
|
|
6
|
+
* Path to the cached control-plane session: `{base}/control-plane-session.json`.
|
|
7
|
+
* `RUN402_CONTROL_PLANE_SESSION_PATH` overrides for testing.
|
|
8
|
+
*/
|
|
9
|
+
export function getControlPlaneSessionPath() {
|
|
10
|
+
return (process.env.RUN402_CONTROL_PLANE_SESSION_PATH ||
|
|
11
|
+
join(getConfigBaseDir(), "control-plane-session.json"));
|
|
12
|
+
}
|
|
13
|
+
/** Tighten 0600 if group/other-readable, warning once. Best-effort, POSIX-only. */
|
|
14
|
+
function selfHealPermissions(p) {
|
|
15
|
+
if (process.platform === "win32")
|
|
16
|
+
return;
|
|
17
|
+
try {
|
|
18
|
+
const mode = statSync(p).mode & 0o777;
|
|
19
|
+
if ((mode & 0o077) !== 0) {
|
|
20
|
+
chmodSync(p, 0o600);
|
|
21
|
+
process.stderr.write(`warning: tightened permissions on ${p} from ${mode.toString(8)} to 600 (was readable by other users).\n`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Best-effort; never block a read on a chmod/stat failure.
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Load the cached control-plane session. Returns `null` for the "no session"
|
|
30
|
+
* cases (absent, unreadable, unparseable). Throws when the file parses as JSON
|
|
31
|
+
* but the shape is wrong, so a corrupted cache surfaces a clear fix-it.
|
|
32
|
+
*/
|
|
33
|
+
export function readControlPlaneSession(path) {
|
|
34
|
+
const p = path ?? getControlPlaneSessionPath();
|
|
35
|
+
if (!existsSync(p))
|
|
36
|
+
return null;
|
|
37
|
+
selfHealPermissions(p);
|
|
38
|
+
let raw;
|
|
39
|
+
try {
|
|
40
|
+
raw = readFileSync(p, "utf-8");
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = JSON.parse(raw);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
53
|
+
throw new Error("control-plane-session.json must contain a JSON object. Delete it and run 'run402 operator login --loopback' to recreate it.");
|
|
54
|
+
}
|
|
55
|
+
const data = parsed;
|
|
56
|
+
if (typeof data.control_plane_session_token !== "string" ||
|
|
57
|
+
data.control_plane_session_token.length === 0) {
|
|
58
|
+
throw new Error("control-plane-session.json missing valid 'control_plane_session_token'. Run 'run402 operator login --loopback' to refresh it.");
|
|
59
|
+
}
|
|
60
|
+
if (typeof data.expires_at !== "number" || !Number.isFinite(data.expires_at)) {
|
|
61
|
+
throw new Error("control-plane-session.json missing valid 'expires_at'. Run 'run402 operator login --loopback' to refresh it.");
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
control_plane_session_token: data.control_plane_session_token,
|
|
65
|
+
token_type: typeof data.token_type === "string" ? data.token_type : "Bearer",
|
|
66
|
+
provenance: typeof data.provenance === "string" ? data.provenance : "loopback_pkce",
|
|
67
|
+
principal_id: typeof data.principal_id === "string" ? data.principal_id : "",
|
|
68
|
+
amr: Array.isArray(data.amr) ? data.amr.filter((a) => typeof a === "string") : [],
|
|
69
|
+
expires_at: data.expires_at,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Persist a control-plane session atomically (temp-file + rename), mode 0600. */
|
|
73
|
+
export function saveControlPlaneSession(data, path) {
|
|
74
|
+
const p = path ?? getControlPlaneSessionPath();
|
|
75
|
+
const dir = dirname(p);
|
|
76
|
+
mkdirSync(dir, { recursive: true });
|
|
77
|
+
const tmp = join(dir, `.control-plane-session.${randomBytes(4).toString("hex")}.tmp`);
|
|
78
|
+
writeFileSync(tmp, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
79
|
+
renameSync(tmp, p);
|
|
80
|
+
chmodSync(p, 0o600);
|
|
81
|
+
}
|
|
82
|
+
/** Delete the cached control-plane session — local half of `operator logout`. Idempotent. */
|
|
83
|
+
export function clearControlPlaneSession(path) {
|
|
84
|
+
const p = path ?? getControlPlaneSessionPath();
|
|
85
|
+
try {
|
|
86
|
+
rmSync(p, { force: true });
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Best-effort: a failed unlink should never crash logout.
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Whether a cached session is past its usable life (with a small skew buffer). */
|
|
93
|
+
export function isControlPlaneSessionExpired(session, nowMs = Date.now(), skewMs = 10_000) {
|
|
94
|
+
return nowMs + skewMs >= session.expires_at;
|
|
95
|
+
}
|
|
96
|
+
/** Read the cached session and return it only if still usable; `null` if absent or expired. */
|
|
97
|
+
export function loadLiveControlPlaneSession(path, nowMs = Date.now()) {
|
|
98
|
+
const s = readControlPlaneSession(path);
|
|
99
|
+
if (!s)
|
|
100
|
+
return null;
|
|
101
|
+
return isControlPlaneSessionExpired(s, nowMs) ? null : s;
|
|
102
|
+
}
|
|
103
|
+
/** Map a gateway token payload (relative `expires_in`) into the cached shape (absolute `expires_at`). */
|
|
104
|
+
export function controlPlaneSessionFromTokenResponse(resp, nowMs = Date.now()) {
|
|
105
|
+
return {
|
|
106
|
+
control_plane_session_token: resp.control_plane_session_token,
|
|
107
|
+
token_type: resp.token_type ?? "Bearer",
|
|
108
|
+
provenance: resp.provenance ?? "loopback_pkce",
|
|
109
|
+
principal_id: resp.principal_id ?? "",
|
|
110
|
+
amr: Array.isArray(resp.amr) ? resp.amr.filter((a) => typeof a === "string") : [],
|
|
111
|
+
expires_at: nowMs + (typeof resp.expires_in === "number" ? resp.expires_in : 0) * 1000,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=control-plane-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-plane-session.js","sourceRoot":"","sources":["../src/control-plane-session.ts"],"names":[],"mappings":"AAAA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Members(args) {
|
|
53
53
|
try {
|
|
54
|
-
const members = await getSdk().org.members(args.billing_account_id);
|
|
54
|
+
const members = await getSdk().org.members.list(args.billing_account_id);
|
|
55
55
|
if (members.length === 0) {
|
|
56
56
|
return { content: [{ type: "text", text: `No members in \`${args.billing_account_id}\`.` }] };
|
|
57
57
|
}
|
|
@@ -73,7 +73,7 @@ export const addOrgMemberSchema = {
|
|
|
73
73
|
};
|
|
74
74
|
export async function handleAddOrgMember(args) {
|
|
75
75
|
try {
|
|
76
|
-
const res = await getSdk().org.
|
|
76
|
+
const res = await getSdk().org.members.add(args.billing_account_id, {
|
|
77
77
|
wallet: args.wallet,
|
|
78
78
|
role: args.role,
|
|
79
79
|
});
|
|
@@ -98,7 +98,7 @@ export const setOrgMemberRoleSchema = {
|
|
|
98
98
|
};
|
|
99
99
|
export async function handleSetOrgMemberRole(args) {
|
|
100
100
|
try {
|
|
101
|
-
const res = await getSdk().org.setRole(args.billing_account_id, args.principal_id, args.role);
|
|
101
|
+
const res = await getSdk().org.members.setRole(args.billing_account_id, args.principal_id, args.role);
|
|
102
102
|
return {
|
|
103
103
|
content: [{ type: "text", text: `Principal \`${res.principal_id}\` is now ${res.role}.` }],
|
|
104
104
|
};
|
|
@@ -114,7 +114,7 @@ export const removeOrgMemberSchema = {
|
|
|
114
114
|
};
|
|
115
115
|
export async function handleRemoveOrgMember(args) {
|
|
116
116
|
try {
|
|
117
|
-
const res = await getSdk().org.
|
|
117
|
+
const res = await getSdk().org.members.revoke(args.billing_account_id, args.principal_id);
|
|
118
118
|
return {
|
|
119
119
|
content: [{ type: "text", text: `Removed principal \`${res.principal_id}\` from \`${args.billing_account_id}\`.` }],
|
|
120
120
|
};
|
package/dist/tools/orgs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orgs.js","sourceRoot":"","sources":["../../src/tools/orgs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,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;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,WAAW,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,+EAA+E;AAE/E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IACxE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sGAAsG,CAAC;CAC1I,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAG3C;IACC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1F,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,GAAG,CAAC,YAAY,aAAa,IAAI,CAAC,kBAAkB,KAAK,EAAE,CAAC;SACpH,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,WAAW,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "run402-mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.41.0",
|
|
4
4
|
"description": "MCP server for Run402 — AI-native Postgres databases with REST API, auth, storage, and row-level security. Pay with x402 USDC micropayments.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
package/sdk/README.md
CHANGED
|
@@ -81,7 +81,7 @@ The `CredentialsProvider` interface has two required methods (`getAuth`, `getPro
|
|
|
81
81
|
| `allowance` | `status`, `create`, `export`, `faucet` |
|
|
82
82
|
| `service` | `status`, `health` (no auth, no setup — works on a fresh install) |
|
|
83
83
|
| `admin` | Operator/admin endpoints: messages/contact, per-project finance (`getProjectFinance`) |
|
|
84
|
-
| `operator` | **The human / email principal** —
|
|
84
|
+
| `operator` | **The human / email principal** — distinct from the agent's per-wallet SIWX identity (and from platform-`admin`). Read session: `deviceStart`, `devicePoll`, `overview({ token })`, `revoke({ token })` — browser-delegated device-authorization (RFC 8628, the `aws sso login` model); `overview` returns the email-union across every wallet that verified the email. Write session (v1.78): `buildCliAuthorizeUrl`/`exchangeCliToken` (loopback-PKCE CLI login) + the hosted `operator.session.*` surface (email magic-link / passkey / OAuth login, `whoami`/`refresh`/`revoke`, step-up, authenticators, recovery) — carry a minted session SDK-wide with `controlPlaneSessionCredentials({ token })`. Drives `run402 operator login[/--loopback]/overview/whoami/logout`. No MCP tool by design — MCP authenticates as the agent, not the human. |
|
|
85
85
|
|
|
86
86
|
CLI-style aliases are available for agent ergonomics: `r.image` aliases `r.ai`,
|
|
87
87
|
and common command names such as `r.billing.balance`, `r.auth.magicLink`,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A cached **control-plane session** — the human principal's *write-capable*
|
|
3
|
+
* bearer, minted by the loopback-PKCE flow (`run402 operator login --loopback`).
|
|
4
|
+
* Distinct from the device-flow {@link OperatorSession} (read-only): this one
|
|
5
|
+
* carries `provenance` (`loopback_pkce`) and `amr`, and is accepted everywhere a
|
|
6
|
+
* SIWX wallet is. Cached at the BASE config dir (email/principal-scoped, shared
|
|
7
|
+
* across local named wallets), mode 0600 — the token is as sensitive as the
|
|
8
|
+
* allowance key.
|
|
9
|
+
*
|
|
10
|
+
* Stored shape vs the gateway payload: the gateway returns a relative
|
|
11
|
+
* `expires_in` (seconds); we persist the absolute `expires_at` (epoch ms) so a
|
|
12
|
+
* cached session can be expiry-checked without knowing when it was written.
|
|
13
|
+
*/
|
|
14
|
+
export interface ControlPlaneSessionCache {
|
|
15
|
+
control_plane_session_token: string;
|
|
16
|
+
token_type: string;
|
|
17
|
+
provenance: string;
|
|
18
|
+
principal_id: string;
|
|
19
|
+
amr: string[];
|
|
20
|
+
/** Epoch ms when the session expires (issued_at + expires_in). */
|
|
21
|
+
expires_at: number;
|
|
22
|
+
}
|
|
23
|
+
/** The token payload returned by `POST /agent/v1/control-plane/cli/token`. */
|
|
24
|
+
export interface ControlPlaneSessionTokenResponse {
|
|
25
|
+
control_plane_session_token: string;
|
|
26
|
+
token_type?: string;
|
|
27
|
+
provenance?: string;
|
|
28
|
+
principal_id?: string;
|
|
29
|
+
amr?: string[];
|
|
30
|
+
expires_in?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Path to the cached control-plane session: `{base}/control-plane-session.json`.
|
|
34
|
+
* `RUN402_CONTROL_PLANE_SESSION_PATH` overrides for testing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getControlPlaneSessionPath(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Load the cached control-plane session. Returns `null` for the "no session"
|
|
39
|
+
* cases (absent, unreadable, unparseable). Throws when the file parses as JSON
|
|
40
|
+
* but the shape is wrong, so a corrupted cache surfaces a clear fix-it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readControlPlaneSession(path?: string): ControlPlaneSessionCache | null;
|
|
43
|
+
/** Persist a control-plane session atomically (temp-file + rename), mode 0600. */
|
|
44
|
+
export declare function saveControlPlaneSession(data: ControlPlaneSessionCache, path?: string): void;
|
|
45
|
+
/** Delete the cached control-plane session — local half of `operator logout`. Idempotent. */
|
|
46
|
+
export declare function clearControlPlaneSession(path?: string): void;
|
|
47
|
+
/** Whether a cached session is past its usable life (with a small skew buffer). */
|
|
48
|
+
export declare function isControlPlaneSessionExpired(session: ControlPlaneSessionCache, nowMs?: number, skewMs?: number): boolean;
|
|
49
|
+
/** Read the cached session and return it only if still usable; `null` if absent or expired. */
|
|
50
|
+
export declare function loadLiveControlPlaneSession(path?: string, nowMs?: number): ControlPlaneSessionCache | null;
|
|
51
|
+
/** Map a gateway token payload (relative `expires_in`) into the cached shape (absolute `expires_at`). */
|
|
52
|
+
export declare function controlPlaneSessionFromTokenResponse(resp: ControlPlaneSessionTokenResponse, nowMs?: number): ControlPlaneSessionCache;
|
|
53
|
+
//# sourceMappingURL=control-plane-session.d.ts.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, chmodSync, renameSync, statSync, rmSync, } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { randomBytes } from "node:crypto";
|
|
4
|
+
import { getConfigBaseDir } from "./config.js";
|
|
5
|
+
/**
|
|
6
|
+
* Path to the cached control-plane session: `{base}/control-plane-session.json`.
|
|
7
|
+
* `RUN402_CONTROL_PLANE_SESSION_PATH` overrides for testing.
|
|
8
|
+
*/
|
|
9
|
+
export function getControlPlaneSessionPath() {
|
|
10
|
+
return (process.env.RUN402_CONTROL_PLANE_SESSION_PATH ||
|
|
11
|
+
join(getConfigBaseDir(), "control-plane-session.json"));
|
|
12
|
+
}
|
|
13
|
+
/** Tighten 0600 if group/other-readable, warning once. Best-effort, POSIX-only. */
|
|
14
|
+
function selfHealPermissions(p) {
|
|
15
|
+
if (process.platform === "win32")
|
|
16
|
+
return;
|
|
17
|
+
try {
|
|
18
|
+
const mode = statSync(p).mode & 0o777;
|
|
19
|
+
if ((mode & 0o077) !== 0) {
|
|
20
|
+
chmodSync(p, 0o600);
|
|
21
|
+
process.stderr.write(`warning: tightened permissions on ${p} from ${mode.toString(8)} to 600 (was readable by other users).\n`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Best-effort; never block a read on a chmod/stat failure.
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Load the cached control-plane session. Returns `null` for the "no session"
|
|
30
|
+
* cases (absent, unreadable, unparseable). Throws when the file parses as JSON
|
|
31
|
+
* but the shape is wrong, so a corrupted cache surfaces a clear fix-it.
|
|
32
|
+
*/
|
|
33
|
+
export function readControlPlaneSession(path) {
|
|
34
|
+
const p = path ?? getControlPlaneSessionPath();
|
|
35
|
+
if (!existsSync(p))
|
|
36
|
+
return null;
|
|
37
|
+
selfHealPermissions(p);
|
|
38
|
+
let raw;
|
|
39
|
+
try {
|
|
40
|
+
raw = readFileSync(p, "utf-8");
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = JSON.parse(raw);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
53
|
+
throw new Error("control-plane-session.json must contain a JSON object. Delete it and run 'run402 operator login --loopback' to recreate it.");
|
|
54
|
+
}
|
|
55
|
+
const data = parsed;
|
|
56
|
+
if (typeof data.control_plane_session_token !== "string" ||
|
|
57
|
+
data.control_plane_session_token.length === 0) {
|
|
58
|
+
throw new Error("control-plane-session.json missing valid 'control_plane_session_token'. Run 'run402 operator login --loopback' to refresh it.");
|
|
59
|
+
}
|
|
60
|
+
if (typeof data.expires_at !== "number" || !Number.isFinite(data.expires_at)) {
|
|
61
|
+
throw new Error("control-plane-session.json missing valid 'expires_at'. Run 'run402 operator login --loopback' to refresh it.");
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
control_plane_session_token: data.control_plane_session_token,
|
|
65
|
+
token_type: typeof data.token_type === "string" ? data.token_type : "Bearer",
|
|
66
|
+
provenance: typeof data.provenance === "string" ? data.provenance : "loopback_pkce",
|
|
67
|
+
principal_id: typeof data.principal_id === "string" ? data.principal_id : "",
|
|
68
|
+
amr: Array.isArray(data.amr) ? data.amr.filter((a) => typeof a === "string") : [],
|
|
69
|
+
expires_at: data.expires_at,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Persist a control-plane session atomically (temp-file + rename), mode 0600. */
|
|
73
|
+
export function saveControlPlaneSession(data, path) {
|
|
74
|
+
const p = path ?? getControlPlaneSessionPath();
|
|
75
|
+
const dir = dirname(p);
|
|
76
|
+
mkdirSync(dir, { recursive: true });
|
|
77
|
+
const tmp = join(dir, `.control-plane-session.${randomBytes(4).toString("hex")}.tmp`);
|
|
78
|
+
writeFileSync(tmp, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
79
|
+
renameSync(tmp, p);
|
|
80
|
+
chmodSync(p, 0o600);
|
|
81
|
+
}
|
|
82
|
+
/** Delete the cached control-plane session — local half of `operator logout`. Idempotent. */
|
|
83
|
+
export function clearControlPlaneSession(path) {
|
|
84
|
+
const p = path ?? getControlPlaneSessionPath();
|
|
85
|
+
try {
|
|
86
|
+
rmSync(p, { force: true });
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Best-effort: a failed unlink should never crash logout.
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Whether a cached session is past its usable life (with a small skew buffer). */
|
|
93
|
+
export function isControlPlaneSessionExpired(session, nowMs = Date.now(), skewMs = 10_000) {
|
|
94
|
+
return nowMs + skewMs >= session.expires_at;
|
|
95
|
+
}
|
|
96
|
+
/** Read the cached session and return it only if still usable; `null` if absent or expired. */
|
|
97
|
+
export function loadLiveControlPlaneSession(path, nowMs = Date.now()) {
|
|
98
|
+
const s = readControlPlaneSession(path);
|
|
99
|
+
if (!s)
|
|
100
|
+
return null;
|
|
101
|
+
return isControlPlaneSessionExpired(s, nowMs) ? null : s;
|
|
102
|
+
}
|
|
103
|
+
/** Map a gateway token payload (relative `expires_in`) into the cached shape (absolute `expires_at`). */
|
|
104
|
+
export function controlPlaneSessionFromTokenResponse(resp, nowMs = Date.now()) {
|
|
105
|
+
return {
|
|
106
|
+
control_plane_session_token: resp.control_plane_session_token,
|
|
107
|
+
token_type: resp.token_type ?? "Bearer",
|
|
108
|
+
provenance: resp.provenance ?? "loopback_pkce",
|
|
109
|
+
principal_id: resp.principal_id ?? "",
|
|
110
|
+
amr: Array.isArray(resp.amr) ? resp.amr.filter((a) => typeof a === "string") : [],
|
|
111
|
+
expires_at: nowMs + (typeof resp.expires_in === "number" ? resp.expires_in : 0) * 1000,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=control-plane-session.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Control-plane **session** credential provider (gateway v1.78). Carries a
|
|
3
|
+
* write-capable `control_plane_session` bearer so the whole SDK authenticates as
|
|
4
|
+
* the human principal — the token is "accepted everywhere a SIWX wallet is", so
|
|
5
|
+
* `r.org.*`, `r.admin.transfers.*`, and `r.operator.session.*` all act as that
|
|
6
|
+
* principal.
|
|
7
|
+
*
|
|
8
|
+
* Isomorphic — no Node APIs. Mint a session with `r.operator.session.verifyEmail`
|
|
9
|
+
* / `passkeyVerify` / the loopback-PKCE `exchangeCliToken`, then:
|
|
10
|
+
*
|
|
11
|
+
* const r = run402({ credentials: controlPlaneSessionCredentials({ token }) });
|
|
12
|
+
* await r.org.whoami(); // resolves the principal + memberships
|
|
13
|
+
*
|
|
14
|
+
* High-stakes writes still require a fresh passkey — an `email`/`oauth` session
|
|
15
|
+
* gets {@link StepUpRequiredError}; run the step-up ceremony
|
|
16
|
+
* (`r.operator.session.stepUpOptions`/`stepUpVerify`) and retry.
|
|
17
|
+
*
|
|
18
|
+
* This credential authenticates control-plane operations only; it carries no
|
|
19
|
+
* project anon/service keys, so {@link CredentialsProvider.getProject} returns
|
|
20
|
+
* null (project-key operations need the keystore/wallet).
|
|
21
|
+
*/
|
|
22
|
+
import type { CredentialsProvider } from "./credentials.js";
|
|
23
|
+
/** Brand marking a provider as control-plane-session-backed. */
|
|
24
|
+
export declare const CONTROL_PLANE_SESSION_CREDENTIALS: unique symbol;
|
|
25
|
+
export interface ControlPlaneSessionMarkedCredentialsProvider extends CredentialsProvider {
|
|
26
|
+
readonly [CONTROL_PLANE_SESSION_CREDENTIALS]: true;
|
|
27
|
+
}
|
|
28
|
+
export interface ControlPlaneSessionCredentialsOptions {
|
|
29
|
+
/** A `control_plane_session` bearer token. Provide this OR `getToken`. */
|
|
30
|
+
token?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Lazily resolve the current token (e.g. read a cache, or rotate via
|
|
33
|
+
* `r.operator.session.refresh`). Called before every authenticated request.
|
|
34
|
+
*/
|
|
35
|
+
getToken?: () => string | Promise<string>;
|
|
36
|
+
}
|
|
37
|
+
/** True if `credentials` was created by {@link controlPlaneSessionCredentials}. */
|
|
38
|
+
export declare function isControlPlaneSessionCredentials(credentials: CredentialsProvider): credentials is ControlPlaneSessionMarkedCredentialsProvider;
|
|
39
|
+
/**
|
|
40
|
+
* Build a {@link CredentialsProvider} that authenticates every request with a
|
|
41
|
+
* `control_plane_session` bearer. Pass a static `token`, or a `getToken`
|
|
42
|
+
* resolver for rotation.
|
|
43
|
+
*/
|
|
44
|
+
export declare function controlPlaneSessionCredentials(opts: ControlPlaneSessionCredentialsOptions): ControlPlaneSessionMarkedCredentialsProvider;
|
|
45
|
+
//# sourceMappingURL=control-plane-credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-plane-credentials.d.ts","sourceRoot":"","sources":["../src/control-plane-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAe,MAAM,kBAAkB,CAAC;AAGzE,gEAAgE;AAChE,eAAO,MAAM,iCAAiC,eAE7C,CAAC;AAEF,MAAM,WAAW,4CAA6C,SAAQ,mBAAmB;IACvF,QAAQ,CAAC,CAAC,iCAAiC,CAAC,EAAE,IAAI,CAAC;CACpD;AAED,MAAM,WAAW,qCAAqC;IACpD,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED,mFAAmF;AACnF,wBAAgB,gCAAgC,CAC9C,WAAW,EAAE,mBAAmB,GAC/B,WAAW,IAAI,4CAA4C,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,qCAAqC,GAC1C,4CAA4C,CA8B9C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Control-plane **session** credential provider (gateway v1.78). Carries a
|
|
3
|
+
* write-capable `control_plane_session` bearer so the whole SDK authenticates as
|
|
4
|
+
* the human principal — the token is "accepted everywhere a SIWX wallet is", so
|
|
5
|
+
* `r.org.*`, `r.admin.transfers.*`, and `r.operator.session.*` all act as that
|
|
6
|
+
* principal.
|
|
7
|
+
*
|
|
8
|
+
* Isomorphic — no Node APIs. Mint a session with `r.operator.session.verifyEmail`
|
|
9
|
+
* / `passkeyVerify` / the loopback-PKCE `exchangeCliToken`, then:
|
|
10
|
+
*
|
|
11
|
+
* const r = run402({ credentials: controlPlaneSessionCredentials({ token }) });
|
|
12
|
+
* await r.org.whoami(); // resolves the principal + memberships
|
|
13
|
+
*
|
|
14
|
+
* High-stakes writes still require a fresh passkey — an `email`/`oauth` session
|
|
15
|
+
* gets {@link StepUpRequiredError}; run the step-up ceremony
|
|
16
|
+
* (`r.operator.session.stepUpOptions`/`stepUpVerify`) and retry.
|
|
17
|
+
*
|
|
18
|
+
* This credential authenticates control-plane operations only; it carries no
|
|
19
|
+
* project anon/service keys, so {@link CredentialsProvider.getProject} returns
|
|
20
|
+
* null (project-key operations need the keystore/wallet).
|
|
21
|
+
*/
|
|
22
|
+
import { LocalError } from "./errors.js";
|
|
23
|
+
/** Brand marking a provider as control-plane-session-backed. */
|
|
24
|
+
export const CONTROL_PLANE_SESSION_CREDENTIALS = Symbol.for("@run402/sdk/control-plane-session-credentials");
|
|
25
|
+
/** True if `credentials` was created by {@link controlPlaneSessionCredentials}. */
|
|
26
|
+
export function isControlPlaneSessionCredentials(credentials) {
|
|
27
|
+
return Boolean(credentials[CONTROL_PLANE_SESSION_CREDENTIALS]);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build a {@link CredentialsProvider} that authenticates every request with a
|
|
31
|
+
* `control_plane_session` bearer. Pass a static `token`, or a `getToken`
|
|
32
|
+
* resolver for rotation.
|
|
33
|
+
*/
|
|
34
|
+
export function controlPlaneSessionCredentials(opts) {
|
|
35
|
+
if (!opts?.token && !opts?.getToken) {
|
|
36
|
+
throw new LocalError("controlPlaneSessionCredentials requires token or getToken", "creating control-plane session credentials");
|
|
37
|
+
}
|
|
38
|
+
const provider = {
|
|
39
|
+
async getAuth() {
|
|
40
|
+
const token = opts.getToken ? await opts.getToken() : opts.token;
|
|
41
|
+
if (!token) {
|
|
42
|
+
throw new LocalError("control-plane session credentials did not return a token", "authenticating with control-plane session");
|
|
43
|
+
}
|
|
44
|
+
return { Authorization: `Bearer ${token}` };
|
|
45
|
+
},
|
|
46
|
+
async getProject() {
|
|
47
|
+
// A control-plane session carries no project anon/service keys.
|
|
48
|
+
return null;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(provider, CONTROL_PLANE_SESSION_CREDENTIALS, {
|
|
52
|
+
value: true,
|
|
53
|
+
enumerable: false,
|
|
54
|
+
});
|
|
55
|
+
return provider;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=control-plane-credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-plane-credentials.js","sourceRoot":"","sources":["../src/control-plane-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,gEAAgE;AAChE,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC,GAAG,CACzD,+CAA+C,CAChD,CAAC;AAgBF,mFAAmF;AACnF,MAAM,UAAU,gCAAgC,CAC9C,WAAgC;IAEhC,OAAO,OAAO,CACX,WAAqE,CACpE,iCAAiC,CAClC,CACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,IAA2C;IAE3C,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,UAAU,CAClB,2DAA2D,EAC3D,4CAA4C,CAC7C,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAwB;QACpC,KAAK,CAAC,OAAO;YACX,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;YACjE,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,UAAU,CAClB,0DAA0D,EAC1D,2CAA2C,CAC5C,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;QAC9C,CAAC;QACD,KAAK,CAAC,UAAU;YACd,gEAAgE;YAChE,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,iCAAiC,EAAE;QACjE,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IACH,OAAO,QAAwD,CAAC;AAClE,CAAC"}
|
package/sdk/dist/errors.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* (or the exported `is*` guards) to branch on errors safely across SDK copies
|
|
16
16
|
* and realms — value comparison, no class-identity dependency.
|
|
17
17
|
*/
|
|
18
|
-
export type Run402ErrorKind = "payment_required" | "project_not_found" | "unauthorized" | "not_authorized" | "api_error" | "network_error" | "local_error" | "deploy_error" | "transfer_freeze";
|
|
18
|
+
export type Run402ErrorKind = "payment_required" | "project_not_found" | "unauthorized" | "not_authorized" | "api_error" | "network_error" | "local_error" | "deploy_error" | "transfer_freeze" | "step_up_required";
|
|
19
19
|
/**
|
|
20
20
|
* Quota-denial scope discriminator (v1.46+). Indicates whether a quota-related
|
|
21
21
|
* denial was enforced against the pooled billing-account total (`"account"`)
|
|
@@ -252,6 +252,34 @@ export declare class TransferFreezeError extends Run402Error {
|
|
|
252
252
|
readonly projectId: string | null;
|
|
253
253
|
constructor(message: string, status: number, body: unknown, context: string);
|
|
254
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* HTTP 403 `STEP_UP_REQUIRED` — the gateway requires a fresh, same-client
|
|
257
|
+
* step-up (a recent `passkey` AMR) before this high-stakes control-plane
|
|
258
|
+
* operation (delete / transfer / membership / invite / payment drain·rotate)
|
|
259
|
+
* may proceed. A `device_flow`-minted session can never satisfy it; the caller
|
|
260
|
+
* must complete the challenge at {@link challengeUrl} (e.g. via
|
|
261
|
+
* `run402 operator login --step-up`) on the same client and retry.
|
|
262
|
+
*
|
|
263
|
+
* Typed fields are lifted from the gateway `details` envelope; the same
|
|
264
|
+
* remediation pointer is also present in {@link Run402Error.nextActions} as an
|
|
265
|
+
* `authenticate` action.
|
|
266
|
+
*/
|
|
267
|
+
export declare class StepUpRequiredError extends Run402Error {
|
|
268
|
+
static readonly DEFAULT_CODE = "STEP_UP_REQUIRED";
|
|
269
|
+
static readonly DEFAULT_CATEGORY = "auth";
|
|
270
|
+
static readonly DEFAULT_RETRYABLE = false;
|
|
271
|
+
readonly kind: "step_up_required";
|
|
272
|
+
/** AMRs that would satisfy the step-up (e.g. `["passkey"]`). Empty when the gateway omitted it. */
|
|
273
|
+
readonly requiredAmr: string[];
|
|
274
|
+
/** Max age in seconds the satisfying auth may be; null when the gateway omitted it. */
|
|
275
|
+
readonly maxAgeSeconds: number | null;
|
|
276
|
+
/** Where to run the step-up challenge; null when the gateway omitted it. */
|
|
277
|
+
readonly challengeUrl: string | null;
|
|
278
|
+
/** Why the step-up was demanded (e.g. `"device_flow_forbidden"`); null when absent. */
|
|
279
|
+
readonly reason: string | null;
|
|
280
|
+
constructor(message: string, status: number, body: unknown, context: string);
|
|
281
|
+
toJSON(): Record<string, unknown>;
|
|
282
|
+
}
|
|
255
283
|
/** True if `e` is any {@link Run402Error} subclass instance, regardless of which SDK copy created it. */
|
|
256
284
|
export declare function isRun402Error(e: unknown): e is Run402Error;
|
|
257
285
|
/** True if `e` is a {@link PaymentRequired}. Survives duplicate SDK copies and realms. */
|
|
@@ -272,6 +300,8 @@ export declare function isLocalError(e: unknown): e is LocalError;
|
|
|
272
300
|
export declare function isDeployError(e: unknown): e is Run402DeployError;
|
|
273
301
|
/** True if `e` is a {@link TransferFreezeError}. */
|
|
274
302
|
export declare function isTransferFreezeError(e: unknown): e is TransferFreezeError;
|
|
303
|
+
/** True if `e` is a {@link StepUpRequiredError}. Survives duplicate SDK copies and realms. */
|
|
304
|
+
export declare function isStepUpRequired(e: unknown): e is StepUpRequiredError;
|
|
275
305
|
/**
|
|
276
306
|
* Extract the v1.46+ quota-denial scope from an error. Returns `"account"`
|
|
277
307
|
* for pooled denials, `"project"` for the orphan fallback, or `undefined`
|
package/sdk/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,kBAAkB,GAClB,mBAAmB,GACnB,cAAc,GACd,gBAAgB,GAChB,WAAW,GACX,eAAe,GACf,aAAa,GACb,cAAc,GACd,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,kBAAkB,GAClB,mBAAmB,GACnB,cAAc,GACd,gBAAgB,GAChB,WAAW,GACX,e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