mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.5 KiB
40 lines
1.5 KiB
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.WebAuthnAbortService = void 0;
|
|
class BaseWebAuthnAbortService {
|
|
constructor() {
|
|
Object.defineProperty(this, "controller", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: void 0
|
|
});
|
|
}
|
|
createNewAbortSignal() {
|
|
// Abort any existing calls to navigator.credentials.create() or navigator.credentials.get()
|
|
if (this.controller) {
|
|
const abortError = new Error('Cancelling existing WebAuthn API call for new one');
|
|
abortError.name = 'AbortError';
|
|
this.controller.abort(abortError);
|
|
}
|
|
const newController = new AbortController();
|
|
this.controller = newController;
|
|
return newController.signal;
|
|
}
|
|
cancelCeremony() {
|
|
if (this.controller) {
|
|
const abortError = new Error('Manually cancelling existing WebAuthn API call');
|
|
abortError.name = 'AbortError';
|
|
this.controller.abort(abortError);
|
|
this.controller = undefined;
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* A service singleton to help ensure that only a single WebAuthn ceremony is active at a time.
|
|
*
|
|
* Users of **@simplewebauthn/browser** shouldn't typically need to use this, but it can help e.g.
|
|
* developers building projects that use client-side routing to better control the behavior of
|
|
* their UX in response to router navigation events.
|
|
*/
|
|
exports.WebAuthnAbortService = new BaseWebAuthnAbortService();
|
|
|