PageSourceSearch

https://accounts.adafruit.com/assets/components/credential-ac4b9a94.js

js adafruit.com collected 2026-10-01 07:51:23 UTC 2,071 bytes, 69 lines download raw bytes

1import * as WebAuthnJSON from "@github/webauthn-json";
2
3function getCSRFToken() {
4  var CSRFSelector = document.querySelector('meta[name="csrf-token"]')
5  if (CSRFSelector) {
6		return CSRFSelector.getAttribute("content")
7	} else {
8		return null
9	}
10}
11
12function callback(url, body) {
13  fetch(url, {
14    method: "POST",
15    body: JSON.stringify(body),
16    headers: {
17      "Content-Type": "application/json",
18      "Accept": "application/json",
19      "X-CSRF-Token": getCSRFToken()
20    },
21    credentials: 'same-origin'
22  }).then(function(response) {
23    if (response.ok) {
24      return response.json();
25    } else {
26      throw new Error('Invalid credentials. Please try again or use an alternative two factor method.');
27    }
28  }).then(function(data) {
29    if (data.redirect) {
30      window.location.replace(data.redirect_url);
31    }
32  }).catch(function(error) {
33    console.log(error.message);
34    const alertElement = document.querySelector('.alert-js');
35    if (alertElement) {
36      alertElement.classList.add('alert-danger');
37      alertElement.classList.remove('alert-info');
38      alertElement.innerHTML += error.message;
39      alertElement.style.display = 'block';
40    }
41  });
42}
43
44function create(callbackUrl, credentialOptions) {
45  WebAuthnJSON.create({ "publicKey": credentialOptions }).then(function(credential) {
46    callback(callbackUrl, credential);
47  }).catch(function(error) {
48    console.log(error);
49  });
50}
51
52function get(credentialOptions) {
53  WebAuthnJSON.get({ "publicKey": credentialOptions }).then(function(credential) {
54
55    callback("/users/validate_credentials", credential);
56  }).catch(function(error) {
57    var message = "Invalid credentials or the request has timed out. Please sign in again or use an alternative two factor method."
58    const alertElement = document.querySelector('.alert-js');
59    if (alertElement) {
60      alertElement.classList.add('alert-danger');
61      alertElement.classList.remove('alert-info');
62      alertElement.innerHTML += message;
63      alertElement.style.display = 'block';
64    }
65  });
66}
67
68export { create, get }
69

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.