Skip to content

server

Server connection and authentication.

4 functions / 2 types

Index

FunctionDescription
authenticateAuthenticate the client using the given strategy.
getUserDetailsExecute the getUserDetails statement.
logoutExecute the logout statement.
setUrlSet the URL of the fdk server the client connects to.
TypeDescription
AuthStrategyThe authentication strategy used by Authenticate.
AuthStrategyKindHow the application proves who it is.

authenticate

authenticate(args: { strategy: ServerAuthStrategy }, transactionId?: string): Promise<void>

Authenticate the client using the given strategy.

The server URL must already be configured via SetServerUrl. Available strategies:

  • session-storage: key is a browser session-storage key holding the access token. Only supported on wasm32.
  • transparent: key is ignored. Marks the application as authenticated without providing a token. Useful for integrations that inject the token some other way (e.g. cookies or service workers).

Both authentication and refresh go through this statement; the work of acquiring a token (e.g. via an OAuth2 flow) is expected to happen outside of the statement system.

Returns Promise<void>.

strategy : ServerAuthStrategy

The authentication strategy to use.

transactionId optional : string

getUserDetails

getUserDetails(transactionId?: string): Promise<string>

Execute the getUserDetails statement.

Returns Promise<string>.

transactionId optional : string

logout

logout(transactionId?: string): Promise<void>

Execute the logout statement.

Returns Promise<void>.

transactionId optional : string

setUrl

setUrl(args: { url: string }, transactionId?: string): Promise<void>

Set the URL of the fdk server the client connects to.

Inserts a ServerUrl resource that the login flow reads when authenticating. This replaces the per-environment URL helpers that previously selected the server at app startup.

Returns Promise<void>.

url : string

The server URL, e.g. https://api.spatialdrive.io.

transactionId optional : string

AuthStrategy

The authentication strategy used by Authenticate.

key : string

The session-storage key holding the access token (only for session-storage).

kind : ServerAuthStrategyKind

Which strategy to use, as an AuthStrategyKind i32 kind.

AuthStrategyKind

Enum

How the application proves who it is.

SessionStorage = 0

key is a browser session-storage key holding the access token. Only supported on wasm32.

Transparent = 1

key is ignored. The application is marked authenticated without a token.