Closed ronhombre closed 8 months ago
Wondering if this is a KotlinJS bug or not as a ByteArray should register as a UInt8Array
It still breaks when run with Bunjs.
Removing the code below fixes it.
if (_get_isNode__xss3j(Companion_getInstance())) {
_get_crypto__fwud1y(Companion_getInstance()).randomFillSync(array);
} else {
}
Leaving just the code below allows it to run.
var offset = 0;
while (offset < bytes.length) {
var len = bytes.length > 65536 ? 65536 : bytes.length;
_get_crypto__fwud1y(Companion_getInstance()).getRandomValues(array.subarray(offset, offset + len | 0));
offset = offset + len | 0;
}
What version of Node.js
is being utilized by bunjs
randomFillSync
should accept a TypedArray
, not just a Uint8Array
.
repositories
block
allprojects {
repositories {
// ...
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}
org.kotlincrypto:secure-random:0.3.1-SNAPSHOT
@05nelsonm Confirmed. Thanks for the fix.
@05nelsonm Confirmed. Thanks for the fix.
Great, will merge the fix and get a release out in a moment
Reproduction Steps:
gradle browserWebpack
build/compileSync/js/main/productionExecutable/kotlin
into a NodeJS project.Note: Additionally, using the compiled Webpack also causes the same bug when running on NodeJS.
Work around: Delete the first if-statement and leave whatever was in the else statement.