Something odd here ... this function "just works" in CLJS
(defn ->encryption-key
[]
(js/crypto.subtle.generateKey
(clj->js {:name "RSA-OAEP"
:modulusLength 4096
:publicExponent (js/Uint8Array. [1 0 1])
:hash "SHA-384"})
extractable?
["encrypt" "decrypt"]))with nbb it fails ... saying that the key needs usages
the fix is
(defn ->encryption-key
[]
(js/crypto.subtle.generateKey
(clj->js {:name "RSA-OAEP"
:modulusLength 4096
:publicExponent (js/Uint8Array. [1 0 1])
:hash "SHA-384"})
extractable?
(clj->js ["encrypt" "decrypt"]))) ; <-- extra clj-js neededis that right?
I don't see why that would be necessary?
In CLJS ["foo" "bar"] would not be an array, it would be a vector
you could also prefix it with #js [..]
point is that it works unadorned in CLJS but not nbb .... is that a bug?
I don't know. What is the type that the last argument of generateKey accepts? And what does CLJS pass and how is that differently than what nbb passes? It's not obvious to me
Perhaps you can print the type of that thing. If the types are equal, the "bug" may be somewhere else
it could be different environments. Node.js implements an assertion in crypto.subtle.generateKey that checks whether the keyUsage argument is in fact an array
maybe the environment you're running your CLJS in is different? you didn't say whether it was Node.js as well or in the browser
Nbb is node
The other was indeed in a browser
Ok so it's a node thing rather than an nbb thing
Thanks Will