Skip to content

Commit

Permalink
Merge pull request #368 from LIT-Protocol/anson/improve-manually-gene…
Browse files Browse the repository at this point in the history
…rating-session-keys

feat(sessionSigs/accessToken): Manually Generating Session Keys
  • Loading branch information
a1ttech authored Oct 16, 2024
2 parents 42dc8fd + 5e29847 commit 2129a68
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/sdk/authentication/session-sigs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@ litNodeClient = new LitNodeClient({
If an instance of `LocalStorage` is not provided as the `storageProvider`, a new session keypair will be generated each time the code runs instead of reusing previously generated signatures and keys.

#### Manually Generating Session Keys
The session keypair can also be generated with the `generateSessionKeyPair()` function. Doing this enables you to pass the generated session keypair as the optional `sessionKey` parameter when generating Session Signatures.

In addition to the automatic generation of session key pairs, you can manually generate a session key pair using the `generateSessionKeyPair()` function. This provides greater control over session management, especially in environments where custom handling of keys is necessary, such as server-side applications.

When a session keypair is generated, it includes both a public key and a private key (using the [Ed25519](https://ed25519.cr.yp.to/) algorithm). These key pairs are unique for the user’s device, ensuring that the session remains secure to that environment.

## Note:

- In a browser environment, the session key is automatically stored in local storage `lit-session-key` for later use, allowing persistent sessions without needing to regenerate the key each time.

- In a Node.js or similar environment, you need to specify a custom `storageProvider` to store and retrieve the session keys. Without this, a new keypair will be generated each time the session is initialised.

If no session key is provided, the SDK will automatically generate a new one. However, manually generating and managing session keys provides more control, especially if you want to cache or persist them securely across different environments.

### Resources you can Request

Expand Down

0 comments on commit 2129a68

Please sign in to comment.