import {SetSecretParams} from '@shopify/shop-minis-platform/actions' import {useHandleAction} from '../../internal/useHandleAction' import {useShopActions} from '../../internal/useShopActions' export interface UseSecureStorageReturns { /** * Get the secret from the secure storage. */ getSecret: () => Promise /** * Set a secret in the secure storage. */ setSecret: (params: SetSecretParams) => Promise /** * Remove the secret from the secure storage. */ removeSecret: () => Promise } export function useSecureStorage(): UseSecureStorageReturns { const {getSecret, setSecret, removeSecret} = useShopActions() return { getSecret: useHandleAction(getSecret), setSecret: useHandleAction(setSecret), removeSecret: useHandleAction(removeSecret), } } /** * The `useSecureStorage` hook provides functions to interact with secure storage for sensitive data. You can use this for authentication tokens or any sensitive data that requires hardware-backed encryption. * * > Caution: You can only store one secret per Mini. * * > Note: Use `useSecureStorage` for sensitive data like auth tokens, API keys, or PII. It provides hardware-backed encryption on both iOS and Android, ensuring data is protected even if the device is compromised. The tradeoff is slower performance and a limit of one secret per Mini. Use `useAsyncStorage` for non-sensitive data like preferences or cached content. It supports multiple key-value pairs and is ~3x faster, but stores data in plaintext. * @publicDocs */ export type UseSecureStorageGeneratedType = () => UseSecureStorageReturns