mirror of
https://github.com/arx-research/libhalo.git
synced 2026-01-09 13:18:04 -05:00
107 lines
4.7 KiB
HTML
107 lines
4.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<!--
|
|
LibHaLo - Programmatically interact with HaLo tags from the web browser, mobile application or the desktop.
|
|
Copyright by Arx Research, Inc., a Delaware corporation
|
|
License: MIT
|
|
-->
|
|
<title>LibHaLo Demo</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
|
|
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
|
|
|
<script type="text/javascript">
|
|
// ensure the library is always fully reloaded
|
|
document.write('<script src="../dist/libhalo.js?_v=' + (Math.random() + '') + '"></scr' + 'ipt>');
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div class="container mt-3 mb-5">
|
|
<h1>LibHaLo Demo</h1>
|
|
<p>
|
|
This demo will help you to reconfigure the NDEF URL feature.
|
|
</p>
|
|
|
|
<strong>URL flags:</strong>
|
|
<div id="flags"></div>
|
|
|
|
<div class="mt-4 mb-4">
|
|
<strong>Number of the additional key slot:</strong>
|
|
<input type="text" class="form-control" id="pkN" value="4">
|
|
<p class="text-muted">This is only relevant if <code>command.flagShowPkN</code> is ON.</p>
|
|
</div>
|
|
|
|
<strong>Status text:</strong>
|
|
<pre id="statusText" style="white-space: pre-wrap; word-break: break-all;">Please click on one of the buttons below.</pre>
|
|
|
|
<button class="btn btn-primary" onclick="btnExecuteNFC();" id="btn-generate">
|
|
Set URL flags
|
|
</button>
|
|
|
|
<script type="text/javascript">
|
|
const FLAGS = {
|
|
flagUseText: ["Use text NDEF record instead of URL record (this would disable iPhone background tag reading)."],
|
|
flagHidePk1: ["Hide public key #1."],
|
|
flagHidePk2: ["Hide public key #2."],
|
|
flagHidePk3: ["Hide public key #3."],
|
|
flagShowPk1Attest: ["Show public key #1 attest signature (only if public key #1 is shown)."],
|
|
flagShowPk2Attest: ["Show public key #2 attest signature (only if public key #2 is shown)."],
|
|
flagHideRNDSIG: ["Hide 'rnd' and 'rndsig' fields."],
|
|
flagHideCMDRES: ["Hide 'cmd' and 'res' fields (this would disable WebNFC)."],
|
|
|
|
flagShowPk3Attest: ["Show public key #3 attest signature."],
|
|
flagShowLatch1Sig: ["Show latch #1 attest signature."],
|
|
flagShowLatch2Sig: ["Show latch #2 attest signature."],
|
|
flagLegacyStatic: ["Use legacy public key format with the 'static' field."],
|
|
flagShowPkN: ["Show additional public key (requires public key #3 to be hidden)."],
|
|
flagShowPkNAttest: ["Show additional public key's attest signature."],
|
|
flagRNDSIGUseBJJ62: ["Use BJJ key slot 0x62 for 'rndsig' signature (only on selected tag batches)."]
|
|
};
|
|
|
|
for (let flag of Object.keys(FLAGS)) {
|
|
document.getElementById('flags').innerHTML += '<div class="form-check">' +
|
|
'<input class="form-check-input" type="checkbox" id="' + flag + '">' +
|
|
' <label class="form-check-label" for="' + flag + '">' +
|
|
' ' + FLAGS[flag][0] + ' (<code>command.' + flag + '</code>)' +
|
|
' </label>' +
|
|
'</div>';
|
|
}
|
|
|
|
function btnExecuteNFC() {
|
|
let command = {
|
|
name: "cfg_ndef",
|
|
pkN: parseInt(document.getElementById('pkN').value)
|
|
};
|
|
|
|
for (let flag of Object.keys(FLAGS)) {
|
|
command[flag] = document.getElementById(flag).checked;
|
|
}
|
|
|
|
document.getElementById('statusText').innerText = 'Executing command: ' + JSON.stringify(command);
|
|
|
|
execHaloCmdWeb(command)
|
|
.then((res) => {
|
|
// operation succeeded, display the result to the user
|
|
document.getElementById('statusText').innerText = 'Result: ' + JSON.stringify(res);
|
|
})
|
|
.catch((e) => {
|
|
console.error(e);
|
|
|
|
if (e instanceof NFCAbortedError) {
|
|
// in case of multiple calls to executeNFCCommand(), for example when somebody is mashing
|
|
// a button, all calls except one will fail by throwing NFCAbortedError
|
|
// this exception should be ignored on the frontend
|
|
} else {
|
|
// the operation has failed, display the reason to the user
|
|
document.getElementById('statusText').style.color = 'black';
|
|
document.getElementById('statusText').innerText = e;
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</div>
|
|
</body>
|
|
</html>
|