Static CreateCreates a directory session from an URL.
The directory session object, that will try the authentication upon calling the authenticate functions.
Static DecodeDecodes the hash content and sends the token to the caller of DirectorySessionInterface.getPopupBasedAuthenticationUrl in case of popup based authentications.
This will trigger the DirectorySessionInterfaceSignal.LoginSuccess signal on the tab that called DirectorySessionInterface.getPopupBasedAuthenticationUrl.
This function makes use of the LocalStorage of the browser.
/**
* Sample to illustrate the use of the authentication in the popup based authentication.
*/
import { DirectorySessionFactory } from 'generated_files/documentation/appinfiniteapi';
if (window.location.hash)
{
// try to decode the authentication hash.
if (DirectorySessionFactory.DecodeAuthenticationHash(window.location.hash))
{
// everything is fine, the other tab is notified
// just need to close the tab
window.close();
}
else {
// output some debug error message.
console.log('Error: unable to decode hash content of authentication');
// display error
const lError: HTMLElement = document.getElementById('error');
lError.textContent = 'Unable to decode hash content of authentication';
}
}
else
{
// we have no hash => go back to main page
// get the url content
const lPath = window.location.pathname;
const lOffset : number = lPath.lastIndexOf('/');
// replace 'authentication.html' by main page 'index.html'
if (lOffset >= 0)
{
// create new location
const sLocation = window.location.origin + lPath.substring(0, lOffset) + '/index.html';
// ang go
window.location.href = sLocation;
}
}
true if the hash was correctly decoded.
The DirectorySessionFactory factory allows to create a DirectorySessionInterface to authenticate onto a 3djuump Infinite directory.
It also provides also a way to decode authentication hashes that are retrieved on the authentication hashes in case of popup based authentication. The authentication system is based on OpenID Connect layer.
The directory session will try to connect to the given Host.
Please refer to Authentication Samples for more explanations about Sessions.
See
DirectorySessionInterface