getAuthDetails
getAuthDetails
returns the details about the authenticated user, in accordance with the Turnkey
SDK's specifications.
This method must be called after authenticate
. Otherwise, this method will throw an error with the message Not Authenticated
.
Usage
ts
import { createTurnkeySigner } from "./turnkey";
const turnkeySigner = await createTurnkeySigner();
const details = await turnkeySigner.getAuthDetails();
ts
import {
TurnkeySigner,
TurnkeySubOrganization,
} from "@alchemy/aa-signers/turnkey";
import { WebauthnStamper } from "@turnkey/webauthn-stamper";
import { http } from "viem";
const TURNKEY_BASE_URL = "https://api.turnkey.com";
export const createTurnkeySigner = async () => {
const turnkeySigner = new TurnkeySigner({
apiUrl: TURNKEY_BASE_URL,
// API Key, WebAuthn, or Email Auth [stampers](https://docs.turnkey.com/category/api-design)
// must sign all requests to Turnkey.
stamper: new WebauthnStamper({
rpId: "your.app.xyz",
}),
});
await turnkeySigner.authenticate({
resolveSubOrganization: async () => {
return new TurnkeySubOrganization({
subOrganizationId: "12345678-1234-1234-1234-123456789abc",
signWith: "0x1234567890123456789012345678901234567890",
});
},
transport: http("https://eth-sepolia.g.alchemy.com/v2/ALCHEMY_API_KEY"),
});
return turnkeySigner;
};
Returns
Promise<TurnkeyUserMetadata>
A Promise
containing the TurnkeyUserMetadata
, and object with the following fields:
organizationId: string
-- unique identifier for the user's organization.organizationName: string
-- human-readable name for the user's organization.userId: string
-- unique identifier for the user.username: string
-- human-readable name for the user.