Sha256: 134de96888a2dce8addff818be3e11b4a28200a7d3e9485d5a261bd80f0f5626
Contents?: true
Size: 624 Bytes
Versions: 18
Compression:
Stored size: 624 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 => { console.log(error) }) } get #options() { return { otp: { transport: ["sms"] }, signal: this.abortController.signal } } get #supportsOTP() { return "OTPCredential" in window } }
Version data entries
18 entries across 18 versions & 1 rubygems