Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@corbado/webauthn-json
Advanced tools
A wrapper for the webauthn API that adapts input/output values to plain JSON with base64url (Corbado fork)
@github/webauthn-json
@github/webauthn-json
is a client-side Javascript library that serves as convenience wrapper for the the WebAuthn API by encoding binary data using base64url (also known as "websafe" or "urlsafe" base64).
The WebAuthn API itself takes input and output values that look almost like JSON, except that binary data is represented as ArrayBuffer
s. Using webauthn-json
allows the data to be sent from/to the server as normal JSON without any custom client-side processing. This will be possible directly in the browser some day, but we're here for you until then.
navigator.credentials.create(...)
with create(parseCreationOptionsFromJSON(...))
.navigator.credentials.get(...)
with get(parseRequestOptionsFromJSON(...))
.Install using:
npm install --save @github/webauthn-json
Then:
import {
create,
parseCreationOptionsFromJSON,
} from "@github/webauthn-json/browser-ponyfill";
const request = fetch("...");
async function createCredential() {
const json = await (await request).json();
const options = parseCreationOptionsFromJSON(json);
const response = await create(options);
fetch("...", {
method: "POST",
body: JSON.stringify(response),
});
}
See here for fully working client-side demo code.
We now recommend using a ponyfill for the new JSON-based APIs in the WebAuthn spec:
// @github/webauthn-json/browser-ponyfill
function supported(): boolean;
function parseCreationOptionsFromJSON(json: JSON): CredentialCreationOptions;
function parseRequestOptionsFromJSON(json: JSON): CredentialRequestOptions;
// You can call `.toJSON()` on the result or pass directly to `JSON.stringify()`.
function create(options: CredentialCreationOptions): Promise<PublicKeyCredential>;
// You can call `.toJSON()` on the result or pass directly to `JSON.stringify()`.
function get(options: CredentialRequestOptions): Promise<PublicKeyCredential>;
This was the original simplified API, which remains supported.
// @github/webauthn-json
function create(requestJSON: JSON): Promise<JSON>;
function get(requestJSON: JSON): Promise<JSON>;
function supported(): boolean;
There are are several ways to encode JSON with binary fields. @github/webauthn-json
focuses on one simple approach: converting the known structure using a simple (custom) schema format. @github/webauthn-json
uses a few tricks for a compact schema encoding: the main build is about ≈1KB when minified and gzipped (although we publish unminified builds).
Right now, we only convert fields explicitly known to be used by the WebAuthn API. This means that you'll have to update to a newer version of this library if you want to use new fields in the future.
To print the current schema, run:
npx @github/webauthn-json schema
Modern browsers generally only support — and most sites only need to use — a small number of extensions. To save code size, @github/webauthn-json
only includes the following extensions by default:
In addition, we handle the following info (that is not technically part of extensions):
transports
(on AuthenticatorAttestationResponse
)1If you need to convert additional input or output extensions, use either of the following:
createExtended()
and getExtended()
from @github/webauthn-json/extended
.parseExtendedCreationOptionsFromJSON()
and parseExtendedRequestOptionsFromJSON()
from @github/webauthn-json/browser-ponyfill/extended
.The scope of @github/webauthn-json
is fairly small — it's essentially feature-complete. However, we're happy to accept issues or pull requests that address the core goal of the project!
This comes from getTransports()
on the AuthenticatorAttestationResponse
. Note that we don't include its three sibling functions (getAuthenticatorData()
, getPublicKey()
, and getPublicKeyAlgorithm()
), since they duplicates information that is available in other parts of the response. In particular, the authenticator data is available inside the signed attestation object. ↩
FAQs
A wrapper for the webauthn API that adapts input/output values to plain JSON with base64url (Corbado fork)
The npm package @corbado/webauthn-json receives a total of 181 weekly downloads. As such, @corbado/webauthn-json popularity was classified as not popular.
We found that @corbado/webauthn-json demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.