Projet

Général

Profil

Fonctionnalité #21979 » ts_fortify.html

Caroline DISTRIQUIN, 03/08/2022 15:52

 
<html>
<head>
<title>Fortify - Doctolib</title>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap" rel="stylesheet">
<!-- Components -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@peculiar/fortify-webcomponents/dist/peculiar/peculiar.esm.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@peculiar/fortify-webcomponents/dist/peculiar/peculiar.css">
<!-- Babel Polyfill -->
<script src="https://fortifyapp.com/external/babel-polyfill/6.26.0/polyfill.min.js"></script>
<!-- WebCrypto Socket -->
<script src="https://fortifyapp.com/external/protobuf/6.8.0/protobuf.min.js"></script>
<!--script src="src/protobuf.js"></script> -->
<!--script src="https://fortifyapp.com/external/webcrypto-local/client/1.1.7/webcrypto-socket.min.js"></script> -->
<script src="https://fortifyapp.com/external/webcrypto-local/client/1.1.7/webcrypto-socket.min.js"></script>
<!-- script src="src/webcrypto-socket.js"></script> -->
<style>
body {
height: 100vh;
background: #6D7D87;
}

peculiar-fortify-certificates {
max-width: 660px;
width: calc(100% - 20px);
margin: 20px auto;
}
</style>

</head>
<body>
<h1>Fortify - Doctolib - Original Certificate Test</h1>
<hr>
<peculiar-fortify-certificates
id="fortify-certificates-wc"
language="en"
/>
<script>
async function main() {
self.ws = new WebcryptoSocket.SocketProvider({
storage: await WebcryptoSocket.BrowserStorage.create(),
});
ws.connect("127.0.0.1:31337")
.on("error", function (e) {
console.error(e);
})
.on("listening", async (e) => {
// Check if end-to-end session is approved
if (! await ws.isLoggedIn()) {
const pin = await ws.challenge();
// show PIN
setTimeout(() => {
alert("2key session PIN:" + pin);
}, 100)
// ask to approve session
await ws.login();
}

ws.cardReader
.on("insert", updateProvider)
.on("remove", updateProvider);
});
}

async function updateProvider() {
const info = await ws.info();
for (const provider of info.providers) {
console.log('Provider:' + provider.id + ', name=' + provider.name + ', atr=' + provider.atr);
const crypto = await ws.getCrypto(provider.id);
await crypto.reset();
}
}

main() ;
var fortifyCertificates = document.getElementById('fortify-certificates-wc');
// All possible propertiest you can find on the documentation page
// https://fortifyapp.com/docs/webcomponents/fortify-certificates/readme#properties
fortifyCertificates.debug = true;
fortifyCertificates.filters = {
expired: false,
//onlySmartcards: false,
onlyWithPrivateKey: true,
keyUsage: ['digitalSignature'],
//subjectDNMatch: 'kubernetes-master',
//issuerDNMatch: 'kubernetes',
providerNameMatch: 'Windows CryptoAPI',
//providerATRMatch: '3B7F96000080318065B0850300EF120FFE829000', // INCA
//providerATRMatch: '3BDB960080B1FE451F830031C164084022300F90000A', // Certigna
//certificateIdMatch: '0123456789',
};

fortifyCertificates.addEventListener('selectionCancel', () => {
console.log('cancel flow');
});

fortifyCertificates.addEventListener('selectionSuccess', (result) => {
console.log(result);
});
</script>
</body>
</html>
    (1-1/1)