Skip to content

Arcana Auth Signer

ArcanaAuthSigner is a signer implementation that extends SmartAccountAuthenticator to leverage the Arcana Auth SDK. It supports features such as authentication, message and typed data signing, and authentication details retrieval.

ArcanaAuthSigner provides implementations for all methods on SmartAccountAuthenticator:

  1. authenticate -- supports user authentication.
  2. getAddress -- gets the address of the the smart contract account's connected signer.
  3. signMessage -- supports message signatures.
  4. signTypedData -- supports typed data signatures.
  5. getAuthDetails -- supports authentication details retrieval.

Install Dependencies

ArcanaAuthSigner requires the installation of the Arcana Auth SDK. aa-signers lists it as an optional dependency.

bash
npm i -s @arcana/auth
bash
yarn add @arcana/auth

Usage

ts
import { ArcanaAuthSigner } from "@alchemy/aa-signers/arcana-auth";

const newArcanaAuthSigner = new ArcanaAuthSigner({
  clientId: "ARCANA_AUTH_CLIENT_ID",
});
// or by using inner

import { AuthProvider } from "@arcana/auth";

const authParams = {
  theme: "light",
  network: "testnet",
  position: "left",
};

const inner = new AuthProvider("ARCANA_AUTH_CLIENT_ID", authParams);
const newArcanaAuthSigner2 = new ArcanaAuthSigner({ inner });

const getUserInfo = await newArcanaAuthSigner.authenticate();

const address = await newArcanaAuthSigner.getAddress();

const details = await newArcanaAuthSigner.getAuthDetails();

const signedMessage = await newArcanaAuthSigner.signMessage("test");

const typedData = {
  types: {
    Request: [{ name: "hello", type: "string" }],
  },
  primaryType: "Request",
  message: {
    hello: "world",
  },
};
const signTypedData = await newArcanaAuthSigner.signTypedData(typedData);
ts
import { ArcanaAuthSigner } from "@alchemy/aa-signers/arcana-auth";

// See https://docs.arcana.network/quick-start/vue-quick-start#step-3-integrate-app for details.
const clientId = "xar_test_...";

export const createArcanaAuthSigner = async () => {
  const arcanaAuthSigner = new ArcanaAuthSigner({ clientId, params: {} });

  await arcanaAuthSigner.authenticate({
    async init() {
      await arcanaAuthSigner.inner.init();
    },
    async connect() {
      await arcanaAuthSigner.inner.connect();
    },
  });

  return arcanaAuthSigner;
};