Skip to main content

Arcana Auth

The login SDK is used to setup social logins for users of the dApp. Upon logging in the SDK also reconstructs the private key of the user using stored key shares which is then used to sign transactions for any operation to prove authenticity. Arcana SDK to perform logins on your app.

Installation#

Using NPM/Yarn#

npm install --save @arcana/auth
yarn add @arcana/auth

Using CDN#

<script src="https://cdn.jsdelivr.net/npm/@arcana/auth"></script>
<script src="https://unpkg.com/@arcana/auth"></script>

Usage#

Initialise the SDK#

const { AuthProvider } = window.arcana.auth;
// or
import { AuthProvider } from '@arcana/auth';
const auth = new AuthProvider({
appID: <appID>,
network: 'testnet'
redirectUri:'',
oauthCreds: [{
type: 'google',
clientID: '',
},
{
type: 'twitter',
clientID: '',
},
{
type: 'github',
clientID: '',
},
{
type: 'discord',
clientID: '',
}]
})

On redirect Page#

const { AuthProvider } = window.arcana.auth;
// or
import { AuthProvider } from '@arcana/auth';
window.onload = () => {
AuthProvider.handleRedirectPage(<origin>);
};

Initiate login#

await auth.loginWithSocial(<loginType>);

Get user info#

const userInfo = auth.getUserInfo();
/*
UserInfo: {
loginType: 'google',
userInfo: {
id: 'abc@example.com',
name: 'ABC DEF',
email: '',
picture: ''
},
privateKey: ''
}
*/

Get public key#

const userInfo = await auth.getPublicKey({
verifier: <loginType>,
id: <email | username>,
});

Check if user already logged in#

const loggedIn = auth.isLoggedIn();
if (!loggedIn) {
await auth.loginWithSocial(<loginType>);
}
const userInfo = auth.getUserInfo()

Clear login session#

await auth.logout();

Variables#

  • loginType - discord, twitter, github, google, twitch, reddit
  • origin - Base url of your app.