Sha256: 28a40dc5c6d4956e538318c41c371879ed036905cd10c117e3e4226c0fd72852
Contents?: true
Size: 625 Bytes
Versions: 10
Compression:
Stored size: 625 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
10 entries across 10 versions & 1 rubygems