Skip to main content

index/interfaces/LaunchpadSession.md

The app's session, as the SDK sees it.

Example​

const sdk = createLaunchpadSDK({
env: 'stage',
session: {
accessToken: () => authMachine.currentToken(), // may wait for boot, refresh one about to expire
onUnauthorized: (rejected) => authMachine.recover(rejected), // fresh token to retry with, or null
},
});

Properties​

PropertyModifierTypeDescription
credentials?readonly"include" | "omit"Whether launchpad-backend requests carry the browser's cookies. Default 'include': the refresh cookie is only stored and presented on credentialed requests. 'omit' for a session that does not use the cookie.

Methods​

accessToken()​

accessToken(): Promise<string | null>

The bearer for the next launchpad-backend request, or null to send it unauthenticated. Awaited before every request, so it may wait (for the app's boot) or refresh first.

Returns​

Promise<string | null>


onUnauthorized()​

onUnauthorized(rejectedToken): Promise<string | null>

A launchpad-backend request answered 401. rejectedToken is the bearer it carried (null: it carried none). Resolve to a fresh token to retry the request once with it, or null to fail the request with that 401. Called once per request at most.

Parameters​

ParameterType
rejectedTokenstring | null

Returns​

Promise<string | null>