UNPKG

@tonyboyle/solana-wallet-universal-links-generator

Version:

A minimal, stateless TypeScript SDK for generating deep links to mobile Solana wallets

63 lines 2.64 kB
export interface KeyPair { publicKey: string; privateKey: string; } export interface EncryptionResult { encrypted: string; nonce: string; } /** * Generate a new x25519 keypair for encryption * Recommended to create a new keypair for every session */ export declare function generateKeyPair(): KeyPair; /** * Generate a random nonce for encryption */ export declare function generateNonce(): string; /** * Encrypt data using Diffie-Hellman key exchange * * @param data - Data to encrypt (can be any type, will be JSON stringified) * @param dappPrivateKey - Your app's private key (base64 encoded) * @param walletPublicKey - Wallet's public key (base58 encoded) * @param nonce - Nonce for encryption (base58 encoded) * @returns Encrypted data and nonce */ export declare function encrypt(data: any, dappPrivateKey: string, walletPublicKey: string, nonce: string): EncryptionResult; /** * Decrypt data using Diffie-Hellman key exchange * * @param encryptedData - Encrypted data (base58 encoded) * @param nonce - Nonce used for encryption (base58 encoded) * @param dappPrivateKey - Your app's private key (base64 encoded) * @param walletPublicKey - Wallet's public key (base58 encoded) * @param dappPublicKey - Your app's public key (base58 encoded, optional) * @returns Decrypted data */ export declare function decrypt(encryptedData: string, nonce: string, dappPrivateKey: string, walletPublicKey: string, dappPublicKey?: string): any; /** * Encrypt a payload for sending to wallet * This is a convenience function that handles the encryption workflow * According to Phantom docs, payload should be "an encrypted JSON string" * * @param payload - Can be an object (will be JSON stringified) or a string * @param dappPrivateKey - Your app's private key (base64 encoded) * @param walletPublicKey - Wallet's public key (base58 encoded) * @returns Encrypted string that can be used as the payload parameter */ export declare function encryptPayload(payload: any, dappPrivateKey: string, walletPublicKey: string): string; /** * Decrypt response data from wallet * This is a convenience function that handles the decryption workflow */ export declare function decryptResponse(encryptedData: string, dappPrivateKey: string, walletPublicKey: string): any; /** * Helper function to encode a message for signing * Converts a string message to base58 encoding as required by wallets * * @param message - The message to encode (string) * @returns Base58-encoded message string */ export declare function encodeMessageForSigning(message: string): string; //# sourceMappingURL=encryption.d.ts.map