@yeepay/yop-typescript-sdk
Version:
TypeScript SDK for interacting with YOP (YeePay Open Platform)
104 lines (103 loc) • 3.46 kB
TypeScript
interface VerifyParams {
data: string;
sign: string;
publicKey: string | Buffer;
}
interface DigitalEnvelopeResult {
status: 'success' | 'failed';
result: string;
message: string;
}
export declare class VerifyUtils {
/**
* Extracts a public key from an X.509 certificate
* @param certificate - PEM formatted X.509 certificate
* @returns Extracted public key in PEM format or null if extraction fails
*/
static extractPublicKeyFromCertificate(certificate: string | Buffer): string | null;
/**
* Formats a raw public key string into PEM format
* @param rawKey - The raw public key string
* @returns Formatted PEM public key
*/
/**
* 格式化原始公钥字符串为 PEM 格式
* @param rawKey - 原始公钥字符串
* @returns 格式化的 PEM 公钥或 null(如果输入无效)
*/
static formatPublicKey(rawKey: string): string | null;
/**
* Validates RSA signature for business results
* @param params - Parameters containing data, sign, and publicKey
* @returns Whether the signature is valid
*/
/**
* 验证 RSA 签名
* @param params - 包含数据、签名和公钥的参数
* @returns 签名是否有效
*/
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
*/
/**
* 验证商户通知签名
* @param result - 结果数据
* @param sign - 签名
* @param publicKeyStr - 公钥
* @returns 签名是否有效
*/
static isValidNotifyResult(result: string, sign: string, publicKeyStr: 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;