Functions
createAuthManager(authManagerParams)
Parameters
LitAuthStorageProvider
required
The storage provider used by the Auth Manager.
import { createAuthManager, storagePlugins } from "@lit-protocol/auth";
const authManager = createAuthManager({
storage: storagePlugins.localStorageNode({
appName: "my-app",
networkName: "naga-local",
storagePath: "./lit-auth-local",
}),
});
Returns
object
Complete AuthManager object with all returned methods.
createEoaAuthContext
Create an EOA (Externally Owned Account) auth context adapter for signing and session issuance.Parameters
object
Hide properties
Hide properties
object
required
EOA configuration for the adapter.
Show properties
Show properties
Account | WalletClient | Signer
required
The EOA used for auth/signing.
AuthConfigV2
required
Configuration for statements, resources, expiration, etc.
Show properties
Show properties
string
SIWE statement suffix appended to Auth message.
string
Domain used in auth message.
LitResourceAbilityRequest[]
Capability resources to include (e.g., [‘lit-action-execution’,’*’]).
AuthSig[]
Optional capability signatures.
ISO 8601 string
Session expiration timestamp (e.g., new Date(Date.now() + 10006015).toISOString()).
LitClient
required
The Lit client instance used for network interactions.
Returns
object
Hide properties
Hide properties
Account | WalletClient | Signer
required
The EOA used for signing.
Authenticator
required
The authenticator used (e.g., ViemAccountAuthenticator, WalletClientAuthenticator).
AuthData
required
Auth data produced by the authenticator.
() => Promise<AuthSig>
required
Callback that returns an AuthSig for session issuance when needed.
SessionKeyPair
required
Ephemeral session key pair associated with the context.
Example
import { createAuthManager, storagePlugins } from '@lit-protocol/auth';
const authManager = createAuthManager({
storage: storagePlugins.localStorageNode({
appName: 'my-app',
networkName: 'naga-local',
storagePath: './lit-auth-local'
})
});
const eoaAuthContext = await authManager.createEoaAuthContext({
config: { account: myViemAccount },
authConfig: {
statement: 'I authorize this action.',
domain: 'example.com',
resources: [ ['lit-action-execution','*'], ['pkp-signing','*'] ],
expiration: new Date(Date.now()+1000*60*15).toISOString()
},
litClient
});
// Use with litClient
await litClient.executeJs({ code: '...', authContext: eoaAuthContext });
createPkpAuthContext
Create a PKP auth context adapter using a user’s AuthData and a PKP public key.Parameters
object
Hide properties
Hide properties
AuthData
required
Authentication data (e.g., from ViemAccountAuthenticator.authenticate(account)).
0x-hex string
required
The PKP public key to bind the context to.
AuthConfigV2
required
LitClient
required
Returns
object
Example
import { ViemAccountAuthenticator } from '@lit-protocol/auth';
const authData = await ViemAccountAuthenticator.authenticate(myViemAccount);
const pkpAuthContext = await authManager.createPkpAuthContext({
authData,
pkpPublicKey: myPkp.publicKey,
authConfig: {
resources: [ ['pkp-signing','*'], ['lit-action-execution','*'] ],
expiration: new Date(Date.now()+1000*60*30).toISOString()
},
litClient
});
// Example: sign via PKP Viem account integration
const pkpAccount = await litClient.getPkpViemAccount({
pkpPublicKey: myPkp.publicKey,
authContext: pkpAuthContext,
chainConfig: myChain
});
createCustomAuthContext
Create a Custom auth context that validates using a Lit Action (by inline code or IPFS CID).Parameters
object
Hide properties
Hide properties
0x-hex string
required
PKP public key used in the custom auth flow.
AuthConfigV2
required
Config controlling resources and expiration for the session.
LitClient
required
object
required
Custom Lit Action parameters.
Returns
object
Hide properties
Hide properties
string
required
Currently ‘ethereum’.
0x-hex string
required
object
() => Promise<AuthSig>
required
object
required
SessionKeyPair
required
Example
const customAuthContext = await authManager.createCustomAuthContext({
pkpPublicKey: evePkp.publicKey,
authConfig: {
resources: [ ['pkp-signing','*'], ['lit-action-execution','*'] ],
expiration: new Date(Date.now()+1000*60*30).toISOString()
},
litClient,
customAuthParams: {
litActionIpfsId: 'QmYourLitActionCID',
jsParams: {
userId: 'eve',
password: 'password'
}
});
await litClient.executeJs({ ipfsId: 'QmYourLitActionCID', authContext: customAuthContext });