Getting Started
Use our provided javascript function in your own HTML website to easily verify the digital signatures emitted by Legitimate's NFC tags
Add the JS snippet
<head>
<script type="text/javascript">
(function(){var a=document.createElement('style');a.innerHTML=`
body { display: none !important; }
`;document.head.appendChild(a);var b='https://api.legitimate.tech/external/v1/tags/verify';document.addEventListener('DOMContentLoaded',()=>{console.log('DOM loaded, making API request');fetch(b,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(Object.fromEntries(new URLSearchParams(window.location.search)))}).then(async A=>{var _=await A.json();if(!A.ok){A.status===422&&_.errors.cmac.indexOf('has expired')!==-1?c('expired_cmac'):c();return}!_.errors?a.innerHTML=`
body { display: block !important; }
#legitimate-custom-error-message { display: none !important; }
#legitimate-expired-cmac-message { display: none !important; }
`:c()}).catch(()=>c())});function c(B='default'){let C=document.getElementById('legitimate-error-message-container');!C&&(console.log('Creating error message container'),C=document.createElement('div'),C.id='legitimate-error-message-container',document.body.appendChild(C));let _c=`
<div style="font-family: sans-serif; color: red; padding: 2rem; text-align: center;">
An error occurred. Please try again later.
</div>
`;if(B==='expired_cmac'){var d=document.getElementById('legitimate-expired-cmac-message');d&&(console.log('Using expired cmac error message'),_c=d.innerHTML)}else{var e=document.getElementById('legitimate-custom-error-message');e&&(console.log('Using custom error message'),_c=e.innerHTML)}C.innerHTML=_c;a.innerHTML=`
body { display: block !important; }
body > *:not(#legitimate-error-message-container) { display: none !important; }
`}})();
</script>
<!-- other code that may need to go into the head element -->
</head>What this script does
Adding Custom Error States
Reused Digital Signature Parameters Error Message
Default Error State Message
Last updated
Was this helpful?

