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AK,CACb,6HAA6H,CAC9H,CAAC;KACH;IACD,MAAM,mBAAmB,CAAC,oBAAoB,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,eAAe,CAAC,GAAW;IAClC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,0HAA0H,CAC3H,CAAC;KACH;AACH,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC","sourcesContent":["import { NativeModules } from 'react-native';\n\nconst { ExponentSecureStore } = NativeModules;\n\nexport type KeychainAccessibilityConstant = number;\n\nexport const AFTER_FIRST_UNLOCK: KeychainAccessibilityConstant =\n ExponentSecureStore.AFTER_FIRST_UNLOCK;\nexport const AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: KeychainAccessibilityConstant =\n ExponentSecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY;\nexport const ALWAYS: KeychainAccessibilityConstant = ExponentSecureStore.ALWAYS;\nexport const WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: KeychainAccessibilityConstant =\n ExponentSecureStore.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY;\nexport const ALWAYS_THIS_DEVICE_ONLY: KeychainAccessibilityConstant =\n ExponentSecureStore.ALWAYS_THIS_DEVICE_ONLY;\nexport const WHEN_UNLOCKED: KeychainAccessibilityConstant = ExponentSecureStore.WHEN_UNLOCKED;\nexport const WHEN_UNLOCKED_THIS_DEVICE_ONLY: KeychainAccessibilityConstant =\n ExponentSecureStore.WHEN_UNLOCKED_THIS_DEVICE_ONLY;\n\nexport type SecureStoreOptions = {\n keychainService?: string;\n keychainAccessible?: KeychainAccessibilityConstant;\n};\n\nexport async function deleteItemAsync(\n key: string,\n options: SecureStoreOptions = {}\n): Promise<void> {\n _ensureValidKey(key);\n await ExponentSecureStore.deleteValueWithKeyAsync(key, options);\n}\n\nexport async function getItemAsync(\n key: string,\n options: SecureStoreOptions = {}\n): Promise<string | null> {\n _ensureValidKey(key);\n return await ExponentSecureStore.getValueWithKeyAsync(key, options);\n}\n\nexport async function setItemAsync(\n key: string,\n value: string,\n options: SecureStoreOptions = {}\n): Promise<void> {\n _ensureValidKey(key);\n if (!_isValidValue(value)) {\n throw new Error(\n `Invalid value provided to SecureStore. Values must be strings; consider JSON-encoding your values if they are serializable.`\n );\n }\n await ExponentSecureStore.setValueWithKeyAsync(value, key, options);\n}\n\nfunction _ensureValidKey(key: string) {\n if (!_isValidKey(key)) {\n throw new Error(\n `Invalid key provided to SecureStore. Keys must not be empty and contain only alphanumeric characters, \".\", \"-\", and \"_\".`\n );\n }\n}\n\nfunction _isValidKey(key: string) {\n return typeof key === 'string' && /^[\\w.-]+$/.test(key);\n}\n\nfunction _isValidValue(value: string) {\n return typeof value === 'string';\n}\n"]}
\No newline at end of file