bean
bean9mo ago

Issues with Crypto Subtle Digest ext:deno_crypto/00_crypto.js

Currently we are using deno_core v0.200.0 deno_runtime v0.123.0 when attempting to invoke crypto.subtle.digest the following error is reported
SHA-256 TypeError: Error parsing args at position 1: serde_v8 error: invalid type; expected: object, got: string
SHA-256 TypeError: Error parsing args at position 1: serde_v8 error: invalid type; expected: object, got: string
example for reproduction
async function main() {
const encoder = new TextEncoder();
const data = encoder.encode('Hello, World!');
const hashed = await crypto.subtle.digest('SHA-256', data);
console.log(new Uint8Array(hashed));
}
async function main() {
const encoder = new TextEncoder();
const data = encoder.encode('Hello, World!');
const hashed = await crypto.subtle.digest('SHA-256', data);
console.log(new Uint8Array(hashed));
}
According to the api docs either a string or enum should be supported as the first param.
13 Replies
ioB
ioB9mo ago
I can't reproduce this, your code runs fine for me. What does data contain? Could you log it and find out?
bean
bean9mo ago
It contains Hello, World! UTF8 encoded but the error happens on attempting to deserialize SHA-256 to a enumeration type. the error looks to be around type conversion. We also tried turning SHA-256 to {name: 'SHA-256'} but it also errors.
ioB
ioB9mo ago
I could be wrong, but me reading this error interprets it as data being the issue (TypeError: Error parsing args at position 1). Position 0 in my experience is the first input. Any reason why your versions of deno_core and deno_runtime are out of date?
bean
bean9mo ago
But its prefixed with SHA-256 TypeError so doesnt that indicate its an issue with the first parameter specifying the algo?
ioB
ioB9mo ago
Not sure, good question. From a google search it does seem that position 1 is the second argument.
bean
bean9mo ago
encode returns a Uint8Array so Im skeptical that a Uint8Array can be coerced to a string
ioB
ioB9mo ago
Hold on, how do you even have TextEncoder with just deno_core and deno_runtime? You'd need to have deno_web for that (or have implemented it yourself)
bean
bean9mo ago
We do use deno_web but its a modified version we have not modified be text encoding bindings nor bindings for the cryptp api's understandable if this is outside support scope.
ioB
ioB9mo ago
Are you able to share a reproduction of this issue? I'd love to poke around. I'm assuming you all also have a vendored version of deno_crypto?
bean
bean9mo ago
no modified version of deno_crypto which is why this is a bit concerning. unfortunately i cannot give you a way to reproduce that can audit the behavior directly as its a remote execution environment where you wont have full log context. we just use whats included in deno_runtime / deno_core and bind through our vendored deno_web bindings. but knowning that you cannot reproduce using non vendored packages is interesting. May i ask how you are testing the above code example?
ioB
ioB9mo ago
I’m just running it in an unmodified deno build Which uses the same crates as you describe, though more up to date
bean
bean9mo ago
If anyone has more information on the error report that could also be helpful, from the looks of the logging structure it seems to be a type error with the first param but now not totally sure. If anyone is able to run the source above through a env built from the exact package versions would help in our confidence in if its a bug in the op bindings or something on our end.
mmastrac
mmastrac9mo ago
Note that we've been porting ops to the new op2 system over the last month and there's some pretty strict lockstep requirements between deno_core and extensions (ie: what we release is supported) due to the pretty massive flux.
More Posts
Anyway to use deno fmt within a script itself without having to call deno again?I am working on a code generator and I'd like to run a string through deno fmt before I save to fileinteraction_endpoint_url: couldn't be verifiedI'm trying to create an http interactions bot using deno deploy, but sometimes my url fails to be veLost access to deno land module, how to reset the repo?My repository was accidentally destroyed on GitHub and I recreated it the same exact way. The webhooBDD with async testsI'd like to run some tests that all call the same helper function that wraps the bdd `it` function. Is there a schedule / pattern for which Deno releases get new Docker files?We'd love to update to Deno 1.37.1 in production, but deno_docker is still at 1.37.0. I've noticed tIs the Fresh compornents test function enabled?Attempting to write a test for Fresh compornents. I was able to verify the rendered content. I am Inquiry Regarding Deno Security Model and Command Injection VulnerabilityI am currently instructing a class on software security and have been exploring Deno's security mode`WARNING: v8::OwnedIsolate for snapshot was leaked` and/or crash after using snapshotOn startup, I create a runtime: ```rust let js_runtime = JsRuntimeForSnapshot::new(deno_corOak: Remove HTML extensions when serving filesUsing Oak, how can I serve `home.html` as `/home` (or `/home/`). I'm aware that `Context#send` existdeno_console not being properly instantiated?Not sure if it's indended, or if I am missing a step, but several core extensions, for example the d