UNPKG

@yeepay/yop-typescript-sdk

Version:

TypeScript SDK for interacting with YOP (YeePay Open Platform)

75 lines (74 loc) 2.63 kB
import { AuthHeaderOptions } from './types.js'; export declare class RsaV3Util { /** * Gets authentication headers for API requests * @param options - Options for generating auth headers * @returns Authentication headers */ static getAuthHeaders(options: AuthHeaderOptions): Record<string, string>; static buildCanonicalHeaders(headersToSign: Record<string, string>): { canonicalHeaderString: string; signedHeadersString: string; }; /** * Gets canonical query string for API requests * @param params - Request parameters * @param method - HTTP method * @returns Canonical query string */ static getCanonicalQueryString(params: Record<string, unknown>, method: string): string; /** * Gets canonical headers for API requests * @param headers - Request headers * @returns Canonical headers string */ /** * Generates a UUID * @returns UUID string */ static uuid(): string; /** * Gets canonical parameters string * @param params - Request parameters * @param type - Content type * @returns Canonical parameters string */ static getCanonicalParams(params?: Record<string, unknown>, type?: string): string; /** * Calculates SHA256 hash and returns hex string * @param params - Request parameters * @param config - Configuration options * @param method - HTTP method * @returns SHA256 hash as hex string */ /** * 对对象的键进行排序,以确保生成一致的 JSON 字符串 * @param obj - 要排序的对象 * @returns 排序后的对象 */ private static sortObjectKeys; /** * 计算SHA256哈希并返回十六进制字符串 * @param params - 请求参数 * @param config - 配置选项 * @param method - HTTP方法 * @returns SHA256哈希的十六进制字符串 */ static getSha256AndHexStr(params: Record<string, unknown>, config: { contentType: string; }, method: string): string; /** * Formats a raw private key string into PEM format * @param rawKey - The raw private key string * @returns Formatted PEM private key */ private static formatPrivateKey; /** * Signs a canonical request using RSA-SHA256 * @param canonicalRequest - The canonical request string to sign * @param secretKey - The private key in PEM format or raw format * @returns The signature string (Base64 URL Safe + $SHA256) */ static sign(canonicalRequest: string, secretKey: string): string; } export default RsaV3Util;