-
Notifications
You must be signed in to change notification settings - Fork 6
/
TokenStore.kt
28 lines (25 loc) · 918 Bytes
/
TokenStore.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.genesys.cloud.messenger.transport.util
/**
* A store for the session token. Users of the library can use the [DefaultTokenStore]
* implementation for simplicity or create a custom token store by making a concrete implementation
* of this class and passing it in to the [MessengerTransportSDK] constructor.
*/
@Deprecated("Use [Vault] instead.")
abstract class TokenStore {
internal val token: String
get() = fetch() ?: TokenGenerator.generate().also {
store(it)
}
/**
* Stores the token into the storage for later fetching.
*
* @param token the token to store in storage
*/
abstract fun store(token: String)
/**
* Fetches the existing token from the token store and returns it, or null if it doesn't exist.
*
* @return the previous stored token or null if no token in storage
*/
abstract fun fetch(): String?
}