createAuth
Creates an authentication object with the given options.
import { createAuth } from 'thirdweb/auth'; const auth = createAuth({...}); // 1. generate a login payload for a client on the server sideconst loginPayload = await auth.generatePayload({ address: '0x123...' }); // 2. send the login payload to the client // 3. verify the login payload that the client sends back laterconst verifiedPayload = await auth.verifyPayload({ payload: loginPayload, signature: '0x123...' }); // 4. generate a JWT for the clientconst jwt = await auth.generateJWT({ payload: verifiedPayload }); // 5. set the JWT as a cookie or otherwise provide it to the client // 6. authenticate the client based on the JWT on subsequent calls const { valid, parsedJWT } = await auth.verifyJWT({ jwt });
generateJWT: ( params: GenerateJWTParams<unknown>, ) => Promise<string>; generatePayload: ( verifyJWT: (params: VerifyJWTParams) => Promise<VerifyJWTResult>; verifyPayload: (};
The options for creating the authentication object.
let options: { domain: string; jwt?: { expirationTimeSeconds?: number; jwtId?: { generate: () => string | Promise<string>; validate: (jwtId: string) => boolean | Promise<boolean>; }; }; login?: { nonce?: { generate: () => string | Promise<string>; validate: (nonce: string) => boolean | Promise<boolean>; }; payloadExpirationTimeSeconds?: number; resources?: Array<string>; statement?: string; uri?: string; version?: string; };};
let returnType: { generateJWT: ( params: GenerateJWTParams<unknown>, ) => Promise<string>; generatePayload: ( verifyJWT: (params: VerifyJWTParams) => Promise<VerifyJWTResult>; verifyPayload: (};
The created authentication object.