Session Management
Comprehensive guide to managing authentication sessions in Para
Overview
Para provides a comprehensive set of methods for managing authentication sessions. These sessions are crucial for secure transaction signing and other authenticated operations. Proper session management helps maintain security while ensuring a seamless user experience.
Session Duration
The Para session length is 2 hours by default, but can be configured to up to 30 days. To configure this parameter, please visit the Configuration section of the Developer Portal. A user signing a message or transaction extends the session by the duration of the session length.
Checking Session Status
Use isSessionActive()
to verify whether a user’s session is currently valid before performing authenticated
operations.
This method returns a boolean indicating if the session is currently valid and active. For external wallet connections, this will always return true.
Example usage:
Maintaining Active Sessions
Use keepSessionAlive()
to extend an active session’s validity without requiring full reauthentication.
This is a lightweight method that attempts to maintain the current session and returns a boolean indicating success or failure.
Example usage:
Refreshing Expired Sessions
Use refreshSession()
when a session has fully expired and needs to be reestablished through user authentication.
When shouldOpenPopup
is true, this method automatically opens an authentication window. Otherwise, it returns a URL
that should be opened in a popup for user authentication. After calling refreshSession()
, you must use
waitForLoginAndSetup()
to wait for the authentication to complete.
Pass the popup window reference to waitForLoginAndSetup()
when handling popups manually. This enables automatic
error detection if the user closes the popup.
Example usage:
Client-Server Session Transfer
Exporting Sessions
Use exportSession()
when you need to transfer session state to a server for performing operations on behalf of the
user.
Returns a Base64 encoded string containing the session state, including user details, wallet information, and authentication data.
Example client-side export:
Importing Sessions
Use importSession()
on your server to restore a previously exported session state.
exportSession()
and restores the complete session state.Example server-side implementation:
Session Verification Tokens
Alternatively, if your server does not use Node.js, you can request a verification token that can be passed to our servers to validate whether the connected session is valid and fetch related user authentication data - for example, the user’s email address.
Our session verification endpoints are as follows:
Environment | URL |
---|---|
SANDBOX | https://api.sandbox.getpara.com/session/verify |
BETA | https://api.beta.getpara.com/session/verify |
PROD | https://api.getpara.com/session/verify |
Send a POST
request to one of the above URLs with the header x-partner-id
set to your Para API key and the following JSON body:
If the session is no longer valid, the request will return a 403
status code. Otherwise, it will return a JSON object of the form:
A sample usage: