Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cose.kt?5e47:24 Uncaught TypeError: sign$Companion.createSync is not a function #56

Closed
thisisrafael opened this issue Jul 28, 2021 · 2 comments

Comments

@thisisrafael
Copy link

Usage (JS)
./gradlew jsBrowserDevelopmentWebpack;
just testing demo.html

everything is okay but the Random or Fixed Generator.
It's "stucking" on QR Code Contents: Generating...
Nothing happen (no code and no qr). I've got this error:

Cose.kt?5e47:24 Uncaught TypeError: sign$Companion.createSync is not a function
at Cose.sign_4mr2q2$ (Cose.kt?5e47:24)
at CoseCreationAdapter.sign_x1bysv$ (CoseCreationAdapter.kt?1914:28)
at DefaultCoseService.encode_fqrh44$ (DefaultCoseService.kt?863c:32)
at Chain.encode (Chain.kt?e7ee:40)
at Generator.encode (JsInterface.kt?35f0:148)
at generateRandom (demo.html:38)
at HTMLButtonElement.onclick (demo.html:312)

for... return sign.createSync(header, Buffer(input.toUint8Array()), signer)

file:
.\src\jsMain\kotlin\ehn\techiop\hcert\kotlin\crypto\Cose.kt

package ehn.techiop.hcert.kotlin.crypto

import Buffer
import cose.Signer
import cose.Verifier
import cose.sign
import ehn.techiop.hcert.kotlin.chain.toByteArray
import ehn.techiop.hcert.kotlin.chain.toUint8Array

internal object Cose {
fun verifySync(signedBitString: ByteArray, pubKey: PubKey): ByteArray {
val key = (pubKey as JsPubKey).toCoseRepresentation()
val verifier = object : Verifier {
override val key = key
}
return sign.verifySync(Buffer.from(signedBitString.toUint8Array()), verifier).toByteArray()
}

fun sign(header: dynamic, input: ByteArray, privKey: PrivKey): Buffer {
    val key = (privKey as JsPrivKey).toCoseRepresentation()
    val signer = object : Signer {
        override val key = key
    }
    return sign.createSync(header, Buffer(input.toUint8Array()), signer)
}

}

@nodh
Copy link
Contributor

nodh commented Jul 30, 2021

I can't reproduce this error.
Are you sure, you've cloned the repo with --recursive? Please try to run git submodule init && git submodule update --recursive, because it looks like you're missing our customized cose-js repository.

@thisisrafael
Copy link
Author

Thank you so much!
"git submodule init && git submodule update --recursive" solved everything
It works perfectly

@nodh nodh closed this as completed Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants