Skip to content

SDK - Auth

Authenticate Session

let resp = await convo.auth.authenticate(
    signerAddress, // Ethereum Address or NEAR Public Key
    signature, // Signed Data in Hex
    timestampm  // Signed Data in Hex
    chain, // Name of the Chain
    accountId: // Near Account Id
);

Example Usage,

let timestamp = Date.now();
let data = convo.auth.getSignatureData(accounts[0], timestamp);
let signature = await web3.send(
    'personal_sign',
    [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(data)), accounts[0].toLowerCase()]
);
convo.auth.authenticate(accounts[0], signature, timestamp, "ethereum").then(console.log);

Validate Authentication

let resp = await convo.auth.validate(
    signerAddress, // Ethereum Address or NEAR Public Key
    token // JWT Auth Token
);

Example,

convo.auth.validate(
    accounts[0],
    ""
).then(console.log);

Get Signature Data

let resp = convo.auth.getSignatureData(
    signerAddress, // Ethereum Address or NEAR Public Key
    timestamp // timestamp
);

Example,

let timestamp = Date.now();
console.log(convo.auth.getSignatureData(accounts[0], timestamp));