@webority-technologies/mobile-core 0.0.1

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 (102) hide show
  1. package/README.md +15 -0
  2. package/lib/commonjs/api/publicClient.js +80 -0
  3. package/lib/commonjs/api/userClient.js +368 -0
  4. package/lib/commonjs/auth/authStore.js +155 -0
  5. package/lib/commonjs/auth/index.js +44 -0
  6. package/lib/commonjs/auth/jwt.js +88 -0
  7. package/lib/commonjs/config/index.js +65 -0
  8. package/lib/commonjs/formatters/currency.js +69 -0
  9. package/lib/commonjs/formatters/date.js +168 -0
  10. package/lib/commonjs/formatters/index.js +77 -0
  11. package/lib/commonjs/formatters/initials.js +32 -0
  12. package/lib/commonjs/formatters/number.js +88 -0
  13. package/lib/commonjs/formatters/phone.js +67 -0
  14. package/lib/commonjs/index.js +383 -0
  15. package/lib/commonjs/initSDK.js +45 -0
  16. package/lib/commonjs/initUserAuth.js +38 -0
  17. package/lib/commonjs/logger/index.js +137 -0
  18. package/lib/commonjs/network/index.js +25 -0
  19. package/lib/commonjs/network/networkStatus.js +98 -0
  20. package/lib/commonjs/package.json +1 -0
  21. package/lib/commonjs/permissions/index.js +200 -0
  22. package/lib/commonjs/storage/index.js +193 -0
  23. package/lib/commonjs/utils/imageCompression.js +75 -0
  24. package/lib/commonjs/utils/index.js +13 -0
  25. package/lib/commonjs/validators/index.js +193 -0
  26. package/lib/commonjs/versionCheck/index.js +395 -0
  27. package/lib/module/api/publicClient.js +76 -0
  28. package/lib/module/api/userClient.js +360 -0
  29. package/lib/module/auth/authStore.js +148 -0
  30. package/lib/module/auth/index.js +5 -0
  31. package/lib/module/auth/jwt.js +82 -0
  32. package/lib/module/config/index.js +57 -0
  33. package/lib/module/formatters/currency.js +64 -0
  34. package/lib/module/formatters/date.js +160 -0
  35. package/lib/module/formatters/index.js +8 -0
  36. package/lib/module/formatters/initials.js +27 -0
  37. package/lib/module/formatters/number.js +81 -0
  38. package/lib/module/formatters/phone.js +61 -0
  39. package/lib/module/index.js +30 -0
  40. package/lib/module/initSDK.js +40 -0
  41. package/lib/module/initUserAuth.js +34 -0
  42. package/lib/module/logger/index.js +133 -0
  43. package/lib/module/network/index.js +4 -0
  44. package/lib/module/network/networkStatus.js +91 -0
  45. package/lib/module/package.json +1 -0
  46. package/lib/module/permissions/index.js +197 -0
  47. package/lib/module/storage/index.js +189 -0
  48. package/lib/module/utils/imageCompression.js +69 -0
  49. package/lib/module/utils/index.js +4 -0
  50. package/lib/module/validators/index.js +171 -0
  51. package/lib/module/versionCheck/index.js +390 -0
  52. package/lib/typescript/commonjs/api/publicClient.d.ts +11 -0
  53. package/lib/typescript/commonjs/api/userClient.d.ts +49 -0
  54. package/lib/typescript/commonjs/auth/authStore.d.ts +43 -0
  55. package/lib/typescript/commonjs/auth/index.d.ts +5 -0
  56. package/lib/typescript/commonjs/auth/jwt.d.ts +31 -0
  57. package/lib/typescript/commonjs/config/index.d.ts +49 -0
  58. package/lib/typescript/commonjs/formatters/currency.d.ts +24 -0
  59. package/lib/typescript/commonjs/formatters/date.d.ts +22 -0
  60. package/lib/typescript/commonjs/formatters/index.d.ts +8 -0
  61. package/lib/typescript/commonjs/formatters/initials.d.ts +11 -0
  62. package/lib/typescript/commonjs/formatters/number.d.ts +15 -0
  63. package/lib/typescript/commonjs/formatters/phone.d.ts +13 -0
  64. package/lib/typescript/commonjs/index.d.ts +30 -0
  65. package/lib/typescript/commonjs/initSDK.d.ts +40 -0
  66. package/lib/typescript/commonjs/initUserAuth.d.ts +22 -0
  67. package/lib/typescript/commonjs/logger/index.d.ts +42 -0
  68. package/lib/typescript/commonjs/network/index.d.ts +3 -0
  69. package/lib/typescript/commonjs/network/networkStatus.d.ts +27 -0
  70. package/lib/typescript/commonjs/package.json +1 -0
  71. package/lib/typescript/commonjs/permissions/index.d.ts +20 -0
  72. package/lib/typescript/commonjs/storage/index.d.ts +42 -0
  73. package/lib/typescript/commonjs/utils/imageCompression.d.ts +31 -0
  74. package/lib/typescript/commonjs/utils/index.d.ts +3 -0
  75. package/lib/typescript/commonjs/validators/index.d.ts +46 -0
  76. package/lib/typescript/commonjs/versionCheck/index.d.ts +80 -0
  77. package/lib/typescript/module/api/publicClient.d.ts +11 -0
  78. package/lib/typescript/module/api/userClient.d.ts +49 -0
  79. package/lib/typescript/module/auth/authStore.d.ts +43 -0
  80. package/lib/typescript/module/auth/index.d.ts +5 -0
  81. package/lib/typescript/module/auth/jwt.d.ts +31 -0
  82. package/lib/typescript/module/config/index.d.ts +49 -0
  83. package/lib/typescript/module/formatters/currency.d.ts +24 -0
  84. package/lib/typescript/module/formatters/date.d.ts +22 -0
  85. package/lib/typescript/module/formatters/index.d.ts +8 -0
  86. package/lib/typescript/module/formatters/initials.d.ts +11 -0
  87. package/lib/typescript/module/formatters/number.d.ts +15 -0
  88. package/lib/typescript/module/formatters/phone.d.ts +13 -0
  89. package/lib/typescript/module/index.d.ts +30 -0
  90. package/lib/typescript/module/initSDK.d.ts +40 -0
  91. package/lib/typescript/module/initUserAuth.d.ts +22 -0
  92. package/lib/typescript/module/logger/index.d.ts +42 -0
  93. package/lib/typescript/module/network/index.d.ts +3 -0
  94. package/lib/typescript/module/network/networkStatus.d.ts +27 -0
  95. package/lib/typescript/module/package.json +1 -0
  96. package/lib/typescript/module/permissions/index.d.ts +20 -0
  97. package/lib/typescript/module/storage/index.d.ts +42 -0
  98. package/lib/typescript/module/utils/imageCompression.d.ts +31 -0
  99. package/lib/typescript/module/utils/index.d.ts +3 -0
  100. package/lib/typescript/module/validators/index.d.ts +46 -0
  101. package/lib/typescript/module/versionCheck/index.d.ts +80 -0
  102. package/package.json +112 -0
@@ -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,49 @@
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
+ /**
32
+ * Set global configuration for all Webority packages
33
+ */
34
+ export declare const setConfig: (config: Partial<Config>) => void;
35
+ /**
36
+ * Get current configuration
37
+ */
38
+ export declare const getConfig: () => Config;
39
+ /**
40
+ * Get a specific config value with optional fallback.
41
+ * If the stored value is `null`, the fallback is returned (when provided).
42
+ */
43
+ export declare function getConfigValue<K extends keyof Config>(key: K): Config[K];
44
+ export declare function getConfigValue<K extends keyof Config>(key: K, fallback: Config[K]): Config[K];
45
+ /**
46
+ * Reset configuration to defaults
47
+ */
48
+ export declare const resetConfig: () => void;
49
+ //# 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,8 @@
1
+ export type { FormatCurrencyOptions } from './currency';
2
+ export { formatCurrency } from './currency';
3
+ export type { DateInput, DateStyle, TimeStyle } from './date';
4
+ export { formatDate, formatDateTime, formatRelativeTime, formatTime } from './date';
5
+ export { getInitials } from './initials';
6
+ export { formatCompactNumber, formatNumber, formatPercent } from './number';
7
+ export { formatPhone, normalizePhone } from './phone';
8
+ //# 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
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Strip everything except digits and a leading `+` (preserved if present).
3
+ */
4
+ export declare const normalizePhone: (input: string) => string;
5
+ /**
6
+ * Format a phone number for human display.
7
+ *
8
+ * - Indian mobile (10 digits) → `XXXXX XXXXX`
9
+ * - With `+91` country code → `+91 XXXXX XXXXX`
10
+ * - Other inputs are returned as `+CC NNNN NNNN…` best-effort grouping.
11
+ */
12
+ export declare const formatPhone: (input: string, defaultCountryCode?: string) => string;
13
+ //# sourceMappingURL=phone.d.ts.map
@@ -0,0 +1,30 @@
1
+ export { default as publicClient } from './api/publicClient';
2
+ export type { RefreshableStore, SessionTerminationCode } from './api/userClient';
3
+ export { default as userClient, injectAuthActions, injectStore, RequestOfflineError, SESSION_TERMINATION_CODES } from './api/userClient';
4
+ export type { KeychainLike, StoredToken } from './auth/authStore';
5
+ export { getToken, removeToken, setKeychainImplementation, storeToken } from './auth/authStore';
6
+ export type { JwtClaims } from './auth/jwt';
7
+ export { decodeJWT, getJWTExpiry, isJWTExpired } from './auth/jwt';
8
+ export type { Config, Environment, LogLevel } from './config';
9
+ export { getConfig, getConfigValue, resetConfig, setConfig } from './config';
10
+ export type { DateInput, DateStyle, FormatCurrencyOptions, TimeStyle } from './formatters';
11
+ export { formatCompactNumber, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, formatPhone, formatRelativeTime, formatTime, getInitials, normalizePhone } from './formatters';
12
+ export type { InitConfig } from './initSDK';
13
+ export { initWebority } from './initSDK';
14
+ export type { AuthActions } from './initUserAuth';
15
+ export { initUserAuth } from './initUserAuth';
16
+ export type { LoggerType, RemoteLogger } from './logger';
17
+ export { Logger, setRemoteLogger } from './logger';
18
+ export type { NetworkConnectionType, NetworkStatus, NetworkStatusListener } from './network';
19
+ export { addNetworkStatusListener, getNetworkStatus, useNetworkStatus } from './network';
20
+ export type { PermissionKind, PermissionStatus } from './permissions';
21
+ export { Permissions } from './permissions';
22
+ export type { AsyncStorageLike, StorageApi } from './storage';
23
+ export { Storage, setStorageImplementation } from './storage';
24
+ export type { CompressImageOptions } from './utils';
25
+ export { compressImage } from './utils';
26
+ export type { PasswordRules } from './validators';
27
+ export { isAadhaar, isAlphanumeric, isBetween, isEmail, isGstin, isHexColor, isIfsc, isIndianMobile, isIndianPincode, isInteger, isNonEmpty, isNumeric, isPan, isPhone, isStrongPassword, isUrl, maxLength, minLength } from './validators';
28
+ export type { DeviceInfoLike, ParsedVersion, Platform, UpdateInfo, UpdateType, VersionCheckResult, VersionCheckType, VersionComparison, VersionData } from './versionCheck';
29
+ export { setDeviceInfoImplementation, useVersionCheck, VersionCheck } from './versionCheck';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Simple initialization API for Webority packages
3
+ * One function to configure everything needed
4
+ */
5
+ import { type Environment, type LogLevel } from './config';
6
+ export interface InitConfig {
7
+ /** Your API base URL (required) */
8
+ baseUrl: string;
9
+ /** Enable/disable logging. Defaults to `true`. */
10
+ loggingEnabled?: boolean;
11
+ /** Log level. Defaults to `'info'`. */
12
+ logLevel?: LogLevel;
13
+ /** Environment. Defaults to `'Development'`. */
14
+ environment?: Environment;
15
+ /**
16
+ * ISO 3166-1 alpha-2 country code (lowercase) used for App Store / Play Store
17
+ * version checks. Defaults to `'in'`.
18
+ */
19
+ country?: string;
20
+ }
21
+ /**
22
+ * Initialize Webority packages with your project configuration.
23
+ *
24
+ * @example
25
+ * // Basic setup
26
+ * initWebority({
27
+ * baseUrl: 'https://api.myapp.com'
28
+ * });
29
+ *
30
+ * @example
31
+ * // Full configuration
32
+ * initWebority({
33
+ * baseUrl: 'https://api.myapp.com',
34
+ * loggingEnabled: __DEV__,
35
+ * logLevel: 'warn',
36
+ * environment: __DEV__ ? 'Development' : 'Production'
37
+ * });
38
+ */
39
+ export declare const initWebority: (config: InitConfig) => void;
40
+ //# sourceMappingURL=initSDK.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Simple initialization API for Webority User package
3
+ * Easy setup for Redux integration
4
+ */
5
+ /**
6
+ * Auth action creators required by the user package.
7
+ */
8
+ export interface AuthActions {
9
+ logout: () => unknown;
10
+ refreshToken: () => unknown;
11
+ }
12
+ /**
13
+ * Initialize user package with Redux store and auth actions.
14
+ *
15
+ * @example
16
+ * import store from './store';
17
+ * import { logout, refreshToken } from './actions/authActions';
18
+ *
19
+ * initUserAuth(store, { logout, refreshToken });
20
+ */
21
+ export declare const initUserAuth: <S>(store: S, authActions: AuthActions) => void;
22
+ //# sourceMappingURL=initUserAuth.d.ts.map
@@ -0,0 +1,42 @@
1
+ import { type LogLevel } from '../config';
2
+ type LogFn = (message: string, ...optionalParams: unknown[]) => void;
3
+ /**
4
+ * Optional remote sink. Apps wire this via `setRemoteLogger()` to forward errors
5
+ * and breadcrumbs to Crashlytics, Sentry, Bugsnag, etc. — without making the
6
+ * library depend on any of them.
7
+ *
8
+ * Every method is optional; the library calls only what the adapter implements.
9
+ */
10
+ export interface RemoteLogger {
11
+ /** Append a breadcrumb (small, non-error event) for crash context. */
12
+ breadcrumb?: (message: string, data?: Record<string, unknown>) => void;
13
+ /** Record a non-fatal error with optional context. */
14
+ recordError?: (error: unknown, context?: Record<string, unknown>) => void;
15
+ /** Bind a logical user to subsequent events. */
16
+ setUser?: (id: string | null, attrs?: Record<string, unknown>) => void;
17
+ /** Attach a custom attribute / tag (e.g. `release`, `env`). */
18
+ setAttribute?: (key: string, value: string | number | boolean | null) => void;
19
+ /** Forward a leveled console message. */
20
+ log?: (level: LogLevel, message: string, optionalParams: unknown[]) => void;
21
+ }
22
+ /**
23
+ * Inject a remote logger adapter (e.g. Firebase Crashlytics, Sentry).
24
+ * Pass `null` to detach. Safe to call before or after `initWebority`.
25
+ */
26
+ export declare const setRemoteLogger: (impl: RemoteLogger | null) => void;
27
+ export interface LoggerType {
28
+ info: LogFn;
29
+ warn: LogFn;
30
+ error: LogFn;
31
+ /** Append a breadcrumb to the remote sink (and log at info level). */
32
+ breadcrumb: (message: string, data?: Record<string, unknown>) => void;
33
+ /** Record a non-fatal error with optional context. */
34
+ recordError: (error: unknown, context?: Record<string, unknown>) => void;
35
+ /** Bind a user identity for subsequent crash reports. */
36
+ setUser: (id: string | null, attrs?: Record<string, unknown>) => void;
37
+ /** Attach a custom attribute (release, build, env, role, etc.). */
38
+ setAttribute: (key: string, value: string | number | boolean | null) => void;
39
+ }
40
+ export declare const Logger: LoggerType;
41
+ export {};
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export type { NetworkConnectionType, NetworkStatus, NetworkStatusListener } from './networkStatus';
2
+ export { addNetworkStatusListener, getNetworkStatus, useNetworkStatus } from './networkStatus';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,27 @@
1
+ export type NetworkConnectionType = 'unknown' | 'none' | 'wifi' | 'cellular' | 'bluetooth' | 'ethernet' | 'wimax' | 'vpn' | 'other';
2
+ export interface NetworkStatus {
3
+ /** True when the device has any network connection. */
4
+ isConnected: boolean;
5
+ /**
6
+ * True when the connection can reach the public internet
7
+ * (NetInfo's reachability probe). `null` when undetermined.
8
+ */
9
+ isInternetReachable: boolean | null;
10
+ type: NetworkConnectionType;
11
+ }
12
+ export type NetworkStatusListener = (status: NetworkStatus) => void;
13
+ /**
14
+ * Imperative one-shot fetch of current network status. Resolves to the default
15
+ * online status when NetInfo is unavailable so callers never crash.
16
+ */
17
+ export declare const getNetworkStatus: () => Promise<NetworkStatus>;
18
+ /**
19
+ * Subscribe to network status changes. Returns an unsubscribe function.
20
+ */
21
+ export declare const addNetworkStatusListener: (listener: NetworkStatusListener) => (() => void);
22
+ /**
23
+ * React hook that returns the current network status and re-renders on change.
24
+ * Reports an optimistic online default when NetInfo is not installed.
25
+ */
26
+ export declare const useNetworkStatus: () => NetworkStatus;
27
+ //# sourceMappingURL=networkStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,20 @@
1
+ export type PermissionKind = 'camera' | 'microphone' | 'photos' | 'photosAdd' | 'mediaLibrary' | 'location' | 'locationAlways' | 'contacts' | 'calendar' | 'reminders' | 'notifications' | 'bluetooth' | 'storage';
2
+ export type PermissionStatus = 'unavailable' | 'denied' | 'limited' | 'granted' | 'blocked';
3
+ /**
4
+ * Cross-platform permissions wrapper. Maps an abstract `PermissionKind`
5
+ * (camera, photos, location, notifications, …) to the right
6
+ * iOS / Android permission string under the hood.
7
+ *
8
+ * Requires `react-native-permissions` as an optional peer dependency;
9
+ * when missing, every check/request resolves to `'unavailable'`.
10
+ */
11
+ export declare const Permissions: {
12
+ check: (kind: PermissionKind) => Promise<PermissionStatus>;
13
+ request: (kind: PermissionKind) => Promise<PermissionStatus>;
14
+ /** Convenience: returns true when the permission is `granted` or `limited`. */
15
+ isAuthorized: (kind: PermissionKind) => Promise<boolean>;
16
+ /** Convenience: check, and request only if not yet granted. */
17
+ ensure: (kind: PermissionKind) => Promise<PermissionStatus>;
18
+ openSettings: () => Promise<boolean>;
19
+ };
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Minimal AsyncStorage shape we depend on.
3
+ * Lets us avoid a hard import on `@react-native-async-storage/async-storage`.
4
+ */
5
+ interface AsyncStorageLike {
6
+ getItem: (key: string) => Promise<string | null>;
7
+ setItem: (key: string, value: string) => Promise<void>;
8
+ removeItem: (key: string) => Promise<void>;
9
+ multiGet?: (keys: readonly string[]) => Promise<readonly [string, string | null][]>;
10
+ multiSet?: (kvs: readonly [string, string][]) => Promise<void>;
11
+ multiRemove?: (keys: readonly string[]) => Promise<void>;
12
+ clear?: () => Promise<void>;
13
+ getAllKeys?: () => Promise<readonly string[]>;
14
+ }
15
+ /**
16
+ * Inject a custom storage backend (e.g. MMKV adapter) at runtime.
17
+ * Pass `null` to reset to the default AsyncStorage backend.
18
+ */
19
+ export declare const setStorageImplementation: (impl: AsyncStorageLike | null) => void;
20
+ export interface StorageApi {
21
+ getItem: (key: string) => Promise<string | null>;
22
+ setItem: (key: string, value: string) => Promise<boolean>;
23
+ removeItem: (key: string) => Promise<boolean>;
24
+ getJson: <T>(key: string) => Promise<T | null>;
25
+ setJson: <T>(key: string, value: T) => Promise<boolean>;
26
+ multiGet: (keys: readonly string[]) => Promise<Record<string, string | null>>;
27
+ multiSet: (entries: Record<string, string>) => Promise<boolean>;
28
+ multiRemove: (keys: readonly string[]) => Promise<boolean>;
29
+ clear: () => Promise<boolean>;
30
+ getAllKeys: () => Promise<string[]>;
31
+ }
32
+ /**
33
+ * Typed AsyncStorage wrapper with safe JSON helpers.
34
+ * All operations swallow errors (logging them) and return a falsy result
35
+ * so that storage problems never crash the app.
36
+ *
37
+ * Backed by `@react-native-async-storage/async-storage` by default;
38
+ * override with `setStorageImplementation()` for MMKV or custom adapters.
39
+ */
40
+ export declare const Storage: StorageApi;
41
+ export type { AsyncStorageLike };
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,31 @@
1
+ export interface CompressImageOptions {
2
+ /** Max image width / height in pixels (preserves aspect ratio). Defaults to 1500. */
3
+ maxSize?: number;
4
+ /**
5
+ * JPEG/WebP quality, 0–1. Overrides the size-based quality ladder when set.
6
+ * When omitted, quality is derived from `fileSize` (see `qualityForFileSize`).
7
+ */
8
+ quality?: number;
9
+ /** Output format. Defaults to `'jpg'`. */
10
+ output?: 'jpg' | 'png' | 'webp';
11
+ /**
12
+ * Size of the source file in bytes, if known. Callers usually already have
13
+ * this from the picker response (e.g. `fileSize` on the selected asset) —
14
+ * pass it through rather than re-deriving it. Drives the adaptive quality
15
+ * ladder; when omitted, quality falls back to the middle rung.
16
+ */
17
+ fileSize?: number;
18
+ }
19
+ /**
20
+ * Bigger source files get compressed harder — a fixed quality either over-compresses
21
+ * small photos or leaves large ones too heavy to upload quickly. Unknown size falls
22
+ * back to the middle rung rather than assuming either extreme.
23
+ */
24
+ export declare const qualityForFileSize: (fileSize?: number) => number;
25
+ /**
26
+ * Compress an image referenced by a URI. Returns a new URI on success, or the
27
+ * original URI on failure / when the optional `react-native-compressor`
28
+ * dependency is missing — so callers can rely on always getting a usable URI.
29
+ */
30
+ export declare const compressImage: (uri: string, options?: CompressImageOptions) => Promise<string>;
31
+ //# sourceMappingURL=imageCompression.d.ts.map
@@ -0,0 +1,3 @@
1
+ export type { CompressImageOptions } from './imageCompression';
2
+ export { compressImage } from './imageCompression';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Generic validators returning `boolean`. All accept `null`/`undefined` safely.
3
+ *
4
+ * Tradeoff: regexes are pragmatic, not RFC-strict. They reject the things real users
5
+ * typo and accept the long tail of legitimate inputs. For RFC-grade validation use
6
+ * a dedicated library at the boundary.
7
+ */
8
+ export declare const isNonEmpty: (value: unknown) => boolean;
9
+ export declare const isEmail: (value: unknown) => boolean;
10
+ /**
11
+ * Validate an Indian mobile number. Accepts:
12
+ * - 10-digit number starting with 6-9
13
+ * - Optional `+91` or `91` country code prefix
14
+ */
15
+ export declare const isIndianMobile: (value: unknown) => boolean;
16
+ /**
17
+ * Generic phone validator: 7–15 digits, optional `+` prefix.
18
+ * Use `isIndianMobile` when you specifically need an Indian mobile number.
19
+ */
20
+ export declare const isPhone: (value: unknown) => boolean;
21
+ export declare const isUrl: (value: unknown) => boolean;
22
+ export declare const isNumeric: (value: unknown) => boolean;
23
+ export declare const isInteger: (value: unknown) => boolean;
24
+ export declare const isAlphanumeric: (value: unknown) => boolean;
25
+ export interface PasswordRules {
26
+ minLength?: number;
27
+ requireUppercase?: boolean;
28
+ requireLowercase?: boolean;
29
+ requireNumber?: boolean;
30
+ requireSymbol?: boolean;
31
+ }
32
+ /**
33
+ * Common password complexity check. Defaults to 8+ chars,
34
+ * one uppercase, one lowercase, one digit.
35
+ */
36
+ export declare const isStrongPassword: (value: unknown, rules?: PasswordRules) => boolean;
37
+ export declare const isIndianPincode: (value: unknown) => boolean;
38
+ export declare const isPan: (value: unknown) => boolean;
39
+ export declare const isGstin: (value: unknown) => boolean;
40
+ export declare const isAadhaar: (value: unknown) => boolean;
41
+ export declare const isIfsc: (value: unknown) => boolean;
42
+ export declare const isHexColor: (value: unknown) => boolean;
43
+ export declare const isBetween: (value: unknown, min: number, max: number, inclusive?: boolean) => boolean;
44
+ export declare const minLength: (value: unknown, length: number) => boolean;
45
+ export declare const maxLength: (value: unknown, length: number) => boolean;
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,80 @@
1
+ import { type Environment } from '../config';
2
+ /**
3
+ * Minimal device-info shape we depend on.
4
+ *
5
+ * This is a LAST RESORT, not the primary path. `Platform.OS` already gives the
6
+ * platform, and every Webority app carries its own store id and version in
7
+ * `appsettings.Compiled.json` — so `setConfig({ appId, appVersion })` covers
8
+ * both remaining values without a native module. The injector below exists for
9
+ * apps that would rather hand us a `react-native-device-info` instance than
10
+ * wire two config keys.
11
+ */
12
+ interface DeviceInfoLike {
13
+ getBundleId: () => string;
14
+ getVersion: () => string;
15
+ }
16
+ /**
17
+ * Supply the app identity from a native module instead of config.
18
+ * Prefer `setConfig({ appId, appVersion })` — it needs no native dependency.
19
+ * Pass `null` to clear.
20
+ */
21
+ export declare const setDeviceInfoImplementation: (impl: DeviceInfoLike | null) => void;
22
+ export type Platform = 'ios' | 'android' | string;
23
+ export type UpdateType = 'major' | 'minor' | 'patch' | 'prerelease' | null;
24
+ export interface ParsedVersion {
25
+ major: number;
26
+ minor: number;
27
+ patch: number;
28
+ prerelease: string;
29
+ }
30
+ export interface VersionData {
31
+ version: string | null;
32
+ released?: string | null;
33
+ releasedAt?: string;
34
+ notes: string;
35
+ url: string | null;
36
+ country?: string;
37
+ lastChecked: string;
38
+ }
39
+ export interface VersionComparison {
40
+ needsUpdate: boolean;
41
+ updateType: UpdateType;
42
+ notice?: string;
43
+ }
44
+ export interface VersionCheckResult {
45
+ isNewVersionAvailable: boolean;
46
+ updateType: UpdateType;
47
+ url: string | null;
48
+ }
49
+ export interface UpdateInfo {
50
+ isUpdateRequired: boolean;
51
+ updateUrl: string | null;
52
+ }
53
+ export interface VersionCheckType {
54
+ /**
55
+ * Check if a new version is available.
56
+ * Includes retry logic and proper error handling.
57
+ */
58
+ isNewVersionAvailable: () => Promise<VersionCheckResult>;
59
+ /**
60
+ * Opens the appropriate store URL to update the app.
61
+ * Uses the provided URL or falls back to direct store URLs.
62
+ */
63
+ openUpdateUrl: (url?: string | null) => Promise<boolean>;
64
+ /**
65
+ * Get the fallback store URL.
66
+ * Useful when URL from version check fails.
67
+ */
68
+ getFallbackStoreUrl: () => string;
69
+ }
70
+ export declare const VersionCheck: VersionCheckType;
71
+ /**
72
+ * Custom hook to check for required app updates.
73
+ *
74
+ * @param isAppReady - Whether the app is ready to perform the check
75
+ * @param environment - The app environment (defaults to the one in config)
76
+ */
77
+ export declare const useVersionCheck: (isAppReady: boolean, environment?: Environment) => UpdateInfo;
78
+ export default VersionCheck;
79
+ export type { DeviceInfoLike };
80
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { type AxiosInstance } from 'axios';
2
+ /**
3
+ * Public Axios Client
4
+ * - Base URL: Set your public API base URL.
5
+ * - No Authorization header is attached.
6
+ * - Includes timeout configuration and error handling.
7
+ * - Handles specific HTTP status codes.
8
+ */
9
+ declare const publicClient: AxiosInstance;
10
+ export default publicClient;
11
+ //# sourceMappingURL=publicClient.d.ts.map
@@ -0,0 +1,49 @@
1
+ import { type AxiosInstance } from 'axios';
2
+ import type { AuthActions } from '../initUserAuth.js';
3
+ /**
4
+ * Thrown by the request interceptor when the device is offline, before the
5
+ * request ever reaches the adapter (and therefore the network). Distinct from
6
+ * an AxiosError so callers can show an offline message instead of a generic
7
+ * request failure.
8
+ */
9
+ export declare class RequestOfflineError extends Error {
10
+ constructor(message?: string);
11
+ }
12
+ /**
13
+ * Sub-codes a 401 response body carries when the session itself is dead
14
+ * (terminated by an admin, or expired server-side) rather than merely
15
+ * out-of-date. These never warrant a refresh attempt — only logout.
16
+ */
17
+ export declare const SESSION_TERMINATION_CODES: {
18
+ readonly TERMINATED: "SESSION_TERMINATED";
19
+ readonly EXPIRED: "SESSION_EXPIRED";
20
+ };
21
+ export type SessionTerminationCode = (typeof SESSION_TERMINATION_CODES)[keyof typeof SESSION_TERMINATION_CODES];
22
+ /**
23
+ * The header is the AUTHORITATIVE signal, verified against the backend:
24
+ * `WeborityJwtMiddleware.ReturnUnauthorized` answers an invalidated session with
25
+ * `401` + `X-Security-Stamp-Invalid: true` and a body of
26
+ * `{ error: 'Unauthorized', message: '...' }` — no code field at all, and
27
+ * `error` is a string rather than an object. An earlier version of this checked
28
+ * only body fields and would therefore never have fired against a real server.
29
+ *
30
+ * The body codes below are kept as a secondary path for any head that does send
31
+ * an explicit sub-code; they match on exact strings, so looking is free.
32
+ */
33
+ export declare const SESSION_INVALID_HEADER = "x-security-stamp-invalid";
34
+ /**
35
+ * Minimal Redux-store shape required by the user client to dispatch
36
+ * refresh-token / logout actions.
37
+ */
38
+ export interface RefreshableStore {
39
+ dispatch: (action: unknown) => Promise<{
40
+ error?: {
41
+ message?: string;
42
+ };
43
+ }>;
44
+ }
45
+ declare const userClient: AxiosInstance;
46
+ export declare const injectStore: <S>(_store: S) => void;
47
+ export declare const injectAuthActions: (actions: AuthActions) => void;
48
+ export default userClient;
49
+ //# sourceMappingURL=userClient.d.ts.map