IdentifyKit

Manages user authentication state for the Monterosa SDK and bridges it into embedded Experiences.

Obtain an instance via IdentifyKit.default or IdentifyKit.from, set credentials to provide the user's authentication token, then call getSessionSignature, getUserData, or updateUserData to interact with the identity service. Register an IdentifyKitListener to react to state changes.

val identifyKit = IdentifyKit.default

identifyKit.add(object : IdentifyKitListener {
override fun onCredentialsUpdated(credentials: Credentials?) { }
override fun onSessionSignatureUpdated(signature: Signature?) { }
override fun onCredentialsValidationFailed(exception: Exception) { }
})

identifyKit.credentials = Credentials(token = "<token>")

// suspending; never throws, failures come back in the Result
identifyKit.getSessionSignature().onSuccess { signature ->
// use signature
}.onFailure { error ->
// handle error
}

signature and userData are cached for ten seconds and then cleared, with listeners notified of the null. Read them fresh from getSessionSignature and getUserData at the point of use rather than holding on to a copy.

A signature is what associates a user with their votes in InteractKit, and what an embedded Experience asks for over the LauncherKit bridge:

// attribute votes to this user
identifyKit.getSessionSignature().onSuccess { signature ->
interactKit.login(signature) { success -> /* now voting as that user */}
}

// let an embedded Experience use the same identity
experienceView.identify = identifyKit

identifyKit.logout() // clears credentials, signature and user data

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override var credentials: Credentials?

The user's authentication credentials.

Link copied to clipboard
open override var identifier: String

The unique identifier for this kit instance.

Link copied to clipboard
open override val listener: MulticastListener<IdentifyKitListener>
Link copied to clipboard
open override var signature: Signature?

The current session signature, or null if no signature has been obtained.

Link copied to clipboard
open override var userData: UserData?

The current user data, or null if no user data has been fetched.

Functions

Link copied to clipboard
open override fun add(listener: IdentifyKitListener)

Registers a listener to receive identity state change notifications.

Link copied to clipboard
open override fun configure(configurationProvider: ConfigurationProvider)
Link copied to clipboard
open suspend override fun getSessionSignature(options: Options?): Result<Signature>

Requests a session signature based on the user's current identity.

Link copied to clipboard
open suspend override fun getUserData(options: Options?): Result<UserData>

Fetches the user data associated with the current identity.

Link copied to clipboard
open fun load()
Link copied to clipboard
open override fun logout()

Logs the user out by clearing their credentials, session signature, and user data, then notifies all registered listeners.

Link copied to clipboard
open override fun remove(listener: IdentifyKitListener)

Unregisters a previously added listener.

Link copied to clipboard
open suspend override fun updateUserData(data: Map<String, Any>, options: Options?): Result<UserData>

Updates the user data associated with the current identity.