1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
9 XPCOMUtils.defineLazyServiceGetter(
12 "@mozilla.org/webauthn/service;1",
17 export const webauthn = {};
20 * Add a virtual authenticator.
22 * @param {string} protocol one of "ctap1/u2f", "ctap2", "ctap2_1"
23 * @param {string} transport one of "usb", "nfc", "ble", "smart-card",
24 * "hybrid", "internal"
25 * @param {boolean} hasResidentKey
26 * @param {boolean} hasUserVerification
27 * @param {boolean} isUserConsenting
28 * @param {boolean} isUserVerified
29 * @returns {id} the id of the added authenticator
31 webauthn.addVirtualAuthenticator = function (
39 return lazy.webauthnService.addVirtualAuthenticator(
50 * Removes a virtual authenticator.
52 * @param {id} authenticatorId the id of the virtual authenticator
54 webauthn.removeVirtualAuthenticator = function (authenticatorId) {
55 lazy.webauthnService.removeVirtualAuthenticator(authenticatorId);
59 * Adds a credential to a previously-added virtual authenticator.
61 * @param {id} authenticatorId the id of the virtual authenticator
62 * @param {string} credentialId a probabilistically-unique byte sequence
63 * identifying a public key credential source and its
64 * authentication assertions (encoded using Base64url
66 * @param {boolean} isResidentCredential if set to true, a client-side
67 * discoverable credential is created. If set to false, a
68 * server-side credential is created instead.
69 * @param {string} rpId The Relying Party ID the credential is scoped to.
70 * @param {string} privateKey An asymmetric key package containing a single
71 * private key per RFC5958, encoded using Base64url Encoding.
72 * @param {string} userHandle The userHandle associated to the credential
73 * encoded using Base64url Encoding.
74 * @param {number} signCount The initial value for a signature counter
75 * associated to the public key credential source.
77 webauthn.addCredential = function (
86 lazy.webauthnService.addCredential(
98 * Gets all credentials from a virtual authenticator.
100 * @param {id} authenticatorId the id of the virtual authenticator
101 * @returns {object} the credentials on the authenticator
103 webauthn.getCredentials = function (authenticatorId) {
104 return lazy.webauthnService.getCredentials(authenticatorId);
108 * Removes a credential from a virtual authenticator.
110 * @param {id} authenticatorId the id of the virtual authenticator
111 * @param {string} credentialId the id of the credential
113 webauthn.removeCredential = function (authenticatorId, credentialId) {
114 lazy.webauthnService.removeCredential(authenticatorId, credentialId);
118 * Removes all credentials from a virtual authenticator.
120 * @param {id} authenticatorId the id of the virtual authenticator
122 webauthn.removeAllCredentials = function (authenticatorId) {
123 lazy.webauthnService.removeAllCredentials(authenticatorId);
127 * Sets the "isUserVerified" bit on a virtual authenticator.
129 * @param {id} authenticatorId the id of the virtual authenticator
130 * @param {bool} isUserVerified the value to set the "isUserVerified" bit to
132 webauthn.setUserVerified = function (authenticatorId, isUserVerified) {
133 lazy.webauthnService.setUserVerified(authenticatorId, isUserVerified);