This document explains the way to process user login and membership information using DID from external services, as a standard for Frontend developers (WebView in the case of web or native app).
didconnect/didconnect.min.js at main · head77x/didconnect
didconnect/didconnect.min.js.map at main · head77x/didconnect
Or Using CDN:
<script src="https://did.gavrint.com/didconnect.min.js"></script>
Using the didconnect.init
function declared in the window
object of JS, the argument passed is the parent window
object requesting the DID login.
After that, two declarations are needed for event handling. Since DIDLogin result is delivered to 'DIDSignInOnSuccess' event and 'DIDSignInOnFailure' event from didconnenct, declare related event listeners.
window.didconnect.init(window);
window.addEventListener('DIDSignInOnSuccess', (returnvalue) => {
// After successful DID login, signing related values and personal information values are delivered - Refer to 3. The value returned after the DID success
});
window.addEventListener('DIDSignInOnFailure', (returnvalue) => {
// Returned result of DID login cancellation or failure
});
You need to open DID in a new pop-up window, and pass signkey (a unique string value to check if the user has gone through the normal login process on your server) and fromwhere (the address of the app calling SSO) as GET parameters in the URL.
let params = encodeURI('signkey='+this.signkeystring+'&fromwhere='+this.requesterHostURL);
let trying = await window.didconnect.signIn(window, params);
The result is delivered in JSON format, and using the userIdentity and signature values, it is necessary to confirm the normal DID access of the final user on your server.
{
protocol: 'App Version',
result: 'OK', // 'Failed', 'Cancel', etc will return with 'msg' for error message
msg: 'Error message',
userIdentity: 'User unique identify key string',
signature: 'DID signature result',
data: {
realname: 'User real name',
mobile: 'User mobile number',
email: 'User email address',
passport: 'User passport information',
birthyear: 'User birth year',
birthmonth: 'User birth month',
birthday: 'User birth day',
address: 'User real address',
emergency: 'Emergency contact information'
}
}