@turnkey/sdk-react-native
Version:
React Native SDK
96 lines • 3.71 kB
TypeScript
import type { Session } from "./types";
/**
* Retrieves the embedded key from secure storage.
*
* - Attempts to retrieve the stored embedded private key using Keychain.
* - Optionally deletes the key from storage after retrieval if `deleteKey` is true.
*
* @param deleteKey - Whether to remove the embedded key after retrieval (defaults to false).
* @param storageKey - The service key for the embedded key.
* @returns The embedded private key if found, otherwise null.
* @throws {TurnkeyReactNativeError} If retrieving or deleting the key fails.
*/
export declare const getEmbeddedKey: (deleteKey: boolean | undefined, storageKey: string) => Promise<string | null>;
/**
* Saves the provided embedded key (private key) securely in storage.
*
* - Uses Keychain to store the private key for the given service key.
*
* @param key - The private key to store securely.
* @param storageKey - The service key under which to store the embedded key.
* @throws {TurnkeyReactNativeError} If saving the key fails.
*/
export declare const saveEmbeddedKey: (key: string, storageKey: string) => Promise<void>;
/**
* Retrieves a stored session from secure storage.
*
* @param sessionKey The unique key identifying the session.
* @returns The session object if found, otherwise `null`.
* @throws If retrieving the session fails.
*/
export declare const getSession: (sessionKey: string) => Promise<Session | null>;
/**
* Saves a session securely in storage.
*
* @param session The session object to store securely.
* @param sessionKey The unique key under which the session is stored.
* @throws If saving the session fails.
*/
export declare const saveSession: (session: Session, sessionKey: string) => Promise<void>;
/**
* Deletes a session from secure storage.
*
* @param sessionKey The unique key identifying the session to reset.
* @throws If deleting the session fails.
*/
export declare const deleteSession: (sessionKey: string) => Promise<void>;
/**
* Retrieves the selected session key from secure storage.
*
* @returns The selected session key as a string, or `null` if not found.
* @throws If retrieving the session key fails.
*/
export declare const getSelectedSessionKey: () => Promise<string | null>;
/**
* Saves the selected session key to secure storage.
*
* @param sessionKey The session key to mark as selected.
* @throws If saving the session key fails.
*/
export declare const saveSelectedSessionKey: (sessionKey: string) => Promise<void>;
/**
* Clears the selected session key from secure storage.
*
* @throws If deleting the session key fails.
*/
export declare const clearSelectedSessionKey: () => Promise<void>;
/**
* Adds a session key to the session list in secure storage.
*
* - Retrieves the existing session list.
* - Appends the new session key if it does not already exist.
* - Stores the updated session list.
*
* @param sessionKey The session key to add.
* @throws If the session key already exists or saving fails.
*/
export declare const addSessionKey: (sessionKey: string) => Promise<void>;
/**
* Retrieves all session keys stored in secure storage.
*
* @returns An array of session keys.
* @throws If retrieving the session list fails.
*/
export declare const getSessionKeys: () => Promise<string[]>;
/**
* Removes a session key from the session list in secure storage.
*
* - Fetches the existing session list.
* - Removes the specified session key.
* - Saves the updated session list back to secure storage.
*
* @param sessionKey The session key to remove.
* @throws If removing the session key fails.
*/
export declare const removeSessionKey: (sessionKey: string) => Promise<void>;
//# sourceMappingURL=storage.d.ts.map