diff --git a/handlers/ssr.ts b/handlers/ssr.ts index ff6e00ab..cf9af621 100644 --- a/handlers/ssr.ts +++ b/handlers/ssr.ts @@ -3,7 +3,7 @@ import { Handler, HandlerOptions } from "../types.ts" import { Crypto } from "../utils/Crypto.ts" import { mergeHeaders } from "../utils/helpers.ts" -export type Render = (ctx: RequestContext) => string | Promise +export type Render = (ctx: RequestContext) => BodyInit | Promise export interface ssrHandlerOptions extends HandlerOptions { crypto?: Crypto } diff --git a/utils/Crypto.ts b/utils/Crypto.ts index 6a15d300..989fa962 100644 --- a/utils/Crypto.ts +++ b/utils/Crypto.ts @@ -49,8 +49,9 @@ export class Crypto { * @param contents: string * @returns hashHex: string */ - async hash(contents: string): Promise { - const hashBuffer = await crypto.subtle.digest(this.algData.hash, encoder.encode(contents)) + async hash(contents: BodyInit): Promise { + const temp = new Response(contents) // how to array buffer all the things + const hashBuffer = await crypto.subtle.digest(this.algData.hash, await temp.arrayBuffer()) return encodeB64(hashBuffer) }