Sha256: a52d8c69d4027a3f349cbaf9483c7471a20ec2963547b621722c8ffacbbdd25b
Contents?: true
Size: 594 Bytes
Versions: 10
Compression:
Stored size: 594 Bytes
Contents
import { Controller } from "@hotwired/stimulus" export default class extends Controller { initialize() { this.abortController = new AbortController() } disconnect() { this.abortController.abort() } connect() { this.#supportsOTP && this.#requestOTP() } #requestOTP() { navigator.credentials.get(this.#options).then(otp => { this.element.value = otp.code }).catch(error => {}) } get #options() { return { otp: { transport: ["sms"] }, signal: this.abortController.signal } } get #supportsOTP() { return "OTPCredential" in window } }
Version data entries
10 entries across 10 versions & 1 rubygems