run402-mcp
Version:
MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.
72 lines • 2.83 kB
TypeScript
/**
* SIWX auth helper — generates SIWX (Sign-In With X / EIP-4361) headers for Run402 API.
* Uses @noble/curves (lighter than viem) for signing.
*/
import type { WalletData } from "./wallet.js";
export interface SIWxAuthHeaders {
"SIGN-IN-WITH-X": string;
}
/**
* EIP-55 mixed-case checksum encoding.
*/
export declare function toChecksumAddress(address: string): string;
interface SIWEMessageOpts {
domain: string;
uri: string;
statement: string;
version?: string;
chainId: number | string;
nonce: string;
issuedAt: string;
expirationTime?: string;
resources?: string[];
}
export interface SIWxAuthOptions extends SIWEMessageOpts {
wallet: Pick<WalletData, "address" | "privateKey">;
type?: "eip191";
}
/** Signs an EIP-191 personal message for `address`; resolves to a 65-byte 0x hex signature. */
export type PersonalMessageSigner = (message: string) => Promise<string>;
/**
* A SIWX header waiting for its signature: `message` is the exact EIP-4361
* text to sign (EIP-191), `finish` turns the signature into the header. This
* is how a signer-backed wallet, whose signature is asynchronous, signs in.
*/
export interface PreparedSIWx {
message: string;
finish(signature: string): SIWxAuthHeaders;
}
export declare function prepareSIWx(opts: SIWEMessageOpts & {
address: string;
type?: "eip191";
}): PreparedSIWx;
/**
* Format an EIP-4361 (SIWE) message. Must be byte-for-byte compatible
* with the `siwe` library's message format used server-side for verification.
*/
export declare function formatSIWEMessage(opts: SIWEMessageOpts, address: string): string;
/** SIWX headers signed with a local private key (synchronous). */
export declare function buildSIWxAuthHeaders(opts: SIWxAuthOptions): SIWxAuthHeaders;
/**
* Thrown where a synchronous signature is required but the wallet signs
* through a signer (`wallet.json` `signer`). Callers that can wait use
* `getWalletAuthHeadersAsync` with the SDK's signer instead.
*/
export declare class SignerWalletError extends Error {
readonly code = "SIGNER_WALLET_ASYNC";
constructor();
}
/**
* SIWX headers for any wallet: a key-backed wallet signs locally; a
* signer-backed one through `signerFor(wallet)`. Null when no wallet exists.
*/
export declare function getWalletAuthHeadersAsync(path: string, walletPath: string | undefined, signerFor: (wallet: WalletData) => Promise<PersonalMessageSigner>): Promise<SIWxAuthHeaders | null>;
/**
* Get SIWX auth headers for the Run402 API.
* Returns null if no local wallet is configured.
*
* @param path - API path (e.g. "/projects/v1") used to build the SIWE uri field.
*/
export declare function getWalletAuthHeaders(path: string, walletPath?: string): SIWxAuthHeaders | null;
export {};
//# sourceMappingURL=wallet-auth.d.ts.map