D
Deno

help

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

Bbean9/30/2023
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.
IioB9/30/2023
I can't reproduce this, your code runs fine for me. What does data contain? Could you log it and find out?
Bbean9/30/2023
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.
IioB9/30/2023
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?
Bbean9/30/2023
But its prefixed with SHA-256 TypeError so doesnt that indicate its an issue with the first parameter specifying the algo?
IioB9/30/2023
Not sure, good question. From a google search it does seem that position 1 is the second argument.
Bbean9/30/2023
encode returns a Uint8Array so Im skeptical that a Uint8Array can be coerced to a string
IioB9/30/2023
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)
Bbean9/30/2023
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.
IioB9/30/2023
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?
Bbean9/30/2023
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?
IioB9/30/2023
I’m just running it in an unmodified deno build Which uses the same crates as you describe, though more up to date
Bbean9/30/2023
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.
Mmmastrac9/30/2023
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.

Looking for more? Join the community!

Recommended 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 dTailwind nonfunctional on fresh-update from 1.3.1 -> 1.4.3After running `deno run -A -r https://fresh.deno.dev/update .` on my project, the tailwind styles doassertEquals deprecated in vscode?Since upgrading to std@0.202.0 I'm seeing that assertEquals is marked deprecated, but I can't see whForce await import() to import a fresh copy?I have a Deno instance that dynamically loads a module with: `await import("some/module.js")` The mFresh ClassList Brokenhttps://github.com/Leave TLS connection open in between testsWhen I have 2 tests that use a database connection and attempt to close the connection `afterAll` thNvim tsserver clash with denolsI have read the docs and added a root_dir in my lua lsp file but for some reason tsserver still lanccircular type reference nonsensewhy does removing an array nest cause this to be a circular dependency?? shouldn't it be functionallGetting exports from an evaluated module with get_module_namespace always results in null valuesTrying to get module exports like the example [here](https://github.com/denoland/deno/pull/14026/fiIs there any way to define a signal inside a route component?Is there any way to define a signal inside a route component? I am trying to do it but an error raiDeno EmitHow come does `deno bundle` work a lot differently to Deno emit (https://deno.land/x/emit@0.28.0 )?