@coinbase/cdp-sdk
Version:
SDK for interacting with the Coinbase Developer Platform Wallet API
14 lines (12 loc) • 440 B
text/typescript
import { subtle } from "uncrypto";
/**
* Auth-specific hash function using uncrypto for Edge runtime compatibility.
* Computes SHA-256 hash of the given data.
*
* @param data - The data to hash
* @returns Promise that resolves to the hex-encoded hash
*/
export const authHash = async (data: Buffer): Promise<string> => {
const hashBuffer = await subtle.digest("SHA-256", data);
return Buffer.from(hashBuffer).toString("hex");
};