Skip to content

Commit

Permalink
keychain: enable structured clone in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Jun 26, 2023
1 parent c87341b commit be6cf82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 3 additions & 6 deletions packages/keychain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
4 changes: 1 addition & 3 deletions packages/keychain/src/store/stores_browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { KeyStore } from "./key-store";
import type { StoreProvider } from "./store-base";

class IdbStoreProvider<T> implements StoreProvider<T> {
// 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) {
Expand Down

0 comments on commit be6cf82

Please sign in to comment.