ts_fortify.html
1 |
<html>
|
---|---|
2 |
<head>
|
3 |
<title>Fortify - Doctolib</title> |
4 |
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap" rel="stylesheet"> |
5 |
<!-- Components -->
|
6 |
<script type="module" src="https://cdn.jsdelivr.net/npm/@peculiar/fortify-webcomponents/dist/peculiar/peculiar.esm.js"></script> |
7 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@peculiar/fortify-webcomponents/dist/peculiar/peculiar.css"> |
8 |
|
9 |
<!-- Babel Polyfill -->
|
10 |
<script src="https://fortifyapp.com/external/babel-polyfill/6.26.0/polyfill.min.js"></script> |
11 |
<!-- WebCrypto Socket -->
|
12 |
<script src="https://fortifyapp.com/external/protobuf/6.8.0/protobuf.min.js"></script> |
13 |
<!--script src="src/protobuf.js"></script> -->
|
14 |
<!--script src="https://fortifyapp.com/external/webcrypto-local/client/1.1.7/webcrypto-socket.min.js"></script> -->
|
15 |
<script src="https://fortifyapp.com/external/webcrypto-local/client/1.1.7/webcrypto-socket.min.js"></script> |
16 |
<!-- script src="src/webcrypto-socket.js"></script> -->
|
17 |
<style>
|
18 |
body {
|
19 |
height: 100vh;
|
20 |
background: #6D7D87;
|
21 |
}
|
22 |
|
23 |
peculiar-fortify-certificates {
|
24 |
max-width: 660px;
|
25 |
width: calc(100% - 20px);
|
26 |
margin: 20px auto;
|
27 |
}
|
28 |
</style>
|
29 |
|
30 |
</head>
|
31 |
<body>
|
32 |
<h1>Fortify - Doctolib - Original Certificate Test</h1> |
33 |
<hr>
|
34 |
<peculiar-fortify-certificates
|
35 |
id="fortify-certificates-wc" |
36 |
language="en" |
37 |
/>
|
38 |
<script>
|
39 |
|
40 |
async function main() {
|
41 |
self.ws = new WebcryptoSocket.SocketProvider({
|
42 |
storage: await WebcryptoSocket.BrowserStorage.create(),
|
43 |
});
|
44 |
ws.connect("127.0.0.1:31337")
|
45 |
.on("error", function (e) {
|
46 |
console.error(e);
|
47 |
})
|
48 |
.on("listening", async (e) => {
|
49 |
// Check if end-to-end session is approved
|
50 |
if (! await ws.isLoggedIn()) {
|
51 |
const pin = await ws.challenge();
|
52 |
// show PIN
|
53 |
setTimeout(() => {
|
54 |
alert("2key session PIN:" + pin);
|
55 |
}, 100)
|
56 |
// ask to approve session
|
57 |
await ws.login();
|
58 |
}
|
59 |
|
60 |
ws.cardReader
|
61 |
.on("insert", updateProvider)
|
62 |
.on("remove", updateProvider);
|
63 |
});
|
64 |
}
|
65 |
|
66 |
async function updateProvider() {
|
67 |
const info = await ws.info();
|
68 |
for (const provider of info.providers) {
|
69 |
console.log('Provider:' + provider.id + ', name=' + provider.name + ', atr=' + provider.atr);
|
70 |
const crypto = await ws.getCrypto(provider.id);
|
71 |
await crypto.reset();
|
72 |
}
|
73 |
}
|
74 |
|
75 |
main() ;
|
76 |
|
77 |
|
78 |
|
79 |
var fortifyCertificates = document.getElementById('fortify-certificates-wc');
|
80 |
// All possible propertiest you can find on the documentation page
|
81 |
// https://fortifyapp.com/docs/webcomponents/fortify-certificates/readme#properties
|
82 |
fortifyCertificates.debug = true;
|
83 |
fortifyCertificates.filters = {
|
84 |
expired: false,
|
85 |
//onlySmartcards: false,
|
86 |
onlyWithPrivateKey: true,
|
87 |
keyUsage: ['digitalSignature'],
|
88 |
//subjectDNMatch: 'kubernetes-master',
|
89 |
//issuerDNMatch: 'kubernetes',
|
90 |
providerNameMatch: 'Windows CryptoAPI',
|
91 |
//providerATRMatch: '3B7F96000080318065B0850300EF120FFE829000', // INCA
|
92 |
//providerATRMatch: '3BDB960080B1FE451F830031C164084022300F90000A', // Certigna
|
93 |
//certificateIdMatch: '0123456789',
|
94 |
};
|
95 |
|
96 |
fortifyCertificates.addEventListener('selectionCancel', () => {
|
97 |
console.log('cancel flow');
|
98 |
});
|
99 |
|
100 |
fortifyCertificates.addEventListener('selectionSuccess', (result) => {
|
101 |
console.log(result);
|
102 |
});
|
103 |
</script>
|
104 |
</body>
|
105 |
</html>
|