semnet-snap-protocol
Version:
TypeScript reference implementation of the SNAP Protocol v1.1 - Agent Internet Edition
91 lines • 2.5 kB
TypeScript
import type { AgentID } from './types.js';
/**
* Generate a new agent identity with Ed25519 keypair
*/
export declare function generateAgentIdentity(): {
identity: AgentID;
privateKey: Uint8Array;
publicKey: Uint8Array;
};
/**
* Generate a UUID v4
*/
export declare function generateUUID(): string;
/**
* Generate a unique message ID
*/
export declare function generateMessageId(): string;
/**
* Generate a unique context ID
*/
export declare function generateContextId(): string;
/**
* Sign a message with Ed25519 private key
*/
export declare function signMessage(message: string, privateKey: Uint8Array): string;
/**
* Verify a message signature with Ed25519 public key
*/
export declare function verifySignature(message: string, signature: string, publicKey: string): boolean;
/**
* Validate agent ID format
*/
export declare function validateAgentId(id: string): boolean;
/**
* Extract UUID from agent ID
*/
export declare function extractUUID(agentId: string): string | null;
/**
* Encode bytes to base64
*/
export declare function encodeBase64(bytes: Uint8Array): string;
/**
* Decode base64 to bytes
*/
export declare function decodeBase64(base64: string): Uint8Array;
/**
* Hash content using SHA-256
*/
export declare function hashContent(content: string): Promise<string>;
/**
* Generate a secure random string
*/
export declare function generateSecureRandom(length?: number): string;
/**
* Create a canonical string representation of an object for signing
*/
export declare function canonicalizeObject(obj: any): string;
/**
* Agent identity utilities
*/
export declare class AgentIdentity {
readonly identity: AgentID;
private readonly privateKey;
readonly publicKey: Uint8Array;
constructor(identity: AgentID, privateKey: Uint8Array, publicKey: Uint8Array);
/**
* Sign a message with this agent's private key
*/
sign(message: string): string;
/**
* Sign an object by creating canonical representation
*/
signObject(obj: any): string;
/**
* Export public identity (safe to share)
*/
exportPublic(): AgentID;
/**
* Export private key (keep secure!)
*/
exportPrivateKey(): string;
/**
* Import agent identity from private key
*/
static fromPrivateKey(identity: AgentID, privateKeyBase64: string): AgentIdentity;
/**
* Generate new agent identity
*/
static generate(): AgentIdentity;
}
//# sourceMappingURL=identity.d.ts.map