@webority/mobile-core 0.0.28 → 0.1.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 (139) hide show
  1. package/lib/commonjs/api/baseUrl.js +1 -34
  2. package/lib/commonjs/api/curl.js +1 -109
  3. package/lib/commonjs/api/multipart.js +1 -21
  4. package/lib/commonjs/api/publicClient.js +1 -79
  5. package/lib/commonjs/api/responseBodyText.js +1 -0
  6. package/lib/commonjs/api/retry.js +1 -91
  7. package/lib/commonjs/api/tokenRefresh.js +1 -205
  8. package/lib/commonjs/api/userClient.js +1 -265
  9. package/lib/commonjs/auth/authStore.js +1 -265
  10. package/lib/commonjs/auth/index.js +1 -44
  11. package/lib/commonjs/auth/jwt.js +1 -112
  12. package/lib/commonjs/config/index.js +1 -72
  13. package/lib/commonjs/deepLink/index.js +1 -286
  14. package/lib/commonjs/download/adapters/expoFs.js +1 -69
  15. package/lib/commonjs/download/adapters/shared.js +1 -13
  16. package/lib/commonjs/download/index.js +1 -250
  17. package/lib/commonjs/formatters/currency.js +1 -70
  18. package/lib/commonjs/formatters/date.js +1 -167
  19. package/lib/commonjs/formatters/dateMath.js +1 -311
  20. package/lib/commonjs/formatters/index.js +1 -246
  21. package/lib/commonjs/formatters/initials.js +1 -32
  22. package/lib/commonjs/formatters/intlCache.js +1 -37
  23. package/lib/commonjs/formatters/number.js +1 -89
  24. package/lib/commonjs/formatters/phone.js +1 -369
  25. package/lib/commonjs/formatters/windowsToIanaTable.js +1 -164
  26. package/lib/commonjs/geolocation/adapters/expoLocation.js +1 -126
  27. package/lib/commonjs/geolocation/index.js +1 -355
  28. package/lib/commonjs/index.js +1 -644
  29. package/lib/commonjs/initSDK.js +1 -66
  30. package/lib/commonjs/initUserAuth.js +1 -37
  31. package/lib/commonjs/logger/crashlytics.js +1 -0
  32. package/lib/commonjs/logger/index.js +1 -301
  33. package/lib/commonjs/logger/redact.js +1 -50
  34. package/lib/commonjs/network/index.js +1 -31
  35. package/lib/commonjs/network/networkStatus.js +1 -171
  36. package/lib/commonjs/permissions/calendar.js +1 -14
  37. package/lib/commonjs/permissions/camera.js +1 -14
  38. package/lib/commonjs/permissions/contacts.js +1 -10
  39. package/lib/commonjs/permissions/index.js +1 -133
  40. package/lib/commonjs/permissions/location.js +1 -14
  41. package/lib/commonjs/permissions/mediaLibrary.js +1 -10
  42. package/lib/commonjs/permissions/notifications.js +1 -10
  43. package/lib/commonjs/permissions/photos.js +1 -14
  44. package/lib/commonjs/phone/countries.js +1 -265
  45. package/lib/commonjs/push/index.js +1 -61
  46. package/lib/commonjs/push/push.js +1 -443
  47. package/lib/commonjs/push/status.js +1 -0
  48. package/lib/commonjs/push/task.js +1 -43
  49. package/lib/commonjs/secureScreen/index.js +1 -0
  50. package/lib/commonjs/share/index.js +1 -70
  51. package/lib/commonjs/smsRetriever/index.js +1 -91
  52. package/lib/commonjs/specs/NativeSmsRetriever.js +1 -15
  53. package/lib/commonjs/sqlite/adapters/expo.js +1 -53
  54. package/lib/commonjs/sqlite/index.js +1 -604
  55. package/lib/commonjs/storage/index.js +1 -214
  56. package/lib/commonjs/types/axios.js +1 -4
  57. package/lib/commonjs/types/globals.d.js +1 -6
  58. package/lib/commonjs/utils/base64.js +1 -24
  59. package/lib/commonjs/utils/imageCompression.js +1 -389
  60. package/lib/commonjs/utils/index.js +1 -19
  61. package/lib/commonjs/validators/index.js +1 -227
  62. package/lib/commonjs/versionCheck/index.js +1 -419
  63. package/lib/module/api/baseUrl.js +1 -30
  64. package/lib/module/api/curl.js +1 -104
  65. package/lib/module/api/multipart.js +1 -16
  66. package/lib/module/api/publicClient.js +1 -75
  67. package/lib/module/api/responseBodyText.js +1 -0
  68. package/lib/module/api/retry.js +1 -85
  69. package/lib/module/api/tokenRefresh.js +1 -192
  70. package/lib/module/api/userClient.js +1 -243
  71. package/lib/module/auth/authStore.js +1 -257
  72. package/lib/module/auth/index.js +1 -5
  73. package/lib/module/auth/jwt.js +1 -106
  74. package/lib/module/config/index.js +1 -64
  75. package/lib/module/deepLink/index.js +1 -280
  76. package/lib/module/download/adapters/expoFs.js +1 -64
  77. package/lib/module/download/adapters/shared.js +1 -8
  78. package/lib/module/download/index.js +1 -242
  79. package/lib/module/formatters/currency.js +1 -65
  80. package/lib/module/formatters/date.js +1 -159
  81. package/lib/module/formatters/dateMath.js +1 -295
  82. package/lib/module/formatters/index.js +1 -9
  83. package/lib/module/formatters/initials.js +1 -27
  84. package/lib/module/formatters/intlCache.js +1 -30
  85. package/lib/module/formatters/number.js +1 -82
  86. package/lib/module/formatters/phone.js +1 -302
  87. package/lib/module/formatters/windowsToIanaTable.js +1 -160
  88. package/lib/module/geolocation/adapters/expoLocation.js +1 -121
  89. package/lib/module/geolocation/index.js +1 -347
  90. package/lib/module/index.js +1 -57
  91. package/lib/module/initSDK.js +1 -61
  92. package/lib/module/initUserAuth.js +1 -33
  93. package/lib/module/logger/crashlytics.js +1 -0
  94. package/lib/module/logger/index.js +1 -295
  95. package/lib/module/logger/redact.js +1 -44
  96. package/lib/module/network/index.js +1 -4
  97. package/lib/module/network/networkStatus.js +1 -161
  98. package/lib/module/permissions/calendar.js +1 -15
  99. package/lib/module/permissions/camera.js +1 -15
  100. package/lib/module/permissions/contacts.js +1 -11
  101. package/lib/module/permissions/index.js +1 -128
  102. package/lib/module/permissions/location.js +1 -15
  103. package/lib/module/permissions/mediaLibrary.js +1 -11
  104. package/lib/module/permissions/notifications.js +1 -11
  105. package/lib/module/permissions/photos.js +1 -15
  106. package/lib/module/phone/countries.js +1 -261
  107. package/lib/module/push/index.js +1 -4
  108. package/lib/module/push/push.js +1 -427
  109. package/lib/module/push/status.js +1 -0
  110. package/lib/module/push/task.js +1 -38
  111. package/lib/module/secureScreen/index.js +1 -0
  112. package/lib/module/share/index.js +1 -64
  113. package/lib/module/smsRetriever/index.js +1 -86
  114. package/lib/module/specs/NativeSmsRetriever.js +1 -13
  115. package/lib/module/sqlite/adapters/expo.js +1 -48
  116. package/lib/module/sqlite/index.js +1 -594
  117. package/lib/module/storage/index.js +1 -208
  118. package/lib/module/types/axios.js +1 -4
  119. package/lib/module/types/globals.d.js +1 -10
  120. package/lib/module/utils/base64.js +1 -19
  121. package/lib/module/utils/imageCompression.js +1 -383
  122. package/lib/module/utils/index.js +1 -4
  123. package/lib/module/validators/index.js +1 -205
  124. package/lib/module/versionCheck/index.js +1 -413
  125. package/lib/typescript/commonjs/api/responseBodyText.d.ts +6 -0
  126. package/lib/typescript/commonjs/index.d.ts +5 -0
  127. package/lib/typescript/commonjs/logger/crashlytics.d.ts +31 -0
  128. package/lib/typescript/commonjs/push/index.d.ts +3 -1
  129. package/lib/typescript/commonjs/push/push.d.ts +9 -1
  130. package/lib/typescript/commonjs/push/status.d.ts +9 -0
  131. package/lib/typescript/commonjs/secureScreen/index.d.ts +25 -0
  132. package/lib/typescript/module/api/responseBodyText.d.ts +6 -0
  133. package/lib/typescript/module/index.d.ts +5 -0
  134. package/lib/typescript/module/logger/crashlytics.d.ts +31 -0
  135. package/lib/typescript/module/push/index.d.ts +3 -1
  136. package/lib/typescript/module/push/push.d.ts +9 -1
  137. package/lib/typescript/module/push/status.d.ts +9 -0
  138. package/lib/typescript/module/secureScreen/index.d.ts +25 -0
  139. package/package.json +23 -4
@@ -1,227 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.minLength = exports.maxLength = exports.isUrl = exports.isStrongPassword = exports.isPhone = exports.isPan = exports.isNumeric = exports.isNonEmpty = exports.isInteger = exports.isIndianPincode = exports.isIndianMobile = exports.isIfsc = exports.isHexColor = exports.isGstin = exports.isEmail = exports.isBetween = exports.isAlphanumeric = exports.isAadhaar = void 0;
7
- /**
8
- * Generic validators returning `boolean`. All accept `null`/`undefined` safely.
9
- *
10
- * Tradeoff: regexes are pragmatic, not RFC-strict. They reject the things real users
11
- * typo and accept the long tail of legitimate inputs. For RFC-grade validation use
12
- * a dedicated library at the boundary.
13
- */
14
-
15
- const RE_EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
16
- const RE_INDIAN_MOBILE = /^[6-9]\d{9}$/;
17
- const RE_NUMERIC = /^-?\d+(?:\.\d+)?$/;
18
- const RE_INTEGER = /^-?\d+$/;
19
- const RE_ALPHANUMERIC = /^[a-zA-Z0-9]+$/;
20
- const RE_PINCODE_IN = /^[1-9]\d{5}$/;
21
- const RE_PAN = /^[A-Z]{5}\d{4}[A-Z]$/;
22
- const RE_GSTIN = /^\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$/;
23
- // UIDAI issues no Aadhaar number starting 0 or 1.
24
- const RE_AADHAAR = /^[2-9]\d{11}$/;
25
- const RE_IFSC = /^[A-Z]{4}0[A-Z0-9]{6}$/;
26
- const RE_HEX_COLOR = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
27
- const asString = v => {
28
- if (typeof v === 'string') {
29
- return v.trim();
30
- }
31
- return null;
32
- };
33
- const isNonEmpty = value => {
34
- const s = asString(value);
35
- return !!s && s.length > 0;
36
- };
37
- exports.isNonEmpty = isNonEmpty;
38
- const isEmail = value => {
39
- const s = asString(value);
40
- return !!s && RE_EMAIL.test(s);
41
- };
42
-
43
- /**
44
- * Validate an Indian mobile number. Accepts:
45
- * - 10-digit number starting with 6-9
46
- * - Optional `+91` or `91` country code prefix
47
- */
48
- exports.isEmail = isEmail;
49
- const isIndianMobile = value => {
50
- const s = asString(value);
51
- if (!s) {
52
- return false;
53
- }
54
- const digits = s.replace(/\D/g, '');
55
- const tail = digits.startsWith('91') && digits.length === 12 ? digits.slice(2) : digits;
56
- return RE_INDIAN_MOBILE.test(tail);
57
- };
58
-
59
- /**
60
- * Generic phone validator: 7–15 digits, optional `+` prefix.
61
- * Use `isIndianMobile` when you specifically need an Indian mobile number.
62
- */
63
- exports.isIndianMobile = isIndianMobile;
64
- const isPhone = value => {
65
- const s = asString(value);
66
- if (!s) {
67
- return false;
68
- }
69
- const digits = s.replace(/[^\d+]/g, '').replace(/^\+/, '');
70
- return digits.length >= 7 && digits.length <= 15 && /^\d+$/.test(digits);
71
- };
72
- exports.isPhone = isPhone;
73
- const isUrl = value => {
74
- const s = asString(value);
75
- if (!s) {
76
- return false;
77
- }
78
- try {
79
- // URL constructor is available on Hermes & JSC.
80
-
81
- new URL(s);
82
- return /^https?:\/\//i.test(s) || /^[a-z][a-z0-9+\-.]*:\/\//i.test(s);
83
- } catch {
84
- return false;
85
- }
86
- };
87
- exports.isUrl = isUrl;
88
- const isNumeric = value => {
89
- if (typeof value === 'number') {
90
- return Number.isFinite(value);
91
- }
92
- const s = asString(value);
93
- return !!s && RE_NUMERIC.test(s);
94
- };
95
- exports.isNumeric = isNumeric;
96
- const isInteger = value => {
97
- if (typeof value === 'number') {
98
- return Number.isInteger(value);
99
- }
100
- const s = asString(value);
101
- return !!s && RE_INTEGER.test(s);
102
- };
103
- exports.isInteger = isInteger;
104
- const isAlphanumeric = value => {
105
- const s = asString(value);
106
- return !!s && RE_ALPHANUMERIC.test(s);
107
- };
108
- exports.isAlphanumeric = isAlphanumeric;
109
- /**
110
- * Common password complexity check. Defaults to 8+ chars,
111
- * one uppercase, one lowercase, one digit.
112
- */
113
- const isStrongPassword = (value, rules = {}) => {
114
- if (typeof value !== 'string') {
115
- return false;
116
- }
117
- const {
118
- minLength = 8,
119
- requireUppercase = true,
120
- requireLowercase = true,
121
- requireNumber = true,
122
- requireSymbol = false
123
- } = rules;
124
- if (value.length < minLength) {
125
- return false;
126
- }
127
- if (requireUppercase && !/[A-Z]/.test(value)) {
128
- return false;
129
- }
130
- if (requireLowercase && !/[a-z]/.test(value)) {
131
- return false;
132
- }
133
- if (requireNumber && !/\d/.test(value)) {
134
- return false;
135
- }
136
- if (requireSymbol && !/[^A-Za-z0-9]/.test(value)) {
137
- return false;
138
- }
139
- return true;
140
- };
141
- exports.isStrongPassword = isStrongPassword;
142
- const isIndianPincode = value => {
143
- const s = asString(value);
144
- return !!s && RE_PINCODE_IN.test(s);
145
- };
146
- exports.isIndianPincode = isIndianPincode;
147
- const isPan = value => {
148
- const s = asString(value);
149
- return !!s && RE_PAN.test(s.toUpperCase());
150
- };
151
- exports.isPan = isPan;
152
- const BASE_36 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
153
-
154
- /**
155
- * The GSTN check character: each of the first fourteen characters' base-36
156
- * value times a weight alternating 1 and 2, the product's quotient and
157
- * remainder by 36 summed; the check character makes the total a multiple of 36.
158
- */
159
- const gstinCheckCharacter = gstin => {
160
- let sum = 0;
161
- for (let i = 0; i < 14; i += 1) {
162
- const product = BASE_36.indexOf(gstin[i]) * (i % 2 === 0 ? 1 : 2);
163
- sum += Math.floor(product / 36) + product % 36;
164
- }
165
- return BASE_36[(36 - sum % 36) % 36];
166
- };
167
- const isGstin = value => {
168
- const s = asString(value)?.toUpperCase();
169
- return !!s && RE_GSTIN.test(s) && s[14] === gstinCheckCharacter(s);
170
- };
171
- exports.isGstin = isGstin;
172
- const VERHOEFF_D = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]];
173
- const VERHOEFF_P = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]];
174
-
175
- /** Verhoeff (dihedral group D5): valid when the running product over the reversed digits is 0. */
176
- const isVerhoeffValid = digits => {
177
- let check = 0;
178
- for (let i = 0; i < digits.length; i += 1) {
179
- const digit = Number(digits[digits.length - 1 - i]);
180
- check = VERHOEFF_D[check][VERHOEFF_P[i % 8][digit]];
181
- }
182
- return check === 0;
183
- };
184
-
185
- /**
186
- * The same rules the Webority servers apply: spaces and hyphens stripped (as
187
- * printed on the card), twelve digits, no leading 0 or 1, and a correct
188
- * Verhoeff check digit.
189
- */
190
- const isAadhaar = value => {
191
- const s = asString(value);
192
- if (!s) {
193
- return false;
194
- }
195
- const digits = s.replace(/[\s-]/g, '');
196
- return RE_AADHAAR.test(digits) && isVerhoeffValid(digits);
197
- };
198
- exports.isAadhaar = isAadhaar;
199
- const isIfsc = value => {
200
- const s = asString(value);
201
- return !!s && RE_IFSC.test(s.toUpperCase());
202
- };
203
- exports.isIfsc = isIfsc;
204
- const isHexColor = value => {
205
- const s = asString(value);
206
- return !!s && RE_HEX_COLOR.test(s);
207
- };
208
- exports.isHexColor = isHexColor;
209
- const isBetween = (value, min, max, inclusive = true) => {
210
- const n = typeof value === 'number' ? value : Number(asString(value));
211
- if (!Number.isFinite(n)) {
212
- return false;
213
- }
214
- return inclusive ? n >= min && n <= max : n > min && n < max;
215
- };
216
- exports.isBetween = isBetween;
217
- const minLength = (value, length) => {
218
- const s = asString(value);
219
- return !!s && s.length >= length;
220
- };
221
- exports.minLength = minLength;
222
- const maxLength = (value, length) => {
223
- const s = asString(value);
224
- return s == null ? true : s.length <= length;
225
- };
226
- exports.maxLength = maxLength;
227
- //# sourceMappingURL=index.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.minLength=exports.maxLength=exports.isUrl=exports.isStrongPassword=exports.isPhone=exports.isPan=exports.isNumeric=exports.isNonEmpty=exports.isInteger=exports.isIndianPincode=exports.isIndianMobile=exports.isIfsc=exports.isHexColor=exports.isGstin=exports.isEmail=exports.isBetween=exports.isAlphanumeric=exports.isAadhaar=void 0;const RE_EMAIL=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,RE_INDIAN_MOBILE=/^[6-9]\d{9}$/,RE_NUMERIC=/^-?\d+(?:\.\d+)?$/,RE_INTEGER=/^-?\d+$/,RE_ALPHANUMERIC=/^[a-zA-Z0-9]+$/,RE_PINCODE_IN=/^[1-9]\d{5}$/,RE_PAN=/^[A-Z]{5}\d{4}[A-Z]$/,RE_GSTIN=/^\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$/,RE_AADHAAR=/^[2-9]\d{11}$/,RE_IFSC=/^[A-Z]{4}0[A-Z0-9]{6}$/,RE_HEX_COLOR=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,asString=t=>"string"==typeof t?t.trim():null,isNonEmpty=t=>{const s=asString(t);return!!s&&s.length>0};exports.isNonEmpty=isNonEmpty;const isEmail=t=>{const s=asString(t);return!!s&&RE_EMAIL.test(s)};exports.isEmail=isEmail;const isIndianMobile=t=>{const s=asString(t);if(!s)return!1;const e=s.replace(/\D/g,""),r=e.startsWith("91")&&12===e.length?e.slice(2):e;return RE_INDIAN_MOBILE.test(r)};exports.isIndianMobile=isIndianMobile;const isPhone=t=>{const s=asString(t);if(!s)return!1;const e=s.replace(/[^\d+]/g,"").replace(/^\+/,"");return e.length>=7&&e.length<=15&&/^\d+$/.test(e)};exports.isPhone=isPhone;const isUrl=t=>{const s=asString(t);if(!s)return!1;try{return new URL(s),/^https?:\/\//i.test(s)||/^[a-z][a-z0-9+\-.]*:\/\//i.test(s)}catch{return!1}};exports.isUrl=isUrl;const isNumeric=t=>{if("number"==typeof t)return Number.isFinite(t);const s=asString(t);return!!s&&RE_NUMERIC.test(s)};exports.isNumeric=isNumeric;const isInteger=t=>{if("number"==typeof t)return Number.isInteger(t);const s=asString(t);return!!s&&RE_INTEGER.test(s)};exports.isInteger=isInteger;const isAlphanumeric=t=>{const s=asString(t);return!!s&&RE_ALPHANUMERIC.test(s)};exports.isAlphanumeric=isAlphanumeric;const isStrongPassword=(t,s={})=>{if("string"!=typeof t)return!1;const{minLength:e=8,requireUppercase:r=!0,requireLowercase:n=!0,requireNumber:i=!0,requireSymbol:o=!1}=s;return!(t.length<e)&&(!(r&&!/[A-Z]/.test(t))&&(!(n&&!/[a-z]/.test(t))&&(!(i&&!/\d/.test(t))&&!(o&&!/[^A-Za-z0-9]/.test(t)))))};exports.isStrongPassword=isStrongPassword;const isIndianPincode=t=>{const s=asString(t);return!!s&&RE_PINCODE_IN.test(s)};exports.isIndianPincode=isIndianPincode;const isPan=t=>{const s=asString(t);return!!s&&RE_PAN.test(s.toUpperCase())};exports.isPan=isPan;const BASE_36="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",gstinCheckCharacter=t=>{let s=0;for(let e=0;e<14;e+=1){const r=BASE_36.indexOf(t[e])*(e%2==0?1:2);s+=Math.floor(r/36)+r%36}return BASE_36[(36-s%36)%36]},isGstin=t=>{const s=asString(t)?.toUpperCase();return!!s&&RE_GSTIN.test(s)&&s[14]===gstinCheckCharacter(s)};exports.isGstin=isGstin;const VERHOEFF_D=[[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],[4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],[8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]],VERHOEFF_P=[[0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],[9,4,5,3,1,2,6,8,7,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]],isVerhoeffValid=t=>{let s=0;for(let e=0;e<t.length;e+=1){const r=Number(t[t.length-1-e]);s=VERHOEFF_D[s][VERHOEFF_P[e%8][r]]}return 0===s},isAadhaar=t=>{const s=asString(t);if(!s)return!1;const e=s.replace(/[\s-]/g,"");return RE_AADHAAR.test(e)&&isVerhoeffValid(e)};exports.isAadhaar=isAadhaar;const isIfsc=t=>{const s=asString(t);return!!s&&RE_IFSC.test(s.toUpperCase())};exports.isIfsc=isIfsc;const isHexColor=t=>{const s=asString(t);return!!s&&RE_HEX_COLOR.test(s)};exports.isHexColor=isHexColor;const isBetween=(t,s,e,r=!0)=>{const n="number"==typeof t?t:Number(asString(t));return!!Number.isFinite(n)&&(r?n>=s&&n<=e:n>s&&n<e)};exports.isBetween=isBetween;const minLength=(t,s)=>{const e=asString(t);return!!e&&e.length>=s};exports.minLength=minLength;const maxLength=(t,s)=>{const e=asString(t);return null==e||e.length<=s};exports.maxLength=maxLength;
@@ -1,419 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useVersionCheck = exports.setDeviceInfoImplementation = exports.default = exports.VersionCheck = void 0;
7
- var Application = _interopRequireWildcard(require("expo-application"));
8
- var _react = require("react");
9
- var _index = require("../config/index.js");
10
- var _index2 = require("../logger/index.js");
11
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
- // Type-only — erased at compile time; react-native stays lazily required below.
13
-
14
- /**
15
- * Minimal device-info shape we depend on.
16
- *
17
- * This is a LAST RESORT, not the primary path. `Platform.OS` already gives the
18
- * platform, and every Webority app carries its own store id and version in
19
- * `appsettings.Compiled.json` — so `setConfig({ appId, appVersion })` covers
20
- * both remaining values without a native module. The injector below exists for
21
- * apps that would rather hand us a `react-native-device-info` instance than
22
- * wire two config keys.
23
- */
24
-
25
- /**
26
- * expo-application, read at call time.
27
- *
28
- * `applicationId` and `nativeApplicationVersion` are module CONSTANTS rather
29
- * than functions, so they are read inside the accessors rather than captured
30
- * here — capturing would snapshot them before the native module has
31
- * initialised.
32
- *
33
- * `setConfig({ appId, appVersion })` still WINS over this: a Webority app
34
- * already carries both in appsettings.Compiled.json, and config is checked
35
- * first. This is the fallback for an app that would rather read its identity
36
- * from the binary it is actually running, which is the one place the two can
37
- * disagree.
38
- */
39
- const expoApplicationBackend = {
40
- getBundleId: () => Application.applicationId ?? '',
41
- getVersion: () => Application.nativeApplicationVersion ?? ''
42
- };
43
-
44
- /** Only what a test or the showcase injected; null means use expo-application. */
45
- let deviceInfo = null;
46
-
47
- /**
48
- * Supply the app identity from a native module instead of config.
49
- * Prefer `setConfig({ appId, appVersion })` — it needs no native dependency.
50
- * Pass `null` to clear.
51
- */
52
- const setDeviceInfoImplementation = impl => {
53
- deviceInfo = impl;
54
- };
55
- exports.setDeviceInfoImplementation = setDeviceInfoImplementation;
56
- const missing = (what, configKey) => {
57
- const err = new Error(`[VersionCheck] the app's ${what} is not available. Call ` + `setConfig({ ${configKey}: '...' }) — every Webority app already has this value in ` + 'appsettings.Compiled.json — or setDeviceInfoImplementation() with a native provider.');
58
- _index2.Logger.error(err.message);
59
- return err;
60
- };
61
-
62
- // Platform comes from React Native itself; there has never been a reason to
63
- // cross a native module boundary for it.
64
- const getSystemName = () => {
65
- const {
66
- Platform
67
- } = require('react-native');
68
- return Platform.OS;
69
- };
70
- const getBundleId = () => {
71
- const fromConfig = (0, _index.getConfigValue)('appId');
72
- if (fromConfig) {
73
- return fromConfig;
74
- }
75
- const fromDevice = (deviceInfo ?? expoApplicationBackend).getBundleId();
76
- if (fromDevice) {
77
- return fromDevice;
78
- }
79
- throw missing('store identifier', 'appId');
80
- };
81
- const getVersion = () => {
82
- const fromConfig = (0, _index.getConfigValue)('appVersion');
83
- if (fromConfig) {
84
- return fromConfig;
85
- }
86
- const fromDevice = (deviceInfo ?? expoApplicationBackend).getVersion();
87
- if (fromDevice) {
88
- return fromDevice;
89
- }
90
- throw missing('version', 'appVersion');
91
- };
92
-
93
- // Constants
94
- const MAX_RETRIES = 3;
95
- const RETRY_DELAY = 3000; // 3 seconds
96
-
97
- const getCountry = () => (0, _index.getConfigValue)('country', 'in').toLowerCase();
98
- // Utility function to parse and coerce version to a valid format
99
- const parseVersion = version => {
100
- _index2.Logger.info(`Parsing version: ${version}`);
101
- const coercedVersion = version.replace(/[^0-9.]/g, '');
102
- const versionParts = coercedVersion.split('.').map(Number);
103
- return {
104
- major: versionParts[0] || 0,
105
- minor: versionParts[1] || 0,
106
- patch: versionParts[2] || 0,
107
- prerelease: version.includes('-') ? version.split('-')[1] ?? '' : ''
108
- };
109
- };
110
-
111
- // Utility function to compare two versions loosely
112
- const diffLoose = (version1, version2) => {
113
- _index2.Logger.info(`Comparing versions: ${version1} and ${version2}`);
114
- if (version1 === version2) {
115
- return null;
116
- }
117
- const v1 = parseVersion(version1);
118
- const v2 = parseVersion(version2);
119
- if (v1.major < v2.major) {
120
- return 'major';
121
- }
122
- if (v1.major > v2.major) {
123
- return null;
124
- }
125
- if (v1.minor < v2.minor) {
126
- return 'minor';
127
- }
128
- if (v1.minor > v2.minor) {
129
- return null;
130
- }
131
- if (v1.patch < v2.patch) {
132
- return 'patch';
133
- }
134
- if (v1.patch > v2.patch) {
135
- return null;
136
- }
137
- if (v1.prerelease && !v2.prerelease) {
138
- return 'prerelease';
139
- }
140
- if (!v1.prerelease && v2.prerelease) {
141
- return null;
142
- }
143
- if (v1.prerelease < v2.prerelease) {
144
- return 'prerelease';
145
- }
146
- if (v1.prerelease > v2.prerelease) {
147
- return null;
148
- }
149
- return null;
150
- };
151
-
152
- // Function to compare current version with the latest version
153
- const versionCompare = (currentVersion, latestVersion) => {
154
- _index2.Logger.info(`Comparing current version: ${currentVersion} with latest version: ${latestVersion}`);
155
- if (!latestVersion) {
156
- return {
157
- needsUpdate: false,
158
- updateType: null,
159
- notice: 'Error: could not get latest version'
160
- };
161
- }
162
- try {
163
- const updateType = diffLoose(currentVersion, latestVersion);
164
- return {
165
- needsUpdate: !!updateType,
166
- updateType
167
- };
168
- } catch (e) {
169
- const message = e instanceof Error ? e.message : String(e);
170
- _index2.Logger.error(`Error comparing versions: ${message}`);
171
- const needsUpdate = currentVersion !== latestVersion && latestVersion > currentVersion;
172
- const updateType = needsUpdate ? 'minor' : null;
173
- return {
174
- needsUpdate,
175
- updateType,
176
- notice: message.replace(/^Invalid Version:/, 'Not a valid version:')
177
- };
178
- }
179
- };
180
-
181
- // Function to fetch version details from Google Play Store
182
- const fetchAndroidVersion = async url => {
183
- _index2.Logger.info(`Fetching Android version from URL: ${url}`);
184
- let response;
185
- try {
186
- response = await fetch(url, {
187
- headers: {
188
- 'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36',
189
- 'sec-fetch-site': 'same-origin'
190
- }
191
- });
192
- } catch (error) {
193
- const message = error instanceof Error ? error.message : String(error);
194
- _index2.Logger.error(`Error fetching data from Google Play Store: ${message}`);
195
- throw new Error('Error fetching data from Google Play Store.');
196
- }
197
- if (!response.ok) {
198
- if (response.status === 404) {
199
- _index2.Logger.error('App with app ID not found in Google Play.');
200
- throw new Error(`App with app ID not found in Google Play.`);
201
- }
202
- _index2.Logger.error(`Error fetching data: ${response.statusText}`);
203
- throw new Error(response.statusText);
204
- }
205
- const text = await response.text();
206
-
207
- // Primary regex pattern for current Play Store format
208
- let versionMatch = text.match(/\[\[\[['"]((\d+\.)+\d+)['"]\]\],/);
209
-
210
- // Alternate patterns as fallbacks
211
- if (!versionMatch) {
212
- // Fallback 1: Look for version in "current version" text
213
- versionMatch = text.match(/Current Version[^\d]+((\d+\.)+\d+)/i);
214
- }
215
- if (!versionMatch) {
216
- // Fallback 2: Look for itemprop="softwareVersion"
217
- versionMatch = text.match(/itemprop="softwareVersion"[^>]*>((\d+\.)+\d+)</i);
218
- }
219
- if (!versionMatch) {
220
- // Fallback 3: Try a more generic pattern for version numbers
221
- const allVersions = text.match(/(\d+\.\d+(\.\d+)?)/g);
222
- // If we found multiple version-like strings, use the first one
223
- versionMatch = allVersions && allVersions.length > 0 ? [null, allVersions[0]] : null;
224
- }
225
- const version = versionMatch ? versionMatch[1] ?? null : null;
226
- if (!version) {
227
- _index2.Logger.warn('Could not extract version from Play Store. Using fallback method.');
228
- }
229
- const notesMatch = text.match(/<div itemprop="description">(.*?)<\/div>/);
230
- const notes = notesMatch ? notesMatch[1] ?? '' : '';
231
- return {
232
- version,
233
- releasedAt: new Date().toISOString(),
234
- notes,
235
- url,
236
- lastChecked: new Date().toISOString()
237
- };
238
- };
239
- // Function to fetch version details from Apple App Store
240
- const fetchIosVersion = async url => {
241
- _index2.Logger.info(`Fetching iOS version from URL: ${url}`);
242
- let response;
243
- try {
244
- response = await fetch(url);
245
- } catch {
246
- _index2.Logger.error('Error connecting to iTunes.');
247
- throw new Error('Error connecting to iTunes.');
248
- }
249
- const data = await response.json();
250
- if (!data || !('results' in data)) {
251
- _index2.Logger.error('Unknown error connecting to iTunes.');
252
- throw new Error('Unknown error connecting to iTunes.');
253
- }
254
- if (!data.results.length) {
255
- _index2.Logger.error('App for this bundle ID not found.');
256
- throw new Error('App for this bundle ID not found.');
257
- }
258
- const result = data.results[0];
259
- return {
260
- version: result.version || null,
261
- released: result.currentVersionReleaseDate || result.releaseDate || null,
262
- notes: result.releaseNotes || '',
263
- url: result.trackViewUrl || result.artistViewUrl || result.sellerUrl || null,
264
- country: getCountry(),
265
- lastChecked: new Date().toISOString()
266
- };
267
- };
268
-
269
- // Function to lookup version based on platform
270
- const lookupVersion = async (platform, identifier) => {
271
- _index2.Logger.info(`Looking up version for platform: ${platform}, identifier: ${identifier}`);
272
- const country = getCountry();
273
- const url = platform === 'ios' ? `https://itunes.apple.com/lookup?bundleId=${identifier}&country=${country}&_=${new Date().valueOf()}` : `https://play.google.com/store/apps/details?id=${identifier}&hl=${country}`;
274
- return platform === 'ios' ? fetchIosVersion(url) : fetchAndroidVersion(url);
275
- };
276
-
277
- /**
278
- * Check for new version with retry logic
279
- */
280
- const checkForUpdates = async () => {
281
- const platform = getSystemName().toLowerCase();
282
- const identifier = getBundleId();
283
- const currentVersion = getVersion();
284
-
285
- // Implement retry mechanism
286
- let retryCount = 0;
287
- let lastError = null;
288
- while (retryCount <= MAX_RETRIES) {
289
- try {
290
- _index2.Logger.info(`Checking if new version is available (attempt ${retryCount + 1}/${MAX_RETRIES + 1})`);
291
- _index2.Logger.info(`Platform: ${platform}, identifier: ${identifier}, current version: ${currentVersion}`);
292
- const latestVersionInfo = await lookupVersion(platform, identifier);
293
- const comparison = versionCompare(currentVersion, latestVersionInfo.version);
294
- return {
295
- isNewVersionAvailable: comparison.needsUpdate,
296
- updateType: comparison.updateType,
297
- url: latestVersionInfo.url
298
- };
299
- } catch (error) {
300
- lastError = error;
301
- const message = error instanceof Error ? error.message : String(error);
302
- _index2.Logger.error(`Error checking version (attempt ${retryCount + 1}/${MAX_RETRIES + 1}): ${message}`);
303
-
304
- // If we've reached max retries, throw the last error
305
- if (retryCount === MAX_RETRIES) {
306
- throw error;
307
- }
308
-
309
- // Otherwise, wait and retry
310
- retryCount++;
311
- _index2.Logger.info(`Retrying version check in ${RETRY_DELAY}ms...`);
312
- await new Promise(resolve => setTimeout(resolve, RETRY_DELAY));
313
- }
314
- }
315
-
316
- // This should never be reached due to the throw above, but just in case
317
- throw lastError instanceof Error ? lastError : new Error('Failed to check for updates after multiple attempts');
318
- };
319
-
320
- /**
321
- * Get fallback store URL based on platform
322
- */
323
- const getFallbackStoreUrl = () => {
324
- const platform = getSystemName().toLowerCase();
325
- const bundleId = getBundleId();
326
- const country = getCountry();
327
- return platform === 'ios' ? `https://apps.apple.com/${country}/app/${bundleId}` : `https://play.google.com/store/apps/details?id=${bundleId}&hl=${country}`;
328
- };
329
- // Version check functionality
330
- const VersionCheck = exports.VersionCheck = {
331
- isNewVersionAvailable: async () => {
332
- return checkForUpdates();
333
- },
334
- openUpdateUrl: async url => {
335
- const {
336
- Linking
337
- } = require('react-native');
338
- try {
339
- if (url) {
340
- _index2.Logger.info(`Opening app store URL: ${url}`);
341
- await Linking.openURL(url);
342
- } else {
343
- const fallbackUrl = getFallbackStoreUrl();
344
- _index2.Logger.info(`Opening fallback store URL: ${fallbackUrl}`);
345
- await Linking.openURL(fallbackUrl);
346
- }
347
- return true;
348
- } catch (error) {
349
- const message = error instanceof Error ? error.message : String(error);
350
- _index2.Logger.error(`Failed to open store URL: ${message}`);
351
-
352
- // Try with fallback URL if the original failed
353
- try {
354
- if (url) {
355
- // Only try fallback if we were using a specific URL before
356
- const fallbackUrl = getFallbackStoreUrl();
357
- _index2.Logger.info(`Trying fallback store URL: ${fallbackUrl}`);
358
- await Linking.openURL(fallbackUrl);
359
- return true;
360
- }
361
- } catch (fallbackError) {
362
- const fbMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
363
- _index2.Logger.error(`Failed to open fallback URL: ${fbMessage}`);
364
- }
365
- return false;
366
- }
367
- },
368
- getFallbackStoreUrl
369
- };
370
-
371
- /**
372
- * Custom hook to check for required app updates.
373
- *
374
- * @param isAppReady - Whether the app is ready to perform the check
375
- * @param environment - The app environment (defaults to the one in config)
376
- */
377
- const useVersionCheck = (isAppReady, environment = (0, _index.getConfigValue)('environment', 'Development')) => {
378
- const [updateInfo, setUpdateInfo] = (0, _react.useState)({
379
- isUpdateRequired: false,
380
- updateUrl: null
381
- });
382
- (0, _react.useEffect)(() => {
383
- let isMounted = true;
384
- const checkVersion = async () => {
385
- try {
386
- // All retry logic is handled in the VersionCheck module
387
- const {
388
- isNewVersionAvailable,
389
- url
390
- } = await VersionCheck.isNewVersionAvailable();
391
- if (isNewVersionAvailable && isMounted) {
392
- _index2.Logger.info('Update required. URL:', url || 'Not available yet');
393
- setUpdateInfo({
394
- isUpdateRequired: true,
395
- updateUrl: url
396
- });
397
- } else if (isMounted) {
398
- _index2.Logger.info('App is up to date');
399
- }
400
- } catch (error) {
401
- _index2.Logger.error('Error checking app version:', error);
402
- }
403
- };
404
-
405
- // Only run version check in Production environment when app is ready
406
- if (isAppReady && environment === 'Production') {
407
- void checkVersion();
408
- }
409
- return () => {
410
- isMounted = false;
411
- };
412
- }, [isAppReady, environment]);
413
- return updateInfo;
414
- };
415
-
416
- // Export for backward compatibility
417
- exports.useVersionCheck = useVersionCheck;
418
- var _default = exports.default = VersionCheck;
419
- //# sourceMappingURL=index.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useVersionCheck=exports.setDeviceInfoImplementation=exports.default=exports.VersionCheck=void 0;var Application=_interopRequireWildcard(require("expo-application")),_react=require("react"),_index=require("../config/index.js"),_index2=require("../logger/index.js");function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var n=new WeakMap,t=new WeakMap;return(_interopRequireWildcard=function(e,r){if(!r&&e&&e.__esModule)return e;var o,i,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(o=r?t:n){if(o.has(e))return o.get(e);o.set(e,a)}for(const r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?o(a,r,i):a[r]=e[r]);return a})(e,r)}const expoApplicationBackend={getBundleId:()=>Application.applicationId??"",getVersion:()=>Application.nativeApplicationVersion??""};let deviceInfo=null;const setDeviceInfoImplementation=e=>{deviceInfo=e};exports.setDeviceInfoImplementation=setDeviceInfoImplementation;const missing=(e,r)=>{const n=new Error(`[VersionCheck] the app's ${e} is not available. Call setConfig({ ${r}: '...' }) — every Webority app already has this value in appsettings.Compiled.json — or setDeviceInfoImplementation() with a native provider.`);return _index2.Logger.error(n.message),n},getSystemName=()=>{const{Platform:e}=require("react-native");return e.OS},getBundleId=()=>{const e=(0,_index.getConfigValue)("appId");if(e)return e;const r=(deviceInfo??expoApplicationBackend).getBundleId();if(r)return r;throw missing("store identifier","appId")},getVersion=()=>{const e=(0,_index.getConfigValue)("appVersion");if(e)return e;const r=(deviceInfo??expoApplicationBackend).getVersion();if(r)return r;throw missing("version","appVersion")},MAX_RETRIES=3,RETRY_DELAY=3e3,getCountry=()=>(0,_index.getConfigValue)("country","in").toLowerCase(),parseVersion=e=>{_index2.Logger.info(`Parsing version: ${e}`);const r=e.replace(/[^0-9.]/g,"").split(".").map(Number);return{major:r[0]||0,minor:r[1]||0,patch:r[2]||0,prerelease:e.includes("-")?e.split("-")[1]??"":""}},diffLoose=(e,r)=>{if(_index2.Logger.info(`Comparing versions: ${e} and ${r}`),e===r)return null;const n=parseVersion(e),t=parseVersion(r);return n.major<t.major?"major":n.major>t.major?null:n.minor<t.minor?"minor":n.minor>t.minor?null:n.patch<t.patch?"patch":n.patch>t.patch?null:n.prerelease&&!t.prerelease?"prerelease":!n.prerelease&&t.prerelease?null:n.prerelease<t.prerelease?"prerelease":(n.prerelease,t.prerelease,null)},versionCompare=(e,r)=>{if(_index2.Logger.info(`Comparing current version: ${e} with latest version: ${r}`),!r)return{needsUpdate:!1,updateType:null,notice:"Error: could not get latest version"};try{const n=diffLoose(e,r);return{needsUpdate:!!n,updateType:n}}catch(n){const t=n instanceof Error?n.message:String(n);_index2.Logger.error(`Error comparing versions: ${t}`);const o=e!==r&&r>e;return{needsUpdate:o,updateType:o?"minor":null,notice:t.replace(/^Invalid Version:/,"Not a valid version:")}}},fetchAndroidVersion=async e=>{let r;_index2.Logger.info(`Fetching Android version from URL: ${e}`);try{r=await fetch(e,{headers:{"User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36","sec-fetch-site":"same-origin"}})}catch(e){const r=e instanceof Error?e.message:String(e);throw _index2.Logger.error(`Error fetching data from Google Play Store: ${r}`),new Error("Error fetching data from Google Play Store.")}if(!r.ok){if(404===r.status)throw _index2.Logger.error("App with app ID not found in Google Play."),new Error("App with app ID not found in Google Play.");throw _index2.Logger.error(`Error fetching data: ${r.statusText}`),new Error(r.statusText)}const n=await r.text();let t=n.match(/\[\[\[['"]((\d+\.)+\d+)['"]\]\],/);if(t||(t=n.match(/Current Version[^\d]+((\d+\.)+\d+)/i)),t||(t=n.match(/itemprop="softwareVersion"[^>]*>((\d+\.)+\d+)</i)),!t){const e=n.match(/(\d+\.\d+(\.\d+)?)/g);t=e&&e.length>0?[null,e[0]]:null}const o=t?t[1]??null:null;o||_index2.Logger.warn("Could not extract version from Play Store. Using fallback method.");const i=n.match(/<div itemprop="description">(.*?)<\/div>/),a=i?i[1]??"":"";return{version:o,releasedAt:(new Date).toISOString(),notes:a,url:e,lastChecked:(new Date).toISOString()}},fetchIosVersion=async e=>{let r;_index2.Logger.info(`Fetching iOS version from URL: ${e}`);try{r=await fetch(e)}catch{throw _index2.Logger.error("Error connecting to iTunes."),new Error("Error connecting to iTunes.")}const n=await r.json();if(!n||!("results"in n))throw _index2.Logger.error("Unknown error connecting to iTunes."),new Error("Unknown error connecting to iTunes.");if(!n.results.length)throw _index2.Logger.error("App for this bundle ID not found."),new Error("App for this bundle ID not found.");const t=n.results[0];return{version:t.version||null,released:t.currentVersionReleaseDate||t.releaseDate||null,notes:t.releaseNotes||"",url:t.trackViewUrl||t.artistViewUrl||t.sellerUrl||null,country:getCountry(),lastChecked:(new Date).toISOString()}},lookupVersion=async(e,r)=>{_index2.Logger.info(`Looking up version for platform: ${e}, identifier: ${r}`);const n=getCountry(),t="ios"===e?`https://itunes.apple.com/lookup?bundleId=${r}&country=${n}&_=${(new Date).valueOf()}`:`https://play.google.com/store/apps/details?id=${r}&hl=${n}`;return"ios"===e?fetchIosVersion(t):fetchAndroidVersion(t)},checkForUpdates=async()=>{const e=getSystemName().toLowerCase(),r=getBundleId(),n=getVersion();let t=0,o=null;for(;t<=3;)try{_index2.Logger.info(`Checking if new version is available (attempt ${t+1}/4)`),_index2.Logger.info(`Platform: ${e}, identifier: ${r}, current version: ${n}`);const o=await lookupVersion(e,r),i=versionCompare(n,o.version);return{isNewVersionAvailable:i.needsUpdate,updateType:i.updateType,url:o.url}}catch(e){o=e;const r=e instanceof Error?e.message:String(e);if(_index2.Logger.error(`Error checking version (attempt ${t+1}/4): ${r}`),3===t)throw e;t++,_index2.Logger.info("Retrying version check in 3000ms..."),await new Promise(e=>setTimeout(e,3e3))}throw o instanceof Error?o:new Error("Failed to check for updates after multiple attempts")},getFallbackStoreUrl=()=>{const e=getSystemName().toLowerCase(),r=getBundleId(),n=getCountry();return"ios"===e?`https://apps.apple.com/${n}/app/${r}`:`https://play.google.com/store/apps/details?id=${r}&hl=${n}`},VersionCheck=exports.VersionCheck={isNewVersionAvailable:async()=>checkForUpdates(),openUpdateUrl:async e=>{const{Linking:r}=require("react-native");try{if(e)_index2.Logger.info(`Opening app store URL: ${e}`),await r.openURL(e);else{const e=getFallbackStoreUrl();_index2.Logger.info(`Opening fallback store URL: ${e}`),await r.openURL(e)}return!0}catch(n){const t=n instanceof Error?n.message:String(n);_index2.Logger.error(`Failed to open store URL: ${t}`);try{if(e){const e=getFallbackStoreUrl();return _index2.Logger.info(`Trying fallback store URL: ${e}`),await r.openURL(e),!0}}catch(e){const r=e instanceof Error?e.message:String(e);_index2.Logger.error(`Failed to open fallback URL: ${r}`)}return!1}},getFallbackStoreUrl:getFallbackStoreUrl},useVersionCheck=(e,r=(0,_index.getConfigValue)("environment","Development"))=>{const[n,t]=(0,_react.useState)({isUpdateRequired:!1,updateUrl:null});return(0,_react.useEffect)(()=>{let n=!0;return e&&"Production"===r&&(async()=>{try{const{isNewVersionAvailable:e,url:r}=await VersionCheck.isNewVersionAvailable();e&&n?(_index2.Logger.info("Update required. URL:",r||"Not available yet"),t({isUpdateRequired:!0,updateUrl:r})):n&&_index2.Logger.info("App is up to date")}catch(e){_index2.Logger.error("Error checking app version:",e)}})(),()=>{n=!1}},[e,r]),n};exports.useVersionCheck=useVersionCheck;var _default=exports.default=VersionCheck;