interface SignSessionKeyProp {
    authMethods: AuthMethod[];
    authSig?: AuthSig;
    chainId?: number;
    domain?: string;
    expiration?: string;
    jsParams?: any;
    litActionCode?: string;
    litActionIpfsId?: string;
    pkpPublicKey?: string;
    resourceAbilityRequests?: LitResourceAbilityRequest[];
    resources: any;
    sessionKey?: SessionKeyPair;
    statement?: string;
}

Hierarchy (view full)

Properties

authMethods: AuthMethod[]

The auth methods to use to sign the session key

authSig?: AuthSig

The auth sig of the user. Returned via the checkAndSignAuthMessage function

chainId?: number
domain?: string

domain param is required, when calling from environment that doesn't have the 'location' object. i.e. NodeJs server.

expiration?: string

When this session signature will expire. The user will have to reauthenticate after this time using whatever auth method you set up. This means you will have to call this signSessionKey function again to get a new session signature. This is a RFC3339 timestamp. The default is 24 hours from now.

jsParams?: any

An object that contains params to expose to the Lit Action. These will be injected to the JS runtime before your code runs, so you can use any of these as normal variables in your Lit Action.

litActionCode?: string

The litActionCode is the JavaScript code that will run on the nodes. You will need to convert the string content to base64.

Buffer.from(litActionCodeString).toString('base64');
litActionIpfsId?: string

You can obtain the Lit Action IPFS CID by converting your JavaScript code using this tool: https://explorer.litprotocol.com/create-action

Note: You do not need to pin your code to IPFS necessarily. You can convert a code string to an IPFS hash using the "ipfs-hash-only" or 'ipfs-unixfs-importer' library.

async function stringToIpfsHash(input: string): Promise<string> {
// Convert the input string to a Buffer
const content = Buffer.from(input);

// Import the content to create an IPFS file
const files = importer([{ content }], {} as any, { onlyHash: true });

// Get the first (and only) file result
const result = (await files.next()).value;

const ipfsHash = (result as any).cid.toString();
if (!ipfsHash.startsWith('Qm')) {
throw new Error('Generated hash does not start with Qm');
}

return ipfsHash;
}
pkpPublicKey?: string

The public key of the PKP

resourceAbilityRequests?: LitResourceAbilityRequest[]

A LIT resource ability is a combination of a LIT resource and a LIT ability.

resources: any
sessionKey?: SessionKeyPair

The serialized session key pair to sign. If not provided, a session key pair will be fetched from localStorge or generated.

statement?: string

The statement text to place at the end of the SIWE statement field.