Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.

Commit f359cf0

Browse files
committed
Update deprecation notice.
It now: - Links to the built-in JSON parsing functions on MDN (which contain explanations, examples, and links to specs). - Provides encouragement and rationale to stop using `@github/webauthn-json`. - Includes useful examples of how to handle the transition, with code that: - Loads a fallback only when needed. - Avoids top-level `await` (which is well-supported by browsers but still errors in TypeScript unless you specifically configure it). - Uses JSDoc comments which ensure that the functions receive the correct types in TypeScript, while still allowing the code to be pasted into vanilla JS.
1 parent f439951 commit f359cf0

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,58 @@
1-
⚠️ ⚠️ ⚠️
1+
# ⚠️ `@github/webauthn-json` is deprecated ⚠️
22

3-
WebAuthn-json has been sunset. Now that [all major browsers support WebAuthn](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API#browser_compatibility) we recommend invoking the native APIs
3+
As of March 2025, stable versions of all major browsers now support the following methods:
44

5-
⚠️ ⚠️ ⚠️
5+
- [`PublicKeyCredential.parseCreationOptionsFromJSON(…)`](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential/parseCreationOptionsFromJSON_static)
6+
- [`PublicKeyCredential.parseRequestOptionsFromJSON(…)`](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential/parseCreationOptionsFromJSON_static)
7+
8+
By design, these are compatible with `@github/webauthn-json` encoding, so you can use them as a drop-in substitute. We strongly recommend doing so, since:
9+
10+
- The browser-native JSON parsing functions are increasingly receiving fields and features (such as user-agent hints and the `prf` extension) that `@github/webauthn-json` will never receive.
11+
- Removing `@github/webauthn-json` from your codebase will remove code from your authentication pages, reducing load times for your users and reducing the chance you will need to debug issues.
12+
13+
## Fallback (not recommended)
14+
15+
If you need to support older browsers in the short-term, consider loading this library only as a fallback:
16+
17+
```js
18+
async function register() {
19+
const parseCreationOptionsFromJSON =
20+
PublicKeyCredential.parseCreationOptionsFromJSON ??
21+
/* @type PublicKeyCredential.parseCreationOptionsFromJSON */
22+
(await import("@github/webauthn-json/browser-ponyfill")).parseCreationOptionsFromJSON;
23+
24+
const publicKey = parseCreationOptionsFromJSON({ /**/ });
25+
return navigator.credentials.create({publicKey});
26+
}
27+
28+
async function authenticate() {
29+
const parseRequestOptionsFromJSON =
30+
PublicKeyCredential.parseRequestOptionsFromJSON ??
31+
/* @type PublicKeyCredential.parseRequestOptionsFromJSON */
32+
(await import("@github/webauthn-json/browser-ponyfill")).parseRequestOptionsFromJSON;
33+
34+
const publicKey = parseRequestOptionsFromJSON({ /**/ });
35+
return navigator.credentials.get({publicKey});
36+
}
37+
```
38+
39+
If you think you need such a fallback, consider testing or instrumenting your code to test if this is really needed for the small percentage of affected users.
40+
41+
If you have any other authentication methods available, it is likely that your users will still be able to authenticate without this fallback in place. They will also receive the browser-native functionality the next time rheir browser updates.
42+
43+
<br>
44+
45+
--------
46+
47+
<br>
48+
49+
This project's old README contents are below:
50+
51+
<br>
52+
53+
--------
54+
55+
<br>
656
757
# `@github/webauthn-json`
858

0 commit comments

Comments
 (0)