Skip to content

getAuthDetails

getAuthDetails returns the details about the authenticated user, specifically the EOA address of the user, and the encrypted headers used to authenticate / manage the user's account.

This method must be called after authenticate. Otherwise, this method will throw an error with the message Not Authenticated.

Usage

ts
import { createPassportSigner } from "./passport";

const passportSigner = await createPassportSigner();

const details = await passportSigner.getAuthDetails();
ts
import { PassportSigner } from "@alchemy/aa-signers/passport";
import { Passport } from "@0xpass/passport";
import { WebauthnSigner } from "@0xpass/webauthn-signer";
import { http } from "viem";
import { sepolia } from "@alchemy/aa-core";

export const passport = new Passport({
  scope_id: "scope_id",
  signer: new WebauthnSigner({
    rpId: "rpId",
    rpName: "rpName",
  }),
});

export const createPassportSigner = async () => {
  const passportSigner = new PassportSigner({ inner: passport });

  await passportSigner.authenticate({
    username: "test",
    userDisplayName: "test",
    chain: sepolia,
    fallbackProvider: http(
      "https://eth-sepolia.g.alchemy.com/v2/ALCHEMY_API_KEY"
    ),
  });

  return passportSigner;
};

Returns

Promise<PassportUserInfo>

A Promise containing the PassportUserInfo, an object with the following fields:

  • authenticatedHeaders: PassportAuthenticatedHeaders -- Headers that include encrypted key and session information.

    • x-encrypted-key: string -- The encrypted key header.
    • x-session: string -- The session header.
  • addresses: Address[] -- An array of blockchain addresses associated with the user.