2.0.0-prerelease.7 • Published 9 months ago

auth-sl v2.0.0-prerelease.7

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

splinterlands-auth

Splinterlands library for authentication (backend + frontend)

  • modules/frontend should be used on the frontend to generate the required data
  • modules/backend should be used on the backend to verify the previously generated and then submitted data
// On the frontend

const auth = new Auth();
const result = await auth.frontend.hive(address);

if (result.status === 'success') {
  if(result.flow === 'hivesigner') {
    const { address, expiresIn, token } = result.data;
    // call endpoint and send address, token
  } else {
    const {sig, ts} = result. result.data
    // call endpoint and send address, sig, ts
  }
  
}

// On the backend
// if sig & ts
const result =  auth.backend.hive(address, sig, ts);
if(result.status === 'success') {
  // great success!
}

// if token
const result =  auth.backend.hivesigner(address, token);
if(result.status === 'success') {
  // great success!
}