one 2.6.18 → 2.6.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/One.podspec +2 -0
  2. package/android/src/main/java/com/margelo/nitro/one/HybridOneDevice.kt +124 -0
  3. package/android/src/main/java/com/margelo/nitro/one/HybridOneHaptics.kt +31 -0
  4. package/android/src/main/java/com/margelo/nitro/one/HybridOneImageManipulator.kt +25 -5
  5. package/android/src/main/java/com/margelo/nitro/one/HybridOneKeepAwake.kt +34 -9
  6. package/android/src/main/java/com/margelo/nitro/one/HybridOneSecureStore.kt +269 -78
  7. package/dist/cjs/index.cjs +3 -0
  8. package/dist/cjs/index.native.cjs +3 -0
  9. package/dist/cjs/index.native.js +3 -0
  10. package/dist/cjs/index.native.js.map +1 -1
  11. package/dist/cjs/one.cjs +1 -0
  12. package/dist/cjs/one.native.cjs +1 -0
  13. package/dist/cjs/one.native.js +1 -0
  14. package/dist/cjs/one.native.js.map +1 -1
  15. package/dist/cjs/platform/extras.cjs +4 -0
  16. package/dist/cjs/platform/extras.native.cjs +4 -0
  17. package/dist/cjs/platform/extras.native.js +4 -0
  18. package/dist/cjs/platform/extras.native.js.map +1 -1
  19. package/dist/cjs/platform/haptics/index.cjs +3 -0
  20. package/dist/cjs/platform/haptics/index.native.cjs +4 -0
  21. package/dist/cjs/platform/haptics/index.native.js +4 -0
  22. package/dist/cjs/platform/haptics/index.native.js.map +1 -1
  23. package/dist/cjs/platform/haptics/validation.cjs +28 -0
  24. package/dist/cjs/platform/haptics/validation.native.cjs +28 -0
  25. package/dist/cjs/platform/haptics/validation.native.js +28 -0
  26. package/dist/cjs/platform/haptics/validation.native.js.map +1 -1
  27. package/dist/cjs/platform/image-manipulator/index.cjs +10 -3
  28. package/dist/cjs/platform/image-manipulator/index.native.cjs +1 -0
  29. package/dist/cjs/platform/image-manipulator/index.native.js +1 -0
  30. package/dist/cjs/platform/image-manipulator/index.native.js.map +1 -1
  31. package/dist/cjs/platform/index.cjs +1 -0
  32. package/dist/cjs/platform/index.native.cjs +1 -0
  33. package/dist/cjs/platform/index.native.js +1 -0
  34. package/dist/cjs/platform/index.native.js.map +1 -1
  35. package/dist/cjs/platform/keep-awake/index.cjs +53 -14
  36. package/dist/cjs/platform/keep-awake/index.native.cjs +29 -2
  37. package/dist/cjs/platform/keep-awake/index.native.js +29 -2
  38. package/dist/cjs/platform/keep-awake/index.native.js.map +1 -1
  39. package/dist/cjs/platform/keep-awake/unavailable.cjs +11 -1
  40. package/dist/cjs/platform/keep-awake/unavailable.native.cjs +11 -1
  41. package/dist/cjs/platform/keep-awake/unavailable.native.js +11 -1
  42. package/dist/cjs/platform/keep-awake/unavailable.native.js.map +1 -1
  43. package/dist/cjs/platform/keep-awake/validate.cjs +15 -1
  44. package/dist/cjs/platform/keep-awake/validate.native.cjs +15 -1
  45. package/dist/cjs/platform/keep-awake/validate.native.js +15 -1
  46. package/dist/cjs/platform/keep-awake/validate.native.js.map +1 -1
  47. package/dist/cjs/platform/localization/index.cjs +100 -0
  48. package/dist/cjs/platform/localization/index.native.cjs +71 -0
  49. package/dist/cjs/platform/localization/index.native.js +73 -0
  50. package/dist/cjs/platform/localization/index.native.js.map +1 -0
  51. package/dist/cjs/platform/localization/map.cjs +86 -0
  52. package/dist/cjs/platform/localization/map.native.cjs +90 -0
  53. package/dist/cjs/platform/localization/map.native.js +92 -0
  54. package/dist/cjs/platform/localization/map.native.js.map +1 -0
  55. package/dist/cjs/platform/localization/types.cjs +16 -0
  56. package/dist/cjs/platform/localization/types.native.cjs +18 -0
  57. package/dist/cjs/platform/localization/types.native.js +20 -0
  58. package/dist/cjs/platform/localization/types.native.js.map +1 -0
  59. package/dist/cjs/platform/secure-store/index.cjs +12 -6
  60. package/dist/cjs/platform/secure-store/index.native.cjs +18 -12
  61. package/dist/cjs/platform/secure-store/index.native.js +18 -12
  62. package/dist/cjs/platform/secure-store/index.native.js.map +1 -1
  63. package/dist/cjs/platform/secure-store/types.cjs +16 -0
  64. package/dist/cjs/platform/secure-store/types.native.cjs +18 -0
  65. package/dist/cjs/platform/secure-store/types.native.js +20 -0
  66. package/dist/cjs/platform/secure-store/types.native.js.map +1 -0
  67. package/dist/cjs/platform/secure-store/validate.cjs +34 -0
  68. package/dist/cjs/platform/secure-store/validate.native.cjs +34 -0
  69. package/dist/cjs/platform/secure-store/validate.native.js +34 -0
  70. package/dist/cjs/platform/secure-store/validate.native.js.map +1 -1
  71. package/dist/esm/index.js +2 -2
  72. package/dist/esm/index.mjs +2 -2
  73. package/dist/esm/index.native.js +2 -2
  74. package/dist/esm/one.mjs +2 -1
  75. package/dist/esm/one.mjs.map +1 -1
  76. package/dist/esm/one.native.js +2 -1
  77. package/dist/esm/one.native.js.map +1 -1
  78. package/dist/esm/platform/extras.mjs +2 -1
  79. package/dist/esm/platform/extras.native.js +2 -1
  80. package/dist/esm/platform/haptics/index.mjs +4 -1
  81. package/dist/esm/platform/haptics/index.mjs.map +1 -1
  82. package/dist/esm/platform/haptics/index.native.js +5 -1
  83. package/dist/esm/platform/haptics/index.native.js.map +1 -1
  84. package/dist/esm/platform/haptics/validation.mjs +27 -1
  85. package/dist/esm/platform/haptics/validation.mjs.map +1 -1
  86. package/dist/esm/platform/haptics/validation.native.js +27 -1
  87. package/dist/esm/platform/haptics/validation.native.js.map +1 -1
  88. package/dist/esm/platform/image-manipulator/index.mjs +10 -3
  89. package/dist/esm/platform/image-manipulator/index.mjs.map +1 -1
  90. package/dist/esm/platform/image-manipulator/index.native.js +1 -0
  91. package/dist/esm/platform/image-manipulator/index.native.js.map +1 -1
  92. package/dist/esm/platform/index.mjs +2 -2
  93. package/dist/esm/platform/index.mjs.map +1 -1
  94. package/dist/esm/platform/index.native.js +2 -2
  95. package/dist/esm/platform/index.native.js.map +1 -1
  96. package/dist/esm/platform/keep-awake/index.mjs +51 -15
  97. package/dist/esm/platform/keep-awake/index.mjs.map +1 -1
  98. package/dist/esm/platform/keep-awake/index.native.js +27 -3
  99. package/dist/esm/platform/keep-awake/index.native.js.map +1 -1
  100. package/dist/esm/platform/keep-awake/unavailable.mjs +12 -2
  101. package/dist/esm/platform/keep-awake/unavailable.mjs.map +1 -1
  102. package/dist/esm/platform/keep-awake/unavailable.native.js +12 -2
  103. package/dist/esm/platform/keep-awake/unavailable.native.js.map +1 -1
  104. package/dist/esm/platform/keep-awake/validate.mjs +10 -1
  105. package/dist/esm/platform/keep-awake/validate.mjs.map +1 -1
  106. package/dist/esm/platform/keep-awake/validate.native.js +10 -1
  107. package/dist/esm/platform/keep-awake/validate.native.js.map +1 -1
  108. package/dist/esm/platform/localization/index.mjs +77 -0
  109. package/dist/esm/platform/localization/index.mjs.map +1 -0
  110. package/dist/esm/platform/localization/index.native.js +46 -0
  111. package/dist/esm/platform/localization/index.native.js.map +1 -0
  112. package/dist/esm/platform/localization/map.mjs +59 -0
  113. package/dist/esm/platform/localization/map.mjs.map +1 -0
  114. package/dist/esm/platform/localization/map.native.js +61 -0
  115. package/dist/esm/platform/localization/map.native.js.map +1 -0
  116. package/dist/esm/platform/localization/types.mjs +0 -0
  117. package/dist/esm/platform/localization/types.native.js +0 -0
  118. package/dist/esm/platform/secure-store/index.mjs +13 -7
  119. package/dist/esm/platform/secure-store/index.mjs.map +1 -1
  120. package/dist/esm/platform/secure-store/index.native.js +19 -13
  121. package/dist/esm/platform/secure-store/index.native.js.map +1 -1
  122. package/dist/esm/platform/secure-store/types.mjs +0 -0
  123. package/dist/esm/platform/secure-store/types.native.js +0 -0
  124. package/dist/esm/platform/secure-store/validate.mjs +33 -1
  125. package/dist/esm/platform/secure-store/validate.mjs.map +1 -1
  126. package/dist/esm/platform/secure-store/validate.native.js +33 -1
  127. package/dist/esm/platform/secure-store/validate.native.js.map +1 -1
  128. package/ios/Nitro/HybridOneDevice.swift +117 -0
  129. package/ios/Nitro/HybridOneHaptics.swift +4 -0
  130. package/ios/Nitro/HybridOneImageManipulator.swift +25 -8
  131. package/ios/Nitro/HybridOneKeepAwake.swift +34 -2
  132. package/ios/Nitro/HybridOneSecureStore.swift +112 -46
  133. package/ios/Tests/ImageManipulator/Package.swift +12 -0
  134. package/ios/Tests/ImageManipulator/README.md +21 -0
  135. package/ios/Tests/ImageManipulator/Sources/NitroModules/Promise.swift +33 -0
  136. package/ios/Tests/ImageManipulator/Sources/OneImageManipulatorCore/Types.swift +41 -0
  137. package/ios/Tests/ImageManipulator/Sources/SDWebImageWebPCoder/SDImageWebPCoder.swift +23 -0
  138. package/nitrogen/generated/android/c++/JAndroidHaptic.hpp +109 -0
  139. package/nitrogen/generated/android/c++/JCalendarInfo.hpp +70 -0
  140. package/nitrogen/generated/android/c++/JHapticImpact.hpp +3 -3
  141. package/nitrogen/generated/android/c++/JHybridOneDeviceSpec.cpp +52 -0
  142. package/nitrogen/generated/android/c++/JHybridOneDeviceSpec.hpp +3 -0
  143. package/nitrogen/generated/android/c++/JHybridOneHapticsSpec.cpp +8 -0
  144. package/nitrogen/generated/android/c++/JHybridOneHapticsSpec.hpp +1 -0
  145. package/nitrogen/generated/android/c++/JHybridOneImageManipulatorSpec.cpp +5 -1
  146. package/nitrogen/generated/android/c++/JHybridOneKeepAwakeSpec.cpp +31 -0
  147. package/nitrogen/generated/android/c++/JHybridOneKeepAwakeSpec.hpp +2 -0
  148. package/nitrogen/generated/android/c++/JHybridOneSecureStoreSpec.cpp +26 -19
  149. package/nitrogen/generated/android/c++/JHybridOneSecureStoreSpec.hpp +6 -6
  150. package/nitrogen/generated/android/c++/JImageTransformOptions.hpp +7 -1
  151. package/nitrogen/generated/android/c++/JLocaleInfo.hpp +110 -0
  152. package/nitrogen/generated/android/c++/JOneImageFlip.hpp +58 -0
  153. package/nitrogen/generated/android/c++/JOneImageFormat.hpp +3 -0
  154. package/nitrogen/generated/android/c++/JSecureStoreAccessibility.hpp +73 -0
  155. package/nitrogen/generated/android/c++/JSecureStoreOptions.hpp +76 -0
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/AndroidHaptic.kt +40 -0
  157. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/CalendarInfo.kt +66 -0
  158. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HapticImpact.kt +2 -2
  159. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneDeviceSpec.kt +17 -0
  160. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneHapticsSpec.kt +4 -0
  161. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneKeepAwakeSpec.kt +8 -0
  162. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneSecureStoreSpec.kt +6 -6
  163. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/ImageTransformOptions.kt +7 -2
  164. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/LocaleInfo.kt +116 -0
  165. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/OneImageFlip.kt +23 -0
  166. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/OneImageFormat.kt +2 -1
  167. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/SecureStoreAccessibility.kt +28 -0
  168. package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/SecureStoreOptions.kt +71 -0
  169. package/nitrogen/generated/ios/One-Swift-Cxx-Bridge.hpp +133 -51
  170. package/nitrogen/generated/ios/One-Swift-Cxx-Umbrella.hpp +19 -1
  171. package/nitrogen/generated/ios/c++/HybridOneDeviceSpecSwift.hpp +31 -0
  172. package/nitrogen/generated/ios/c++/HybridOneHapticsSpecSwift.hpp +9 -0
  173. package/nitrogen/generated/ios/c++/HybridOneImageManipulatorSpecSwift.hpp +4 -1
  174. package/nitrogen/generated/ios/c++/HybridOneKeepAwakeSpecSwift.hpp +18 -1
  175. package/nitrogen/generated/ios/c++/HybridOneSecureStoreSpecSwift.hpp +18 -13
  176. package/nitrogen/generated/ios/swift/AndroidHaptic.swift +108 -0
  177. package/nitrogen/generated/ios/swift/CalendarInfo.swift +96 -0
  178. package/nitrogen/generated/ios/swift/HapticImpact.swift +4 -4
  179. package/nitrogen/generated/ios/swift/HybridOneDeviceSpec.swift +3 -0
  180. package/nitrogen/generated/ios/swift/HybridOneDeviceSpec_cxx.swift +56 -0
  181. package/nitrogen/generated/ios/swift/HybridOneHapticsSpec.swift +1 -0
  182. package/nitrogen/generated/ios/swift/HybridOneHapticsSpec_cxx.swift +11 -0
  183. package/nitrogen/generated/ios/swift/HybridOneKeepAwakeSpec.swift +3 -1
  184. package/nitrogen/generated/ios/swift/HybridOneKeepAwakeSpec_cxx.swift +41 -3
  185. package/nitrogen/generated/ios/swift/HybridOneSecureStoreSpec.swift +6 -6
  186. package/nitrogen/generated/ios/swift/HybridOneSecureStoreSpec_cxx.swift +12 -12
  187. package/nitrogen/generated/ios/swift/ImageTransformOptions.swift +16 -5
  188. package/nitrogen/generated/ios/swift/LocaleInfo.swift +250 -0
  189. package/nitrogen/generated/ios/swift/OneImageFlip.swift +40 -0
  190. package/nitrogen/generated/ios/swift/OneImageFormat.swift +4 -0
  191. package/nitrogen/generated/ios/swift/SecureStoreAccessibility.swift +60 -0
  192. package/nitrogen/generated/ios/swift/SecureStoreOptions.swift +107 -0
  193. package/nitrogen/generated/shared/c++/AndroidHaptic.hpp +144 -0
  194. package/nitrogen/generated/shared/c++/CalendarInfo.hpp +96 -0
  195. package/nitrogen/generated/shared/c++/HapticImpact.hpp +5 -5
  196. package/nitrogen/generated/shared/c++/HybridOneDeviceSpec.cpp +3 -0
  197. package/nitrogen/generated/shared/c++/HybridOneDeviceSpec.hpp +11 -0
  198. package/nitrogen/generated/shared/c++/HybridOneHapticsSpec.cpp +1 -0
  199. package/nitrogen/generated/shared/c++/HybridOneHapticsSpec.hpp +4 -0
  200. package/nitrogen/generated/shared/c++/HybridOneKeepAwakeSpec.cpp +2 -0
  201. package/nitrogen/generated/shared/c++/HybridOneKeepAwakeSpec.hpp +4 -1
  202. package/nitrogen/generated/shared/c++/HybridOneSecureStoreSpec.hpp +9 -7
  203. package/nitrogen/generated/shared/c++/ImageTransformOptions.hpp +8 -1
  204. package/nitrogen/generated/shared/c++/LocaleInfo.hpp +136 -0
  205. package/nitrogen/generated/shared/c++/OneImageFlip.hpp +76 -0
  206. package/nitrogen/generated/shared/c++/OneImageFormat.hpp +4 -0
  207. package/nitrogen/generated/shared/c++/SecureStoreAccessibility.hpp +96 -0
  208. package/nitrogen/generated/shared/c++/SecureStoreOptions.hpp +102 -0
  209. package/package.json +15 -15
  210. package/src/index.ts +3 -0
  211. package/src/one.test.ts +2 -0
  212. package/src/one.ts +3 -0
  213. package/src/platform/extras.ts +3 -0
  214. package/src/platform/haptics/index.native.ts +13 -3
  215. package/src/platform/haptics/index.ts +12 -3
  216. package/src/platform/haptics/types.ts +25 -0
  217. package/src/platform/haptics/validation.ts +31 -1
  218. package/src/platform/image-manipulator/index.native.ts +3 -0
  219. package/src/platform/image-manipulator/index.ts +10 -3
  220. package/src/platform/index.native.ts +3 -2
  221. package/src/platform/index.ts +3 -2
  222. package/src/platform/keep-awake/index.native.ts +31 -2
  223. package/src/platform/keep-awake/index.ts +66 -17
  224. package/src/platform/keep-awake/unavailable.ts +12 -2
  225. package/src/platform/keep-awake/validate.ts +16 -0
  226. package/src/platform/localization/index.native.ts +47 -0
  227. package/src/platform/localization/index.ts +90 -0
  228. package/src/platform/localization/map.ts +77 -0
  229. package/src/platform/localization/types.ts +36 -0
  230. package/src/platform/secure-store/index.native.ts +26 -13
  231. package/src/platform/secure-store/index.ts +20 -7
  232. package/src/platform/secure-store/types.ts +33 -0
  233. package/src/platform/secure-store/validate.ts +48 -0
  234. package/src/platform/specs/OneDevice.nitro.ts +34 -0
  235. package/src/platform/specs/OneHaptics.nitro.ts +4 -1
  236. package/src/platform/specs/OneImageManipulator.nitro.ts +4 -1
  237. package/src/platform/specs/OneKeepAwake.nitro.ts +2 -0
  238. package/src/platform/specs/OneSecureStore.nitro.ts +12 -8
  239. package/types/index.d.ts +1 -1
  240. package/types/index.d.ts.map +1 -1
  241. package/types/one.d.ts +2 -1
  242. package/types/one.d.ts.map +1 -1
  243. package/types/platform/extras.d.ts +3 -0
  244. package/types/platform/extras.d.ts.map +1 -1
  245. package/types/platform/haptics/index.d.ts +2 -2
  246. package/types/platform/haptics/index.d.ts.map +1 -1
  247. package/types/platform/haptics/index.native.d.ts +2 -2
  248. package/types/platform/haptics/index.native.d.ts.map +1 -1
  249. package/types/platform/haptics/types.d.ts +3 -0
  250. package/types/platform/haptics/types.d.ts.map +1 -1
  251. package/types/platform/haptics/validation.d.ts +3 -1
  252. package/types/platform/haptics/validation.d.ts.map +1 -1
  253. package/types/platform/image-manipulator/index.d.ts +1 -1
  254. package/types/platform/image-manipulator/index.d.ts.map +1 -1
  255. package/types/platform/image-manipulator/index.native.d.ts +1 -1
  256. package/types/platform/image-manipulator/index.native.d.ts.map +1 -1
  257. package/types/platform/index.d.ts +3 -3
  258. package/types/platform/index.d.ts.map +1 -1
  259. package/types/platform/index.native.d.ts +3 -3
  260. package/types/platform/index.native.d.ts.map +1 -1
  261. package/types/platform/keep-awake/index.d.ts +3 -0
  262. package/types/platform/keep-awake/index.d.ts.map +1 -1
  263. package/types/platform/keep-awake/index.native.d.ts +5 -0
  264. package/types/platform/keep-awake/index.native.d.ts.map +1 -1
  265. package/types/platform/keep-awake/unavailable.d.ts +4 -0
  266. package/types/platform/keep-awake/unavailable.d.ts.map +1 -1
  267. package/types/platform/keep-awake/validate.d.ts +3 -0
  268. package/types/platform/keep-awake/validate.d.ts.map +1 -1
  269. package/types/platform/localization/index.d.ts +7 -0
  270. package/types/platform/localization/index.d.ts.map +1 -0
  271. package/types/platform/localization/index.native.d.ts +7 -0
  272. package/types/platform/localization/index.native.d.ts.map +1 -0
  273. package/types/platform/localization/map.d.ts +9 -0
  274. package/types/platform/localization/map.d.ts.map +1 -0
  275. package/types/platform/localization/types.d.ts +31 -0
  276. package/types/platform/localization/types.d.ts.map +1 -0
  277. package/types/platform/secure-store/index.d.ts +8 -7
  278. package/types/platform/secure-store/index.d.ts.map +1 -1
  279. package/types/platform/secure-store/index.native.d.ts +8 -7
  280. package/types/platform/secure-store/index.native.d.ts.map +1 -1
  281. package/types/platform/secure-store/types.d.ts +24 -0
  282. package/types/platform/secure-store/types.d.ts.map +1 -0
  283. package/types/platform/secure-store/validate.d.ts +3 -0
  284. package/types/platform/secure-store/validate.d.ts.map +1 -1
  285. package/types/platform/specs/OneDevice.nitro.d.ts +25 -0
  286. package/types/platform/specs/OneDevice.nitro.d.ts.map +1 -1
  287. package/types/platform/specs/OneHaptics.nitro.d.ts +2 -1
  288. package/types/platform/specs/OneHaptics.nitro.d.ts.map +1 -1
  289. package/types/platform/specs/OneImageManipulator.nitro.d.ts +3 -1
  290. package/types/platform/specs/OneImageManipulator.nitro.d.ts.map +1 -1
  291. package/types/platform/specs/OneKeepAwake.nitro.d.ts +2 -0
  292. package/types/platform/specs/OneKeepAwake.nitro.d.ts.map +1 -1
  293. package/types/platform/specs/OneSecureStore.nitro.d.ts +8 -6
  294. package/types/platform/specs/OneSecureStore.nitro.d.ts.map +1 -1
@@ -60,7 +60,7 @@ import { Widgets, LiveActivities, WidgetUI } from './widgets/index'
60
60
 
61
61
  export * from './extras'
62
62
  export { Storage } from './storage/index.native'
63
- export { KeepAwake } from './keep-awake/index'
63
+ export { KeepAwake, useKeepAwake } from './keep-awake/index'
64
64
  export { Print } from './print/index'
65
65
  export { StoreReview } from './store-review/index'
66
66
  export { QuickActions } from './quick-actions/index'
@@ -278,6 +278,7 @@ export type {
278
278
  export { ImageManipulator } from './image-manipulator/index.native'
279
279
  export type {
280
280
  ImageCrop,
281
+ ImageFlip,
281
282
  ImageFormat,
282
283
  ImageResize,
283
284
  ImageManipulatorOptions,
@@ -324,7 +325,7 @@ export type {
324
325
  ReminderInfo,
325
326
  ReminderInput,
326
327
  } from './calendar/index'
327
- export type { HapticImpact, HapticNotification, HapticsApi } from './haptics/index.native'
328
+ export type { AndroidHaptic, HapticImpact, HapticNotification, HapticsApi } from './haptics/index.native'
328
329
  export type {
329
330
  LaunchScreenApi,
330
331
  LaunchScreenHideOptions,
@@ -61,7 +61,7 @@ export type { LocalAuthenticationStatus } from './local-authentication/index'
61
61
  export { ProtectedStore } from './protected-store/index'
62
62
  export type { ProtectedStorePolicy } from './protected-store/index'
63
63
  export { Storage } from './storage/index'
64
- export { KeepAwake } from './keep-awake/index'
64
+ export { KeepAwake, useKeepAwake } from './keep-awake/index'
65
65
  export { Print } from './print/index'
66
66
  export { StoreReview } from './store-review/index'
67
67
  export { QuickActions } from './quick-actions/index'
@@ -152,6 +152,7 @@ export type {
152
152
  export { ImageManipulator } from './image-manipulator/index'
153
153
  export type {
154
154
  ImageCrop,
155
+ ImageFlip,
155
156
  ImageFormat,
156
157
  ImageResize,
157
158
  ImageManipulatorOptions,
@@ -198,7 +199,7 @@ export type {
198
199
  ReminderInfo,
199
200
  ReminderInput,
200
201
  } from './calendar/index'
201
- export type { HapticImpact, HapticNotification, HapticsApi } from './haptics/index'
202
+ export type { AndroidHaptic, HapticImpact, HapticNotification, HapticsApi } from './haptics/index'
202
203
  export type { LaunchScreenApi, LaunchScreenHideOptions } from './launchScreen/index'
203
204
  export { AppInfo } from './app-info/index'
204
205
  export type { AppInfoApi } from './app-info/index'
@@ -1,7 +1,8 @@
1
+ import { useEffect, useId } from 'react'
1
2
  import { NitroModules } from 'react-native-nitro-modules'
2
3
  import { rethrowNativeError } from '../nativeError'
3
4
  import type { OneKeepAwake } from '../specs/OneKeepAwake.nitro'
4
- import { assertKeepAwakeEnabled } from './validate'
5
+ import { assertKeepAwakeEnabled, assertKeepAwakeTag, normalizeKeepAwakeTag } from './validate'
5
6
 
6
7
  let hybrid: OneKeepAwake | undefined
7
8
 
@@ -19,4 +20,32 @@ function setEnabled(enabled: boolean): Promise<void> {
19
20
  return native().setEnabled(enabled).catch(rethrowNativeError)
20
21
  }
21
22
 
22
- export const KeepAwake = Object.freeze({ isEnabled, setEnabled })
23
+ function activate(tag?: string): Promise<void> {
24
+ assertKeepAwakeTag(tag, 'activate')
25
+ return native().activate(normalizeKeepAwakeTag(tag)).catch(rethrowNativeError)
26
+ }
27
+
28
+ function deactivate(tag?: string): Promise<void> {
29
+ assertKeepAwakeTag(tag, 'deactivate')
30
+ return native().deactivate(normalizeKeepAwakeTag(tag)).catch(rethrowNativeError)
31
+ }
32
+
33
+ export function useKeepAwake(tag?: string): void {
34
+ const fallback = useId()
35
+ assertKeepAwakeTag(tag, 'useKeepAwake')
36
+ // a hook without a tag owns an id unique to its component instance, never
37
+ // the shared default tag, matching expo-keep-awake.
38
+ const effective = tag ?? fallback
39
+ useEffect(() => {
40
+ // a hook has no caller to reject to, so failures are reported, as
41
+ // usePreventScreenCapture does.
42
+ activate(effective).catch((error: unknown) => {
43
+ console.error(`Failed to keep the screen awake: ${String(error)}`)
44
+ })
45
+ return () => {
46
+ deactivate(effective).catch(() => {})
47
+ }
48
+ }, [effective])
49
+ }
50
+
51
+ export const KeepAwake = Object.freeze({ isEnabled, setEnabled, activate, deactivate })
@@ -1,27 +1,76 @@
1
+ import { useEffect, useId } from 'react'
1
2
  import { KeepAwake as unavailable } from './unavailable'
2
- import { assertKeepAwakeEnabled } from './validate'
3
+ import {
4
+ assertKeepAwakeEnabled,
5
+ assertKeepAwakeTag,
6
+ normalizeKeepAwakeTag,
7
+ } from './validate'
8
+
9
+ const active = new Set<string>()
3
10
  let lock: WakeLockSentinel | undefined
4
11
  let operation: Promise<void> = Promise.resolve()
12
+
13
+ function live(): boolean {
14
+ return !!lock && !lock.released
15
+ }
16
+
17
+ function apply(owner: 'setEnabled' | 'activate' | 'deactivate'): Promise<void> {
18
+ const next = operation
19
+ .catch(() => {})
20
+ .then(async () => {
21
+ if (active.size === 0) {
22
+ await lock?.release()
23
+ lock = undefined
24
+ return
25
+ }
26
+ if (live()) return
27
+ if (!navigator.wakeLock)
28
+ throw new Error(`KeepAwake.${owner}: Screen Wake Lock is unavailable`)
29
+ lock = await navigator.wakeLock.request('screen')
30
+ })
31
+ operation = next
32
+ return next
33
+ }
34
+
5
35
  export const KeepAwake = Object.freeze({
6
36
  isEnabled: async (): Promise<boolean> =>
7
- typeof window !== 'undefined' && !!lock && !lock.released,
37
+ typeof window !== 'undefined' && active.size > 0 && live(),
8
38
  setEnabled: (enabled: boolean): Promise<void> => {
9
39
  assertKeepAwakeEnabled(enabled)
10
40
  if (typeof window === 'undefined') return unavailable.setEnabled(enabled)
11
- const next = operation
12
- .catch(() => {})
13
- .then(async () => {
14
- if (!enabled) {
15
- await lock?.release()
16
- lock = undefined
17
- return
18
- }
19
- if (lock && !lock.released) return
20
- if (!navigator.wakeLock)
21
- throw new Error('KeepAwake.setEnabled: Screen Wake Lock is unavailable')
22
- lock = await navigator.wakeLock.request('screen')
23
- })
24
- operation = next
25
- return next
41
+ if (enabled) active.add(normalizeKeepAwakeTag(undefined))
42
+ else active.delete(normalizeKeepAwakeTag(undefined))
43
+ return apply('setEnabled')
44
+ },
45
+ activate: (tag?: string): Promise<void> => {
46
+ assertKeepAwakeTag(tag, 'activate')
47
+ if (typeof window === 'undefined') return unavailable.activate(tag)
48
+ active.add(normalizeKeepAwakeTag(tag))
49
+ return apply('activate')
50
+ },
51
+ deactivate: (tag?: string): Promise<void> => {
52
+ assertKeepAwakeTag(tag, 'deactivate')
53
+ if (typeof window === 'undefined') return unavailable.deactivate(tag)
54
+ active.delete(normalizeKeepAwakeTag(tag))
55
+ return apply('deactivate')
26
56
  },
27
57
  })
58
+
59
+ export function useKeepAwake(tag?: string): void {
60
+ const fallback = useId()
61
+ assertKeepAwakeTag(tag, 'useKeepAwake')
62
+ // a hook without a tag owns an id unique to its component instance, never
63
+ // the shared default tag, matching expo-keep-awake.
64
+ const effective = tag ?? fallback
65
+ useEffect(() => {
66
+ if (typeof window === 'undefined') return
67
+ // a hook has no caller to reject to, so failures are reported, as
68
+ // usePreventScreenCapture does.
69
+ KeepAwake.activate(effective).catch((error: unknown) => {
70
+ console.error(`Failed to keep the screen awake: ${String(error)}`)
71
+ })
72
+ return () => {
73
+ KeepAwake.deactivate(effective).catch(() => {})
74
+ }
75
+ }, [effective])
76
+ }
@@ -1,4 +1,4 @@
1
- import { assertKeepAwakeEnabled } from './validate'
1
+ import { assertKeepAwakeEnabled, assertKeepAwakeTag } from './validate'
2
2
 
3
3
  function isEnabled(): Promise<boolean> {
4
4
  return Promise.resolve(false)
@@ -9,4 +9,14 @@ function setEnabled(enabled: boolean): Promise<void> {
9
9
  return Promise.resolve()
10
10
  }
11
11
 
12
- export const KeepAwake = Object.freeze({ isEnabled, setEnabled })
12
+ function activate(tag?: string): Promise<void> {
13
+ assertKeepAwakeTag(tag, 'activate')
14
+ return Promise.resolve()
15
+ }
16
+
17
+ function deactivate(tag?: string): Promise<void> {
18
+ assertKeepAwakeTag(tag, 'deactivate')
19
+ return Promise.resolve()
20
+ }
21
+
22
+ export const KeepAwake = Object.freeze({ isEnabled, setEnabled, activate, deactivate })
@@ -4,3 +4,19 @@ export function assertKeepAwakeEnabled(value: unknown): asserts value is boolean
4
4
  throw new Error('KeepAwake.setEnabled: enabled must be a boolean')
5
5
  }
6
6
  }
7
+
8
+ // expo's default tag, used when activate/deactivate omit one.
9
+ export const keepAwakeDefaultTag = 'ExpoKeepAwakeDefaultTag'
10
+
11
+ export function assertKeepAwakeTag(
12
+ value: unknown,
13
+ owner: 'activate' | 'deactivate' | 'useKeepAwake'
14
+ ): asserts value is string | undefined {
15
+ if (value !== undefined && typeof value !== 'string') {
16
+ throw new Error(`KeepAwake.${owner}: tag must be a string`)
17
+ }
18
+ }
19
+
20
+ export function normalizeKeepAwakeTag(value: string | undefined): string {
21
+ return value ?? keepAwakeDefaultTag
22
+ }
@@ -0,0 +1,47 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { NitroModules } from 'react-native-nitro-modules'
3
+ import type { OneDevice } from '../specs/OneDevice.nitro'
4
+ import { toCalendars, toLocales } from './map'
5
+ import type { Calendar, Locale, Localization as LocalizationApi } from './types'
6
+
7
+ export type { Calendar, Locale, LocalizationApi }
8
+
9
+ // expo-localization's synchronous reads plus its live hooks, backed by the
10
+ // OneDevice nitro hybrid object (created on first use and cached). the first
11
+ // hook subscription starts the platform locale observer and the last removal
12
+ // stops it, so a change can never race the subscription.
13
+ let hybrid: OneDevice | undefined
14
+
15
+ function native(): OneDevice {
16
+ hybrid ??= NitroModules.createHybridObject<OneDevice>('OneDevice')
17
+ return hybrid
18
+ }
19
+
20
+ function getLocales(): [Locale, ...Locale[]] {
21
+ return toLocales(native().getLocales())
22
+ }
23
+
24
+ function getCalendars(): [Calendar, ...Calendar[]] {
25
+ return toCalendars(native().getCalendars())
26
+ }
27
+
28
+ function useLocales(): [Locale, ...Locale[]] {
29
+ const [locales, setLocales] = useState<[Locale, ...Locale[]]>(() => getLocales())
30
+ useEffect(() => {
31
+ setLocales(getLocales())
32
+ return native().addLocalizationListener(() => setLocales(getLocales()))
33
+ }, [])
34
+ return locales
35
+ }
36
+
37
+ function useCalendars(): [Calendar, ...Calendar[]] {
38
+ const [calendars, setCalendars] = useState<[Calendar, ...Calendar[]]>(() => getCalendars())
39
+ useEffect(() => {
40
+ setCalendars(getCalendars())
41
+ return native().addLocalizationListener(() => setCalendars(getCalendars()))
42
+ }, [])
43
+ return calendars
44
+ }
45
+
46
+ export const Localization: LocalizationApi = Object.freeze({ getLocales, getCalendars })
47
+ export { useCalendars, useLocales }
@@ -0,0 +1,90 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { FALLBACK_CALENDAR, FALLBACK_LOCALE } from './map'
3
+ import type { Calendar, Locale, Localization as LocalizationApi } from './types'
4
+
5
+ export type { Calendar, Locale, LocalizationApi }
6
+
7
+ // web entry. same shape as the native entry, read from Intl and navigator:
8
+ // currency and measurement are not exposed on the web, so they stay null as
9
+ // in expo-localization. on the server every read is the en-US fallback, so a
10
+ // route module that imports this renders under SSR and SSG.
11
+ function localeFor(tag: string): Locale {
12
+ try {
13
+ const parsed = new Intl.Locale(tag)
14
+ const numbers = new Intl.NumberFormat(tag).formatToParts(1234567.89)
15
+ const part = (type: string) => numbers.find((entry) => entry.type === type)?.value ?? null
16
+ // Intl.Locale textInfo and weekInfo are stage-3: read them structurally.
17
+ const direction = (parsed as { textInfo?: { direction?: string } }).textInfo?.direction
18
+ return {
19
+ languageTag: parsed.baseName,
20
+ languageCode: parsed.language ?? null,
21
+ languageScriptCode: parsed.script ?? null,
22
+ regionCode: parsed.region ?? null,
23
+ languageRegionCode: parsed.region ?? null,
24
+ currencyCode: null,
25
+ currencySymbol: null,
26
+ languageCurrencyCode: null,
27
+ languageCurrencySymbol: null,
28
+ decimalSeparator: part('decimal'),
29
+ digitGroupingSeparator: part('group'),
30
+ textDirection: direction === 'rtl' ? 'rtl' : 'ltr',
31
+ measurementSystem: null,
32
+ temperatureUnit: null,
33
+ }
34
+ } catch {
35
+ return { ...FALLBACK_LOCALE, languageTag: tag }
36
+ }
37
+ }
38
+
39
+ function getLocales(): [Locale, ...Locale[]] {
40
+ if (typeof navigator === 'undefined' || !navigator.languages?.length) {
41
+ return [FALLBACK_LOCALE]
42
+ }
43
+ const locales = [...navigator.languages].map(localeFor)
44
+ return locales.length > 0 ? (locales as [Locale, ...Locale[]]) : [FALLBACK_LOCALE]
45
+ }
46
+
47
+ function getCalendars(): [Calendar, ...Calendar[]] {
48
+ if (typeof Intl === 'undefined') return [FALLBACK_CALENDAR]
49
+ try {
50
+ const options = new Intl.DateTimeFormat().resolvedOptions()
51
+ const parsed = new Intl.Locale(options.locale) as Intl.Locale & {
52
+ hourCycle?: string
53
+ weekInfo?: { firstDay?: number }
54
+ }
55
+ const firstDay = parsed.weekInfo?.firstDay
56
+ return [
57
+ {
58
+ calendar: options.calendar ?? null,
59
+ timeZone: options.timeZone ?? null,
60
+ uses24hourClock:
61
+ parsed.hourCycle === undefined ? null : parsed.hourCycle === 'h23' || parsed.hourCycle === 'h24',
62
+ // weekInfo numbers monday as 1; expo numbers sunday as 1.
63
+ firstWeekday: firstDay === undefined ? null : (firstDay % 7) + 1,
64
+ },
65
+ ]
66
+ } catch {
67
+ return [FALLBACK_CALENDAR]
68
+ }
69
+ }
70
+
71
+ function subscribe(refresh: () => void): (() => void) | undefined {
72
+ if (typeof window === 'undefined') return undefined
73
+ window.addEventListener('languagechange', refresh)
74
+ return () => window.removeEventListener('languagechange', refresh)
75
+ }
76
+
77
+ function useLocales(): [Locale, ...Locale[]] {
78
+ const [locales, setLocales] = useState<[Locale, ...Locale[]]>(() => getLocales())
79
+ useEffect(() => subscribe(() => setLocales(getLocales())), [])
80
+ return locales
81
+ }
82
+
83
+ function useCalendars(): [Calendar, ...Calendar[]] {
84
+ const [calendars, setCalendars] = useState<[Calendar, ...Calendar[]]>(() => getCalendars())
85
+ useEffect(() => subscribe(() => setCalendars(getCalendars())), [])
86
+ return calendars
87
+ }
88
+
89
+ export const Localization: LocalizationApi = Object.freeze({ getLocales, getCalendars })
90
+ export { useCalendars, useLocales }
@@ -0,0 +1,77 @@
1
+ import type { CalendarInfo, LocaleInfo } from '../specs/OneDevice.nitro'
2
+ import type { Calendar, Locale } from './types'
3
+
4
+ // the native spec carries unknown fields as undefined; expo's shape carries
5
+ // them as null. this is the only place that conversion happens.
6
+ export function toLocale(info: LocaleInfo): Locale {
7
+ return {
8
+ languageTag: info.languageTag,
9
+ languageCode: info.languageCode ?? null,
10
+ languageScriptCode: info.languageScriptCode ?? null,
11
+ regionCode: info.regionCode ?? null,
12
+ languageRegionCode: info.languageRegionCode ?? null,
13
+ currencyCode: info.currencyCode ?? null,
14
+ currencySymbol: info.currencySymbol ?? null,
15
+ languageCurrencyCode: info.languageCurrencyCode ?? null,
16
+ languageCurrencySymbol: info.languageCurrencySymbol ?? null,
17
+ decimalSeparator: info.decimalSeparator ?? null,
18
+ digitGroupingSeparator: info.digitGroupingSeparator ?? null,
19
+ textDirection: info.textDirection === 'rtl' ? 'rtl' : 'ltr',
20
+ measurementSystem:
21
+ info.measurementSystem === 'metric' ||
22
+ info.measurementSystem === 'us' ||
23
+ info.measurementSystem === 'uk'
24
+ ? info.measurementSystem
25
+ : null,
26
+ temperatureUnit:
27
+ info.temperatureUnit === 'celsius' || info.temperatureUnit === 'fahrenheit'
28
+ ? info.temperatureUnit
29
+ : null,
30
+ }
31
+ }
32
+
33
+ export function toCalendar(info: CalendarInfo): Calendar {
34
+ return {
35
+ calendar: info.calendar ?? null,
36
+ timeZone: info.timeZone ?? null,
37
+ uses24hourClock: info.uses24hourClock ?? null,
38
+ firstWeekday: info.firstWeekday ?? null,
39
+ }
40
+ }
41
+
42
+ // expo guarantees at least one entry. native always answers with the current
43
+ // locale, so an empty list means a broken build: fall back to a plain en-US
44
+ // snapshot rather than handing callers an empty array to crash on.
45
+ export const FALLBACK_LOCALE: Locale = {
46
+ languageTag: 'en-US',
47
+ languageCode: 'en',
48
+ languageScriptCode: null,
49
+ regionCode: 'US',
50
+ languageRegionCode: 'US',
51
+ currencyCode: null,
52
+ currencySymbol: null,
53
+ languageCurrencyCode: null,
54
+ languageCurrencySymbol: null,
55
+ decimalSeparator: null,
56
+ digitGroupingSeparator: null,
57
+ textDirection: 'ltr',
58
+ measurementSystem: null,
59
+ temperatureUnit: null,
60
+ }
61
+
62
+ export const FALLBACK_CALENDAR: Calendar = {
63
+ calendar: 'gregory',
64
+ timeZone: null,
65
+ uses24hourClock: null,
66
+ firstWeekday: null,
67
+ }
68
+
69
+ export function toLocales(infos: LocaleInfo[]): [Locale, ...Locale[]] {
70
+ const locales = infos.map(toLocale)
71
+ return locales.length > 0 ? (locales as [Locale, ...Locale[]]) : [FALLBACK_LOCALE]
72
+ }
73
+
74
+ export function toCalendars(infos: CalendarInfo[]): [Calendar, ...Calendar[]] {
75
+ const calendars = infos.map(toCalendar)
76
+ return calendars.length > 0 ? (calendars as [Calendar, ...Calendar[]]) : [FALLBACK_CALENDAR]
77
+ }
@@ -0,0 +1,36 @@
1
+ // expo-localization's Locale and Calendar shapes, field for field: unknown
2
+ // values are null, never undefined, and text direction, measurement system
3
+ // and temperature unit are lowercase string unions.
4
+
5
+ export interface Locale {
6
+ languageTag: string
7
+ languageCode: string | null
8
+ languageScriptCode: string | null
9
+ regionCode: string | null
10
+ languageRegionCode: string | null
11
+ currencyCode: string | null
12
+ currencySymbol: string | null
13
+ languageCurrencyCode: string | null
14
+ languageCurrencySymbol: string | null
15
+ decimalSeparator: string | null
16
+ digitGroupingSeparator: string | null
17
+ textDirection: 'ltr' | 'rtl'
18
+ measurementSystem: 'metric' | 'us' | 'uk' | null
19
+ temperatureUnit: 'celsius' | 'fahrenheit' | null
20
+ }
21
+
22
+ export interface Calendar {
23
+ /** unicode calendar type, e.g. 'gregory', 'buddhist', 'islamic' */
24
+ calendar: string | null
25
+ timeZone: string | null
26
+ uses24hourClock: boolean | null
27
+ /** first day of the week: sunday is 1, saturday is 7 */
28
+ firstWeekday: number | null
29
+ }
30
+
31
+ export interface Localization {
32
+ /** preferred locales in the user's order, always at least one */
33
+ getLocales(): [Locale, ...Locale[]]
34
+ /** preferred calendars, always at least one */
35
+ getCalendars(): [Calendar, ...Calendar[]]
36
+ }
@@ -1,7 +1,14 @@
1
1
  import { NitroModules } from 'react-native-nitro-modules'
2
2
  import { rethrowNativeError } from '../nativeError'
3
3
  import type { OneSecureStore } from '../specs/OneSecureStore.nitro'
4
- import { assertSecureStoreKey, assertSecureStoreValue } from './validate'
4
+ import type { SecureStoreOptions } from './types'
5
+ import {
6
+ assertSecureStoreKey,
7
+ assertSecureStoreOptions,
8
+ assertSecureStoreValue,
9
+ } from './validate'
10
+
11
+ export type { SecureStoreAccessibility, SecureStoreOptions } from './types'
5
12
 
6
13
  // string key-value storage matching expo-secure-store's item api, backed by
7
14
  // the OneSecureStore nitro hybrid object (created on first use and cached).
@@ -13,49 +20,55 @@ function native(): OneSecureStore {
13
20
  return hybrid
14
21
  }
15
22
 
16
- function getItem(key: string): Promise<string | null> {
23
+ function getItem(key: string, options?: SecureStoreOptions): Promise<string | null> {
17
24
  assertSecureStoreKey(key, 'SecureStore.getItem')
25
+ const checked = assertSecureStoreOptions(options, 'SecureStore.getItem')
18
26
  return native()
19
- .getItem(key)
27
+ .getItem(key, checked)
20
28
  .then((value) => value ?? null, rethrowNativeError)
21
29
  }
22
30
 
23
- function setItem(key: string, value: string): Promise<void> {
31
+ function setItem(key: string, value: string, options?: SecureStoreOptions): Promise<void> {
24
32
  assertSecureStoreKey(key, 'SecureStore.setItem')
25
33
  assertSecureStoreValue(value, 'SecureStore.setItem')
26
- return native().setItem(key, value).catch(rethrowNativeError)
34
+ const checked = assertSecureStoreOptions(options, 'SecureStore.setItem')
35
+ return native().setItem(key, value, checked).catch(rethrowNativeError)
27
36
  }
28
37
 
29
- function deleteItem(key: string): Promise<void> {
38
+ function deleteItem(key: string, options?: SecureStoreOptions): Promise<void> {
30
39
  assertSecureStoreKey(key, 'SecureStore.deleteItem')
31
- return native().deleteItem(key).catch(rethrowNativeError)
40
+ const checked = assertSecureStoreOptions(options, 'SecureStore.deleteItem')
41
+ return native().deleteItem(key, checked).catch(rethrowNativeError)
32
42
  }
33
43
 
34
44
  // the synchronous verbs block the js thread on the keychain or keystore, as
35
45
  // expo-secure-store's getItem and setItem do: for values a first render needs
36
- function getItemSync(key: string): string | null {
46
+ function getItemSync(key: string, options?: SecureStoreOptions): string | null {
37
47
  assertSecureStoreKey(key, 'SecureStore.getItemSync')
48
+ const checked = assertSecureStoreOptions(options, 'SecureStore.getItemSync')
38
49
  try {
39
- return native().getItemSync(key) ?? null
50
+ return native().getItemSync(key, checked) ?? null
40
51
  } catch (error) {
41
52
  rethrowNativeError(error)
42
53
  }
43
54
  }
44
55
 
45
- function setItemSync(key: string, value: string): void {
56
+ function setItemSync(key: string, value: string, options?: SecureStoreOptions): void {
46
57
  assertSecureStoreKey(key, 'SecureStore.setItemSync')
47
58
  assertSecureStoreValue(value, 'SecureStore.setItemSync')
59
+ const checked = assertSecureStoreOptions(options, 'SecureStore.setItemSync')
48
60
  try {
49
- native().setItemSync(key, value)
61
+ native().setItemSync(key, value, checked)
50
62
  } catch (error) {
51
63
  rethrowNativeError(error)
52
64
  }
53
65
  }
54
66
 
55
- function deleteItemSync(key: string): void {
67
+ function deleteItemSync(key: string, options?: SecureStoreOptions): void {
56
68
  assertSecureStoreKey(key, 'SecureStore.deleteItemSync')
69
+ const checked = assertSecureStoreOptions(options, 'SecureStore.deleteItemSync')
57
70
  try {
58
- native().deleteItemSync(key)
71
+ native().deleteItemSync(key, checked)
59
72
  } catch (error) {
60
73
  rethrowNativeError(error)
61
74
  }
@@ -1,38 +1,51 @@
1
- import { assertSecureStoreKey, assertSecureStoreValue } from './validate'
1
+ import type { SecureStoreOptions } from './types'
2
+ import {
3
+ assertSecureStoreKey,
4
+ assertSecureStoreOptions,
5
+ assertSecureStoreValue,
6
+ } from './validate'
7
+
8
+ export type { SecureStoreAccessibility, SecureStoreOptions } from './types'
2
9
 
3
10
  // web entry. secure storage has no honest web equivalent: anything kept in
4
11
  // localStorage or a cookie persists in cleartext, so every verb rejects
5
12
  // instead of faking it. same signatures as the native entry: the published
6
13
  // declarations are built from this file and serve both platforms.
7
- function getItem(key: string): Promise<string | null> {
14
+ function getItem(key: string, options?: SecureStoreOptions): Promise<string | null> {
8
15
  assertSecureStoreKey(key, 'SecureStore.getItem')
16
+ assertSecureStoreOptions(options, 'SecureStore.getItem')
9
17
  return Promise.reject(new Error('SecureStore.getItem needs an iOS or Android build'))
10
18
  }
11
19
 
12
- function setItem(key: string, value: string): Promise<void> {
20
+ function setItem(key: string, value: string, options?: SecureStoreOptions): Promise<void> {
13
21
  assertSecureStoreKey(key, 'SecureStore.setItem')
14
22
  assertSecureStoreValue(value, 'SecureStore.setItem')
23
+ assertSecureStoreOptions(options, 'SecureStore.setItem')
15
24
  return Promise.reject(new Error('SecureStore.setItem needs an iOS or Android build'))
16
25
  }
17
26
 
18
- function deleteItem(key: string): Promise<void> {
27
+ function deleteItem(key: string, options?: SecureStoreOptions): Promise<void> {
19
28
  assertSecureStoreKey(key, 'SecureStore.deleteItem')
29
+ assertSecureStoreOptions(options, 'SecureStore.deleteItem')
20
30
  return Promise.reject(new Error('SecureStore.deleteItem needs an iOS or Android build'))
21
31
  }
22
32
 
23
- function getItemSync(key: string): string | null {
33
+ function getItemSync(key: string, options?: SecureStoreOptions): string | null {
24
34
  assertSecureStoreKey(key, 'SecureStore.getItemSync')
35
+ assertSecureStoreOptions(options, 'SecureStore.getItemSync')
25
36
  throw new Error('SecureStore.getItemSync needs an iOS or Android build')
26
37
  }
27
38
 
28
- function setItemSync(key: string, value: string): void {
39
+ function setItemSync(key: string, value: string, options?: SecureStoreOptions): void {
29
40
  assertSecureStoreKey(key, 'SecureStore.setItemSync')
30
41
  assertSecureStoreValue(value, 'SecureStore.setItemSync')
42
+ assertSecureStoreOptions(options, 'SecureStore.setItemSync')
31
43
  throw new Error('SecureStore.setItemSync needs an iOS or Android build')
32
44
  }
33
45
 
34
- function deleteItemSync(key: string): void {
46
+ function deleteItemSync(key: string, options?: SecureStoreOptions): void {
35
47
  assertSecureStoreKey(key, 'SecureStore.deleteItemSync')
48
+ assertSecureStoreOptions(options, 'SecureStore.deleteItemSync')
36
49
  throw new Error('SecureStore.deleteItemSync needs an iOS or Android build')
37
50
  }
38
51
 
@@ -0,0 +1,33 @@
1
+ // expo-secure-store's SecureStoreOptions, with its numeric
2
+ // KeychainAccessibilityConstant values as a lowercase string union.
3
+ export type SecureStoreAccessibility =
4
+ | 'afterFirstUnlock'
5
+ | 'afterFirstUnlockThisDeviceOnly'
6
+ | 'always'
7
+ | 'alwaysThisDeviceOnly'
8
+ | 'whenPasscodeSetThisDeviceOnly'
9
+ | 'whenUnlocked'
10
+ | 'whenUnlockedThisDeviceOnly'
11
+
12
+ export interface SecureStoreOptions {
13
+ /**
14
+ * ios: the keychain item's service (kSecAttrService). android: the
15
+ * AndroidKeyStore key alias. an item set with a service is read and
16
+ * deleted with the same service.
17
+ */
18
+ keychainService?: string
19
+ /** ios only: when the item is accessible (kSecAttrAccessible). default 'whenUnlocked' */
20
+ keychainAccessible?: SecureStoreAccessibility
21
+ /**
22
+ * require biometric authentication to read or write the item. ios uses a
23
+ * biometryCurrentSet access control; android uses a user-authentication
24
+ * bound AndroidKeyStore key, invalidated when biometrics change. on
25
+ * android the prompt needs a foreground activity, so the sync verbs throw
26
+ * for an authenticated item instead of prompting.
27
+ */
28
+ requireAuthentication?: boolean
29
+ /** message shown while requireAuthentication prompts */
30
+ authenticationPrompt?: string
31
+ /** ios only: the keychain access group the item belongs to */
32
+ accessGroup?: string
33
+ }