Closed jadedevin13 closed 1 year ago
Hello @jadedevin13, please fill out the issue template. And because you mentioned "edge", please include the cloud runtime and a code sample to reproduce the issue.
SimpleWebAuthn isn't yet supported for use in ESM-only environments. I'm working on this though. See #338 and #366.
I'll try to test the following codes over the weekend.
// Import webcrypto
import * as platformCrypto from "crypto";
import * as peculiarCrypto from "@peculiar/webcrypto";
let webcrypto;
if ((typeof self !== "undefined") && "crypto" in self) {
// Always use crypto if available natively (browser / Deno)
webcrypto = self.crypto;
} else {
// Always use node webcrypto if available ( >= 16.0 )
if(platformCrypto && platformCrypto.webcrypto) {
webcrypto = platformCrypto.webcrypto;
} else {
// Fallback to @peculiar/webcrypto
webcrypto = new peculiarCrypto.Crypto();
}
}