/** * Zod schemas for NEAR CLI credential file formats * * NEAR CLI stores credentials in `~/.near-credentials/` with the following structure: * * ## Directory Structure * ``` * ~/.near-credentials/ * ├── mainnet/ * │ ├── account.near.json # Single key per account * │ └── account.near/ # Multiple keys per account * │ └── ed25519_PublicKeyBase58.json * ├── testnet/ * │ └── account.testnet.json * └── implicit/ * └── accountId.json * ``` * * ## File Format * Each credential file contains: * - `account_id` (optional): Named account ID * - `public_key`: Public key in format "ed25519:Base58EncodedKey" * - `private_key`: Private key in format "ed25519:Base58EncodedKey" * - `seed_phrase_hd_path` (optional): BIP32 derivation path (e.g., "m/44'/397'/0'") * - `master_seed_phrase` (optional): BIP39 seed phrase * - `implicit_account_id` (optional): Implicit account ID (hex of public key) * * @see https://github.com/near/near-cli */ import { z } from "zod"; /** * Schema for NEAR CLI credential file * * This matches the format used by near-cli and near-cli-rs for storing * account credentials on the filesystem. * * @example * ```json * { * "account_id": "example.testnet", * "public_key": "ed25519:8nFkHgRePSGD9UsK3Hx6234567890abcdefghijklmnop", * "private_key": "ed25519:3D4c2v8K5x...", * "seed_phrase_hd_path": "m/44'/397'/0'", * "master_seed_phrase": "word1 word2 word3 ...", * "implicit_account_id": "1234567890abcdef..." * } * ``` */ export declare const NearCliCredentialSchema: z.ZodObject<{ account_id: z.ZodOptional; public_key: z.ZodString; private_key: z.ZodString; seed_phrase_hd_path: z.ZodOptional; master_seed_phrase: z.ZodOptional; implicit_account_id: z.ZodOptional; }, z.core.$strip>; /** * TypeScript type for NEAR CLI credential */ export type NearCliCredential = z.infer; /** * Legacy format used by some tools (uses "secret_key" instead of "private_key") * This is supported for reading only, not writing */ export declare const LegacyCredentialSchema: z.ZodObject<{ account_id: z.ZodOptional; public_key: z.ZodString; secret_key: z.ZodString; seed_phrase_hd_path: z.ZodOptional; master_seed_phrase: z.ZodOptional; implicit_account_id: z.ZodOptional; }, z.core.$strip>; /** * TypeScript type for legacy credential format */ export type LegacyCredential = z.infer; /** * Network identifiers supported by NEAR */ export declare const NetworkSchema: z.ZodEnum<{ mainnet: "mainnet"; testnet: "testnet"; localnet: "localnet"; betanet: "betanet"; }>; /** * TypeScript type for network identifier */ export type Network = z.infer; /** * Parse a credential file, supporting both modern and legacy formats * * @param data - Raw JSON data from credential file * @returns Parsed credential with normalized field names * @throws {z.ZodError} If the data doesn't match any supported format */ export declare function parseCredentialFile(data: unknown): NearCliCredential; //# sourceMappingURL=credential-schemas.d.ts.map