jcayzacJ
Denoβ€’3d ago
jcayzac

definition for subtle crypto broken?

This code fails when I type-check because
crypto.subtle.digest
expects a
BufferSource
as 2nd param, contradicting all the docs and all the examples out there:

async function digest(data: Uint8Array): Promise<string> {
    return Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', data)))
        .map((b) => b.toString(16).padStart(2, '0'))
        .join('')
}


There's nothing wrong with the code and it works just fine, but to pass typechecking I have to cast to
any
and silence that, which isn't great πŸ˜•

deno 2.5.6 (stable, release, aarch64-apple-darwin)
v8 14.0.365.5-rusty
typescript 5.9.2
Was this page helpful?