Skip to content

Instantly share code, notes, and snippets.

@JWally
Last active January 27, 2024 12:30
Show Gist options
  • Save JWally/3b462b9b3e7b9f6885fa77cf71312d6d to your computer and use it in GitHub Desktop.
Save JWally/3b462b9b3e7b9f6885fa77cf71312d6d to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head><meta charSet="utf-8"/></head>
<body><h1>GOODBYE FRAUD!</h1></body>
<!-- Adding library from NPM via UNPKG -->
<script type="module" >
// Pull Library from CDN
import {XRAY} from 'https://unpkg.com/@keyri/xray/index.mjs';
const _xray = new XRAY(); // Instantiate the wrapper class
await _xray.load(); // Load the library into memory
const xray = _xray.xray; // `.xray` is the actual worker here
// THIS GIVES YOU ALL YOU NEED -
// SOMEHOW SEND IT TO YOUR SERVER FOR PROCESSING!
// (extra form field, xhr json data, whatever)
let encrypted_fraud_data = await xray.scan({"apiUrl": "local"});
// USE YOUR OWN API IN REAL LIFE!!!
const your_data_handler_url = "https://abcdefghijk.execute-api.xx-yyy-z.amazonaws.com/prod";
try{
// Send the data to your server
const data_response = await fetch(your_data_handler_url, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(encrypted_fraud_data)
});
// This is whatever _YOUR_ server returns
const data = await data_response.json();
// Cool things go here! Or not!
} catch(e){
console.error(e);
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment