Functions
createAuthManager(authManagerParams
)
Parameters
The storage provider used by the Auth Manager.
Copy
import { createAuthManager, storagePlugins } from "@lit-protocol/auth";
const authManager = createAuthManager({
storage: storagePlugins.localStorageNode({
appName: "my-app",
networkName: "naga-local",
storagePath: "./lit-auth-local",
}),
});
Returns
Complete AuthManager object with all returned methods.
createEoaAuthContext
Create an EOA (Externally Owned Account) auth context adapter for signing and session issuance.Parameters
Hide properties
Hide properties
EOA configuration for the adapter.
Show properties
Show properties
The EOA used for auth/signing.
Configuration for statements, resources, expiration, etc.
Show properties
Show properties
SIWE statement suffix appended to Auth message.
Domain used in auth message.
Capability resources to include (e.g., [‘lit-action-execution’,’*’]).
Optional capability signatures.
Session expiration timestamp (e.g., new Date(Date.now() + 10006015).toISOString()).
The Lit client instance used for network interactions.
Returns
Hide properties
Hide properties
The EOA used for signing.
The authenticator used (e.g., ViemAccountAuthenticator, WalletClientAuthenticator).
Auth data produced by the authenticator.
Callback that returns an AuthSig for session issuance when needed.
Ephemeral session key pair associated with the context.
Example
Copy
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
Hide properties
Hide properties
Authentication data (e.g., from ViemAccountAuthenticator.authenticate(account)).
The PKP public key to bind the context to.
Returns
Hide properties
Hide properties
Currently ‘ethereum’.
Example
Copy
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
Hide properties
Hide properties
PKP public key used in the custom auth flow.
Config controlling resources and expiration for the session.
Custom Lit Action parameters.
Show properties
Show properties
Inline Lit Action code (base64-encoding handled externally if needed).
IPFS CID of the Lit Action to run.
Arbitrary parameters exposed inside the Lit Action. Note: The implementation nests your provided object under a top-level key
jsParams
before sending to nodes.Returns
Hide properties
Hide properties
Currently ‘ethereum’.
Example
Copy
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 });