@webority/mobile-core 0.0.23

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 (211) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/android/build.gradle +65 -0
  4. package/android/src/newarch/java/com/webority/mobilecore/smsretriever/AppSignatureHelper.kt +57 -0
  5. package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverModule.kt +20 -0
  6. package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverModuleImpl.kt +146 -0
  7. package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverPackage.kt +33 -0
  8. package/lib/commonjs/api/baseUrl.js +34 -0
  9. package/lib/commonjs/api/curl.js +109 -0
  10. package/lib/commonjs/api/publicClient.js +73 -0
  11. package/lib/commonjs/api/retry.js +75 -0
  12. package/lib/commonjs/api/tokenRefresh.js +205 -0
  13. package/lib/commonjs/api/userClient.js +255 -0
  14. package/lib/commonjs/auth/authStore.js +232 -0
  15. package/lib/commonjs/auth/index.js +44 -0
  16. package/lib/commonjs/auth/jwt.js +112 -0
  17. package/lib/commonjs/config/index.js +66 -0
  18. package/lib/commonjs/deepLink/index.js +286 -0
  19. package/lib/commonjs/download/adapters/expoFs.js +69 -0
  20. package/lib/commonjs/download/adapters/shared.js +13 -0
  21. package/lib/commonjs/download/index.js +250 -0
  22. package/lib/commonjs/formatters/currency.js +69 -0
  23. package/lib/commonjs/formatters/date.js +168 -0
  24. package/lib/commonjs/formatters/dateMath.js +310 -0
  25. package/lib/commonjs/formatters/index.js +246 -0
  26. package/lib/commonjs/formatters/initials.js +32 -0
  27. package/lib/commonjs/formatters/number.js +88 -0
  28. package/lib/commonjs/formatters/phone.js +369 -0
  29. package/lib/commonjs/formatters/windowsToIanaTable.js +164 -0
  30. package/lib/commonjs/geolocation/adapters/expoLocation.js +126 -0
  31. package/lib/commonjs/geolocation/index.js +355 -0
  32. package/lib/commonjs/index.js +630 -0
  33. package/lib/commonjs/initSDK.js +66 -0
  34. package/lib/commonjs/initUserAuth.js +37 -0
  35. package/lib/commonjs/logger/index.js +291 -0
  36. package/lib/commonjs/network/index.js +31 -0
  37. package/lib/commonjs/network/networkStatus.js +133 -0
  38. package/lib/commonjs/package.json +1 -0
  39. package/lib/commonjs/permissions/calendar.js +14 -0
  40. package/lib/commonjs/permissions/camera.js +14 -0
  41. package/lib/commonjs/permissions/contacts.js +10 -0
  42. package/lib/commonjs/permissions/index.js +133 -0
  43. package/lib/commonjs/permissions/location.js +14 -0
  44. package/lib/commonjs/permissions/mediaLibrary.js +10 -0
  45. package/lib/commonjs/permissions/notifications.js +10 -0
  46. package/lib/commonjs/permissions/photos.js +14 -0
  47. package/lib/commonjs/phone/countries.js +265 -0
  48. package/lib/commonjs/share/index.js +70 -0
  49. package/lib/commonjs/smsRetriever/index.js +91 -0
  50. package/lib/commonjs/specs/NativeSmsRetriever.js +15 -0
  51. package/lib/commonjs/sqlite/adapters/expo.js +53 -0
  52. package/lib/commonjs/sqlite/index.js +604 -0
  53. package/lib/commonjs/storage/index.js +214 -0
  54. package/lib/commonjs/types/globals.d.js +6 -0
  55. package/lib/commonjs/utils/imageCompression.js +389 -0
  56. package/lib/commonjs/utils/index.js +19 -0
  57. package/lib/commonjs/validators/index.js +227 -0
  58. package/lib/commonjs/versionCheck/index.js +419 -0
  59. package/lib/module/api/baseUrl.js +30 -0
  60. package/lib/module/api/curl.js +104 -0
  61. package/lib/module/api/publicClient.js +69 -0
  62. package/lib/module/api/retry.js +69 -0
  63. package/lib/module/api/tokenRefresh.js +192 -0
  64. package/lib/module/api/userClient.js +233 -0
  65. package/lib/module/auth/authStore.js +224 -0
  66. package/lib/module/auth/index.js +5 -0
  67. package/lib/module/auth/jwt.js +106 -0
  68. package/lib/module/config/index.js +58 -0
  69. package/lib/module/deepLink/index.js +280 -0
  70. package/lib/module/download/adapters/expoFs.js +64 -0
  71. package/lib/module/download/adapters/shared.js +8 -0
  72. package/lib/module/download/index.js +242 -0
  73. package/lib/module/formatters/currency.js +64 -0
  74. package/lib/module/formatters/date.js +160 -0
  75. package/lib/module/formatters/dateMath.js +294 -0
  76. package/lib/module/formatters/index.js +9 -0
  77. package/lib/module/formatters/initials.js +27 -0
  78. package/lib/module/formatters/number.js +81 -0
  79. package/lib/module/formatters/phone.js +302 -0
  80. package/lib/module/formatters/windowsToIanaTable.js +160 -0
  81. package/lib/module/geolocation/adapters/expoLocation.js +121 -0
  82. package/lib/module/geolocation/index.js +347 -0
  83. package/lib/module/index.js +54 -0
  84. package/lib/module/initSDK.js +61 -0
  85. package/lib/module/initUserAuth.js +33 -0
  86. package/lib/module/logger/index.js +285 -0
  87. package/lib/module/network/index.js +4 -0
  88. package/lib/module/network/networkStatus.js +124 -0
  89. package/lib/module/package.json +1 -0
  90. package/lib/module/permissions/calendar.js +15 -0
  91. package/lib/module/permissions/camera.js +15 -0
  92. package/lib/module/permissions/contacts.js +11 -0
  93. package/lib/module/permissions/index.js +128 -0
  94. package/lib/module/permissions/location.js +15 -0
  95. package/lib/module/permissions/mediaLibrary.js +11 -0
  96. package/lib/module/permissions/notifications.js +11 -0
  97. package/lib/module/permissions/photos.js +15 -0
  98. package/lib/module/phone/countries.js +261 -0
  99. package/lib/module/share/index.js +64 -0
  100. package/lib/module/smsRetriever/index.js +86 -0
  101. package/lib/module/specs/NativeSmsRetriever.js +13 -0
  102. package/lib/module/sqlite/adapters/expo.js +48 -0
  103. package/lib/module/sqlite/index.js +594 -0
  104. package/lib/module/storage/index.js +208 -0
  105. package/lib/module/types/globals.d.js +10 -0
  106. package/lib/module/utils/imageCompression.js +383 -0
  107. package/lib/module/utils/index.js +4 -0
  108. package/lib/module/validators/index.js +205 -0
  109. package/lib/module/versionCheck/index.js +413 -0
  110. package/lib/typescript/commonjs/api/baseUrl.d.ts +20 -0
  111. package/lib/typescript/commonjs/api/curl.d.ts +18 -0
  112. package/lib/typescript/commonjs/api/publicClient.d.ts +11 -0
  113. package/lib/typescript/commonjs/api/retry.d.ts +27 -0
  114. package/lib/typescript/commonjs/api/tokenRefresh.d.ts +43 -0
  115. package/lib/typescript/commonjs/api/userClient.d.ts +37 -0
  116. package/lib/typescript/commonjs/auth/authStore.d.ts +79 -0
  117. package/lib/typescript/commonjs/auth/index.d.ts +5 -0
  118. package/lib/typescript/commonjs/auth/jwt.d.ts +31 -0
  119. package/lib/typescript/commonjs/config/index.d.ts +55 -0
  120. package/lib/typescript/commonjs/deepLink/index.d.ts +54 -0
  121. package/lib/typescript/commonjs/download/adapters/expoFs.d.ts +38 -0
  122. package/lib/typescript/commonjs/download/adapters/shared.d.ts +3 -0
  123. package/lib/typescript/commonjs/download/index.d.ts +86 -0
  124. package/lib/typescript/commonjs/formatters/currency.d.ts +24 -0
  125. package/lib/typescript/commonjs/formatters/date.d.ts +22 -0
  126. package/lib/typescript/commonjs/formatters/dateMath.d.ts +88 -0
  127. package/lib/typescript/commonjs/formatters/index.d.ts +10 -0
  128. package/lib/typescript/commonjs/formatters/initials.d.ts +11 -0
  129. package/lib/typescript/commonjs/formatters/number.d.ts +15 -0
  130. package/lib/typescript/commonjs/formatters/phone.d.ts +133 -0
  131. package/lib/typescript/commonjs/formatters/windowsToIanaTable.d.ts +18 -0
  132. package/lib/typescript/commonjs/geolocation/adapters/expoLocation.d.ts +42 -0
  133. package/lib/typescript/commonjs/geolocation/index.d.ts +90 -0
  134. package/lib/typescript/commonjs/index.d.ts +54 -0
  135. package/lib/typescript/commonjs/initSDK.d.ts +72 -0
  136. package/lib/typescript/commonjs/initUserAuth.d.ts +41 -0
  137. package/lib/typescript/commonjs/logger/index.d.ts +81 -0
  138. package/lib/typescript/commonjs/network/index.d.ts +3 -0
  139. package/lib/typescript/commonjs/network/networkStatus.d.ts +43 -0
  140. package/lib/typescript/commonjs/package.json +1 -0
  141. package/lib/typescript/commonjs/permissions/calendar.d.ts +2 -0
  142. package/lib/typescript/commonjs/permissions/camera.d.ts +2 -0
  143. package/lib/typescript/commonjs/permissions/contacts.d.ts +2 -0
  144. package/lib/typescript/commonjs/permissions/index.d.ts +48 -0
  145. package/lib/typescript/commonjs/permissions/location.d.ts +2 -0
  146. package/lib/typescript/commonjs/permissions/mediaLibrary.d.ts +2 -0
  147. package/lib/typescript/commonjs/permissions/notifications.d.ts +2 -0
  148. package/lib/typescript/commonjs/permissions/photos.d.ts +2 -0
  149. package/lib/typescript/commonjs/phone/countries.d.ts +13 -0
  150. package/lib/typescript/commonjs/share/index.d.ts +29 -0
  151. package/lib/typescript/commonjs/smsRetriever/index.d.ts +30 -0
  152. package/lib/typescript/commonjs/specs/NativeSmsRetriever.d.ts +15 -0
  153. package/lib/typescript/commonjs/sqlite/adapters/expo.d.ts +30 -0
  154. package/lib/typescript/commonjs/sqlite/index.d.ts +113 -0
  155. package/lib/typescript/commonjs/storage/index.d.ts +64 -0
  156. package/lib/typescript/commonjs/utils/imageCompression.d.ts +152 -0
  157. package/lib/typescript/commonjs/utils/index.d.ts +3 -0
  158. package/lib/typescript/commonjs/validators/index.d.ts +51 -0
  159. package/lib/typescript/commonjs/versionCheck/index.d.ts +80 -0
  160. package/lib/typescript/module/api/baseUrl.d.ts +20 -0
  161. package/lib/typescript/module/api/curl.d.ts +18 -0
  162. package/lib/typescript/module/api/publicClient.d.ts +11 -0
  163. package/lib/typescript/module/api/retry.d.ts +27 -0
  164. package/lib/typescript/module/api/tokenRefresh.d.ts +43 -0
  165. package/lib/typescript/module/api/userClient.d.ts +37 -0
  166. package/lib/typescript/module/auth/authStore.d.ts +79 -0
  167. package/lib/typescript/module/auth/index.d.ts +5 -0
  168. package/lib/typescript/module/auth/jwt.d.ts +31 -0
  169. package/lib/typescript/module/config/index.d.ts +55 -0
  170. package/lib/typescript/module/deepLink/index.d.ts +54 -0
  171. package/lib/typescript/module/download/adapters/expoFs.d.ts +38 -0
  172. package/lib/typescript/module/download/adapters/shared.d.ts +3 -0
  173. package/lib/typescript/module/download/index.d.ts +86 -0
  174. package/lib/typescript/module/formatters/currency.d.ts +24 -0
  175. package/lib/typescript/module/formatters/date.d.ts +22 -0
  176. package/lib/typescript/module/formatters/dateMath.d.ts +88 -0
  177. package/lib/typescript/module/formatters/index.d.ts +10 -0
  178. package/lib/typescript/module/formatters/initials.d.ts +11 -0
  179. package/lib/typescript/module/formatters/number.d.ts +15 -0
  180. package/lib/typescript/module/formatters/phone.d.ts +133 -0
  181. package/lib/typescript/module/formatters/windowsToIanaTable.d.ts +18 -0
  182. package/lib/typescript/module/geolocation/adapters/expoLocation.d.ts +42 -0
  183. package/lib/typescript/module/geolocation/index.d.ts +90 -0
  184. package/lib/typescript/module/index.d.ts +54 -0
  185. package/lib/typescript/module/initSDK.d.ts +72 -0
  186. package/lib/typescript/module/initUserAuth.d.ts +41 -0
  187. package/lib/typescript/module/logger/index.d.ts +81 -0
  188. package/lib/typescript/module/network/index.d.ts +3 -0
  189. package/lib/typescript/module/network/networkStatus.d.ts +43 -0
  190. package/lib/typescript/module/package.json +1 -0
  191. package/lib/typescript/module/permissions/calendar.d.ts +2 -0
  192. package/lib/typescript/module/permissions/camera.d.ts +2 -0
  193. package/lib/typescript/module/permissions/contacts.d.ts +2 -0
  194. package/lib/typescript/module/permissions/index.d.ts +48 -0
  195. package/lib/typescript/module/permissions/location.d.ts +2 -0
  196. package/lib/typescript/module/permissions/mediaLibrary.d.ts +2 -0
  197. package/lib/typescript/module/permissions/notifications.d.ts +2 -0
  198. package/lib/typescript/module/permissions/photos.d.ts +2 -0
  199. package/lib/typescript/module/phone/countries.d.ts +13 -0
  200. package/lib/typescript/module/share/index.d.ts +29 -0
  201. package/lib/typescript/module/smsRetriever/index.d.ts +30 -0
  202. package/lib/typescript/module/specs/NativeSmsRetriever.d.ts +15 -0
  203. package/lib/typescript/module/sqlite/adapters/expo.d.ts +30 -0
  204. package/lib/typescript/module/sqlite/index.d.ts +113 -0
  205. package/lib/typescript/module/storage/index.d.ts +64 -0
  206. package/lib/typescript/module/utils/imageCompression.d.ts +152 -0
  207. package/lib/typescript/module/utils/index.d.ts +3 -0
  208. package/lib/typescript/module/validators/index.d.ts +51 -0
  209. package/lib/typescript/module/versionCheck/index.d.ts +80 -0
  210. package/package.json +298 -0
  211. package/src/specs/NativeSmsRetriever.ts +16 -0
@@ -0,0 +1,27 @@
1
+ import type { AxiosError, AxiosInstance } from 'axios';
2
+ export interface RetryPolicy {
3
+ retries?: number;
4
+ /** `attempt` is 1-based: 1 is the first retry, not the original request. */
5
+ retryDelayMs?: (attempt: number) => number;
6
+ shouldRetry?: (error: AxiosError) => boolean;
7
+ onRetry?: (attempt: number, error: AxiosError) => void;
8
+ }
9
+ declare module 'axios' {
10
+ interface AxiosRequestConfig {
11
+ /** `false` opts a single request out of retrying; an object overrides the client policy. */
12
+ retry?: boolean | RetryPolicy;
13
+ }
14
+ }
15
+ /**
16
+ * Status-based ONLY, deliberately: a bare network error (no `error.response`)
17
+ * is never retryable. Both clients carry non-idempotent requests, login and OTP
18
+ * on the public one and every write on the user one, and a broken connection
19
+ * says nothing about whether the request reached the server. Retrying can
20
+ * therefore create a second session, or a duplicate record, that the user never
21
+ * sees. A generic network-error retry rule is not a substitute: it decides on
22
+ * the transport alone and never looks at the HTTP method, so it retries POSTs
23
+ * as readily as GETs.
24
+ */
25
+ export declare const isRetryableStatus: (status: number | undefined) => boolean;
26
+ export declare const attachRetry: (client: AxiosInstance, policy?: RetryPolicy) => void;
27
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1,43 @@
1
+ import type { UserAuthOptions } from '../initUserAuth.js';
2
+ /**
3
+ * The one token-refresh flow in the library, run by userClient's interceptors.
4
+ * The library calls the refresh endpoint itself, so it can tell a rejected
5
+ * refresh token (400 or 401: the session is over) from a transient failure
6
+ * (network, timeout, 5xx: the session is kept and the caller sees the error).
7
+ * A refresh is single flight. A download goes through the app's client, so it
8
+ * reaches this only when that client is userClient.
9
+ */
10
+ /**
11
+ * Minimal Redux-store shape required by the user client to dispatch logout.
12
+ */
13
+ export interface RefreshableStore {
14
+ dispatch: (action: unknown) => unknown;
15
+ }
16
+ export declare const injectStore: <S>(_store: S) => void;
17
+ export declare const injectUserAuth: (options: UserAuthOptions) => void;
18
+ /**
19
+ * Clear any in-flight token refresh and reject everything queued behind it.
20
+ * Call this on logout.
21
+ *
22
+ * Without it, a refresh that was already in flight when the user logged out
23
+ * resolves afterwards and replays every queued request with a token for a
24
+ * session that has ended. The queue is module state, so it survives the logout
25
+ * entirely: nothing else clears it. A consumer app hit this and hand-wrote the
26
+ * same function locally, which is how it was found.
27
+ */
28
+ export declare const resetRefreshState: () => void;
29
+ export declare const getErrorMessage: (error: unknown) => string;
30
+ /** The refresh endpoint's path, once initUserAuth has run. */
31
+ export declare const getRefreshPath: () => string | undefined;
32
+ export declare const dispatchLogout: () => Promise<void>;
33
+ export declare const isRefreshInFlight: () => boolean;
34
+ /** Wait for the in-flight refresh without joining it: resolved or rejected by processQueue. */
35
+ export declare const queueBehindRefresh: () => Promise<string>;
36
+ /**
37
+ * Refresh the access token, joining a refresh already in flight rather than
38
+ * starting a second one. Every request queued behind it is replayed on success
39
+ * and rejected on failure. Logs out only when the failure proves the session
40
+ * is over; a network error, timeout or 5xx keeps it and rejects.
41
+ */
42
+ export declare const refreshAccessToken: () => Promise<string>;
43
+ //# sourceMappingURL=tokenRefresh.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { type AxiosInstance } from 'axios';
2
+ export type { RefreshableStore } from './tokenRefresh.js';
3
+ export { injectStore, injectUserAuth, resetRefreshState } from './tokenRefresh.js';
4
+ /**
5
+ * Thrown by the request interceptor when the device is offline, before the
6
+ * request ever reaches the adapter (and therefore the network). Distinct from
7
+ * an AxiosError so callers can show an offline message instead of a generic
8
+ * request failure.
9
+ */
10
+ export declare class RequestOfflineError extends Error {
11
+ constructor(message?: string);
12
+ }
13
+ /**
14
+ * Sub-codes a 401 response body carries when the session itself is dead
15
+ * (terminated by an admin, or expired server-side) rather than merely
16
+ * out-of-date. These never warrant a refresh attempt — only logout.
17
+ */
18
+ export declare const SESSION_TERMINATION_CODES: {
19
+ readonly TERMINATED: "SESSION_TERMINATED";
20
+ readonly EXPIRED: "SESSION_EXPIRED";
21
+ };
22
+ export type SessionTerminationCode = (typeof SESSION_TERMINATION_CODES)[keyof typeof SESSION_TERMINATION_CODES];
23
+ /**
24
+ * The header is the AUTHORITATIVE signal, verified against the backend:
25
+ * `WeborityJwtMiddleware.ReturnUnauthorized` answers an invalidated session with
26
+ * `401` + `X-Security-Stamp-Invalid: true` and a body of
27
+ * `{ error: 'Unauthorized', message: '...' }` — no code field at all, and
28
+ * `error` is a string rather than an object. An earlier version of this checked
29
+ * only body fields and would therefore never have fired against a real server.
30
+ *
31
+ * The body codes below are kept as a secondary path for any head that does send
32
+ * an explicit sub-code; they match on exact strings, so looking is free.
33
+ */
34
+ export declare const SESSION_INVALID_HEADER = "x-security-stamp-invalid";
35
+ declare const userClient: AxiosInstance;
36
+ export default userClient;
37
+ //# sourceMappingURL=userClient.d.ts.map
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Token data persisted in the keychain.
3
+ */
4
+ /**
5
+ * The two keys the library itself reads. Everything in the library that needs
6
+ * the bearer token, the HTTP client and the authenticated image cache,
7
+ * resolves it through these rather than repeating the literal, so
8
+ * one of them cannot silently drift and start reading a key nothing writes.
9
+ * Apps are free to store their own tokens under any other key.
10
+ */
11
+ export declare const ACCESS_TOKEN_KEY = "accessToken";
12
+ export declare const REFRESH_TOKEN_KEY = "refreshToken";
13
+ export interface StoredToken {
14
+ token: string;
15
+ expiry: string;
16
+ }
17
+ /**
18
+ * The shape this module speaks to its store through. expo-secure-store is
19
+ * adapted to it below; an app or a test can supply anything else of this shape
20
+ * through `setKeychainImplementation`.
21
+ */
22
+ /**
23
+ * The GENERIC password API, not the internet-credentials one.
24
+ *
25
+ * `kSecClassInternetPassword` exists for credentials bound to a server, protocol
26
+ * and port, and it integrates with Safari and AutoFill. A bearer token keyed by
27
+ * a name like "accessToken" is none of those things, and the library was only
28
+ * satisfying that API's required `server` argument by passing the key twice,
29
+ * once as the server and once as the service. That is misuse of the class.
30
+ *
31
+ * `kSecClassGenericPassword` is the class for app-local secrets, which is what a
32
+ * token is. It is what expo-secure-store uses underneath, and what the consumer
33
+ * app being migrated had already chosen for itself.
34
+ */
35
+ /**
36
+ * The credential shape the seam reads back, declared here rather than imported
37
+ * from whichever package a consumer's backend comes from. A type-only import of
38
+ * a package this library does not declare survives into the published `.d.ts`,
39
+ * where a consumer that has not installed it either fails to typecheck or,
40
+ * under the RN template's `skipLibCheck: true`, loses all checking on these
41
+ * members with no signal. Any credential object with these three members
42
+ * satisfies it structurally.
43
+ */
44
+ interface SecureCredentials {
45
+ username: string;
46
+ password: string;
47
+ service: string;
48
+ }
49
+ interface KeychainLike {
50
+ setGenericPassword: (username: string, password: string, options?: {
51
+ service?: string;
52
+ }) => Promise<unknown>;
53
+ getGenericPassword: (options?: {
54
+ service?: string;
55
+ }) => Promise<SecureCredentials | false>;
56
+ resetGenericPassword: (options?: {
57
+ service?: string;
58
+ }) => Promise<unknown>;
59
+ }
60
+ /**
61
+ * Replace the secure-store backend. Intended for TESTS and for the showcase,
62
+ * which injects a failing store to demo the write-failure path; it is not how
63
+ * an app configures the library. Pass `null` to restore expo-secure-store.
64
+ */
65
+ export declare const setKeychainImplementation: (impl: KeychainLike | null) => void;
66
+ /**
67
+ * Store token with expiry.
68
+ */
69
+ export declare const storeToken: (key: string, token: string, expiry: string) => Promise<void>;
70
+ /**
71
+ * Retrieve token and check if expired.
72
+ */
73
+ export declare const getToken: (key: string) => Promise<StoredToken | null>;
74
+ /**
75
+ * Remove token by key.
76
+ */
77
+ export declare const removeToken: (key: string) => Promise<void>;
78
+ export type { KeychainLike, SecureCredentials };
79
+ //# sourceMappingURL=authStore.d.ts.map
@@ -0,0 +1,5 @@
1
+ export type { StoredToken } from './authStore.js';
2
+ export { getToken, removeToken, storeToken } from './authStore.js';
3
+ export type { JwtClaims } from './jwt.js';
4
+ export { decodeJWT, getJWTExpiry, isJWTExpired } from './jwt.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Standard claims plus arbitrary keys.
3
+ * `sub`, `exp`, `iat`, `nbf` follow RFC 7519 conventions.
4
+ */
5
+ export interface JwtClaims {
6
+ sub?: string;
7
+ exp?: number;
8
+ iat?: number;
9
+ nbf?: number;
10
+ iss?: string;
11
+ aud?: string | string[];
12
+ [key: string]: unknown;
13
+ }
14
+ /**
15
+ * Decode a JWT's payload claims. Does **not** verify the signature.
16
+ *
17
+ * @returns claims object on success, `null` if the token is malformed.
18
+ */
19
+ export declare const decodeJWT: <T extends JwtClaims = JwtClaims>(token: string) => T | null;
20
+ /**
21
+ * Returns true when the token is expired (or unparseable / missing `exp`).
22
+ *
23
+ * @param token JWT string
24
+ * @param leewaySeconds amount of clock-skew tolerance to apply (default 30s)
25
+ */
26
+ export declare const isJWTExpired: (token: string, leewaySeconds?: number) => boolean;
27
+ /**
28
+ * Returns the token's expiry as a Date, or `null` when no `exp` claim exists.
29
+ */
30
+ export declare const getJWTExpiry: (token: string) => Date | null;
31
+ //# sourceMappingURL=jwt.d.ts.map
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Configuration management for Webority packages
3
+ * Provides a flexible way to inject configuration without hard dependencies
4
+ */
5
+ export type LogLevel = 'info' | 'warn' | 'error';
6
+ export type Environment = 'Development' | 'Production' | 'Staging';
7
+ export interface Config {
8
+ /** API base URL (required before making API calls) */
9
+ baseUrl: string | null;
10
+ /** Enable/disable logging globally */
11
+ loggingEnabled: boolean;
12
+ /** Minimum log level to emit */
13
+ logLevel: LogLevel;
14
+ /** Current runtime environment */
15
+ environment: Environment;
16
+ /**
17
+ * ISO 3166-1 alpha-2 country code (lowercase) used by the version-check
18
+ * module to scope App Store / Play Store lookups. Defaults to `'in'`.
19
+ */
20
+ country: string;
21
+ /**
22
+ * The app's store identifier — Android package name / iOS bundle id. Every
23
+ * Webority app already has this in its `appsettings.Compiled.json`, so the
24
+ * version-check module reads it from here rather than crossing the native
25
+ * bridge for a value the app already knows.
26
+ */
27
+ appId: string | null;
28
+ /** The app's user-visible version string, e.g. `'1.4.2'`. Same rationale as `appId`. */
29
+ appVersion: string | null;
30
+ /**
31
+ * Log a copy-pasteable curl command for every API request. Credentials are
32
+ * redacted either way, but this is still request-level noise, so it stays off
33
+ * unless an app asks for it while debugging.
34
+ */
35
+ logCurl: boolean;
36
+ }
37
+ /**
38
+ * Set global configuration for all Webority packages
39
+ */
40
+ export declare const setConfig: (config: Partial<Config>) => void;
41
+ /**
42
+ * Get current configuration
43
+ */
44
+ export declare const getConfig: () => Config;
45
+ /**
46
+ * Get a specific config value with optional fallback.
47
+ * If the stored value is `null`, the fallback is returned (when provided).
48
+ */
49
+ export declare function getConfigValue<K extends keyof Config>(key: K): Config[K];
50
+ export declare function getConfigValue<K extends keyof Config>(key: K, fallback: Config[K]): Config[K];
51
+ /**
52
+ * Reset configuration to defaults
53
+ */
54
+ export declare const resetConfig: () => void;
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,54 @@
1
+ export interface ParsedLink {
2
+ /** The original URL, trimmed. */
3
+ url: string;
4
+ /** Lower-cased scheme without `://`, or '' when the URL carried none. */
5
+ scheme: string;
6
+ /**
7
+ * The authority for http(s) URLs. Custom schemes put the first route segment
8
+ * there (`myapp://order/12`), so for those `host` is `segments[0]` and stays
9
+ * part of `path` so one route pattern matches both link shapes.
10
+ */
11
+ host: string;
12
+ /** Route path with no leading or trailing slash. */
13
+ path: string;
14
+ segments: string[];
15
+ /** Query values, decoded. A repeated key keeps its last occurrence. */
16
+ query: Record<string, string>;
17
+ }
18
+ export interface DeepLinkRoute {
19
+ /** A path pattern with `:param` segments (`order/:id`), or a RegExp on `path`. */
20
+ match: string | RegExp;
21
+ requiresAuth?: boolean;
22
+ handler: (link: ParsedLink, params: Record<string, string>) => void;
23
+ }
24
+ export interface DeepLinkConfig {
25
+ routes: DeepLinkRoute[];
26
+ /** Navigator readiness. Links arriving before this is true are queued. */
27
+ isReady?: () => boolean;
28
+ isAuthenticated?: () => boolean;
29
+ /** Called when an auth-gated link is stashed; the app sends the user to login. */
30
+ onUnauthenticated?: (link: ParsedLink) => void;
31
+ onUnmatched?: (link: ParsedLink) => void;
32
+ }
33
+ /**
34
+ * Parse a deep-link URL. Returns null for anything that is not a usable URL so
35
+ * a hostile or truncated link can never throw on the native event path.
36
+ */
37
+ export declare const parseDeepLink: (url: string) => ParsedLink | null;
38
+ export declare const DeepLink: {
39
+ configure: (next: DeepLinkConfig) => void;
40
+ start: () => Promise<void>;
41
+ stop: () => void;
42
+ handleUrl: (url: string) => void;
43
+ setReady: (ready: boolean) => void;
44
+ /** Replay the stashed link, once. Call after a successful login. */
45
+ replayPending: () => void;
46
+ getPending: () => ParsedLink | null;
47
+ };
48
+ /**
49
+ * Configure and start the deep-link service for the lifetime of a component.
50
+ * The stored config delegates to the latest render, so new route closures do
51
+ * not tear down and re-subscribe the native listener.
52
+ */
53
+ export declare const useDeepLink: (deepLinkConfig: DeepLinkConfig) => void;
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,38 @@
1
+ import type { FileSystemLike } from '../index.js';
2
+ /**
3
+ * expo-file-system. Shape verified against 57.0.6, where the legacy function
4
+ * API (`downloadAsync`, `getInfoAsync`) still exists on the main entry point
5
+ * but every one of those functions THROWS at runtime; they now live behind
6
+ * `expo-file-system/legacy`. This adapter therefore uses the class API only.
7
+ *
8
+ * The REQUIRE lives in the entry point beside this file, never here.
9
+ */
10
+ interface ExpoFileLike {
11
+ readonly uri: string;
12
+ readonly exists: boolean;
13
+ readonly size: number;
14
+ create: (options?: {
15
+ intermediates?: boolean;
16
+ overwrite?: boolean;
17
+ }) => void;
18
+ write: (content: Uint8Array) => void;
19
+ delete: () => void;
20
+ }
21
+ interface ExpoDirectoryLike {
22
+ readonly uri: string;
23
+ create: (options?: {
24
+ intermediates?: boolean;
25
+ idempotent?: boolean;
26
+ }) => void;
27
+ }
28
+ export interface ExpoFileSystemModuleLike {
29
+ File: new (uri: string) => ExpoFileLike;
30
+ Directory: new (uri: string) => ExpoDirectoryLike;
31
+ Paths: {
32
+ document: ExpoDirectoryLike;
33
+ cache: ExpoDirectoryLike;
34
+ };
35
+ }
36
+ export declare const adaptExpoFileSystem: (mod: unknown) => FileSystemLike | null;
37
+ export {};
38
+ //# sourceMappingURL=expoFs.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** Coerce a driver-supplied size, which some report as a string. */
2
+ export declare const asNumber: (value: unknown) => number;
3
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,86 @@
1
+ export interface FileSystemDirs {
2
+ documents: string;
3
+ cache: string;
4
+ downloads: string;
5
+ }
6
+ /**
7
+ * The slice of a filesystem module this module actually uses. expo-file-system
8
+ * is adapted onto it, and a test or the showcase can inject its own with
9
+ * `setFileSystemImplementation`.
10
+ */
11
+ export interface FileSystemLike {
12
+ dirs: FileSystemDirs;
13
+ write: (path: string, bytes: Uint8Array) => Promise<void>;
14
+ exists: (path: string) => Promise<boolean>;
15
+ stat: (path: string) => Promise<{
16
+ size: number;
17
+ }>;
18
+ unlink: (path: string) => Promise<void>;
19
+ mkdir: (path: string) => Promise<void>;
20
+ }
21
+ export interface DownloadHttpRequestConfig {
22
+ headers?: Record<string, string>;
23
+ responseType: 'arraybuffer';
24
+ timeout?: number;
25
+ signal?: AbortSignal;
26
+ onDownloadProgress?: (event: {
27
+ loaded: number;
28
+ total?: number;
29
+ }) => void;
30
+ }
31
+ /**
32
+ * The slice of an HTTP client a download needs. The app's axios instance
33
+ * (mobile-core's `userClient` or `publicClient`, or its own) satisfies it as is,
34
+ * so whatever that client adds to a request (bearer token, tenant header, refresh
35
+ * and retry on 401) applies to the download too. Declared structurally, as
36
+ * mobile-support's client is, so no axios type leaks into the declarations.
37
+ */
38
+ export interface DownloadHttpClient {
39
+ get<T = unknown>(url: string, config?: DownloadHttpRequestConfig): Promise<{
40
+ data: T;
41
+ }>;
42
+ }
43
+ export type DownloadDestination = 'documents' | 'cache' | 'downloads';
44
+ export interface DownloadOptions {
45
+ /** Sends the request: `userClient` for a signed-in download, `publicClient` for an open one. */
46
+ client: DownloadHttpClient;
47
+ url: string;
48
+ fileName?: string;
49
+ destination?: DownloadDestination;
50
+ /** Sent with the request, beside whatever the client adds itself. */
51
+ headers?: Record<string, string>;
52
+ mimeType?: string;
53
+ onProgress?: (received: number, total: number, fraction: number) => void;
54
+ overwrite?: boolean;
55
+ signal?: AbortSignal;
56
+ }
57
+ export interface DownloadResult {
58
+ path: string;
59
+ bytes: number;
60
+ mimeType?: string;
61
+ fromCache: boolean;
62
+ }
63
+ export type DownloadErrorCode = 'unsupported' | 'permission-denied' | 'network' | 'http-error' | 'write-failed' | 'aborted' | 'empty-file';
64
+ export declare class DownloadError extends Error {
65
+ readonly code: DownloadErrorCode;
66
+ readonly status?: number;
67
+ constructor(code: DownloadErrorCode, message: string, status?: number);
68
+ }
69
+ /**
70
+ * Replace the filesystem backend. Intended for TESTS and for the showcase,
71
+ * which injects a denying backend to demo the permission error; an app gets
72
+ * expo-file-system without wiring anything. Pass `null` to restore it.
73
+ */
74
+ export declare const setFileSystemImplementation: (impl: FileSystemLike | null) => void;
75
+ /**
76
+ * Download a file to the device through the app's own HTTP client, so it is
77
+ * authenticated exactly as the app's other calls are. The whole file is held
78
+ * in memory before it is written, which suits documents and reports rather
79
+ * than large media.
80
+ *
81
+ * A finished download is always verified to be non-empty: a 0-byte file looks
82
+ * like a success to every caller and then wedges whatever consumes it, so it is
83
+ * reported as `empty-file` and nothing is kept.
84
+ */
85
+ export declare const downloadFile: (options: DownloadOptions) => Promise<DownloadResult>;
86
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,24 @@
1
+ export interface FormatCurrencyOptions {
2
+ /** ISO 4217 currency code. Defaults to `'INR'`. */
3
+ currency?: string;
4
+ /** BCP-47 locale tag. Defaults to `'en-IN'` (Indian numbering system). */
5
+ locale?: string;
6
+ /** Minimum fraction digits. Defaults to 0 for whole amounts, 2 otherwise. */
7
+ minimumFractionDigits?: number;
8
+ /** Maximum fraction digits. Defaults to 2. */
9
+ maximumFractionDigits?: number;
10
+ /** Strip the currency symbol — useful when the symbol is rendered separately. */
11
+ stripSymbol?: boolean;
12
+ }
13
+ /**
14
+ * Format an amount as currency. Defaults to **INR** with Indian numbering (`en-IN`),
15
+ * which matches the standard convention across Webority projects.
16
+ *
17
+ * @example
18
+ * formatCurrency(150000) // ₹1,50,000
19
+ * formatCurrency(1234.5) // ₹1,234.50
20
+ * formatCurrency(99, { currency: 'USD', locale: 'en-US' }) // $99.00
21
+ * formatCurrency(150000, { stripSymbol: true }) // 1,50,000
22
+ */
23
+ export declare const formatCurrency: (amount: number | null | undefined, options?: FormatCurrencyOptions) => string;
24
+ //# sourceMappingURL=currency.d.ts.map
@@ -0,0 +1,22 @@
1
+ export type DateInput = Date | string | number;
2
+ export type DateStyle = 'short' | 'medium' | 'long' | 'full';
3
+ export type TimeStyle = 'short' | 'medium' | 'long';
4
+ /**
5
+ * Locale-aware date formatter. Defaults to `'medium'` style and `'en-IN'` locale,
6
+ * matching the Indian-locale convention used across Webority apps.
7
+ */
8
+ export declare const formatDate: (value: DateInput, style?: DateStyle, locale?: string) => string;
9
+ /**
10
+ * Locale-aware time formatter (24-hour fallback when Intl is unavailable).
11
+ */
12
+ export declare const formatTime: (value: DateInput, style?: TimeStyle, locale?: string) => string;
13
+ /**
14
+ * Combined date + time formatter.
15
+ */
16
+ export declare const formatDateTime: (value: DateInput, dateStyle?: DateStyle, timeStyle?: TimeStyle, locale?: string) => string;
17
+ /**
18
+ * Returns a humanized relative-time string (e.g. "5 minutes ago", "in 3 days").
19
+ * Uses `Intl.RelativeTimeFormat` when available; otherwise a sensible English fallback.
20
+ */
21
+ export declare const formatRelativeTime: (value: DateInput, base?: DateInput, locale?: string) => string;
22
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1,88 @@
1
+ import type { DateInput } from './date.js';
2
+ /**
3
+ * Whether two values fall on the same calendar day in the device's local
4
+ * timezone. Invalid input on either side returns false rather than throwing.
5
+ */
6
+ export declare const isSameDay: (a: DateInput, b: DateInput) => boolean;
7
+ /** `a` is strictly before `b`. Invalid input on either side returns false. */
8
+ export declare const isDateBefore: (a: DateInput, b: DateInput) => boolean;
9
+ /** `a` is strictly after `b`. Invalid input on either side returns false. */
10
+ export declare const isDateAfter: (a: DateInput, b: DateInput) => boolean;
11
+ /**
12
+ * `a - b` in milliseconds, matching dayjs's `a.diff(b)` sign convention
13
+ * (positive when `a` is later than `b`). Returns `NaN` if either side fails
14
+ * to parse, the same way subtracting two invalid dayjs objects would.
15
+ */
16
+ export declare const diffMs: (a: DateInput, b: DateInput) => number;
17
+ /**
18
+ * Midnight of the given date, in the device's local timezone. Returns null
19
+ * for unparseable input.
20
+ */
21
+ export declare const startOfDay: (value: DateInput) => Date | null;
22
+ /**
23
+ * Adds (or, with a negative count, subtracts) whole calendar days in the
24
+ * device's local timezone. Returns null for unparseable input.
25
+ */
26
+ export declare const addDays: (value: DateInput, count: number) => Date | null;
27
+ /**
28
+ * Small dayjs/moment-style token formatter — YYYY/YY, MMMM/MMM/MM/M,
29
+ * DD/D, dddd/ddd, HH/H (24h), hh/h (12h), mm/m, ss/s, A/a (upper/lower AM/PM).
30
+ * Everything else in the pattern (spaces, commas, colons) passes through
31
+ * literally. Hand-rolled rather than a dependency because this fleet's date
32
+ * formatting needs are a small, closed token set, not general i18n — for
33
+ * genuinely locale-aware output, `formatDate`/`formatTime` (Intl-backed, in
34
+ * `./date`) are the ones to reach for; this is for matching an exact
35
+ * existing pattern (a legacy display string, an API's expected shape).
36
+ *
37
+ * `utc: true` reads every field from the UTC calendar/clock instead of the
38
+ * device's local one — see `formatDateDDMMMYYYY`'s note on why this isn't
39
+ * cosmetic.
40
+ */
41
+ export declare const formatDatePattern: (value: DateInput, pattern: string, options?: {
42
+ utc?: boolean;
43
+ }) => string;
44
+ /**
45
+ * `DD MMM, YYYY` — zero-padded day, short month, comma, year (e.g.
46
+ * `05 Sep, 2025`). A specific legacy pattern some apps already display,
47
+ * not the fleet's own product convention: `formatDate` (the Intl `style`-based
48
+ * formatter in `./date`) is the one to reach for in new code. This exists so
49
+ * an app already showing this exact pattern can move off a date library
50
+ * without a visible change.
51
+ *
52
+ * `utc: true` reads the calendar day from the UTC fields instead of the
53
+ * device's local ones — matching `dayjs.utc(x).format(...)`, not
54
+ * `dayjs(x).format(...)`. The two disagree whenever local time has crossed a
55
+ * day boundary UTC hasn't yet (or vice versa), so this is not a cosmetic
56
+ * option; pass it only to match a call site that was genuinely UTC-explicit.
57
+ */
58
+ export declare const formatDateDDMMMYYYY: (value: DateInput, options?: {
59
+ utc?: boolean;
60
+ }) => string;
61
+ /** `YYYY-MM-DD`, in the device's local timezone. */
62
+ export declare const formatDateISO: (value: DateInput) => string;
63
+ /**
64
+ * `hh:mm A` in the device's local timezone — zero-padded 12-hour clock,
65
+ * uppercase AM/PM (e.g. `09:30 PM`).
66
+ */
67
+ export declare const formatTime12h: (value: DateInput) => string;
68
+ /**
69
+ * `hh:mm a` (zero-padded 12-hour, lowercase am/pm) of the given instant as
70
+ * seen in `ianaTimeZone` (e.g. `Asia/Kolkata`) — not the device's own
71
+ * timezone. Reads the hour/minute/period through `Intl.DateTimeFormat`'s
72
+ * `formatToParts` rather than its assembled string, because the assembled
73
+ * string's spacing before AM/PM varies by JS engine (some insert a narrow
74
+ * no-break space, U+202F, instead of a plain space) and isn't reliably
75
+ * zero-padded either. Throws if `ianaTimeZone` isn't a timezone Intl
76
+ * recognises — the same failure mode as handing dayjs.tz() a bad zone name.
77
+ */
78
+ export declare const formatTimeInZone: (value: DateInput, ianaTimeZone: string) => string;
79
+ /**
80
+ * Same as {@link formatTimeInZone}, but for a .NET-style Windows timezone ID
81
+ * (e.g. `"India Standard Time"`) rather than an IANA one. .NET's own
82
+ * `TimeZoneInfo` API only knows Windows IDs, so a backend built on it hands
83
+ * these to clients directly — `Intl`, by contrast, only recognises IANA
84
+ * names, so the ID has to be translated before it can be used here. Throws
85
+ * if `windowsTimeZoneId` has no known IANA mapping.
86
+ */
87
+ export declare const formatTimeInWindowsZone: (value: DateInput, windowsTimeZoneId: string) => string;
88
+ //# sourceMappingURL=dateMath.d.ts.map
@@ -0,0 +1,10 @@
1
+ export type { FormatCurrencyOptions } from './currency.js';
2
+ export { formatCurrency } from './currency.js';
3
+ export type { DateInput, DateStyle, TimeStyle } from './date.js';
4
+ export { formatDate, formatDateTime, formatRelativeTime, formatTime } from './date.js';
5
+ export { addDays, diffMs, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, isDateAfter, isDateBefore, isSameDay, startOfDay } from './dateMath.js';
6
+ export { getInitials } from './initials.js';
7
+ export { formatCompactNumber, formatNumber, formatPercent } from './number.js';
8
+ export type { FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind } from './phone.js';
9
+ export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from './phone.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Returns up to `maxChars` uppercase initials from a name.
3
+ *
4
+ * @example
5
+ * getInitials('Navneet Singh') // 'NS'
6
+ * getInitials('mary anne lee', 3) // 'MAL'
7
+ * getInitials('navneet') // 'NA'
8
+ * getInitials(' ') // ''
9
+ */
10
+ export declare const getInitials: (name: string | null | undefined, maxChars?: number) => string;
11
+ //# sourceMappingURL=initials.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Locale-aware number formatter. Defaults to `'en-IN'` (Indian grouping).
3
+ */
4
+ export declare const formatNumber: (value: number | null | undefined, fractionDigits?: number, locale?: string) => string;
5
+ /**
6
+ * Format a 0–1 ratio (or 0–100 percent) as a percent string.
7
+ * Pass `asRatio: false` if your input is already on the 0–100 scale.
8
+ */
9
+ export declare const formatPercent: (value: number | null | undefined, fractionDigits?: number, asRatio?: boolean, locale?: string) => string;
10
+ /**
11
+ * Format a number compactly (1.2K, 3.4M, 1.5L, 2.3Cr).
12
+ * Defaults to Indian compact notation via `'en-IN'` locale (lakh / crore).
13
+ */
14
+ export declare const formatCompactNumber: (value: number | null | undefined, locale?: string) => string;
15
+ //# sourceMappingURL=number.d.ts.map