Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Blisache-html

blisache-html is a javascript package providing handlers to be hooked as html <form> submit event listener.

In the example below you register the function registerHandleSubmit as submit event listener on all elements tagged with blisacheRegister class.

import { registerHandleSubmit } from "blisache-html";

document.querySelectorAll('.blisacheRegister').forEach(form => {
  form.addEventListener("submit", registerHandleSubmit);
});

Then you define your registration form :

<form action="/register" method="post" class="blisacheRegister">
    <input type="email" name="email" data-blisache-login />
    <input type="text" name="name" data-blisache-name />
    <input type="text" name="custom_data" />
    <button type="submit">Register</button>
</form>

When this form is submited the registerHandleSubmit event handler is called. Data from the form inputs are fetched through the custom attributes data-blisache-login and data-blisache-name and are passed to the register() function from blisache-client. There is a data-blisache-credential_id custom attribute available to wire data to the credential_id field of the credential_revoke() function.

The register() function outputs message and signature as bytes arrays.

The handler then appends two new inputs to your form - blisache_message and blisache_signature - containing respectively message and signature data base64 encoded.

The form is then sent to your backend’s endpoint for processing. Notice that you can add more data to your form like the additional custom_data input. When receiving this form on server-side there will be 5 fields :

  • email
  • name
  • custom_data
  • blisache_message
  • blisache_signature

You need to verify blisache_signature against blisache_message to be sûre that data comes from blisache servers and has not been altered.

blisache_message and blisache_signature then can be base64 decoded and json deserialized according to the BlisacheResponse or BlisacheErrorResponse formats.