UNPKG

@yeepay/yop-nodejs-sdk

Version:

YOP NodeJS SDK with TypeScript support

75 lines (74 loc) 2.42 kB
interface VerifyParams { data: string; sign: string; publicKey: string; } interface DigitalEnvelopeResult { status: 'success' | 'failed'; result: string; message: string; } export declare class VerifyUtils { /** * Validates RSA signature for business results * @param params - Parameters containing data, sign, and publicKey * @returns Whether the signature is valid */ static isValidRsaResult(params: VerifyParams): boolean; /** * Extracts result from response string * @param str - Response string * @returns Extracted result */ static getResult(str: string): string; /** * Handles digital envelope decryption * @param content - Digital envelope content * @param isv_private_key - Merchant private key * @param yop_public_key - YOP platform public key * @returns Processing result */ static digital_envelope_handler(content: string, isv_private_key: string, yop_public_key: string): DigitalEnvelopeResult; /** * Validates merchant notification signature * @param result - Result data * @param sign - Signature * @param public_key - Public key * @returns Whether the signature is valid */ static isValidNotifyResult(result: string, sign: string, public_key: string): boolean; /** * Restores base64 safe data * @param data - Data to restore * @returns Restored data */ static base64_safe_handler(data: string): string; /** * Formats private key with header * @param key - Private key without header * @returns Formatted private key */ static key_format(key: string): string; /** * Decrypts data using RSA * @param content - Encrypted content * @param privateKey - Private key * @returns Decrypted data */ static rsaDecrypt(content: string, privateKey: string): Buffer; /** * Decrypts data using AES * @param encrypted - Encrypted content * @param key - Encryption key * @returns Decrypted data */ static aesDecrypt(encrypted: string, key: Buffer): string; /** * Gets business result from content * @param content - Content to extract from * @param format - Format of the content * @returns Extracted business result */ static getBizResult(content: string, format?: string): string; } export default VerifyUtils;