@webority/mobile-core 0.0.29 → 0.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 (242) hide show
  1. package/README.md +32 -0
  2. package/lib/commonjs/api/baseUrl.js +1 -34
  3. package/lib/commonjs/api/clientHeaders.js +1 -0
  4. package/lib/commonjs/api/curl.js +1 -109
  5. package/lib/commonjs/api/minAppVersion.js +1 -0
  6. package/lib/commonjs/api/multipart.js +1 -21
  7. package/lib/commonjs/api/publicClient.js +1 -79
  8. package/lib/commonjs/api/requestDefaults.js +1 -0
  9. package/lib/commonjs/api/responseBodyText.js +1 -0
  10. package/lib/commonjs/api/retry.js +1 -91
  11. package/lib/commonjs/api/tokenRefresh.js +1 -205
  12. package/lib/commonjs/api/userClient.js +1 -265
  13. package/lib/commonjs/auth/authStore.js +1 -265
  14. package/lib/commonjs/auth/index.js +1 -44
  15. package/lib/commonjs/auth/jwt.js +1 -112
  16. package/lib/commonjs/config/index.js +1 -72
  17. package/lib/commonjs/deepLink/index.js +1 -286
  18. package/lib/commonjs/download/adapters/expoFs.js +1 -69
  19. package/lib/commonjs/download/adapters/shared.js +1 -13
  20. package/lib/commonjs/download/index.js +1 -250
  21. package/lib/commonjs/errors/extractApiError.js +1 -0
  22. package/lib/commonjs/errors/index.js +1 -0
  23. package/lib/commonjs/formatters/currency.js +1 -70
  24. package/lib/commonjs/formatters/date.js +1 -167
  25. package/lib/commonjs/formatters/dateMath.js +1 -311
  26. package/lib/commonjs/formatters/formatConfig.js +1 -0
  27. package/lib/commonjs/formatters/house.js +1 -0
  28. package/lib/commonjs/formatters/index.js +1 -246
  29. package/lib/commonjs/formatters/initials.js +1 -32
  30. package/lib/commonjs/formatters/intlCache.js +1 -37
  31. package/lib/commonjs/formatters/number.js +1 -89
  32. package/lib/commonjs/formatters/phone.js +1 -369
  33. package/lib/commonjs/formatters/windowsToIanaTable.js +1 -164
  34. package/lib/commonjs/geolocation/adapters/expoLocation.js +1 -126
  35. package/lib/commonjs/geolocation/index.js +1 -355
  36. package/lib/commonjs/index.js +1 -644
  37. package/lib/commonjs/initSDK.js +1 -66
  38. package/lib/commonjs/initUserAuth.js +1 -37
  39. package/lib/commonjs/logger/crashlytics.js +1 -0
  40. package/lib/commonjs/logger/index.js +1 -301
  41. package/lib/commonjs/logger/redact.js +1 -50
  42. package/lib/commonjs/network/index.js +1 -31
  43. package/lib/commonjs/network/networkStatus.js +1 -171
  44. package/lib/commonjs/permissions/calendar.js +1 -14
  45. package/lib/commonjs/permissions/camera.js +1 -14
  46. package/lib/commonjs/permissions/contacts.js +1 -10
  47. package/lib/commonjs/permissions/index.js +1 -133
  48. package/lib/commonjs/permissions/location.js +1 -14
  49. package/lib/commonjs/permissions/mediaLibrary.js +1 -10
  50. package/lib/commonjs/permissions/notifications.js +1 -10
  51. package/lib/commonjs/permissions/photos.js +1 -14
  52. package/lib/commonjs/phone/countries.js +1 -265
  53. package/lib/commonjs/push/index.js +1 -61
  54. package/lib/commonjs/push/push.js +1 -468
  55. package/lib/commonjs/push/status.js +1 -0
  56. package/lib/commonjs/push/task.js +1 -43
  57. package/lib/commonjs/query/apiBaseQuery.js +1 -0
  58. package/lib/commonjs/query/createAppApi.js +1 -0
  59. package/lib/commonjs/query/index.js +1 -0
  60. package/lib/commonjs/query/listeners.js +1 -0
  61. package/lib/commonjs/query/paging.js +1 -0
  62. package/lib/commonjs/query/tags.js +1 -0
  63. package/lib/commonjs/redux/errorToastMiddleware.js +1 -0
  64. package/lib/commonjs/redux/index.js +1 -0
  65. package/lib/commonjs/redux/rootReducer.js +1 -0
  66. package/lib/commonjs/redux/serializableCheck.js +1 -0
  67. package/lib/commonjs/secureScreen/index.js +1 -0
  68. package/lib/commonjs/share/index.js +1 -70
  69. package/lib/commonjs/smsRetriever/index.js +1 -91
  70. package/lib/commonjs/specs/NativeSmsRetriever.js +1 -15
  71. package/lib/commonjs/sqlite/adapters/expo.js +1 -53
  72. package/lib/commonjs/sqlite/index.js +1 -604
  73. package/lib/commonjs/storage/index.js +1 -214
  74. package/lib/commonjs/types/axios.js +1 -4
  75. package/lib/commonjs/types/globals.d.js +1 -6
  76. package/lib/commonjs/utils/base64.js +1 -24
  77. package/lib/commonjs/utils/imageCompression.js +1 -389
  78. package/lib/commonjs/utils/index.js +1 -19
  79. package/lib/commonjs/validators/index.js +1 -227
  80. package/lib/commonjs/versionCheck/buildNumber.js +1 -0
  81. package/lib/commonjs/versionCheck/index.js +1 -419
  82. package/lib/module/api/baseUrl.js +1 -30
  83. package/lib/module/api/clientHeaders.js +1 -0
  84. package/lib/module/api/curl.js +1 -104
  85. package/lib/module/api/minAppVersion.js +1 -0
  86. package/lib/module/api/multipart.js +1 -16
  87. package/lib/module/api/publicClient.js +1 -75
  88. package/lib/module/api/requestDefaults.js +1 -0
  89. package/lib/module/api/responseBodyText.js +1 -0
  90. package/lib/module/api/retry.js +1 -85
  91. package/lib/module/api/tokenRefresh.js +1 -192
  92. package/lib/module/api/userClient.js +1 -243
  93. package/lib/module/auth/authStore.js +1 -257
  94. package/lib/module/auth/index.js +1 -5
  95. package/lib/module/auth/jwt.js +1 -106
  96. package/lib/module/config/index.js +1 -64
  97. package/lib/module/deepLink/index.js +1 -280
  98. package/lib/module/download/adapters/expoFs.js +1 -64
  99. package/lib/module/download/adapters/shared.js +1 -8
  100. package/lib/module/download/index.js +1 -242
  101. package/lib/module/errors/extractApiError.js +1 -0
  102. package/lib/module/errors/index.js +1 -0
  103. package/lib/module/formatters/currency.js +1 -65
  104. package/lib/module/formatters/date.js +1 -159
  105. package/lib/module/formatters/dateMath.js +1 -295
  106. package/lib/module/formatters/formatConfig.js +1 -0
  107. package/lib/module/formatters/house.js +1 -0
  108. package/lib/module/formatters/index.js +1 -9
  109. package/lib/module/formatters/initials.js +1 -27
  110. package/lib/module/formatters/intlCache.js +1 -30
  111. package/lib/module/formatters/number.js +1 -82
  112. package/lib/module/formatters/phone.js +1 -302
  113. package/lib/module/formatters/windowsToIanaTable.js +1 -160
  114. package/lib/module/geolocation/adapters/expoLocation.js +1 -121
  115. package/lib/module/geolocation/index.js +1 -347
  116. package/lib/module/index.js +1 -57
  117. package/lib/module/initSDK.js +1 -61
  118. package/lib/module/initUserAuth.js +1 -33
  119. package/lib/module/logger/crashlytics.js +1 -0
  120. package/lib/module/logger/index.js +1 -295
  121. package/lib/module/logger/redact.js +1 -44
  122. package/lib/module/network/index.js +1 -4
  123. package/lib/module/network/networkStatus.js +1 -161
  124. package/lib/module/permissions/calendar.js +1 -15
  125. package/lib/module/permissions/camera.js +1 -15
  126. package/lib/module/permissions/contacts.js +1 -11
  127. package/lib/module/permissions/index.js +1 -128
  128. package/lib/module/permissions/location.js +1 -15
  129. package/lib/module/permissions/mediaLibrary.js +1 -11
  130. package/lib/module/permissions/notifications.js +1 -11
  131. package/lib/module/permissions/photos.js +1 -15
  132. package/lib/module/phone/countries.js +1 -261
  133. package/lib/module/push/index.js +1 -4
  134. package/lib/module/push/push.js +1 -452
  135. package/lib/module/push/status.js +1 -0
  136. package/lib/module/push/task.js +1 -38
  137. package/lib/module/query/apiBaseQuery.js +1 -0
  138. package/lib/module/query/createAppApi.js +1 -0
  139. package/lib/module/query/index.js +1 -0
  140. package/lib/module/query/listeners.js +1 -0
  141. package/lib/module/query/paging.js +1 -0
  142. package/lib/module/query/tags.js +1 -0
  143. package/lib/module/redux/errorToastMiddleware.js +1 -0
  144. package/lib/module/redux/index.js +1 -0
  145. package/lib/module/redux/rootReducer.js +1 -0
  146. package/lib/module/redux/serializableCheck.js +1 -0
  147. package/lib/module/secureScreen/index.js +1 -0
  148. package/lib/module/share/index.js +1 -64
  149. package/lib/module/smsRetriever/index.js +1 -86
  150. package/lib/module/specs/NativeSmsRetriever.js +1 -13
  151. package/lib/module/sqlite/adapters/expo.js +1 -48
  152. package/lib/module/sqlite/index.js +1 -594
  153. package/lib/module/storage/index.js +1 -208
  154. package/lib/module/types/axios.js +1 -4
  155. package/lib/module/types/globals.d.js +1 -10
  156. package/lib/module/utils/base64.js +1 -19
  157. package/lib/module/utils/imageCompression.js +1 -383
  158. package/lib/module/utils/index.js +1 -4
  159. package/lib/module/validators/index.js +1 -205
  160. package/lib/module/versionCheck/buildNumber.js +1 -0
  161. package/lib/module/versionCheck/index.js +1 -413
  162. package/lib/typescript/commonjs/api/clientHeaders.d.ts +25 -0
  163. package/lib/typescript/commonjs/api/minAppVersion.d.ts +24 -0
  164. package/lib/typescript/commonjs/api/requestDefaults.d.ts +21 -0
  165. package/lib/typescript/commonjs/api/responseBodyText.d.ts +6 -0
  166. package/lib/typescript/commonjs/api/retry.d.ts +23 -9
  167. package/lib/typescript/commonjs/api/tokenRefresh.d.ts +14 -2
  168. package/lib/typescript/commonjs/api/userClient.d.ts +1 -1
  169. package/lib/typescript/commonjs/auth/authStore.d.ts +76 -0
  170. package/lib/typescript/commonjs/auth/index.d.ts +2 -2
  171. package/lib/typescript/commonjs/config/index.d.ts +31 -2
  172. package/lib/typescript/commonjs/errors/extractApiError.d.ts +69 -0
  173. package/lib/typescript/commonjs/errors/index.d.ts +3 -0
  174. package/lib/typescript/commonjs/formatters/currency.d.ts +22 -7
  175. package/lib/typescript/commonjs/formatters/date.d.ts +13 -13
  176. package/lib/typescript/commonjs/formatters/dateMath.d.ts +4 -2
  177. package/lib/typescript/commonjs/formatters/formatConfig.d.ts +48 -0
  178. package/lib/typescript/commonjs/formatters/house.d.ts +143 -0
  179. package/lib/typescript/commonjs/formatters/index.d.ts +4 -0
  180. package/lib/typescript/commonjs/formatters/number.d.ts +15 -5
  181. package/lib/typescript/commonjs/index.d.ts +26 -8
  182. package/lib/typescript/commonjs/initSDK.d.ts +18 -6
  183. package/lib/typescript/commonjs/initUserAuth.d.ts +29 -0
  184. package/lib/typescript/commonjs/logger/crashlytics.d.ts +31 -0
  185. package/lib/typescript/commonjs/logger/index.d.ts +17 -0
  186. package/lib/typescript/commonjs/push/index.d.ts +3 -1
  187. package/lib/typescript/commonjs/push/push.d.ts +1 -1
  188. package/lib/typescript/commonjs/push/status.d.ts +9 -0
  189. package/lib/typescript/commonjs/query/apiBaseQuery.d.ts +55 -0
  190. package/lib/typescript/commonjs/query/createAppApi.d.ts +21 -0
  191. package/lib/typescript/commonjs/query/index.d.ts +9 -0
  192. package/lib/typescript/commonjs/query/listeners.d.ts +11 -0
  193. package/lib/typescript/commonjs/query/paging.d.ts +42 -0
  194. package/lib/typescript/commonjs/query/tags.d.ts +31 -0
  195. package/lib/typescript/commonjs/redux/errorToastMiddleware.d.ts +51 -0
  196. package/lib/typescript/commonjs/redux/index.d.ts +6 -0
  197. package/lib/typescript/commonjs/redux/rootReducer.d.ts +19 -0
  198. package/lib/typescript/commonjs/redux/serializableCheck.d.ts +14 -0
  199. package/lib/typescript/commonjs/secureScreen/index.d.ts +25 -0
  200. package/lib/typescript/commonjs/versionCheck/buildNumber.d.ts +14 -0
  201. package/lib/typescript/commonjs/versionCheck/index.d.ts +28 -17
  202. package/lib/typescript/module/api/clientHeaders.d.ts +25 -0
  203. package/lib/typescript/module/api/minAppVersion.d.ts +24 -0
  204. package/lib/typescript/module/api/requestDefaults.d.ts +21 -0
  205. package/lib/typescript/module/api/responseBodyText.d.ts +6 -0
  206. package/lib/typescript/module/api/retry.d.ts +23 -9
  207. package/lib/typescript/module/api/tokenRefresh.d.ts +14 -2
  208. package/lib/typescript/module/api/userClient.d.ts +1 -1
  209. package/lib/typescript/module/auth/authStore.d.ts +76 -0
  210. package/lib/typescript/module/auth/index.d.ts +2 -2
  211. package/lib/typescript/module/config/index.d.ts +31 -2
  212. package/lib/typescript/module/errors/extractApiError.d.ts +69 -0
  213. package/lib/typescript/module/errors/index.d.ts +3 -0
  214. package/lib/typescript/module/formatters/currency.d.ts +22 -7
  215. package/lib/typescript/module/formatters/date.d.ts +13 -13
  216. package/lib/typescript/module/formatters/dateMath.d.ts +4 -2
  217. package/lib/typescript/module/formatters/formatConfig.d.ts +48 -0
  218. package/lib/typescript/module/formatters/house.d.ts +143 -0
  219. package/lib/typescript/module/formatters/index.d.ts +4 -0
  220. package/lib/typescript/module/formatters/number.d.ts +15 -5
  221. package/lib/typescript/module/index.d.ts +26 -8
  222. package/lib/typescript/module/initSDK.d.ts +18 -6
  223. package/lib/typescript/module/initUserAuth.d.ts +29 -0
  224. package/lib/typescript/module/logger/crashlytics.d.ts +31 -0
  225. package/lib/typescript/module/logger/index.d.ts +17 -0
  226. package/lib/typescript/module/push/index.d.ts +3 -1
  227. package/lib/typescript/module/push/push.d.ts +1 -1
  228. package/lib/typescript/module/push/status.d.ts +9 -0
  229. package/lib/typescript/module/query/apiBaseQuery.d.ts +55 -0
  230. package/lib/typescript/module/query/createAppApi.d.ts +21 -0
  231. package/lib/typescript/module/query/index.d.ts +9 -0
  232. package/lib/typescript/module/query/listeners.d.ts +11 -0
  233. package/lib/typescript/module/query/paging.d.ts +42 -0
  234. package/lib/typescript/module/query/tags.d.ts +31 -0
  235. package/lib/typescript/module/redux/errorToastMiddleware.d.ts +51 -0
  236. package/lib/typescript/module/redux/index.d.ts +6 -0
  237. package/lib/typescript/module/redux/rootReducer.d.ts +19 -0
  238. package/lib/typescript/module/redux/serializableCheck.d.ts +14 -0
  239. package/lib/typescript/module/secureScreen/index.d.ts +25 -0
  240. package/lib/typescript/module/versionCheck/buildNumber.d.ts +14 -0
  241. package/lib/typescript/module/versionCheck/index.d.ts +28 -17
  242. package/package.json +52 -5
@@ -1,112 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isJWTExpired = exports.getJWTExpiry = exports.decodeJWT = void 0;
7
- var _index = require("../logger/index.js");
8
- /**
9
- * Standard claims plus arbitrary keys.
10
- * `sub`, `exp`, `iat`, `nbf` follow RFC 7519 conventions.
11
- */
12
-
13
- const base64UrlToBase64 = input => {
14
- const padded = input + '='.repeat((4 - input.length % 4) % 4);
15
- return padded.replace(/-/g, '+').replace(/_/g, '/');
16
- };
17
- const BASE64_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
18
-
19
- /**
20
- * Pure-JS base64, used only when the runtime has no `atob`.
21
- *
22
- * This used to be `require('buffer')`. That was a latent bundling failure for
23
- * every consumer: `buffer` is a Node builtin that React Native does not
24
- * provide, it was never declared as a dependency, and Metro resolves requires
25
- * STATICALLY — so sitting inside an unreached fallback branch did not save it.
26
- * The app still failed to bundle, with an error naming this file. It only went
27
- * unnoticed because the repo's own checks never bundle for a device.
28
- *
29
- * Decoding four base64 characters yields three bytes; the padding tells us how
30
- * many of those three are real.
31
- */
32
- const decodeBase64Fallback = input => {
33
- let out = '';
34
- for (let i = 0; i < input.length; i += 4) {
35
- const chunk = [0, 1, 2, 3].map(offset => BASE64_ALPHABET.indexOf(input[i + offset] ?? '='));
36
- const bits = Math.max(chunk[0], 0) << 18 | Math.max(chunk[1], 0) << 12 | Math.max(chunk[2], 0) << 6 | Math.max(chunk[3], 0);
37
- out += String.fromCharCode(bits >> 16 & 0xff);
38
- if (chunk[2] !== -1) {
39
- out += String.fromCharCode(bits >> 8 & 0xff);
40
- }
41
- if (chunk[3] !== -1) {
42
- out += String.fromCharCode(bits & 0xff);
43
- }
44
- }
45
- return out;
46
- };
47
- const decodeBase64 = input =>
48
- // Every RN runtime the library supports has `atob` (Hermes 0.71+), so the
49
- // fallback is a safety net rather than a path anyone is expected to take.
50
- typeof atob === 'function' ? atob(input) : decodeBase64Fallback(input);
51
- const utf8FromBinary = binary => {
52
- // Convert percent-encoded UTF-8 sequence so multi-byte chars survive.
53
- try {
54
- return decodeURIComponent(binary.split('').map(c => '%' + c.charCodeAt(0).toString(16).padStart(2, '0')).join(''));
55
- } catch {
56
- return binary;
57
- }
58
- };
59
-
60
- /**
61
- * Decode a JWT's payload claims. Does **not** verify the signature.
62
- *
63
- * @returns claims object on success, `null` if the token is malformed.
64
- */
65
- const decodeJWT = token => {
66
- if (!token || typeof token !== 'string') {
67
- return null;
68
- }
69
- const parts = token.split('.');
70
- if (parts.length !== 3) {
71
- _index.Logger.warn('[jwt] decodeJWT: token is not a valid JWT (expected 3 segments)');
72
- return null;
73
- }
74
- try {
75
- const payload = parts[1];
76
- const json = utf8FromBinary(decodeBase64(base64UrlToBase64(payload)));
77
- return JSON.parse(json);
78
- } catch (error) {
79
- _index.Logger.warn('[jwt] decodeJWT failed to parse payload', error);
80
- return null;
81
- }
82
- };
83
-
84
- /**
85
- * Returns true when the token is expired (or unparseable / missing `exp`).
86
- *
87
- * @param token JWT string
88
- * @param leewaySeconds amount of clock-skew tolerance to apply (default 30s)
89
- */
90
- exports.decodeJWT = decodeJWT;
91
- const isJWTExpired = (token, leewaySeconds = 30) => {
92
- const claims = decodeJWT(token);
93
- if (!claims || typeof claims.exp !== 'number') {
94
- return true;
95
- }
96
- const nowSeconds = Math.floor(Date.now() / 1000);
97
- return claims.exp <= nowSeconds + leewaySeconds;
98
- };
99
-
100
- /**
101
- * Returns the token's expiry as a Date, or `null` when no `exp` claim exists.
102
- */
103
- exports.isJWTExpired = isJWTExpired;
104
- const getJWTExpiry = token => {
105
- const claims = decodeJWT(token);
106
- if (!claims || typeof claims.exp !== 'number') {
107
- return null;
108
- }
109
- return new Date(claims.exp * 1000);
110
- };
111
- exports.getJWTExpiry = getJWTExpiry;
112
- //# sourceMappingURL=jwt.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isJWTExpired=exports.getJWTExpiry=exports.decodeJWT=void 0;var _index=require("../logger/index.js");const base64UrlToBase64=e=>(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),BASE64_ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",decodeBase64Fallback=e=>{let t="";for(let r=0;r<e.length;r+=4){const o=[0,1,2,3].map(t=>BASE64_ALPHABET.indexOf(e[r+t]??"=")),n=Math.max(o[0],0)<<18|Math.max(o[1],0)<<12|Math.max(o[2],0)<<6|Math.max(o[3],0);t+=String.fromCharCode(n>>16&255),-1!==o[2]&&(t+=String.fromCharCode(n>>8&255)),-1!==o[3]&&(t+=String.fromCharCode(255&n))}return t},decodeBase64=e=>"function"==typeof atob?atob(e):decodeBase64Fallback(e),utf8FromBinary=e=>{try{return decodeURIComponent(e.split("").map(e=>"%"+e.charCodeAt(0).toString(16).padStart(2,"0")).join(""))}catch{return e}},decodeJWT=e=>{if(!e||"string"!=typeof e)return null;const t=e.split(".");if(3!==t.length)return _index.Logger.warn("[jwt] decodeJWT: token is not a valid JWT (expected 3 segments)"),null;try{const e=t[1],r=utf8FromBinary(decodeBase64(base64UrlToBase64(e)));return JSON.parse(r)}catch(e){return _index.Logger.warn("[jwt] decodeJWT failed to parse payload",e),null}};exports.decodeJWT=decodeJWT;const isJWTExpired=(e,t=30)=>{const r=decodeJWT(e);if(!r||"number"!=typeof r.exp)return!0;const o=Math.floor(Date.now()/1e3);return r.exp<=o+t};exports.isJWTExpired=isJWTExpired;const getJWTExpiry=e=>{const t=decodeJWT(e);return t&&"number"==typeof t.exp?new Date(1e3*t.exp):null};exports.getJWTExpiry=getJWTExpiry;
@@ -1,72 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getConfig = exports.DEFAULT_LOG_LEVEL = void 0;
7
- exports.getConfigValue = getConfigValue;
8
- exports.setConfig = exports.resetConfig = void 0;
9
- /**
10
- * Configuration management for Webority packages
11
- * Provides a flexible way to inject configuration without hard dependencies
12
- */
13
-
14
- /**
15
- * Info lines (each token refresh, each unauthorised URL) reach the device log
16
- * and any remote sink, so a release build that sets nothing logs warnings and
17
- * errors only.
18
- */
19
- const DEFAULT_LOG_LEVEL = exports.DEFAULT_LOG_LEVEL = __DEV__ ? 'info' : 'warn';
20
- const DEFAULT_CONFIG = {
21
- baseUrl: null,
22
- loggingEnabled: true,
23
- logLevel: DEFAULT_LOG_LEVEL,
24
- environment: 'Development',
25
- country: 'in',
26
- appId: null,
27
- appVersion: null,
28
- logCurl: false
29
- };
30
- let globalConfig = {
31
- ...DEFAULT_CONFIG
32
- };
33
-
34
- /**
35
- * Set global configuration for all Webority packages
36
- */
37
- const setConfig = config => {
38
- globalConfig = {
39
- ...globalConfig,
40
- ...config
41
- };
42
- };
43
-
44
- /**
45
- * Get current configuration
46
- */
47
- exports.setConfig = setConfig;
48
- const getConfig = () => globalConfig;
49
-
50
- /**
51
- * Get a specific config value with optional fallback.
52
- * If the stored value is `null`, the fallback is returned (when provided).
53
- */
54
- exports.getConfig = getConfig;
55
- function getConfigValue(key, fallback) {
56
- const value = globalConfig[key];
57
- if (value !== null) {
58
- return value;
59
- }
60
- return fallback;
61
- }
62
-
63
- /**
64
- * Reset configuration to defaults
65
- */
66
- const resetConfig = () => {
67
- globalConfig = {
68
- ...DEFAULT_CONFIG
69
- };
70
- };
71
- exports.resetConfig = resetConfig;
72
- //# sourceMappingURL=index.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getConfig=exports.DEFAULT_TIMEOUT_MS=exports.DEFAULT_RETRIES=exports.DEFAULT_LOG_LEVEL=exports.DEFAULT_CORRELATION_ID_HEADER=void 0,exports.getConfigValue=getConfigValue,exports.setConfig=exports.resetConfig=void 0;const DEFAULT_LOG_LEVEL=exports.DEFAULT_LOG_LEVEL=__DEV__?"info":"warn",DEFAULT_TIMEOUT_MS=exports.DEFAULT_TIMEOUT_MS=3e4,DEFAULT_RETRIES=exports.DEFAULT_RETRIES=3,DEFAULT_CORRELATION_ID_HEADER=exports.DEFAULT_CORRELATION_ID_HEADER="X-Correlation-Id",DEFAULT_CONFIG={baseUrl:null,loggingEnabled:!0,logLevel:DEFAULT_LOG_LEVEL,environment:"Development",country:"in",appId:null,appVersion:null,commit:null,appBuild:null,appStoreId:null,logCurl:!1,timeoutMs:DEFAULT_TIMEOUT_MS,retries:DEFAULT_RETRIES,correlationIdHeader:DEFAULT_CORRELATION_ID_HEADER};let globalConfig={...DEFAULT_CONFIG};const setConfig=o=>{globalConfig={...globalConfig,...o}};exports.setConfig=setConfig;const getConfig=()=>globalConfig;function getConfigValue(o,e){const t=globalConfig[o];return null!==t?t:e}exports.getConfig=getConfig;const resetConfig=()=>{globalConfig={...DEFAULT_CONFIG}};exports.resetConfig=resetConfig;
@@ -1,286 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useDeepLink = exports.parseDeepLink = exports.DeepLink = void 0;
7
- var _react = require("react");
8
- var _reactNative = require("react-native");
9
- var _index = require("../logger/index.js");
10
- const PREFIX = '[@webority/mobile-core]';
11
- const decodeSafe = value => {
12
- try {
13
- return decodeURIComponent(value.replace(/\+/g, ' '));
14
- } catch {
15
- return value;
16
- }
17
- };
18
- const parseQuery = raw => {
19
- const out = {};
20
- if (!raw) {
21
- return out;
22
- }
23
- for (const pair of raw.split('&')) {
24
- if (!pair) {
25
- continue;
26
- }
27
- const eq = pair.indexOf('=');
28
- const key = decodeSafe(eq >= 0 ? pair.slice(0, eq) : pair);
29
- if (!key) {
30
- continue;
31
- }
32
- out[key] = eq >= 0 ? decodeSafe(pair.slice(eq + 1)) : '';
33
- }
34
- return out;
35
- };
36
- const trimSlashes = value => value.replace(/^\/+/, '').replace(/\/+$/, '');
37
-
38
- /**
39
- * Parse a deep-link URL. Returns null for anything that is not a usable URL so
40
- * a hostile or truncated link can never throw on the native event path.
41
- */
42
- const parseDeepLink = url => {
43
- if (typeof url !== 'string') {
44
- return null;
45
- }
46
- const trimmed = url.trim();
47
- if (!trimmed || /\s/.test(trimmed)) {
48
- return null;
49
- }
50
- const withoutFragment = trimmed.split('#')[0] ?? '';
51
- const schemeEnd = withoutFragment.indexOf('://');
52
- let scheme = '';
53
- let rest = withoutFragment;
54
- if (schemeEnd >= 0) {
55
- const rawScheme = withoutFragment.slice(0, schemeEnd);
56
- if (!/^[a-zA-Z][a-zA-Z0-9+.-]*$/.test(rawScheme)) {
57
- return null;
58
- }
59
- scheme = rawScheme.toLowerCase();
60
- rest = withoutFragment.slice(schemeEnd + 3);
61
- }
62
- const queryStart = rest.indexOf('?');
63
- const rawPath = queryStart >= 0 ? rest.slice(0, queryStart) : rest;
64
- const query = parseQuery(queryStart >= 0 ? rest.slice(queryStart + 1) : '');
65
- let host = '';
66
- let pathPart = rawPath;
67
- if (scheme === 'http' || scheme === 'https') {
68
- const slash = rawPath.indexOf('/');
69
- host = slash >= 0 ? rawPath.slice(0, slash) : rawPath;
70
- pathPart = slash >= 0 ? rawPath.slice(slash + 1) : '';
71
- }
72
- const path = trimSlashes(pathPart);
73
- const segments = path ? path.split('/').filter(Boolean) : [];
74
- if (scheme && scheme !== 'http' && scheme !== 'https') {
75
- host = segments[0] ?? '';
76
- }
77
- return {
78
- url: trimmed,
79
- scheme,
80
- host,
81
- path,
82
- segments,
83
- query
84
- };
85
- };
86
- exports.parseDeepLink = parseDeepLink;
87
- const matchPattern = (pattern, segments) => {
88
- const patternSegments = trimSlashes(pattern).split('/').filter(Boolean);
89
- if (patternSegments.length !== segments.length) {
90
- return null;
91
- }
92
- const params = {};
93
- for (let i = 0; i < patternSegments.length; i += 1) {
94
- const p = patternSegments[i];
95
- const s = segments[i];
96
- if (p.startsWith(':')) {
97
- const name = p.slice(1);
98
- if (!name) {
99
- return null;
100
- }
101
- params[name] = s;
102
- } else if (p.toLowerCase() !== s.toLowerCase()) {
103
- return null;
104
- }
105
- }
106
- return params;
107
- };
108
- const matchRegExp = (pattern, path) => {
109
- // A /g or /y pattern carries lastIndex between calls, so the same link would
110
- // match on one dispatch and miss on the next.
111
- if (pattern.global || pattern.sticky) {
112
- pattern.lastIndex = 0;
113
- }
114
- const result = pattern.exec(path);
115
- if (!result) {
116
- return null;
117
- }
118
- const params = {};
119
- for (let i = 1; i < result.length; i += 1) {
120
- const group = result[i];
121
- if (group !== undefined) {
122
- params[String(i)] = group;
123
- }
124
- }
125
- for (const [name, value] of Object.entries(result.groups ?? {})) {
126
- if (value !== undefined) {
127
- params[name] = value;
128
- }
129
- }
130
- return params;
131
- };
132
- const matchRoute = (routes, link) => {
133
- for (const route of routes) {
134
- const params = typeof route.match === 'string' ? matchPattern(route.match, link.segments) : matchRegExp(route.match, link.path);
135
- if (params) {
136
- return {
137
- route,
138
- params
139
- };
140
- }
141
- }
142
- return null;
143
- };
144
- let config = null;
145
- let subscription = null;
146
- let started = false;
147
- let pending = null;
148
- let readyOverride = null;
149
- const isReady = () => {
150
- if (readyOverride !== null) {
151
- return readyOverride;
152
- }
153
- return config?.isReady?.() ?? true;
154
- };
155
- const isAuthenticated = () => config?.isAuthenticated?.() ?? true;
156
- const dispatch = link => {
157
- const active = config;
158
- if (!active) {
159
- return;
160
- }
161
- const matched = matchRoute(active.routes, link);
162
- if (!matched) {
163
- active.onUnmatched?.(link);
164
- return;
165
- }
166
- if (matched.route.requiresAuth && !isAuthenticated()) {
167
- pending = link;
168
- active.onUnauthenticated?.(link);
169
- return;
170
- }
171
- matched.route.handler(link, matched.params);
172
- };
173
- const flushPending = () => {
174
- const link = pending;
175
- if (!link) {
176
- return;
177
- }
178
- // Cleared BEFORE dispatch: a handler that navigates can re-enter this path,
179
- // and a link that fires twice is the classic deep-link duplicate-screen bug.
180
- pending = null;
181
- dispatch(link);
182
- };
183
- const configure = next => {
184
- if (!next || !Array.isArray(next.routes)) {
185
- throw new Error(`${PREFIX} DeepLink.configure() needs a config object with a "routes" array. ` + 'Pass { routes: [{ match: "order/:id", handler }] }.');
186
- }
187
- config = next;
188
- };
189
- const handleUrl = url => {
190
- if (!config) {
191
- _index.Logger.error(`${PREFIX} DeepLink received a URL before configure() was called; the link was dropped. ` + 'Call DeepLink.configure({ routes }) (or useDeepLink) during app start.');
192
- return;
193
- }
194
- const parsed = parseDeepLink(url);
195
- // A malformed URL still reaches the app through onUnmatched, with the raw
196
- // value in `url`, rather than vanishing.
197
- if (!parsed) {
198
- config.onUnmatched?.({
199
- url: typeof url === 'string' ? url : '',
200
- scheme: '',
201
- host: '',
202
- path: '',
203
- segments: [],
204
- query: {}
205
- });
206
- return;
207
- }
208
- const link = parsed;
209
- if (!isReady()) {
210
- pending = link;
211
- return;
212
- }
213
- dispatch(link);
214
- };
215
- const start = async () => {
216
- if (!config) {
217
- throw new Error(`${PREFIX} DeepLink.start() was called before configure(). ` + 'Call DeepLink.configure({ routes }) first, or use the useDeepLink() hook.');
218
- }
219
- if (started) {
220
- return;
221
- }
222
- started = true;
223
- // Subscribe before reading the cold-start URL so a link arriving during the
224
- // await is not lost.
225
- subscription = _reactNative.Linking.addEventListener('url', event => {
226
- handleUrl(event.url);
227
- });
228
- try {
229
- const initial = await _reactNative.Linking.getInitialURL();
230
- if (initial) {
231
- handleUrl(initial);
232
- }
233
- } catch (error) {
234
- _index.Logger.error(`${PREFIX} DeepLink could not read the cold-start URL`, error);
235
- }
236
- };
237
- const stop = () => {
238
- subscription?.remove?.();
239
- subscription = null;
240
- started = false;
241
- pending = null;
242
- readyOverride = null;
243
- };
244
- const setReady = ready => {
245
- readyOverride = ready;
246
- if (ready) {
247
- flushPending();
248
- }
249
- };
250
- const DeepLink = exports.DeepLink = {
251
- configure,
252
- start,
253
- stop,
254
- handleUrl,
255
- setReady,
256
- /** Replay the stashed link, once. Call after a successful login. */
257
- replayPending: flushPending,
258
- getPending: () => pending
259
- };
260
-
261
- /**
262
- * Configure and start the deep-link service for the lifetime of a component.
263
- * The stored config delegates to the latest render, so new route closures do
264
- * not tear down and re-subscribe the native listener.
265
- */
266
- const useDeepLink = deepLinkConfig => {
267
- const configRef = (0, _react.useRef)(deepLinkConfig);
268
- configRef.current = deepLinkConfig;
269
- (0, _react.useEffect)(() => {
270
- DeepLink.configure({
271
- get routes() {
272
- return configRef.current.routes;
273
- },
274
- isReady: () => configRef.current.isReady?.() ?? true,
275
- isAuthenticated: () => configRef.current.isAuthenticated?.() ?? true,
276
- onUnauthenticated: link => configRef.current.onUnauthenticated?.(link),
277
- onUnmatched: link => configRef.current.onUnmatched?.(link)
278
- });
279
- void DeepLink.start();
280
- return () => {
281
- DeepLink.stop();
282
- };
283
- }, []);
284
- };
285
- exports.useDeepLink = useDeepLink;
286
- //# sourceMappingURL=index.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useDeepLink=exports.parseDeepLink=exports.DeepLink=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../logger/index.js");const PREFIX="[@webority/mobile-core]",decodeSafe=e=>{try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}},parseQuery=e=>{const t={};if(!e)return t;for(const r of e.split("&")){if(!r)continue;const e=r.indexOf("="),n=decodeSafe(e>=0?r.slice(0,e):r);n&&(t[n]=e>=0?decodeSafe(r.slice(e+1)):"")}return t},trimSlashes=e=>e.replace(/^\/+/,"").replace(/\/+$/,""),parseDeepLink=e=>{if("string"!=typeof e)return null;const t=e.trim();if(!t||/\s/.test(t))return null;const r=t.split("#")[0]??"",n=r.indexOf("://");let i="",s=r;if(n>=0){const e=r.slice(0,n);if(!/^[a-zA-Z][a-zA-Z0-9+.-]*$/.test(e))return null;i=e.toLowerCase(),s=r.slice(n+3)}const o=s.indexOf("?"),a=o>=0?s.slice(0,o):s,c=parseQuery(o>=0?s.slice(o+1):"");let u="",l=a;if("http"===i||"https"===i){const e=a.indexOf("/");u=e>=0?a.slice(0,e):a,l=e>=0?a.slice(e+1):""}const d=trimSlashes(l),p=d?d.split("/").filter(Boolean):[];return i&&"http"!==i&&"https"!==i&&(u=p[0]??""),{url:t,scheme:i,host:u,path:d,segments:p,query:c}};exports.parseDeepLink=parseDeepLink;const matchPattern=(e,t)=>{const r=trimSlashes(e).split("/").filter(Boolean);if(r.length!==t.length)return null;const n={};for(let e=0;e<r.length;e+=1){const i=r[e],s=t[e];if(i.startsWith(":")){const e=i.slice(1);if(!e)return null;n[e]=s}else if(i.toLowerCase()!==s.toLowerCase())return null}return n},matchRegExp=(e,t)=>{(e.global||e.sticky)&&(e.lastIndex=0);const r=e.exec(t);if(!r)return null;const n={};for(let e=1;e<r.length;e+=1){const t=r[e];void 0!==t&&(n[String(e)]=t)}for(const[e,t]of Object.entries(r.groups??{}))void 0!==t&&(n[e]=t);return n},matchRoute=(e,t)=>{for(const r of e){const e="string"==typeof r.match?matchPattern(r.match,t.segments):matchRegExp(r.match,t.path);if(e)return{route:r,params:e}}return null};let config=null,subscription=null,started=!1,pending=null,readyOverride=null;const isReady=()=>null!==readyOverride?readyOverride:config?.isReady?.()??!0,isAuthenticated=()=>config?.isAuthenticated?.()??!0,dispatch=e=>{const t=config;if(!t)return;const r=matchRoute(t.routes,e);if(r)return r.route.requiresAuth&&!isAuthenticated()?(pending=e,void t.onUnauthenticated?.(e)):void r.route.handler(e,r.params);t.onUnmatched?.(e)},flushPending=()=>{const e=pending;e&&(pending=null,dispatch(e))},configure=e=>{if(!e||!Array.isArray(e.routes))throw new Error(`${PREFIX} DeepLink.configure() needs a config object with a "routes" array. Pass { routes: [{ match: "order/:id", handler }] }.`);config=e},handleUrl=e=>{if(!config)return void _index.Logger.error(`${PREFIX} DeepLink received a URL before configure() was called; the link was dropped. Call DeepLink.configure({ routes }) (or useDeepLink) during app start.`);const t=parseDeepLink(e);if(!t)return void config.onUnmatched?.({url:"string"==typeof e?e:"",scheme:"",host:"",path:"",segments:[],query:{}});const r=t;isReady()?dispatch(r):pending=r},start=async()=>{if(!config)throw new Error(`${PREFIX} DeepLink.start() was called before configure(). Call DeepLink.configure({ routes }) first, or use the useDeepLink() hook.`);if(!started){started=!0,subscription=_reactNative.Linking.addEventListener("url",e=>{handleUrl(e.url)});try{const e=await _reactNative.Linking.getInitialURL();e&&handleUrl(e)}catch(e){_index.Logger.error(`${PREFIX} DeepLink could not read the cold-start URL`,e)}}},stop=()=>{subscription?.remove?.(),subscription=null,started=!1,pending=null,readyOverride=null},setReady=e=>{readyOverride=e,e&&flushPending()},DeepLink=exports.DeepLink={configure:configure,start:start,stop:stop,handleUrl:handleUrl,setReady:setReady,replayPending:flushPending,getPending:()=>pending},useDeepLink=e=>{const t=(0,_react.useRef)(e);t.current=e,(0,_react.useEffect)(()=>(DeepLink.configure({get routes(){return t.current.routes},isReady:()=>t.current.isReady?.()??!0,isAuthenticated:()=>t.current.isAuthenticated?.()??!0,onUnauthenticated:e=>t.current.onUnauthenticated?.(e),onUnmatched:e=>t.current.onUnmatched?.(e)}),DeepLink.start(),()=>{DeepLink.stop()}),[])};exports.useDeepLink=useDeepLink;
@@ -1,69 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.adaptExpoFileSystem = void 0;
7
- /**
8
- * expo-file-system. Shape verified against 57.0.6, where the legacy function
9
- * API (`downloadAsync`, `getInfoAsync`) still exists on the main entry point
10
- * but every one of those functions THROWS at runtime; they now live behind
11
- * `expo-file-system/legacy`. This adapter therefore uses the class API only.
12
- *
13
- * The REQUIRE lives in the entry point beside this file, never here.
14
- */
15
-
16
- /**
17
- * expo reports a directory as a URI with a trailing slash, and the download
18
- * module joins a directory to a file name with a `/` of its own.
19
- */
20
- const asDirectoryPath = uri => uri.replace(/\/+$/, '');
21
- const adaptExpoFileSystem = mod => {
22
- const lib = mod?.default ?? mod;
23
- if (typeof lib?.File !== 'function' || typeof lib.File.prototype?.write !== 'function') {
24
- return null;
25
- }
26
- const {
27
- File,
28
- Directory,
29
- Paths
30
- } = lib;
31
- const documents = asDirectoryPath(Paths.document.uri);
32
- return {
33
- dirs: {
34
- documents,
35
- cache: asDirectoryPath(Paths.cache.uri),
36
- // expo exposes no public Downloads directory, so a "downloads" request
37
- // lands in the app's documents directory instead of the shared folder.
38
- downloads: documents
39
- },
40
- write: (path, bytes) => {
41
- const file = new File(path);
42
- file.create({
43
- intermediates: true,
44
- overwrite: true
45
- });
46
- file.write(bytes);
47
- return Promise.resolve();
48
- },
49
- exists: path => Promise.resolve(new File(path).exists),
50
- stat: path => Promise.resolve({
51
- size: new File(path).size
52
- }),
53
- unlink: path => {
54
- new File(path).delete();
55
- return Promise.resolve();
56
- },
57
- // The download module calls this for a directory that usually already
58
- // exists, so it must be idempotent rather than throw on the second run.
59
- mkdir: path => {
60
- new Directory(path).create({
61
- intermediates: true,
62
- idempotent: true
63
- });
64
- return Promise.resolve();
65
- }
66
- };
67
- };
68
- exports.adaptExpoFileSystem = adaptExpoFileSystem;
69
- //# sourceMappingURL=expoFs.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.adaptExpoFileSystem=void 0;const asDirectoryPath=e=>e.replace(/\/+$/,""),adaptExpoFileSystem=e=>{const t=e?.default??e;if("function"!=typeof t?.File||"function"!=typeof t.File.prototype?.write)return null;const{File:r,Directory:i,Paths:o}=t,s=asDirectoryPath(o.document.uri);return{dirs:{documents:s,cache:asDirectoryPath(o.cache.uri),downloads:s},write:(e,t)=>{const i=new r(e);return i.create({intermediates:!0,overwrite:!0}),i.write(t),Promise.resolve()},exists:e=>Promise.resolve(new r(e).exists),stat:e=>Promise.resolve({size:new r(e).size}),unlink:e=>(new r(e).delete(),Promise.resolve()),mkdir:e=>(new i(e).create({intermediates:!0,idempotent:!0}),Promise.resolve())}};exports.adaptExpoFileSystem=adaptExpoFileSystem;
@@ -1,13 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.asNumber = void 0;
7
- /** Coerce a driver-supplied size, which some report as a string. */
8
- const asNumber = value => {
9
- const n = typeof value === 'number' ? value : Number(value);
10
- return Number.isFinite(n) ? n : 0;
11
- };
12
- exports.asNumber = asNumber;
13
- //# sourceMappingURL=shared.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.asNumber=void 0;const asNumber=e=>{const r="number"==typeof e?e:Number(e);return Number.isFinite(r)?r:0};exports.asNumber=asNumber;