[Optional] Identity Verification
const crypto = require('crypto');
const secretKey = <hmacSecretKey>; // Replace this with the secretKey from Saturn Dashboard
const userIdentifier = current_user.id.toString();
const hash = crypto.createHmac('sha256', secretKey).update(userIdentifier).digest('hex');/**
* @param {string} uid - [Required] User ID
* @param {string} email - [Optional] User Email
* @param {string} name - [Optional] User Name
*/
const initSaturnUser = (uid, email, name) => {
if (!uid) return;
// Backend Call
getUserHmacHash(userData.uid).then((hash) => {
if (window?.$saturn && window?.$saturn?.isLoaded) {
window.$saturn.setUser(uid, {
email: email,
name: name,
identifierHash: hash,
});
} else {
window.addEventListener(
"saturn:ready",
function () {
window.$saturn.setUser(uid, {
email: email,
name: name,
});
},
{ once: true }
);
}
});
};Last updated