Auth SDK
In this tutorial you will learn how to integrate your dApp with Arcana Auth SDK.
Prerequisites
- Make sure you can access Arcana Developer Dashboard:
- Install the
@arcana/auth
package. For details, see Arcana Auth Quick Start Guide.
Steps
To integrate your dApp with Arcana Auth SDK, you need to simply configure the dApp user experience settings and initialize the Auth SDK with requisite details.
Step 1: Register and Configure dApp User Experience
Log in to the Arcana Developer Dashboard. Register your app by creating a new entry for it and specifying dApp name. Configure your dApp settings as per the user experience that you wish to provide in your dApp:
User Authentication experience: Click on the
Auth
tab in the dashboard and choose from a list of supported authentication mechanisms:- Discord
- GitHub
- Twitch
You may be required to configure additional details such as origin and redirect URI or email ID etc., depending upon your use case and choice of authentication mechanisms. Refer to social OAuth and passwordless login for details.
Wallet UI
Arcana Auth SDK provides a standard Ethereum provider that can be used by dApps for enabling users to sign data access blockchain transactions. The Wallet UI setting is used to tailor user experience for signing blockchain transactions. Choose the wallet UI mode as per your dApp requirements. If the Wallet UI mode is enabled, users need to manually approve all file access operations and sign them. By default it is disabled whereby all file access operations initiated by the dApp user are automatically approved.
note
Besides these configuration settings, you can leave the other settings to default. You can also modify other settings. See how to configure your dApp guide for details on other settings related to user data storage, bandwidth usage, dApp branding etc.
Once your dApp is configured, Save the settings on the dashboard. Make sure you note down the appID assigned to your newly configured dApp. This will be required to initialize the Arcana Auth SDK.
Step 2: Initialize the Auth SDK
Create AuthProvider from the Auth SDK and call init function to initialize the SDK. The dApp must wait until the initialization is complete before invoking any of the other Auth SDK functions such as triggering login, encryption/decryption, or obtaining public keys etc.
Import the AuthProvider:
import { AuthProvider } from '@arcana/auth'
Create and initialize AuthProvider. You need to specify the appID assigned to your dApp in the previous step. In the example below, appID is '20':
const auth = new AuthProvider('20')
await auth.init({
//appMode can be 0, 1, or 2 depending upon wallet UI mode that needs to be configured
// no ui, widget, full ui modes.
appMode: 2,
position: "right",
});
provider = auth.getProvider()
// or
provider = window.ethereumnote
If your dApp requires to enable storage operations for the users, you also need to integrate with Arcana Storage SDK. Save this Ethereum provider exposed by the Auth SDK in the dApp. It will be required to initialize and access Storage SDK functions.
That is all! 🎉
You have successfully integrated your dApp with the Auth SDK and can invoke any supported functions.
What's Next?
Once you have integrated with Arcana Auth SDK, you can onboard dApp users through social authentication and passwordless login. Also, you can use the Auth SDK for encrypting data, decrypting data.
To enable user data privacy by allowing authenticated users to control data access, you need to integrate with Arcana Storage SDK as well. The Storage SDK allows dApp users to control data access by signing blockchain transactions corresponding to any storage operations. This includes file store, retrieve, share, revoke access, change file ownershipbe and more.
Refer to the following how to guides for details:
- Upload, Download or delete a file from the Arcana Store
- Share, Revoke access for file data in Arcana store
- Change file owner or transfer file ownership
See also
- Social authentication using Auth SDK: Google
- Passwordless authentication using Auth SDK
- Auth SDK Errors
- Minting private NFTs using Arcana Network
- Viewing private NFTs using Arcana Network