@rownd/react-native 0.2.5 → 2.2.0

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 (252) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +34 -52
  3. package/android/build.gradle +127 -37
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +1 -1
  6. package/android/src/main/java/com/reactnativerowndplugin/RowndPluginModule.kt +98 -0
  7. package/android/src/main/java/com/reactnativerowndplugin/RowndPluginPackage.kt +16 -0
  8. package/ios/{ReactNative.xcodeproj → Rownd.xcodeproj}/project.pbxproj +13 -12
  9. package/ios/RowndPlugin-Bridging-Header.h +3 -0
  10. package/ios/RowndPlugin.m +26 -0
  11. package/ios/RowndPlugin.swift +83 -0
  12. package/ios/RowndPluginEventEmitter.m +12 -0
  13. package/ios/RowndPluginEventEmitter.swift +19 -0
  14. package/lib/commonjs/components/GlobalContext.js +32 -298
  15. package/lib/commonjs/components/GlobalContext.js.map +1 -1
  16. package/lib/commonjs/components/{BottomSheetTextInput/types.js → GlobalContext.types.js} +1 -1
  17. package/lib/commonjs/components/GlobalContext.types.js.map +1 -0
  18. package/lib/commonjs/constants/action.js +13 -0
  19. package/lib/commonjs/constants/action.js.map +1 -0
  20. package/lib/commonjs/hooks/rownd.js +15 -146
  21. package/lib/commonjs/hooks/rownd.js.map +1 -1
  22. package/lib/commonjs/index.js +2 -12
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/reducer/rowndReducer.js +89 -0
  25. package/lib/commonjs/reducer/rowndReducer.js.map +1 -0
  26. package/lib/commonjs/utils/config.js +0 -26
  27. package/lib/commonjs/utils/config.js.map +1 -1
  28. package/lib/commonjs/utils/nativeModule.js +72 -0
  29. package/lib/commonjs/utils/nativeModule.js.map +1 -0
  30. package/lib/module/components/GlobalContext.js +30 -293
  31. package/lib/module/components/GlobalContext.js.map +1 -1
  32. package/lib/module/components/GlobalContext.types.js +2 -0
  33. package/lib/module/components/GlobalContext.types.js.map +1 -0
  34. package/lib/module/constants/action.js +6 -0
  35. package/lib/module/constants/action.js.map +1 -0
  36. package/lib/module/hooks/rownd.js +12 -137
  37. package/lib/module/hooks/rownd.js.map +1 -1
  38. package/lib/module/index.js +2 -4
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/reducer/rowndReducer.js +78 -0
  41. package/lib/module/reducer/rowndReducer.js.map +1 -0
  42. package/lib/module/utils/config.js +1 -16
  43. package/lib/module/utils/config.js.map +1 -1
  44. package/lib/module/utils/nativeModule.js +48 -0
  45. package/lib/module/utils/nativeModule.js.map +1 -0
  46. package/lib/typescript/components/GlobalContext.d.ts +13 -0
  47. package/lib/typescript/{src/components/GlobalContext.d.ts → components/GlobalContext.types.d.ts} +9 -35
  48. package/lib/typescript/constants/action.d.ts +7 -0
  49. package/lib/typescript/{src/hooks → hooks}/rownd.d.ts +10 -13
  50. package/lib/typescript/index.d.ts +3 -0
  51. package/lib/typescript/reducer/rowndReducer.d.ts +4 -0
  52. package/lib/typescript/utils/config.d.ts +10 -0
  53. package/lib/typescript/utils/nativeModule.d.ts +10 -0
  54. package/package.json +36 -56
  55. package/rownd-react-native.podspec +36 -0
  56. package/src/components/GlobalContext.tsx +47 -457
  57. package/src/components/GlobalContext.types.ts +105 -0
  58. package/src/constants/action.ts +8 -0
  59. package/src/hooks/rownd.ts +29 -147
  60. package/src/index.tsx +2 -4
  61. package/src/reducer/rowndReducer.ts +78 -0
  62. package/src/utils/config.ts +0 -27
  63. package/src/utils/nativeModule.ts +69 -0
  64. package/android/src/main/java/com/reactnative/ReactNativePackage.java +0 -22
  65. package/android/src/main/java/com/reactnative/ReactNativeViewManager.java +0 -31
  66. package/ios/ReactNativeViewManager.m +0 -34
  67. package/lib/commonjs/assets/images/checkmark--filled.svg +0 -12
  68. package/lib/commonjs/assets/images/email-verify-waiting.svg +0 -36
  69. package/lib/commonjs/assets/images/error-icon-material.svg +0 -1
  70. package/lib/commonjs/assets/images/phone-verify-waiting.svg +0 -26
  71. package/lib/commonjs/components/AuthenticatedComponent.js +0 -35
  72. package/lib/commonjs/components/AuthenticatedComponent.js.map +0 -1
  73. package/lib/commonjs/components/AutoSigninDialog.js +0 -132
  74. package/lib/commonjs/components/AutoSigninDialog.js.map +0 -1
  75. package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js +0 -65
  76. package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js.map +0 -1
  77. package/lib/commonjs/components/BottomSheetTextInput/index.js +0 -24
  78. package/lib/commonjs/components/BottomSheetTextInput/index.js.map +0 -1
  79. package/lib/commonjs/components/BottomSheetTextInput/types.js.map +0 -1
  80. package/lib/commonjs/components/DarkText.js +0 -35
  81. package/lib/commonjs/components/DarkText.js.map +0 -1
  82. package/lib/commonjs/components/DefaultContext.js +0 -266
  83. package/lib/commonjs/components/DefaultContext.js.map +0 -1
  84. package/lib/commonjs/components/RowndComponents.js +0 -25
  85. package/lib/commonjs/components/RowndComponents.js.map +0 -1
  86. package/lib/commonjs/components/RowndProvider.js +0 -55
  87. package/lib/commonjs/components/RowndProvider.js.map +0 -1
  88. package/lib/commonjs/components/SignIn.js +0 -644
  89. package/lib/commonjs/components/SignIn.js.map +0 -1
  90. package/lib/commonjs/components/images/CheckmarkFilled.js +0 -40
  91. package/lib/commonjs/components/images/CheckmarkFilled.js.map +0 -1
  92. package/lib/commonjs/components/images/EmailVerifyWaiting.js +0 -100
  93. package/lib/commonjs/components/images/EmailVerifyWaiting.js.map +0 -1
  94. package/lib/commonjs/components/images/ErrorIcon.js +0 -31
  95. package/lib/commonjs/components/images/ErrorIcon.js.map +0 -1
  96. package/lib/commonjs/components/images/PhoneVerifyWaiting.js +0 -91
  97. package/lib/commonjs/components/images/PhoneVerifyWaiting.js.map +0 -1
  98. package/lib/commonjs/data/actions.js +0 -26
  99. package/lib/commonjs/data/actions.js.map +0 -1
  100. package/lib/commonjs/hooks/api.js +0 -155
  101. package/lib/commonjs/hooks/api.js.map +0 -1
  102. package/lib/commonjs/hooks/debounce.js +0 -38
  103. package/lib/commonjs/hooks/debounce.js.map +0 -1
  104. package/lib/commonjs/hooks/fingerprint.js +0 -176
  105. package/lib/commonjs/hooks/fingerprint.js.map +0 -1
  106. package/lib/commonjs/hooks/index.js +0 -48
  107. package/lib/commonjs/hooks/index.js.map +0 -1
  108. package/lib/commonjs/hooks/interval.js +0 -31
  109. package/lib/commonjs/hooks/interval.js.map +0 -1
  110. package/lib/commonjs/hooks/nav.js +0 -39
  111. package/lib/commonjs/hooks/nav.js.map +0 -1
  112. package/lib/commonjs/index.tsx.bak +0 -26
  113. package/lib/commonjs/types.js +0 -2
  114. package/lib/commonjs/types.js.map +0 -1
  115. package/lib/commonjs/utils/events.js +0 -57
  116. package/lib/commonjs/utils/events.js.map +0 -1
  117. package/lib/commonjs/utils/form.js +0 -46
  118. package/lib/commonjs/utils/form.js.map +0 -1
  119. package/lib/commonjs/utils/queue.js +0 -117
  120. package/lib/commonjs/utils/queue.js.map +0 -1
  121. package/lib/commonjs/utils/storage.js +0 -15
  122. package/lib/commonjs/utils/storage.js.map +0 -1
  123. package/lib/commonjs/utils/tokens.js +0 -35
  124. package/lib/commonjs/utils/tokens.js.map +0 -1
  125. package/lib/commonjs/utils/user-data.js +0 -21
  126. package/lib/commonjs/utils/user-data.js.map +0 -1
  127. package/lib/module/assets/images/checkmark--filled.svg +0 -12
  128. package/lib/module/assets/images/email-verify-waiting.svg +0 -36
  129. package/lib/module/assets/images/error-icon-material.svg +0 -1
  130. package/lib/module/assets/images/phone-verify-waiting.svg +0 -26
  131. package/lib/module/components/AuthenticatedComponent.js +0 -24
  132. package/lib/module/components/AuthenticatedComponent.js.map +0 -1
  133. package/lib/module/components/AutoSigninDialog.js +0 -110
  134. package/lib/module/components/AutoSigninDialog.js.map +0 -1
  135. package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js +0 -52
  136. package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js.map +0 -1
  137. package/lib/module/components/BottomSheetTextInput/index.js +0 -5
  138. package/lib/module/components/BottomSheetTextInput/index.js.map +0 -1
  139. package/lib/module/components/BottomSheetTextInput/types.js +0 -2
  140. package/lib/module/components/BottomSheetTextInput/types.js.map +0 -1
  141. package/lib/module/components/DarkText.js +0 -24
  142. package/lib/module/components/DarkText.js.map +0 -1
  143. package/lib/module/components/DefaultContext.js +0 -244
  144. package/lib/module/components/DefaultContext.js.map +0 -1
  145. package/lib/module/components/RowndComponents.js +0 -12
  146. package/lib/module/components/RowndComponents.js.map +0 -1
  147. package/lib/module/components/RowndProvider.js +0 -39
  148. package/lib/module/components/RowndProvider.js.map +0 -1
  149. package/lib/module/components/SignIn.js +0 -616
  150. package/lib/module/components/SignIn.js.map +0 -1
  151. package/lib/module/components/images/CheckmarkFilled.js +0 -27
  152. package/lib/module/components/images/CheckmarkFilled.js.map +0 -1
  153. package/lib/module/components/images/EmailVerifyWaiting.js +0 -87
  154. package/lib/module/components/images/EmailVerifyWaiting.js.map +0 -1
  155. package/lib/module/components/images/ErrorIcon.js +0 -18
  156. package/lib/module/components/images/ErrorIcon.js.map +0 -1
  157. package/lib/module/components/images/PhoneVerifyWaiting.js +0 -78
  158. package/lib/module/components/images/PhoneVerifyWaiting.js.map +0 -1
  159. package/lib/module/data/actions.js +0 -19
  160. package/lib/module/data/actions.js.map +0 -1
  161. package/lib/module/hooks/api.js +0 -135
  162. package/lib/module/hooks/api.js.map +0 -1
  163. package/lib/module/hooks/debounce.js +0 -29
  164. package/lib/module/hooks/debounce.js.map +0 -1
  165. package/lib/module/hooks/fingerprint.js +0 -157
  166. package/lib/module/hooks/fingerprint.js.map +0 -1
  167. package/lib/module/hooks/index.js +0 -7
  168. package/lib/module/hooks/index.js.map +0 -1
  169. package/lib/module/hooks/interval.js +0 -23
  170. package/lib/module/hooks/interval.js.map +0 -1
  171. package/lib/module/hooks/nav.js +0 -30
  172. package/lib/module/hooks/nav.js.map +0 -1
  173. package/lib/module/index.tsx.bak +0 -26
  174. package/lib/module/types.js +0 -2
  175. package/lib/module/types.js.map +0 -1
  176. package/lib/module/utils/events.js +0 -45
  177. package/lib/module/utils/events.js.map +0 -1
  178. package/lib/module/utils/form.js +0 -34
  179. package/lib/module/utils/form.js.map +0 -1
  180. package/lib/module/utils/queue.js +0 -109
  181. package/lib/module/utils/queue.js.map +0 -1
  182. package/lib/module/utils/storage.js +0 -6
  183. package/lib/module/utils/storage.js.map +0 -1
  184. package/lib/module/utils/tokens.js +0 -24
  185. package/lib/module/utils/tokens.js.map +0 -1
  186. package/lib/module/utils/user-data.js +0 -14
  187. package/lib/module/utils/user-data.js.map +0 -1
  188. package/lib/package.json +0 -173
  189. package/lib/typescript/src/components/AuthenticatedComponent.d.ts +0 -7
  190. package/lib/typescript/src/components/AutoSigninDialog.d.ts +0 -2
  191. package/lib/typescript/src/components/BottomSheetTextInput/BottomSheetTextInput.d.ts +0 -4
  192. package/lib/typescript/src/components/BottomSheetTextInput/index.d.ts +0 -2
  193. package/lib/typescript/src/components/BottomSheetTextInput/types.d.ts +0 -3
  194. package/lib/typescript/src/components/DarkText.d.ts +0 -3
  195. package/lib/typescript/src/components/DefaultContext.d.ts +0 -12
  196. package/lib/typescript/src/components/RowndComponents.d.ts +0 -2
  197. package/lib/typescript/src/components/RowndProvider.d.ts +0 -8
  198. package/lib/typescript/src/components/SignIn.d.ts +0 -2
  199. package/lib/typescript/src/components/images/CheckmarkFilled.d.ts +0 -4
  200. package/lib/typescript/src/components/images/EmailVerifyWaiting.d.ts +0 -4
  201. package/lib/typescript/src/components/images/ErrorIcon.d.ts +0 -4
  202. package/lib/typescript/src/components/images/PhoneVerifyWaiting.d.ts +0 -4
  203. package/lib/typescript/src/data/actions.d.ts +0 -20
  204. package/lib/typescript/src/hooks/api.d.ts +0 -12
  205. package/lib/typescript/src/hooks/debounce.d.ts +0 -5
  206. package/lib/typescript/src/hooks/fingerprint.d.ts +0 -12
  207. package/lib/typescript/src/hooks/index.d.ts +0 -6
  208. package/lib/typescript/src/hooks/interval.d.ts +0 -2
  209. package/lib/typescript/src/hooks/nav.d.ts +0 -6
  210. package/lib/typescript/src/index.d.ts +0 -4
  211. package/lib/typescript/src/types.d.ts +0 -26
  212. package/lib/typescript/src/utils/config.d.ts +0 -18
  213. package/lib/typescript/src/utils/events.d.ts +0 -22
  214. package/lib/typescript/src/utils/form.d.ts +0 -18
  215. package/lib/typescript/src/utils/queue.d.ts +0 -21
  216. package/lib/typescript/src/utils/storage.d.ts +0 -3
  217. package/lib/typescript/src/utils/tokens.d.ts +0 -4
  218. package/lib/typescript/src/utils/user-data.d.ts +0 -3
  219. package/react-native.podspec +0 -19
  220. package/src/assets/images/checkmark--filled.svg +0 -12
  221. package/src/assets/images/email-verify-waiting.svg +0 -36
  222. package/src/assets/images/error-icon-material.svg +0 -1
  223. package/src/assets/images/phone-verify-waiting.svg +0 -26
  224. package/src/components/AuthenticatedComponent.tsx +0 -30
  225. package/src/components/AutoSigninDialog.tsx +0 -131
  226. package/src/components/BottomSheetTextInput/BottomSheetTextInput.tsx +0 -57
  227. package/src/components/BottomSheetTextInput/index.ts +0 -5
  228. package/src/components/BottomSheetTextInput/types.ts +0 -3
  229. package/src/components/DarkText.tsx +0 -16
  230. package/src/components/DefaultContext.tsx +0 -278
  231. package/src/components/RowndComponents.tsx +0 -18
  232. package/src/components/RowndProvider.tsx +0 -56
  233. package/src/components/SignIn.tsx +0 -797
  234. package/src/components/images/CheckmarkFilled.tsx +0 -30
  235. package/src/components/images/EmailVerifyWaiting.tsx +0 -95
  236. package/src/components/images/ErrorIcon.tsx +0 -11
  237. package/src/components/images/PhoneVerifyWaiting.tsx +0 -74
  238. package/src/data/actions.ts +0 -21
  239. package/src/hooks/api.ts +0 -162
  240. package/src/hooks/debounce.ts +0 -36
  241. package/src/hooks/fingerprint.ts +0 -217
  242. package/src/hooks/index.ts +0 -7
  243. package/src/hooks/interval.ts +0 -25
  244. package/src/hooks/nav.tsx +0 -29
  245. package/src/index.tsx.bak +0 -26
  246. package/src/types.ts +0 -27
  247. package/src/utils/events.ts +0 -54
  248. package/src/utils/form.tsx +0 -64
  249. package/src/utils/queue.ts +0 -75
  250. package/src/utils/storage.ts +0 -7
  251. package/src/utils/tokens.ts +0 -26
  252. package/src/utils/user-data.ts +0 -15
@@ -1,30 +0,0 @@
1
- import * as React from 'react';
2
- import Svg, { SvgProps, Defs, Path, Polygon, Rect } from 'react-native-svg';
3
- /* SVGR has dropped some elements not supported by react-native-svg: style */
4
-
5
- const SvgComponent = (props: SvgProps) => (
6
- <Svg
7
- id="icon"
8
- // @ts-ignore
9
- xmlns="http://www.w3.org/2000/svg"
10
- width={32}
11
- height={32}
12
- viewBox="0 0 32 32"
13
- {...props}
14
- >
15
- <Defs />
16
- <Path d="M16,2A14,14,0,1,0,30,16,14,14,0,0,0,16,2ZM14,21.5908l-5-5L10.5906,15,14,18.4092,21.41,11l1.5957,1.5859Z" />
17
- <Polygon
18
- id="inner-path"
19
- points="14 21.591 9 16.591 10.591 15 14 18.409 21.41 11 23.005 12.585 14 21.591"
20
- />
21
- <Rect
22
- id="_Transparent_Rectangle_"
23
- data-name="&lt;Transparent Rectangle&gt;"
24
- width={32}
25
- height={32}
26
- />
27
- </Svg>
28
- );
29
-
30
- export default SvgComponent;
@@ -1,95 +0,0 @@
1
- import * as React from 'react';
2
- import Svg, { SvgProps, Defs, Rect, Path, G, Use } from 'react-native-svg';
3
- /* SVGR has dropped some elements not supported by react-native-svg: title, filter */
4
-
5
- const SvgComponent = (props: SvgProps) => (
6
- <Svg
7
- width="79px"
8
- height="68px"
9
- viewBox="0 0 79 68"
10
- // @ts-ignore
11
- xmlns="http://www.w3.org/2000/svg"
12
- xmlnsXlink="http://www.w3.org/1999/xlink"
13
- {...props}
14
- >
15
- <Defs>
16
- <Rect
17
- id="path-1"
18
- x={9.69736842}
19
- y={6.17105263}
20
- width={53.7763158}
21
- height={45.8421053}
22
- rx={8}
23
- />
24
- <Path
25
- d="M1.49198314,22.8826009 L27.3602885,37.5009111 C33.5004408,40.9707422 41.014234,40.9500831 47.1352131,37.4465401 L72.5558685,22.8961951 C73.0351888,22.6218404 73.6461631,22.7879979 73.9205178,23.2673182 C74.007089,23.4185653 74.0526316,23.5898106 74.0526316,23.7640813 L74.0526316,63 C74.0526316,65.209139 72.2617706,67 70.0526316,67 L4,67 C1.790861,67 2.705415e-16,65.209139 0,63 L0,23.7532056 C8.43762138e-16,23.2009209 0.44771525,22.7532056 1,22.7532056 C1.17240673,22.7532056 1.34188502,22.7977797 1.49198314,22.8826009 Z"
26
- id="path-3"
27
- />
28
- </Defs>
29
- <G
30
- id="V2-post--feedback"
31
- stroke="none"
32
- strokeWidth={1}
33
- fill="none"
34
- fillRule="evenodd"
35
- >
36
- <G
37
- id="xlg-1312px-16-column-copy-96"
38
- transform="translate(-616.000000, -265.000000)"
39
- >
40
- <G id="Group" transform="translate(618.000000, 265.000000)">
41
- <Path
42
- d="M1.1333848,21.7417845 L33.0948714,2.49908682 C35.6464021,0.96291506 38.8400625,0.97130271 41.383489,2.52085558 L72.9358668,21.743773 C73.4075139,22.0311185 73.5569199,22.6464036 73.2695744,23.1180507 C73.2235298,23.1936281 73.1676563,23.2627588 73.1034181,23.3236315 L37.2457723,57.3026316 L37.2457723,57.3026316 L0.965647178,23.3284209 C0.562522036,22.9509179 0.54175124,22.3180937 0.919254307,21.9149685 C0.982302388,21.8476412 1.0543624,21.7893607 1.1333848,21.7417845 Z"
43
- id="Path-28"
44
- fill="#545454"
45
- />
46
- <G id="Rectangle">
47
- <Use
48
- fill="black"
49
- fillOpacity={1}
50
- // @ts-ignore
51
- filter="url(#filter-2)"
52
- xlinkHref="#path-1"
53
- />
54
- <Use fill="#FFFFFF" fillRule="evenodd" xlinkHref="#path-1" />
55
- </G>
56
- <Rect
57
- id="Rectangle"
58
- fillOpacity={0.4}
59
- fill="#D8D8D8"
60
- x={18.5131579}
61
- y={19.3947368}
62
- width={36.1447368}
63
- height={3.52631579}
64
- />
65
- <Rect
66
- id="Rectangle-Copy"
67
- fillOpacity={0.4}
68
- fill="#D8D8D8"
69
- x={18.5131579}
70
- y={27.3289474}
71
- width={36.1447368}
72
- height={26.4473684}
73
- />
74
- <G id="Rectangle">
75
- <Use
76
- fill="black"
77
- fillOpacity={1}
78
- // @ts-ignore
79
- filter="url(#filter-4)"
80
- xlinkHref="#path-3"
81
- />
82
- <Use fill="#646464" fillRule="evenodd" xlinkHref="#path-3" />
83
- </G>
84
- <Path
85
- d="M23.2845382,51.744338 L1.76315789,67 L1.76315789,67 L71.4078947,67 L49.8865144,51.744338 C41.9186006,46.0961966 31.252452,46.0961966 23.2845382,51.744338 Z"
86
- id="Path-29"
87
- fill="#545454"
88
- />
89
- </G>
90
- </G>
91
- </G>
92
- </Svg>
93
- );
94
-
95
- export default SvgComponent;
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- import Svg, { SvgProps, Path } from 'react-native-svg';
3
- /* SVGR has dropped some elements not supported by react-native-svg: title */
4
-
5
- const SvgComponent = (props: SvgProps) => (
6
- <Svg width={24} height={24} xmlns="http://www.w3.org/2000/svg" {...props}>
7
- <Path d="M0 0h48v1H0z" fill="#DA1E28" fillRule="evenodd" />
8
- </Svg>
9
- );
10
-
11
- export default SvgComponent;
@@ -1,74 +0,0 @@
1
- import * as React from 'react';
2
- import Svg, { SvgProps, Defs, Rect, G, Use, Circle } from 'react-native-svg';
3
- /* SVGR has dropped some elements not supported by react-native-svg: title, filter */
4
-
5
- const SvgComponent = (props: SvgProps) => (
6
- <Svg
7
- width="62px"
8
- height="100px"
9
- viewBox="0 0 62 100"
10
- // @ts-ignore
11
- xmlns="http://www.w3.org/2000/svg"
12
- xmlnsXlink="http://www.w3.org/1999/xlink"
13
- {...props}
14
- >
15
- <Defs>
16
- <Rect id="path-1" x={0} y={0} width={58} height={96} rx={8} />
17
- </Defs>
18
- <G
19
- id="SMS-verify-from-web-stay-on-web-(BR)"
20
- stroke="none"
21
- strokeWidth={1}
22
- fill="none"
23
- fillRule="evenodd"
24
- >
25
- <G
26
- id="xlg-1312px-16-column-copy-51"
27
- transform="translate(-625.000000, -259.000000)"
28
- >
29
- <G id="unverified-phone" transform="translate(627.000000, 261.000000)">
30
- <G id="Rectangle">
31
- <Use
32
- fill="black"
33
- fillOpacity={1}
34
- // @ts-ignore
35
- filter="url(#filter-2)"
36
- xlinkHref="#path-1"
37
- />
38
- <Use fill="#444444" fillRule="evenodd" xlinkHref="#path-1" />
39
- </G>
40
- <Circle id="Oval" fill="#000000" cx={29} cy={89} r={5} />
41
- <Rect
42
- id="Rectangle"
43
- fill="#FFFFFF"
44
- x={5}
45
- y={11}
46
- width={48}
47
- height={71}
48
- rx={2}
49
- />
50
- <Rect
51
- id="Rectangle"
52
- fillOpacity={0.4}
53
- fill="#D8D8D8"
54
- x={10}
55
- y={20}
56
- width={38}
57
- height={5}
58
- />
59
- <Rect
60
- id="Rectangle-Copy"
61
- fillOpacity={0.4}
62
- fill="#D8D8D8"
63
- x={10}
64
- y={31}
65
- width={38}
66
- height={36}
67
- />
68
- </G>
69
- </G>
70
- </G>
71
- </Svg>
72
- );
73
-
74
- export default SvgComponent;
@@ -1,21 +0,0 @@
1
- export enum ActionType {
2
- SET_CONTAINER_VISIBLE = 'SET_CONTAINER_VISIBLE',
3
- CHANGE_ROUTE = 'CHANGE_ROUTE',
4
- LOGIN_SUCCESS = 'LOGIN_SUCCESS',
5
- LOAD_USER = 'LOAD_USER',
6
- REFRESH_TOKEN = 'REFRESH_TOKEN',
7
- SIGN_OUT = 'SIGN_OUT',
8
- UPDATE_LOCAL_ACLS = 'UPDATE_LOCAL_ACLS',
9
- SET_USER_DATA_FIELD = 'SET_USER_DATA_FIELD',
10
- SET_USER_DATA = 'SET_USER_DATA',
11
- SET_REFRESH_USER_DATA = 'SET_REFRESH_USER_DATA',
12
- LOAD_STATE = 'LOAD_STATE',
13
- SET_SECTION = 'SET_SECTION',
14
- SET_IS_SAVING_USER_DATA = 'SET_IS_SAVING_USER_DATA',
15
- SET_APP_CONFIG = 'SET_APP_CONFIG',
16
- }
17
-
18
- export type TAction = {
19
- type: ActionType;
20
- payload?: any;
21
- };
package/src/hooks/api.ts DELETED
@@ -1,162 +0,0 @@
1
- import ky from 'ky';
2
- import jwt_decode, { JwtPayload } from 'jwt-decode';
3
-
4
- import { useGlobalContext, GlobalState } from '../components/GlobalContext';
5
- import AutoQueue from '../utils/queue';
6
- import { useRef, useEffect } from 'react';
7
- import { Platform } from 'react-native';
8
- import { ActionType } from '../data/actions';
9
-
10
- import packageJson from '../../package.json';
11
-
12
- type RefreshTokenResp = {
13
- access_token: string;
14
- refresh_token: string;
15
- };
16
-
17
- const refreshQueue = new AutoQueue<RefreshTokenResp>();
18
-
19
- export const DEFAULT_USER_AGENT = `Rownd SDK for React Native/${packageJson.version} (Language: TypeScript/JavaScript; Platform=${Platform.OS};)`;
20
-
21
- export default function useApi() {
22
- const { state, dispatch } = useGlobalContext();
23
-
24
- const authRef = useRef({
25
- access_token: state.auth.access_token,
26
- refresh_token: state.auth.refresh_token,
27
- });
28
-
29
- useEffect(() => {
30
- authRef.current = {
31
- access_token: state.auth.access_token,
32
- refresh_token: state.auth.refresh_token,
33
- };
34
- }, [state.auth.access_token, state.auth.refresh_token]);
35
-
36
- function isNewAccessTokenNeeded(request?: Request) {
37
- // stateCopy = stateCopy || state;
38
- // Skip requests that don't need authentication
39
- if (
40
- (!!request && !request?.headers.get('authorization')) ||
41
- !authRef.current?.access_token
42
- ) {
43
- return false;
44
- }
45
-
46
- const tokenPayload: JwtPayload = jwt_decode(authRef.current?.access_token);
47
-
48
- // Shave 5 minutes off the token expiration to account for clock skew
49
- const tokenExpiration = (tokenPayload.exp! - 5 * 60) * 1000;
50
- if (tokenExpiration > Date.now()) {
51
- return false; // shouldn't be expired
52
- }
53
-
54
- return true;
55
- }
56
-
57
- async function _newAccessTokenFromRefreshToken(
58
- this: AutoQueue<RefreshTokenResp>,
59
- stateCopy?: GlobalState
60
- ) {
61
- stateCopy = stateCopy || state;
62
- if (this?._cache?.resp) {
63
- // logger.log('using cached refresh response');
64
- return this._cache.resp;
65
- }
66
-
67
- try {
68
- // logger.log('requesting new refresh token');
69
- const resp: RefreshTokenResp = await ky
70
- .post(`${stateCopy.config?.apiUrl}/hub/auth/token`, {
71
- json: {
72
- refresh_token: stateCopy.auth?.refresh_token,
73
- },
74
- })
75
- .json();
76
-
77
- this._cache.resp = resp;
78
-
79
- // Update local cache ref immediately to prevent stale auth checks
80
- authRef.current = {
81
- access_token: resp.access_token,
82
- refresh_token: resp.refresh_token,
83
- };
84
-
85
- dispatch({
86
- type: ActionType.REFRESH_TOKEN,
87
- payload: resp,
88
- });
89
-
90
- return resp;
91
- } catch (err) {
92
- dispatch({
93
- type: ActionType.SIGN_OUT,
94
- });
95
-
96
- throw err;
97
- }
98
- }
99
-
100
- async function newAccessTokenFromRefreshToken(
101
- stateCopy?: GlobalState
102
- ): Promise<RefreshTokenResp> {
103
- return await refreshQueue.enqueue(
104
- _newAccessTokenFromRefreshToken.bind(refreshQueue, stateCopy)
105
- );
106
- }
107
-
108
- const client = useRef(
109
- ky.extend({
110
- prefixUrl: state.config?.apiUrl,
111
- headers: {
112
- 'Content-Type': 'application/json',
113
- 'User-Agent': DEFAULT_USER_AGENT,
114
- },
115
- retry: {
116
- limit: 2,
117
- statusCodes: [401, 408, 429, 500, 502, 503, 504],
118
- },
119
- hooks: {
120
- beforeRequest: [
121
- // Auto-refresh tokens
122
- async (request) => {
123
- // Skip requests that don't need authentication
124
- if (!isNewAccessTokenNeeded(request)) {
125
- return;
126
- }
127
-
128
- const tokenResp: RefreshTokenResp =
129
- await newAccessTokenFromRefreshToken();
130
-
131
- request.headers.set(
132
- 'Authorization',
133
- `Bearer ${tokenResp.access_token}`
134
- );
135
- },
136
- ],
137
- beforeRetry: [
138
- async ({ request /*, options, error, retryCount*/ }) => {
139
- // Skip requests that don't need authentication
140
- if (!isNewAccessTokenNeeded(request)) {
141
- return;
142
- }
143
-
144
- const tokenResp: RefreshTokenResp =
145
- await newAccessTokenFromRefreshToken();
146
-
147
- request.headers.set(
148
- 'Authorization',
149
- `Bearer ${tokenResp.access_token}`
150
- );
151
- },
152
- ],
153
- },
154
- })
155
- ).current;
156
-
157
- return {
158
- client,
159
- newAccessTokenFromRefreshToken,
160
- isNewAccessTokenNeeded,
161
- };
162
- }
@@ -1,36 +0,0 @@
1
- import { debounce } from 'debounce';
2
- import { useMemo, useEffect, useRef } from 'react';
3
-
4
- export default function useDebounce(cb: any, delay: any) {
5
- const immediate = false;
6
- const inputsRef = useRef(cb);
7
- const isMounted = useIsMounted();
8
- useEffect(() => {
9
- inputsRef.current = { cb, delay };
10
- });
11
-
12
- return useMemo(
13
- () =>
14
- debounce(
15
- (...args: any) => {
16
- // Don't execute callback, if (1) component in the meanwhile
17
- // has been unmounted or (2) delay has changed
18
- if (inputsRef.current.delay === delay && isMounted())
19
- inputsRef.current.cb(...args);
20
- },
21
- delay,
22
- immediate
23
- ),
24
- [delay, immediate, isMounted]
25
- );
26
- }
27
-
28
- function useIsMounted() {
29
- const isMountedRef = useRef(true);
30
- useEffect(() => {
31
- return () => {
32
- isMountedRef.current = false;
33
- };
34
- }, []);
35
- return () => isMountedRef.current;
36
- }
@@ -1,217 +0,0 @@
1
- import DeviceInfo from 'react-native-device-info';
2
- import { useEffect, useCallback } from 'react';
3
- import useApi from './api';
4
- import { useGlobalContext } from '../components/GlobalContext';
5
- import storage from '../utils/storage';
6
- import { sha256 } from 'react-native-sha256';
7
-
8
- interface IFingerprint {
9
- message: string;
10
- hash: string;
11
- challenge: string;
12
- }
13
-
14
- interface IChallenge {
15
- key: string;
16
- value: string;
17
- }
18
-
19
- let isFingerprintingInProgress = false;
20
-
21
- export default function () {
22
- const { state } = useGlobalContext();
23
- const { client: api } = useApi();
24
-
25
- /**
26
- * Computes hashes for all possible lookup fields values coupled with the app ID
27
- * @param appId
28
- * @param rawLookupValues
29
- * @returns array of challenge hashes
30
- */
31
- async function computePossibleChallengeLookupValues(
32
- appId: string,
33
- rawLookupValues: string[]
34
- ): Promise<string[]> {
35
- const lookupHashes = [];
36
- for (const value of rawLookupValues) {
37
- lookupHashes.push(await sha256(`${appId}:${value}`));
38
- }
39
- return lookupHashes;
40
- }
41
-
42
- /**
43
- * Looks for a challenge in storage based on presented lookup values
44
- */
45
- const getChallengeIfPresent = useCallback(
46
- async (
47
- appId: string | undefined,
48
- challengeLookupValues: string[]
49
- ): Promise<IChallenge | null> => {
50
- if (!appId) {
51
- return null;
52
- }
53
-
54
- const challenges: Record<string, string[]> = JSON.parse(
55
- storage.getString('challenges') || '{}'
56
- );
57
-
58
- if (!Object.keys(challenges).length) {
59
- return null;
60
- }
61
-
62
- let challengeKey = '';
63
- let challengeValue = '';
64
- for (const value of challengeLookupValues) {
65
- const hash = await sha256(`${appId}:${value}`);
66
- const challenge = Object.entries(challenges).find(([, hashes]) =>
67
- hashes.includes(hash)
68
- );
69
-
70
- if (challenge) {
71
- challengeKey = hash;
72
- challengeValue = challenge[0];
73
- break;
74
- }
75
- }
76
-
77
- if (!challengeKey || !challengeValue) {
78
- return null;
79
- }
80
-
81
- return {
82
- key: challengeKey,
83
- value: challengeValue,
84
- };
85
- },
86
- []
87
- );
88
-
89
- const getFingerprint = useCallback(async () => {
90
- const visitorId = DeviceInfo.getDeviceId();
91
-
92
- return {
93
- visitorId,
94
- };
95
- }, []);
96
-
97
- const registerFingerprint = useCallback(async () => {
98
- if (
99
- !state.auth.access_token ||
100
- !state.auth.is_verified_user ||
101
- !state.app.id ||
102
- isFingerprintingInProgress
103
- ) {
104
- return;
105
- }
106
-
107
- isFingerprintingInProgress = true;
108
-
109
- try {
110
- // Check for existing challenge
111
- const challengeEntry = await getChallengeIfPresent(
112
- state.app.id,
113
- [state.user?.data?.email, state.user?.data?.phone_number].filter(
114
- Boolean
115
- )
116
- );
117
-
118
- const fingerprint = await getFingerprint();
119
- const payload: IFingerprint = await api
120
- .post('hub/auth/fingerprints', {
121
- headers: {
122
- Authorization: `Bearer ${state.auth.access_token}`,
123
- },
124
- json: {
125
- hash: fingerprint.visitorId,
126
- challenge: challengeEntry?.value || null, // Might exist from a previous run, in which case this request will be a no-op
127
- },
128
- })
129
- .json();
130
-
131
- if (payload.challenge === challengeEntry?.key) {
132
- // This is a no-op
133
- console.debug('Fingerprint already registered');
134
- return;
135
- }
136
-
137
- // Save the challenge for future sign-ins if we don't have one already or we got a new one from the server
138
- const challengeLookupHashes = await computePossibleChallengeLookupValues(
139
- state.app.id,
140
- [state.user?.data?.email, state.user?.data?.phone_number].filter(
141
- Boolean
142
- )
143
- );
144
- if (payload.challenge && challengeLookupHashes.length > 0) {
145
- const challenges = JSON.parse(storage.getString('challenges') || '{}');
146
- storage.set(
147
- 'challenges',
148
- JSON.stringify({
149
- ...challenges,
150
- [payload.challenge]: challengeLookupHashes,
151
- })
152
- );
153
- }
154
- } catch (err) {
155
- console.warn('Failed to register fingerprint', err);
156
- } finally {
157
- isFingerprintingInProgress = false;
158
- }
159
- }, [
160
- api,
161
- state.app.id,
162
- state.auth.access_token,
163
- state.auth.is_verified_user,
164
- state.user?.data?.email,
165
- state.user?.data?.phone_number,
166
- getChallengeIfPresent,
167
- getFingerprint,
168
- ]);
169
-
170
- const clearFingerprint = useCallback((challenge: string) => {
171
- const challenges: Record<string, string[]> = JSON.parse(
172
- storage.getString('challenges') || '{}'
173
- );
174
- delete challenges[challenge];
175
- storage.set('challenges', JSON.stringify(challenges));
176
- }, []);
177
-
178
- useEffect(() => {
179
- if (!state.auth.access_token) {
180
- return;
181
- }
182
-
183
- (async () => {
184
- // If already fingerprinted, don't try again
185
- const existingChallenge = await getChallengeIfPresent(
186
- state.app.id,
187
- [state.user?.data?.email, state.user?.data?.phone_number].filter(
188
- Boolean
189
- )
190
- );
191
-
192
- // Don't need to re-register a fingerprint if we already have one registered
193
- if (existingChallenge) {
194
- console.debug(
195
- 'Found existing challenge, so not requesting fingerprint registration.'
196
- );
197
- return;
198
- }
199
-
200
- // We have an access token, so we can use it to get the fingerprint
201
- registerFingerprint();
202
- })();
203
- }, [
204
- getChallengeIfPresent,
205
- registerFingerprint,
206
- state.app.id,
207
- state.auth.access_token,
208
- state.user?.data?.email,
209
- state.user?.data?.phone_number,
210
- ]);
211
-
212
- return {
213
- getFingerprint,
214
- getChallengeIfPresent,
215
- clearFingerprint,
216
- };
217
- }
@@ -1,7 +0,0 @@
1
- import useApi from './api';
2
- import useDebounce from './debounce';
3
- import useInterval from './interval';
4
- import useNav from './nav';
5
- import useDeviceFingerprint from './fingerprint';
6
-
7
- export { useApi, useDebounce, useInterval, useNav, useDeviceFingerprint };
@@ -1,25 +0,0 @@
1
- import { useEffect, useLayoutEffect, useRef } from 'react';
2
-
3
- function useInterval(callback: () => void, delay: number | null) {
4
- const savedCallback = useRef(callback);
5
-
6
- // Remember the latest callback if it changes.
7
- useLayoutEffect(() => {
8
- savedCallback.current = callback;
9
- }, [callback]);
10
-
11
- // Set up the interval.
12
- useEffect(() => {
13
- // Don't schedule if no delay is specified.
14
- // Note: 0 is a valid value for delay.
15
- if (!delay && delay !== 0) {
16
- return;
17
- }
18
-
19
- const id = setInterval(() => savedCallback.current(), delay);
20
-
21
- return () => clearInterval(id);
22
- }, [delay]);
23
- }
24
-
25
- export default useInterval;