Our no-code/low-code approach is embodied in Widget. Deployment onto any web property is as simple as adding a script to the <head> tag of your index.html file:
const isWidgetReady = () => typeof window !== 'undefined' && 'Sesame' in window
if (isWidgetReady()) {
// call API methods
}
window.Sesame.open()
window.Sesame.close()
window.Sesame.hide()
window.Sesame.show()
const authData = {
payload: 'VU7CJfh7jivtbeP7dlbPe5QkCRo3kRzuUJWiAu/vtmhF+kl9+s6d7p4XMx3wlLCPHMWMGEtQgs+oz1ePVehYgd6m+MXuKiGeBGjk7pPjlh/iQrjT7y/uhftuccZNG6H0LepW8kF2coQPu6QDtmA7qDOPkD02m2bI0LtShaCZ8M6xydM=',
publicKey: 'yGsboXRCQ/I1W9hLWP1cM1mRWxA5wyX0ShowXcj+V0k=',
nonce: 'PwZPaFup7uhgmq8HOoX+IZtDSpL66iau'
} - comes from client BE side
window.Sesame.login(authData)
import nacl from 'tweetnacl'
import naclUtil from 'tweetnacl-util'
const msgParams = {
walletAddress: '0x1234', // wallet address of the user to log in
nonce: 'any string', //signed nonce
}
// function call should be next
const aData = encrypt('PUBLIC_KEY', JSON.stringify(msgParams))
export function encrypt(receiverPublicKey: string, msgParams: string) {
const ephemeralKeyPair = nacl.box.keyPair()
const pubKeyUInt8Array = naclUtil.decodeBase64(receiverPublicKey)
const msgParamsUInt8Array = naclUtil.decodeUTF8(msgParams)
const nonce = nacl.randomBytes(nacl.box.nonceLength)
const encryptedMessage = nacl.box(
msgParamsUInt8Array,
nonce,
pubKeyUInt8Array,
ephemeralKeyPair.secretKey,
)
return {
payload: naclUtil.encodeBase64(encryptedMessage),
publicKey: naclUtil.encodeBase64(ephemeralKeyPair.publicKey),
nonce: naclUtil.encodeBase64(nonce),
}
}