@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.
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/android/build.gradle +65 -0
- package/android/src/newarch/java/com/webority/mobilecore/smsretriever/AppSignatureHelper.kt +57 -0
- package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverModule.kt +20 -0
- package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverModuleImpl.kt +146 -0
- package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverPackage.kt +33 -0
- package/lib/commonjs/api/baseUrl.js +34 -0
- package/lib/commonjs/api/curl.js +109 -0
- package/lib/commonjs/api/publicClient.js +73 -0
- package/lib/commonjs/api/retry.js +75 -0
- package/lib/commonjs/api/tokenRefresh.js +205 -0
- package/lib/commonjs/api/userClient.js +255 -0
- package/lib/commonjs/auth/authStore.js +232 -0
- package/lib/commonjs/auth/index.js +44 -0
- package/lib/commonjs/auth/jwt.js +112 -0
- package/lib/commonjs/config/index.js +66 -0
- package/lib/commonjs/deepLink/index.js +286 -0
- package/lib/commonjs/download/adapters/expoFs.js +69 -0
- package/lib/commonjs/download/adapters/shared.js +13 -0
- package/lib/commonjs/download/index.js +250 -0
- package/lib/commonjs/formatters/currency.js +69 -0
- package/lib/commonjs/formatters/date.js +168 -0
- package/lib/commonjs/formatters/dateMath.js +310 -0
- package/lib/commonjs/formatters/index.js +246 -0
- package/lib/commonjs/formatters/initials.js +32 -0
- package/lib/commonjs/formatters/number.js +88 -0
- package/lib/commonjs/formatters/phone.js +369 -0
- package/lib/commonjs/formatters/windowsToIanaTable.js +164 -0
- package/lib/commonjs/geolocation/adapters/expoLocation.js +126 -0
- package/lib/commonjs/geolocation/index.js +355 -0
- package/lib/commonjs/index.js +630 -0
- package/lib/commonjs/initSDK.js +66 -0
- package/lib/commonjs/initUserAuth.js +37 -0
- package/lib/commonjs/logger/index.js +291 -0
- package/lib/commonjs/network/index.js +31 -0
- package/lib/commonjs/network/networkStatus.js +133 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/permissions/calendar.js +14 -0
- package/lib/commonjs/permissions/camera.js +14 -0
- package/lib/commonjs/permissions/contacts.js +10 -0
- package/lib/commonjs/permissions/index.js +133 -0
- package/lib/commonjs/permissions/location.js +14 -0
- package/lib/commonjs/permissions/mediaLibrary.js +10 -0
- package/lib/commonjs/permissions/notifications.js +10 -0
- package/lib/commonjs/permissions/photos.js +14 -0
- package/lib/commonjs/phone/countries.js +265 -0
- package/lib/commonjs/share/index.js +70 -0
- package/lib/commonjs/smsRetriever/index.js +91 -0
- package/lib/commonjs/specs/NativeSmsRetriever.js +15 -0
- package/lib/commonjs/sqlite/adapters/expo.js +53 -0
- package/lib/commonjs/sqlite/index.js +604 -0
- package/lib/commonjs/storage/index.js +214 -0
- package/lib/commonjs/types/globals.d.js +6 -0
- package/lib/commonjs/utils/imageCompression.js +389 -0
- package/lib/commonjs/utils/index.js +19 -0
- package/lib/commonjs/validators/index.js +227 -0
- package/lib/commonjs/versionCheck/index.js +419 -0
- package/lib/module/api/baseUrl.js +30 -0
- package/lib/module/api/curl.js +104 -0
- package/lib/module/api/publicClient.js +69 -0
- package/lib/module/api/retry.js +69 -0
- package/lib/module/api/tokenRefresh.js +192 -0
- package/lib/module/api/userClient.js +233 -0
- package/lib/module/auth/authStore.js +224 -0
- package/lib/module/auth/index.js +5 -0
- package/lib/module/auth/jwt.js +106 -0
- package/lib/module/config/index.js +58 -0
- package/lib/module/deepLink/index.js +280 -0
- package/lib/module/download/adapters/expoFs.js +64 -0
- package/lib/module/download/adapters/shared.js +8 -0
- package/lib/module/download/index.js +242 -0
- package/lib/module/formatters/currency.js +64 -0
- package/lib/module/formatters/date.js +160 -0
- package/lib/module/formatters/dateMath.js +294 -0
- package/lib/module/formatters/index.js +9 -0
- package/lib/module/formatters/initials.js +27 -0
- package/lib/module/formatters/number.js +81 -0
- package/lib/module/formatters/phone.js +302 -0
- package/lib/module/formatters/windowsToIanaTable.js +160 -0
- package/lib/module/geolocation/adapters/expoLocation.js +121 -0
- package/lib/module/geolocation/index.js +347 -0
- package/lib/module/index.js +54 -0
- package/lib/module/initSDK.js +61 -0
- package/lib/module/initUserAuth.js +33 -0
- package/lib/module/logger/index.js +285 -0
- package/lib/module/network/index.js +4 -0
- package/lib/module/network/networkStatus.js +124 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permissions/calendar.js +15 -0
- package/lib/module/permissions/camera.js +15 -0
- package/lib/module/permissions/contacts.js +11 -0
- package/lib/module/permissions/index.js +128 -0
- package/lib/module/permissions/location.js +15 -0
- package/lib/module/permissions/mediaLibrary.js +11 -0
- package/lib/module/permissions/notifications.js +11 -0
- package/lib/module/permissions/photos.js +15 -0
- package/lib/module/phone/countries.js +261 -0
- package/lib/module/share/index.js +64 -0
- package/lib/module/smsRetriever/index.js +86 -0
- package/lib/module/specs/NativeSmsRetriever.js +13 -0
- package/lib/module/sqlite/adapters/expo.js +48 -0
- package/lib/module/sqlite/index.js +594 -0
- package/lib/module/storage/index.js +208 -0
- package/lib/module/types/globals.d.js +10 -0
- package/lib/module/utils/imageCompression.js +383 -0
- package/lib/module/utils/index.js +4 -0
- package/lib/module/validators/index.js +205 -0
- package/lib/module/versionCheck/index.js +413 -0
- package/lib/typescript/commonjs/api/baseUrl.d.ts +20 -0
- package/lib/typescript/commonjs/api/curl.d.ts +18 -0
- package/lib/typescript/commonjs/api/publicClient.d.ts +11 -0
- package/lib/typescript/commonjs/api/retry.d.ts +27 -0
- package/lib/typescript/commonjs/api/tokenRefresh.d.ts +43 -0
- package/lib/typescript/commonjs/api/userClient.d.ts +37 -0
- package/lib/typescript/commonjs/auth/authStore.d.ts +79 -0
- package/lib/typescript/commonjs/auth/index.d.ts +5 -0
- package/lib/typescript/commonjs/auth/jwt.d.ts +31 -0
- package/lib/typescript/commonjs/config/index.d.ts +55 -0
- package/lib/typescript/commonjs/deepLink/index.d.ts +54 -0
- package/lib/typescript/commonjs/download/adapters/expoFs.d.ts +38 -0
- package/lib/typescript/commonjs/download/adapters/shared.d.ts +3 -0
- package/lib/typescript/commonjs/download/index.d.ts +86 -0
- package/lib/typescript/commonjs/formatters/currency.d.ts +24 -0
- package/lib/typescript/commonjs/formatters/date.d.ts +22 -0
- package/lib/typescript/commonjs/formatters/dateMath.d.ts +88 -0
- package/lib/typescript/commonjs/formatters/index.d.ts +10 -0
- package/lib/typescript/commonjs/formatters/initials.d.ts +11 -0
- package/lib/typescript/commonjs/formatters/number.d.ts +15 -0
- package/lib/typescript/commonjs/formatters/phone.d.ts +133 -0
- package/lib/typescript/commonjs/formatters/windowsToIanaTable.d.ts +18 -0
- package/lib/typescript/commonjs/geolocation/adapters/expoLocation.d.ts +42 -0
- package/lib/typescript/commonjs/geolocation/index.d.ts +90 -0
- package/lib/typescript/commonjs/index.d.ts +54 -0
- package/lib/typescript/commonjs/initSDK.d.ts +72 -0
- package/lib/typescript/commonjs/initUserAuth.d.ts +41 -0
- package/lib/typescript/commonjs/logger/index.d.ts +81 -0
- package/lib/typescript/commonjs/network/index.d.ts +3 -0
- package/lib/typescript/commonjs/network/networkStatus.d.ts +43 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/permissions/calendar.d.ts +2 -0
- package/lib/typescript/commonjs/permissions/camera.d.ts +2 -0
- package/lib/typescript/commonjs/permissions/contacts.d.ts +2 -0
- package/lib/typescript/commonjs/permissions/index.d.ts +48 -0
- package/lib/typescript/commonjs/permissions/location.d.ts +2 -0
- package/lib/typescript/commonjs/permissions/mediaLibrary.d.ts +2 -0
- package/lib/typescript/commonjs/permissions/notifications.d.ts +2 -0
- package/lib/typescript/commonjs/permissions/photos.d.ts +2 -0
- package/lib/typescript/commonjs/phone/countries.d.ts +13 -0
- package/lib/typescript/commonjs/share/index.d.ts +29 -0
- package/lib/typescript/commonjs/smsRetriever/index.d.ts +30 -0
- package/lib/typescript/commonjs/specs/NativeSmsRetriever.d.ts +15 -0
- package/lib/typescript/commonjs/sqlite/adapters/expo.d.ts +30 -0
- package/lib/typescript/commonjs/sqlite/index.d.ts +113 -0
- package/lib/typescript/commonjs/storage/index.d.ts +64 -0
- package/lib/typescript/commonjs/utils/imageCompression.d.ts +152 -0
- package/lib/typescript/commonjs/utils/index.d.ts +3 -0
- package/lib/typescript/commonjs/validators/index.d.ts +51 -0
- package/lib/typescript/commonjs/versionCheck/index.d.ts +80 -0
- package/lib/typescript/module/api/baseUrl.d.ts +20 -0
- package/lib/typescript/module/api/curl.d.ts +18 -0
- package/lib/typescript/module/api/publicClient.d.ts +11 -0
- package/lib/typescript/module/api/retry.d.ts +27 -0
- package/lib/typescript/module/api/tokenRefresh.d.ts +43 -0
- package/lib/typescript/module/api/userClient.d.ts +37 -0
- package/lib/typescript/module/auth/authStore.d.ts +79 -0
- package/lib/typescript/module/auth/index.d.ts +5 -0
- package/lib/typescript/module/auth/jwt.d.ts +31 -0
- package/lib/typescript/module/config/index.d.ts +55 -0
- package/lib/typescript/module/deepLink/index.d.ts +54 -0
- package/lib/typescript/module/download/adapters/expoFs.d.ts +38 -0
- package/lib/typescript/module/download/adapters/shared.d.ts +3 -0
- package/lib/typescript/module/download/index.d.ts +86 -0
- package/lib/typescript/module/formatters/currency.d.ts +24 -0
- package/lib/typescript/module/formatters/date.d.ts +22 -0
- package/lib/typescript/module/formatters/dateMath.d.ts +88 -0
- package/lib/typescript/module/formatters/index.d.ts +10 -0
- package/lib/typescript/module/formatters/initials.d.ts +11 -0
- package/lib/typescript/module/formatters/number.d.ts +15 -0
- package/lib/typescript/module/formatters/phone.d.ts +133 -0
- package/lib/typescript/module/formatters/windowsToIanaTable.d.ts +18 -0
- package/lib/typescript/module/geolocation/adapters/expoLocation.d.ts +42 -0
- package/lib/typescript/module/geolocation/index.d.ts +90 -0
- package/lib/typescript/module/index.d.ts +54 -0
- package/lib/typescript/module/initSDK.d.ts +72 -0
- package/lib/typescript/module/initUserAuth.d.ts +41 -0
- package/lib/typescript/module/logger/index.d.ts +81 -0
- package/lib/typescript/module/network/index.d.ts +3 -0
- package/lib/typescript/module/network/networkStatus.d.ts +43 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/permissions/calendar.d.ts +2 -0
- package/lib/typescript/module/permissions/camera.d.ts +2 -0
- package/lib/typescript/module/permissions/contacts.d.ts +2 -0
- package/lib/typescript/module/permissions/index.d.ts +48 -0
- package/lib/typescript/module/permissions/location.d.ts +2 -0
- package/lib/typescript/module/permissions/mediaLibrary.d.ts +2 -0
- package/lib/typescript/module/permissions/notifications.d.ts +2 -0
- package/lib/typescript/module/permissions/photos.d.ts +2 -0
- package/lib/typescript/module/phone/countries.d.ts +13 -0
- package/lib/typescript/module/share/index.d.ts +29 -0
- package/lib/typescript/module/smsRetriever/index.d.ts +30 -0
- package/lib/typescript/module/specs/NativeSmsRetriever.d.ts +15 -0
- package/lib/typescript/module/sqlite/adapters/expo.d.ts +30 -0
- package/lib/typescript/module/sqlite/index.d.ts +113 -0
- package/lib/typescript/module/storage/index.d.ts +64 -0
- package/lib/typescript/module/utils/imageCompression.d.ts +152 -0
- package/lib/typescript/module/utils/index.d.ts +3 -0
- package/lib/typescript/module/validators/index.d.ts +51 -0
- package/lib/typescript/module/versionCheck/index.d.ts +80 -0
- package/package.json +298 -0
- package/src/specs/NativeSmsRetriever.ts +16 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* English display names for every country libphonenumber-js knows, keyed by
|
|
3
|
+
* ISO 3166-1 alpha-2. GENERATED by scripts/gen-phone-countries.mjs from Node's
|
|
4
|
+
* Intl.DisplayNames('en', { type: 'region' }) over getCountries() on 2026-09-14;
|
|
5
|
+
* '&' is written as 'and'. Re-run the script rather than editing by hand.
|
|
6
|
+
*
|
|
7
|
+
* Lives on its own import path (mobile-core/phone/countries) so an app that
|
|
8
|
+
* never opens a full country list does not carry these 245 strings in its
|
|
9
|
+
* bundle. Pair with getPhoneCountries() from the package root for the calling
|
|
10
|
+
* codes; a country picker that needs another language supplies its own names.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PHONE_COUNTRY_NAMES: Readonly<Record<string, string>>;
|
|
13
|
+
//# sourceMappingURL=countries.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opens a downloaded file through the system share sheet, where the person picks
|
|
3
|
+
* a viewer or saves it. A separate entry point because it names expo-sharing, an
|
|
4
|
+
* optional peer: Metro resolves every require reachable from an import, so keeping
|
|
5
|
+
* it off the main barrel and off `/download` lets an app skip the package when it
|
|
6
|
+
* never opens files.
|
|
7
|
+
*
|
|
8
|
+
* The share sheet rather than `Linking.openURL`: Android 7 and later refuse a
|
|
9
|
+
* `file://` link, and a `content://` link sent through Linking carries no read
|
|
10
|
+
* grant, so the OS-open route never reached a viewer there.
|
|
11
|
+
*/
|
|
12
|
+
export type ShareErrorCode = 'unavailable' | 'failed';
|
|
13
|
+
export declare class ShareError extends Error {
|
|
14
|
+
readonly code: ShareErrorCode;
|
|
15
|
+
constructor(code: ShareErrorCode, message: string);
|
|
16
|
+
}
|
|
17
|
+
export interface ShareFileOptions {
|
|
18
|
+
/** Picks the apps Android offers; mapped to a UTI for iOS where one is known. */
|
|
19
|
+
mimeType?: string;
|
|
20
|
+
/** The share sheet's title on Android. */
|
|
21
|
+
dialogTitle?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Hands a local file (the `path` `downloadFile` returns) to the share sheet.
|
|
25
|
+
* A bare path is given a `file://` scheme. Rejects with `ShareError`: `unavailable`
|
|
26
|
+
* when the device has no share sheet, `failed` when the sheet could not open the file.
|
|
27
|
+
*/
|
|
28
|
+
export declare const shareFile: (path: string, options?: ShareFileOptions) => Promise<void>;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface SmsRetrieverError {
|
|
2
|
+
type: 'TIMEOUT' | 'SERVICE_UNAVAILABLE' | 'UNKNOWN_ERROR';
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SmsListenerSubscription {
|
|
6
|
+
remove: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface SmsRetrieverBackend {
|
|
9
|
+
getAppHash: () => Promise<string>;
|
|
10
|
+
startListening: (onMessage: (message: string) => void, onError?: (error: SmsRetrieverError) => void) => SmsListenerSubscription;
|
|
11
|
+
}
|
|
12
|
+
/** Test-only injection point. Pass `null` to reset to the native module. */
|
|
13
|
+
export declare const setSmsRetrieverImplementation: (impl: SmsRetrieverBackend | null) => void;
|
|
14
|
+
/**
|
|
15
|
+
* The Play Services SMS Retriever API — auto-reads an incoming OTP SMS with
|
|
16
|
+
* no SMS permission, matched by an 11-character app-signature hash
|
|
17
|
+
* (`getAppHash`) the backend appends to the message. Android only; every
|
|
18
|
+
* method is safe to call on iOS and resolves/reports unavailable rather than
|
|
19
|
+
* throwing, so a caller doesn't need a platform check at every call site.
|
|
20
|
+
*
|
|
21
|
+
* OTP extraction is left to the caller — `onMessage` receives the raw SMS
|
|
22
|
+
* text, since the expected OTP format (digit count, prefix) is a backend
|
|
23
|
+
* concern, not this module's.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SmsRetriever: {
|
|
26
|
+
isAvailable: () => boolean;
|
|
27
|
+
getAppHash: () => Promise<string>;
|
|
28
|
+
startListening: (onMessage: (message: string) => void, onError?: (error: SmsRetrieverError) => void) => SmsListenerSubscription;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Android-only — the Play Services SMS Retriever API has no iOS equivalent.
|
|
4
|
+
* The JS wrapper in `smsRetriever/index.ts` never touches this module on
|
|
5
|
+
* iOS, so `getEnforcing` only ever runs on Android, where autolinking has
|
|
6
|
+
* registered `SmsRetrieverPackage`.
|
|
7
|
+
*/
|
|
8
|
+
export interface Spec extends TurboModule {
|
|
9
|
+
startSMSListener(): void;
|
|
10
|
+
stopSMSListener(): void;
|
|
11
|
+
getAppHash(): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: Spec;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=NativeSmsRetriever.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SqliteDriver } from '../index';
|
|
2
|
+
/**
|
|
3
|
+
* expo-sqlite. Shape verified against 57.0.2 rather than assumed, and it is the
|
|
4
|
+
* one driver that cannot share an adapter with the others: expo splits reads
|
|
5
|
+
* from writes. `getAllAsync` yields rows but no change count, `runAsync` yields
|
|
6
|
+
* `{ changes, lastInsertRowId }` but no rows, and SqliteResultSet needs all
|
|
7
|
+
* three from one call. `prepareAsync` + `executeAsync` is the only call that
|
|
8
|
+
* returns both, so every statement goes through it rather than being routed by
|
|
9
|
+
* sniffing the SQL for a leading SELECT.
|
|
10
|
+
*
|
|
11
|
+
* The REQUIRE lives in the driver entry point beside this file, never here.
|
|
12
|
+
*/
|
|
13
|
+
export interface ExpoSqliteExecuteResult {
|
|
14
|
+
lastInsertRowId: number;
|
|
15
|
+
changes: number;
|
|
16
|
+
getAllAsync: () => Promise<Record<string, unknown>[]>;
|
|
17
|
+
}
|
|
18
|
+
export interface ExpoSqliteStatementLike {
|
|
19
|
+
executeAsync: (params: unknown[]) => Promise<ExpoSqliteExecuteResult>;
|
|
20
|
+
finalizeAsync: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export interface ExpoSqliteDatabaseLike {
|
|
23
|
+
prepareAsync: (source: string) => Promise<ExpoSqliteStatementLike>;
|
|
24
|
+
closeAsync: () => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export interface ExpoSqliteModuleLike {
|
|
27
|
+
openDatabaseAsync: (name: string, options?: Record<string, unknown>, directory?: string) => Promise<ExpoSqliteDatabaseLike>;
|
|
28
|
+
}
|
|
29
|
+
export declare const adaptExpoSqlite: (mod: ExpoSqliteModuleLike) => SqliteDriver;
|
|
30
|
+
//# sourceMappingURL=expo.d.ts.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* expo-sqlite is the fleet's only sanctioned SQLite driver (react-native.md:
|
|
3
|
+
* "we will always use expo-sqlite, what Expo gives, we don't look elsewhere
|
|
4
|
+
* ever") — this module resolves it automatically, with no app-side wiring.
|
|
5
|
+
* `setSqliteImplementation` still exists, narrowed to tests and the showcase:
|
|
6
|
+
* it injects a denying/failing backend to reach error paths a healthy device
|
|
7
|
+
* never takes, the same pattern every other injectable surface in this
|
|
8
|
+
* library follows. It is not a way to pick an alternate real driver.
|
|
9
|
+
*/
|
|
10
|
+
export interface SqliteResultSet {
|
|
11
|
+
rows: Record<string, unknown>[];
|
|
12
|
+
rowsAffected: number;
|
|
13
|
+
insertId?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SqliteDatabase {
|
|
16
|
+
execute: (sql: string, params?: readonly unknown[]) => Promise<SqliteResultSet>;
|
|
17
|
+
close: () => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface SqliteDriver {
|
|
20
|
+
open: (name: string, options?: {
|
|
21
|
+
location?: string;
|
|
22
|
+
}) => Promise<SqliteDatabase>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Test/showcase-only injection point — see the module header. Not a way to
|
|
26
|
+
* pick an alternate real driver; `@webority/mobile-core` always
|
|
27
|
+
* resolves expo-sqlite when nothing is injected. Pass `null` to clear it.
|
|
28
|
+
*/
|
|
29
|
+
export declare const setSqliteImplementation: (impl: SqliteDriver | null) => void;
|
|
30
|
+
export declare const isSqliteAvailable: () => boolean;
|
|
31
|
+
/** The ledger of applied migrations. Never emptied by `wipe`. */
|
|
32
|
+
export declare const MIGRATIONS_TABLE = "_webority_migrations";
|
|
33
|
+
/**
|
|
34
|
+
* SQLite cannot bind an identifier to `?`, so every table/column name reaching
|
|
35
|
+
* a statement is concatenated. This is the ONE place that is allowed to happen,
|
|
36
|
+
* and it throws rather than quoting a hostile name into something executable.
|
|
37
|
+
*/
|
|
38
|
+
export declare const assertSqlIdentifier: (value: unknown, kind?: string) => string;
|
|
39
|
+
/** Normalise a JS value into something every SQLite driver can bind. */
|
|
40
|
+
export declare const toSqliteValue: (value: unknown) => unknown;
|
|
41
|
+
/** SQLite has no boolean type, so a stored flag comes back as 0/1 or '0'/'1'. */
|
|
42
|
+
export declare const fromSqliteBoolean: (value: unknown) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Build an `IN (...)` clause with one placeholder per value. An empty list
|
|
45
|
+
* yields a clause that matches nothing, because `IN ()` is a syntax error.
|
|
46
|
+
*/
|
|
47
|
+
export declare const whereIn: (column: string, values: readonly unknown[]) => {
|
|
48
|
+
sql: string;
|
|
49
|
+
params: unknown[];
|
|
50
|
+
};
|
|
51
|
+
export interface RawWhere {
|
|
52
|
+
sql: string;
|
|
53
|
+
params?: readonly unknown[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Either a map of column to value (ANDed, `null` meaning IS NULL) or a raw
|
|
57
|
+
* fragment for anything the object form cannot express.
|
|
58
|
+
*/
|
|
59
|
+
export type Where = Record<string, unknown> | RawWhere;
|
|
60
|
+
export interface FindOptions {
|
|
61
|
+
orderBy?: string;
|
|
62
|
+
limit?: number;
|
|
63
|
+
offset?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface Migration {
|
|
66
|
+
version: number;
|
|
67
|
+
name?: string;
|
|
68
|
+
up: string | string[] | ((tx: Pick<Db, 'execute'>) => Promise<void>);
|
|
69
|
+
}
|
|
70
|
+
export interface MigrateOptions {
|
|
71
|
+
/**
|
|
72
|
+
* Skip the downgrade guard. Only set this when the app knows the older code
|
|
73
|
+
* can read the newer schema.
|
|
74
|
+
*/
|
|
75
|
+
allowDowngrade?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export declare const DEFAULT_PRAGMAS: Readonly<Record<string, string | number>>;
|
|
78
|
+
export interface OpenDatabaseOptions {
|
|
79
|
+
location?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Merged over DEFAULT_PRAGMAS and applied on open. Pass `false` to apply none.
|
|
82
|
+
*/
|
|
83
|
+
pragmas?: Record<string, string | number> | false;
|
|
84
|
+
}
|
|
85
|
+
export interface Db {
|
|
86
|
+
readonly name: string;
|
|
87
|
+
execute: (sql: string, params?: readonly unknown[]) => Promise<SqliteResultSet>;
|
|
88
|
+
select: <T = Record<string, unknown>>(sql: string, params?: readonly unknown[]) => Promise<T[]>;
|
|
89
|
+
selectOne: <T = Record<string, unknown>>(sql: string, params?: readonly unknown[]) => Promise<T | null>;
|
|
90
|
+
transaction: <T>(work: (tx: Pick<Db, 'execute' | 'select' | 'selectOne'>) => Promise<T>) => Promise<T>;
|
|
91
|
+
insert: (table: string, row: Record<string, unknown>) => Promise<number | undefined>;
|
|
92
|
+
insertMany: (table: string, rows: Record<string, unknown>[]) => Promise<number>;
|
|
93
|
+
update: (table: string, values: Record<string, unknown>, where: Where) => Promise<number>;
|
|
94
|
+
remove: (table: string, where: Where) => Promise<number>;
|
|
95
|
+
upsert: (table: string, row: Record<string, unknown>, conflictColumns: string[]) => Promise<void>;
|
|
96
|
+
findAll: <T = Record<string, unknown>>(table: string, where?: Where, options?: FindOptions) => Promise<T[]>;
|
|
97
|
+
findOne: <T = Record<string, unknown>>(table: string, where?: Where) => Promise<T | null>;
|
|
98
|
+
count: (table: string, where?: Where) => Promise<number>;
|
|
99
|
+
tableExists: (table: string) => Promise<boolean>;
|
|
100
|
+
createTable: (table: string, columns: Record<string, string>, options?: {
|
|
101
|
+
ifNotExists?: boolean;
|
|
102
|
+
}) => Promise<void>;
|
|
103
|
+
dropTable: (table: string, options?: {
|
|
104
|
+
ifExists?: boolean;
|
|
105
|
+
}) => Promise<void>;
|
|
106
|
+
wipe: () => Promise<void>;
|
|
107
|
+
reset: (migrations: Migration[]) => Promise<number>;
|
|
108
|
+
migrate: (migrations: Migration[], options?: MigrateOptions) => Promise<number>;
|
|
109
|
+
baseline: (version: number, migrations?: Migration[]) => Promise<void>;
|
|
110
|
+
close: () => Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
export declare const openDatabase: (name: string, options?: OpenDatabaseOptions) => Promise<Db>;
|
|
113
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* The batch API exists under TWO names, and both are live in this fleet.
|
|
11
|
+
*
|
|
12
|
+
* `@react-native-async-storage/async-storage` 3 renamed the v1 trio and
|
|
13
|
+
* changed their shapes: `getMany` returns a Record where `multiGet` returned
|
|
14
|
+
* pairs, and `setMany` takes a Record where `multiSet` took pairs. The v1
|
|
15
|
+
* names are still what `expo-sqlite/kv-store` and AsyncStorage 2 expose.
|
|
16
|
+
*
|
|
17
|
+
* Declaring only one set is not a compile error and not a runtime error — it
|
|
18
|
+
* silently falls through to the per-key loop below. The fleet pins
|
|
19
|
+
* AsyncStorage 3, so recognising only the v1 names put every consumer on N
|
|
20
|
+
* round-trips per batch with nothing to notice.
|
|
21
|
+
*/
|
|
22
|
+
getMany?: (keys: string[]) => Promise<Record<string, string | null>>;
|
|
23
|
+
setMany?: (entries: Record<string, string>) => Promise<void>;
|
|
24
|
+
removeMany?: (keys: string[]) => Promise<void>;
|
|
25
|
+
multiGet?: (keys: readonly string[]) => Promise<readonly [string, string | null][]>;
|
|
26
|
+
multiSet?: (kvs: readonly [string, string][]) => Promise<void>;
|
|
27
|
+
multiRemove?: (keys: readonly string[]) => Promise<void>;
|
|
28
|
+
clear?: () => Promise<void>;
|
|
29
|
+
getAllKeys?: () => Promise<readonly string[]>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Always true now that the backend ships with the library. Kept because callers
|
|
33
|
+
* whose use of storage is an OPTIMISATION branch on it, and removing it would
|
|
34
|
+
* be a breaking change for no gain.
|
|
35
|
+
*/
|
|
36
|
+
export declare const isStorageAvailable: () => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Replace the storage backend. Intended for TESTS and for the showcase; an app
|
|
39
|
+
* gets expo-sqlite/kv-store without wiring anything. Pass `null` to restore it.
|
|
40
|
+
*/
|
|
41
|
+
export declare const setStorageImplementation: (impl: AsyncStorageLike | null) => void;
|
|
42
|
+
export interface StorageApi {
|
|
43
|
+
getItem: (key: string) => Promise<string | null>;
|
|
44
|
+
setItem: (key: string, value: string) => Promise<boolean>;
|
|
45
|
+
removeItem: (key: string) => Promise<boolean>;
|
|
46
|
+
getJson: <T>(key: string) => Promise<T | null>;
|
|
47
|
+
setJson: <T>(key: string, value: T) => Promise<boolean>;
|
|
48
|
+
multiGet: (keys: readonly string[]) => Promise<Record<string, string | null>>;
|
|
49
|
+
multiSet: (entries: Record<string, string>) => Promise<boolean>;
|
|
50
|
+
multiRemove: (keys: readonly string[]) => Promise<boolean>;
|
|
51
|
+
clear: () => Promise<boolean>;
|
|
52
|
+
getAllKeys: () => Promise<string[]>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Typed AsyncStorage wrapper with safe JSON helpers.
|
|
56
|
+
* All operations swallow errors (logging them) and return a falsy result
|
|
57
|
+
* so that storage problems never crash the app.
|
|
58
|
+
*
|
|
59
|
+
* Backed by `expo-sqlite/kv-store` by default;
|
|
60
|
+
* override with `setStorageImplementation()` for MMKV or custom adapters.
|
|
61
|
+
*/
|
|
62
|
+
export declare const Storage: StorageApi;
|
|
63
|
+
export type { AsyncStorageLike };
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image compression for uploads: the whole shell an app needs around a
|
|
3
|
+
* picked photo, so an app calls this once and uploads what comes back.
|
|
4
|
+
*
|
|
5
|
+
* What it does, in order:
|
|
6
|
+
*
|
|
7
|
+
* 1. Measures the source. A missing or EMPTY file throws `ImageUnreadableError`
|
|
8
|
+
* so the user is asked to retake: the OS evicts a camera temp file between
|
|
9
|
+
* capture and a delayed save, and uploading the empty result is a certain
|
|
10
|
+
* server rejection that can wedge an outbox.
|
|
11
|
+
* 2. Decodes the photo ONCE and reads its size. The longer side is brought
|
|
12
|
+
* down to `maxSize` (1500 by default, the fleet standard); a photo already
|
|
13
|
+
* within it is never enlarged.
|
|
14
|
+
* 3. Re-encodes at a quality picked from the source's real byte size (bigger
|
|
15
|
+
* files are compressed harder), or at the `quality` given. The re-encode
|
|
16
|
+
* drops EXIF as a side effect; location and time travel as payload fields,
|
|
17
|
+
* never add a second stripping step.
|
|
18
|
+
* 4. With `maxBytes`, keeps re-encoding at a lower quality, then a smaller
|
|
19
|
+
* size, until the output fits, deleting each superseded file.
|
|
20
|
+
* 5. Measures the output the same way as the source and returns everything
|
|
21
|
+
* an upload needs: uri, pixel size, byte size, mime type, extension, file
|
|
22
|
+
* name and a ready `FormData` part.
|
|
23
|
+
*
|
|
24
|
+
* Only an ENCODER failure falls back to the original file, reported through
|
|
25
|
+
* `compressed: false` with the original's own type and size; the reference
|
|
26
|
+
* apps upload the original rather than lose the photo. An unreadable file is
|
|
27
|
+
* never a fallback, it throws.
|
|
28
|
+
*
|
|
29
|
+
* Backed by `expo-image-manipulator` and `expo-file-system`; an app wires
|
|
30
|
+
* nothing. Tests and the showcase inject a backend through
|
|
31
|
+
* `setImageCompressorImplementation`.
|
|
32
|
+
*/
|
|
33
|
+
export type ImageOutputFormat = 'jpg' | 'png' | 'webp';
|
|
34
|
+
export interface CompressImageOptions {
|
|
35
|
+
/** Bound on the LONGER side in pixels; never enlarges. Defaults to 1500. */
|
|
36
|
+
maxSize?: number;
|
|
37
|
+
/**
|
|
38
|
+
* JPEG/WebP quality, 0 to 1. Overrides the size-based quality ladder. PNG
|
|
39
|
+
* is lossless and ignores it.
|
|
40
|
+
*/
|
|
41
|
+
quality?: number;
|
|
42
|
+
/** Output format. Defaults to `'jpg'`. */
|
|
43
|
+
output?: ImageOutputFormat;
|
|
44
|
+
/**
|
|
45
|
+
* Byte size of the source as the picker reported it. Only a HINT for the
|
|
46
|
+
* quality ladder when the file cannot be measured (an Android `content://`
|
|
47
|
+
* URI); a measurable file is measured, because the picker's number can be
|
|
48
|
+
* stale by the time this runs.
|
|
49
|
+
*/
|
|
50
|
+
fileSize?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Byte ceiling for the output (an API's upload limit). Quality is stepped
|
|
53
|
+
* down to `minQuality`, then the size is stepped down, until the output
|
|
54
|
+
* fits. Best effort: the result's `size` says whether it did.
|
|
55
|
+
*/
|
|
56
|
+
maxBytes?: number;
|
|
57
|
+
/** Lowest quality the `maxBytes` ladder may reach. Defaults to 0.4. */
|
|
58
|
+
minQuality?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Base name for the output file (any extension is replaced by the output
|
|
61
|
+
* format's). Defaults to the source's own name, or `image`. A picked photo
|
|
62
|
+
* has no useful name of its own; a list of twelve documents all called
|
|
63
|
+
* `image.jpg` is unreadable.
|
|
64
|
+
*/
|
|
65
|
+
name?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface CompressedImage {
|
|
68
|
+
/** Local URI of the file to upload. */
|
|
69
|
+
uri: string;
|
|
70
|
+
/** Pixel size; null only for an uncompressed original that could not be decoded. */
|
|
71
|
+
width: number | null;
|
|
72
|
+
height: number | null;
|
|
73
|
+
/** Byte size on disk; null only for an uncompressed original that could not be measured. */
|
|
74
|
+
size: number | null;
|
|
75
|
+
/** `image/jpeg`, `image/png` or `image/webp`; the original's own type when `compressed` is false. */
|
|
76
|
+
mimeType: string;
|
|
77
|
+
/** Extension without the dot: `jpg`, `png`, `webp`. */
|
|
78
|
+
extension: string;
|
|
79
|
+
/** `<name>.<extension>`. */
|
|
80
|
+
fileName: string;
|
|
81
|
+
/** False when the encoder failed and this is the untouched original. */
|
|
82
|
+
compressed: boolean;
|
|
83
|
+
/** The quality the output was encoded at; null for PNG and for an original. */
|
|
84
|
+
quality: number | null;
|
|
85
|
+
/** The file part React Native's `FormData` wants: `formData.append('file', part)`. */
|
|
86
|
+
part: {
|
|
87
|
+
uri: string;
|
|
88
|
+
name: string;
|
|
89
|
+
type: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** The source was missing or empty, or the encoder produced an empty file. */
|
|
93
|
+
export declare class ImageUnreadableError extends Error {
|
|
94
|
+
readonly uri: string;
|
|
95
|
+
constructor(uri: string, reason: string);
|
|
96
|
+
}
|
|
97
|
+
export interface ImageFileStat {
|
|
98
|
+
exists: boolean;
|
|
99
|
+
size: number;
|
|
100
|
+
}
|
|
101
|
+
export interface EncodeOptions {
|
|
102
|
+
/** Target size; one side only, the other follows the aspect ratio. Omit both to keep the size. */
|
|
103
|
+
width?: number;
|
|
104
|
+
height?: number;
|
|
105
|
+
quality: number;
|
|
106
|
+
format: 'jpeg' | 'png' | 'webp';
|
|
107
|
+
}
|
|
108
|
+
export interface EncodedImage {
|
|
109
|
+
uri: string;
|
|
110
|
+
width: number;
|
|
111
|
+
height: number;
|
|
112
|
+
}
|
|
113
|
+
/** A decoded image, held in memory until `close`. */
|
|
114
|
+
export interface OpenedImage {
|
|
115
|
+
width: number;
|
|
116
|
+
height: number;
|
|
117
|
+
encode: (options: EncodeOptions) => Promise<EncodedImage>;
|
|
118
|
+
close: () => void;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* What the algorithm needs from a backend. The default is built on
|
|
122
|
+
* expo-image-manipulator and expo-file-system.
|
|
123
|
+
*/
|
|
124
|
+
export interface ImageCompressorLike {
|
|
125
|
+
/** Size and existence of a local file; null when the URI cannot be measured (unsupported scheme). */
|
|
126
|
+
stat: (uri: string) => Promise<ImageFileStat | null>;
|
|
127
|
+
/** Delete a file this module wrote; errors are swallowed by the caller. */
|
|
128
|
+
remove: (uri: string) => Promise<void>;
|
|
129
|
+
/** Decode once; `encode` re-renders from the decoded image, not the file. */
|
|
130
|
+
open: (uri: string) => Promise<OpenedImage>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Replace the backend. Intended for TESTS and for the showcase; an app gets
|
|
134
|
+
* the expo modules without wiring anything. Pass `null` to restore them.
|
|
135
|
+
*/
|
|
136
|
+
export declare const setImageCompressorImplementation: (impl: ImageCompressorLike | null) => void;
|
|
137
|
+
/**
|
|
138
|
+
* Bigger source files get compressed harder: a fixed quality either
|
|
139
|
+
* over-compresses small photos or leaves large ones too heavy to upload
|
|
140
|
+
* quickly. Unknown size falls back to the middle rung rather than assuming
|
|
141
|
+
* either extreme. The fleet ladder (`react-native.md`).
|
|
142
|
+
*/
|
|
143
|
+
export declare const qualityForFileSize: (fileSize?: number | null) => number;
|
|
144
|
+
/**
|
|
145
|
+
* Compress an image for upload. See the module comment for the contract.
|
|
146
|
+
*
|
|
147
|
+
* @throws ImageUnreadableError when the source is missing or empty, or the
|
|
148
|
+
* encoder produced an empty file. Any other failure returns the original with
|
|
149
|
+
* `compressed: false`.
|
|
150
|
+
*/
|
|
151
|
+
export declare const compressImage: (uri: string, options?: CompressImageOptions) => Promise<CompressedImage>;
|
|
152
|
+
//# sourceMappingURL=imageCompression.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
/**
|
|
41
|
+
* The same rules the Webority servers apply: spaces and hyphens stripped (as
|
|
42
|
+
* printed on the card), twelve digits, no leading 0 or 1, and a correct
|
|
43
|
+
* Verhoeff check digit.
|
|
44
|
+
*/
|
|
45
|
+
export declare const isAadhaar: (value: unknown) => boolean;
|
|
46
|
+
export declare const isIfsc: (value: unknown) => boolean;
|
|
47
|
+
export declare const isHexColor: (value: unknown) => boolean;
|
|
48
|
+
export declare const isBetween: (value: unknown, min: number, max: number, inclusive?: boolean) => boolean;
|
|
49
|
+
export declare const minLength: (value: unknown, length: number) => boolean;
|
|
50
|
+
export declare const maxLength: (value: unknown, length: number) => boolean;
|
|
51
|
+
//# 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,20 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves `baseURL` PER REQUEST rather than at module evaluation.
|
|
4
|
+
*
|
|
5
|
+
* `axios.create({ baseURL: getConfigValue('baseUrl') })` reads the value once,
|
|
6
|
+
* when the module is first imported — which happens the moment anything touches
|
|
7
|
+
* the package barrel, long before an app's startup code can call `setConfig`.
|
|
8
|
+
* The result was a client permanently pinned to `undefined` and a `setConfig`
|
|
9
|
+
* that appeared to do nothing, with no error anywhere: requests just went to a
|
|
10
|
+
* relative URL.
|
|
11
|
+
*
|
|
12
|
+
* A consumer cannot fix that by ordering its own imports, because the import
|
|
13
|
+
* that loses the race is usually one it never wrote. So the clients stop
|
|
14
|
+
* capturing the value and ask for it per request instead.
|
|
15
|
+
*
|
|
16
|
+
* An explicit per-request `baseURL` still wins, which is what keeps a one-off
|
|
17
|
+
* call to a different host possible.
|
|
18
|
+
*/
|
|
19
|
+
export declare const applyConfiguredBaseUrl: (client: AxiosInstance) => void;
|
|
20
|
+
//# sourceMappingURL=baseUrl.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Builds a copy-pasteable curl command for a request, with every credential
|
|
4
|
+
* replaced by a placeholder.
|
|
5
|
+
*
|
|
6
|
+
* The redaction is the point, not a nicety. An unredacted version of this in a
|
|
7
|
+
* consumer app put `Authorization: Bearer <token>` and the login request's
|
|
8
|
+
* plaintext password into the device console of a *release* staging build.
|
|
9
|
+
* A curl line is worth having; a curl line that has to be trusted not to be
|
|
10
|
+
* enabled in the wrong build is not.
|
|
11
|
+
*/
|
|
12
|
+
export declare const buildCurl: (config: AxiosRequestConfig) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Logs the curl equivalent of a request. Never throws: a failure to describe a
|
|
15
|
+
* request must not be able to fail the request itself.
|
|
16
|
+
*/
|
|
17
|
+
export declare const logCurl: (config: AxiosRequestConfig) => void;
|
|
18
|
+
//# sourceMappingURL=curl.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
|