(key: ArrayBuffer, data: string)
| 35 | } |
| 36 | |
| 37 | async function hmacSha256(key: ArrayBuffer, data: string): Promise<ArrayBuffer> { |
| 38 | const cryptoKey = await crypto.subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]); |
| 39 | const encoded = new TextEncoder().encode(data); |
| 40 | return crypto.subtle.sign("HMAC", cryptoKey, encoded.buffer as ArrayBuffer); |
| 41 | } |
| 42 | |
| 43 | /** 派生 AWS Signature V4 签名密钥 */ |
| 44 | async function deriveSigningKey( |
no outgoing calls
no test coverage detected