TheJehyT
Convex Community2y ago
3 replies
TheJehy

Convex runtime does not support SecureRandom

I am trying to create tokens which I can use for auth.

Docs say that crypto, CryptoKey, and SubtleCrypto are available. I think I'm only using those APIs, however...

The following error is thrown from the dashboard when running my mutation.
[Request ID: a175daeb49a29da5] Server Error
Convex runtime does not support SecureRandom


crypto.subtle.importKey("jwk", keys.sig_private_key_doc, { name: 'ECDSA', namedCurve: 'P-256' }, false, ["sign"])


I'm trying to debug this runtime issue. The full code of the mutation that's throwing the error is this:

const create_session = mutation({
    args: {},
    handler: async (ctx, args) => {
        const keys = (await ctx.db.query("auth").first())!
        const sig_private_key = crypto.subtle.importKey("jwk", keys.sig_private_key_doc, { name: 'ECDSA', namedCurve: 'P-256' }, false, ["sign"])

    },
})


What needs to change so I can do things like importKey, and verify JWTs without moving to actions?
Was this page helpful?