From be6cf82e497e117d896f9fbca2520a8109270c4e Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Mon, 26 Jun 2023 22:21:04 +0000 Subject: [PATCH] keychain: enable structured clone in Firefox --- packages/keychain/README.md | 9 +++------ packages/keychain/src/store/stores_browser.ts | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/keychain/README.md b/packages/keychain/README.md index ffdad5c0..9fef9d1e 100644 --- a/packages/keychain/README.md +++ b/packages/keychain/README.md @@ -4,11 +4,9 @@ This package is part of [NDNts](https://yoursunny.com/p/NDNts/), Named Data Netw This package provides signing algorithms, encryption algorithms, and certificate management features. -The implementation uses [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API). - -* Modern browsers and Node.js 16.x natively support WebCrypto. -* Most browsers restrict WebCrypto to [secure contexts](https://www.w3.org/TR/powerful-features/) only. - During development, you may use `http://localhost` or [ngrok](https://ngrok.com/). +The implementation uses [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) that is natively supported in modern browers and Node.js since 16.x. +Most browsers restrict WebCrypto to [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts) only, so that this implementation will not work on a webpage that is not delivered securely. +During development, you may use `http://localhost` or [ngrok](https://ngrok.com/) to serve the webpage from a secure context. ## Signing Algorithms @@ -92,7 +90,6 @@ Private keys are saved as non-extractable `CryptoKey` objects. ## Known Issues -* In Firefox, persistent keychain stores JWK instead of `CryptoKey`, due to [Mozilla Bug 1545813](https://bugzilla.mozilla.org/show_bug.cgi?id=1545813). * In Firefox, persistent keychain is unusable in a Private Browsing window, due to [Mozilla Bug 781982](https://bugzilla.mozilla.org/show_bug.cgi?id=1639542). * In Chrome, AES 192-bit key is not supported. * Ed25519 in browser is implemented in JavaScript, which is less secure than native Web Crypto implementation. diff --git a/packages/keychain/src/store/stores_browser.ts b/packages/keychain/src/store/stores_browser.ts index c2b44735..c8db1494 100644 --- a/packages/keychain/src/store/stores_browser.ts +++ b/packages/keychain/src/store/stores_browser.ts @@ -6,9 +6,7 @@ import { KeyStore } from "./key-store"; import type { StoreProvider } from "./store-base"; class IdbStoreProvider implements StoreProvider { - // Firefox does not support structured clone of ECDSA CryptoKey. - // https://bugzilla.mozilla.org/show_bug.cgi?id=1545813 - public readonly canSClone = !/rv:.*Gecko\//.test(navigator.userAgent); + public readonly canSClone: boolean = true; private readonly store: UseStore; constructor(dbName: string) {