Last active
May 15, 2018 17:25
-
-
Save microshine/cf6d154c5c7e9cffa1e40c2adfa77e1f to your computer and use it in GitHub Desktop.
fortify token event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- Data signing/verify --> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Example #5</title> | |
<script src="https://peculiarventures.github.io/pv-webcrypto-tests/src/promise.js"></script> | |
<script src="https://peculiarventures.github.io/pv-webcrypto-tests/src/es5-shim.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.js"></script> | |
<script src="https://peculiarventures.github.io/pv-webcrypto-tests/src/webcrypto-liner.min.js"></script> | |
<script src="https://peculiarventures.github.io/pv-webcrypto-tests/src/asmcrypto.js"></script> | |
<script src="https://peculiarventures.github.io/pv-webcrypto-tests/src/elliptic.js"></script> | |
<script src="https://cdn.rawgit.com/dcodeIO/protobuf.js/6.8.0/dist/protobuf.js"></script> | |
<script src="https://cdn.rawgit.com/jakearchibald/idb/97e4e878/lib/idb.js"></script> | |
<script src="https://min.gitcdn.link/repo/undoZen/fetch/master/fetch.js"></script> | |
<script src="https://peculiarventures.github.io/webcrypto-local/webcrypto-socket.js"></script> | |
<script src="https://peculiarventures.github.io/fortify-examples/src/pvtsutils.js"></script> | |
</head> | |
<body> | |
<script> | |
var ws = new WebcryptoSocket.SocketProvider(); | |
var isOpen = false; | |
ws.connect("127.0.0.1:31337") | |
.on("error", function (e) { | |
console.error(e); | |
}) | |
.on("listening", async e => { | |
const isLoggedIn = await ws.isLoggedIn(); | |
if (!isLoggedIn) { | |
const challenge = await ws.challenge(); | |
alert(`Challenge: ${challenge}`); | |
await ws.login(); | |
} | |
const info = await ws.info(); | |
const provider = info.providers[0]; | |
const crypto = await ws.getCrypto(provider.id); | |
const hash = await crypto.subtle.digest("SHA-256", new Uint8Array([1, 0, 1])); | |
console.log("SHA-256:", pvtsutils.Convert.ToHex(hash)); | |
}) | |
.on("token", function (info) { | |
console.log("Token", info); | |
}) | |
.on("close", function () { | |
console.log("CLOSE"); | |
}); | |
ws.cardReader.on("insert", (info) => { | |
console.log("SCARD:INSERT", info); | |
}); | |
ws.cardReader.on("remove", (info) => { | |
console.log("SCARD:REMOVE", info); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment