How to Implement Wallet Authentication with WeaveDB

How to Implement Wallet Authentication with WeaveDB

Introduction

Authentication is an important aspect of building with WeaveDB, ensuring secure access to your data and the user experience. In this guide, we will cover the integration process for five wallet platforms supported by WeaveDB that enables seamless and secure interactions for your decentralized applications (Dapps).

What are these Integrations and how do they work with WeaveDB?

WeaveDB provides support for various wallet integrations, each offering solution to different blockchain ecosystems and authentication methods. Here's a brief overview of the integrations covered in this guide:

  1. Metamask (EVM - secp256k1):

    Metamask is a popular Ethereum wallet that allows users to manage their Ethereum-based assets and interact with decentralized applications.

    • Authentication Method: Authentication is achieved through EIP-712 signatures using the secp256k1 elliptic curve.
  2. Internet Identity (DFINITY - ed25519):

    Internet Identity is an authentication solution on the DFINITY blockchain, enabling biometric authentication on any device.

    • Authentication Method: Authentication is accomplished using ed25519 signatures.
  3. ArConnect (Arweave - rsa256):

    ArConnect is a simple browser wallet designed for the Arweave blockchain, facilitating easy storage and management of Arweave tokens.

    • Authentication Method: Authentication involves using rsa256 signatures for Arweave transactions.
  4. IntmaxWallet (Intmax zkRollup - secp256k1-2 | poseidon):

    Intmax is a highly scalable Ethereum Layer 2 (L2) zkRollup with privacy features for web applications.

    • Authentication Method: IntmaxWallet supports authentication using secp256k1-2 and poseidon algorithms.
  5. Lens Profile (Lens Protocol - secp256k1-2):

    Lens Protocol is a Polygon-based NFT social protocol that utilizes the Lit Protocol for secure authentication of Lens Profile NFTs.

    • Authentication Method: Authentication is achieved using the secp256k1-2 algorithm.

Now, let's get into the code and learn how to implement authentication with WeaveDB for each of these integrations.

MetaMask (EVM - secp256k1)

// Create a temporary address using browser-connected Metamask
const expiry = 60 * 60 * 24 * 7; // Set expiry to a week
const { identity } = await db.createTempAddress(null, expiry);

// Store the identity in IndexedDB for auto-signing
await db.add({ name: "Bob", age: 20 }, "people", identity);

Internet Identity (DFINITY - ed25519)

// Log in with Internet Identity
const iiUrl = `https://identity.ic0.app`;
const authClient = await AuthClient.create();
await new Promise((resolve, reject) => {
  authClient.login({
    identityProvider: iiUrl,
    onSuccess: resolve,
    onError: reject
  });
});

// Create a temporary address with Internet Identity
const { identity } = await db.createTempAddressWithII(ii, expiry);

ArConnect (Arweave - rsa256)

// Create a temporary address with ArConnect
const expiry = 60 * 60 * 24 * 7; // Set expiry to a week
const { identity } = await db.createTempAddressWithAR(null, expiry);

IntmaxWallet (Intmax - secp256k1-2 | poseidon)

// Create a temporary address with Intmax
const signer = new IntmaxWalletSigner();
const expiry = 60 * 60 * 24 * 7; // Set expiry to a week
const { identity } = db.createTempAddressWithIntmax(signer, expiry);

Lens Profile (Lens Protocol - secp256k1-2)

// Create a temporary address with Lens Profile
const expiry = 60 * 60 * 24 * 7; // Set expiry to a week
const { identity } = db.createTempAddressWithLens(expiry);

This documentation guide provides a comprehensive walkthrough of integrating authentication with WeaveDB across various wallet platforms. By understanding the authentication methods and following the provided code snippets, you can implement a secure and user-friendly authentication process for your Dapps.

Be sure to refer to the official documentation here for more details and docs guides for integration and developer support from the team

Did you find this article valuable?

Support Gordian Etim by becoming a sponsor. Any amount is appreciated!