Closed palant closed 7 years ago
Agree on deriveKey
. I don't remember the original reasoning for it to return Promise, I guess I kept it when thinking I'd add asynchrony to it, but instead added deriveKeyNonBlocking
for that. I'll think about changing it.
deriveKeyNonBlocking
allows rendering to proceed while calculating result — it adjusts timeouts automatically to make pieces of calculation take no more than 100ms. The original idea was to use a worker there, but workers are more complicated and not supported everywhere, so it's like that for now. I think for a worker (if it will be implemented) I'll have another method rather than change this one.
Made deriveKey
return Uint8Array
and published as v0.9.0.
The method
Scrypt.deriveKey()
is synchronous. Still, it wraps the result in a promise just for the sake of it. This is pointless and complicates using the library unnecessarily. If the point is usingScrypt.deriveKey()
andScrypt.deriveKeyNonBlocking()
in the same way, the caller can callPromise.resolve()
on the call result themselves.Side-note: is there really still a value in
Scrypt.deriveKeyNonBlocking()
? The proper way of doing this would be creating a worker and runningScrypt.deriveKey()
there.