@webority-technologies/mobile-core 0.0.6 → 0.0.7
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/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/formatters/dateMath.js +4 -4
- package/lib/commonjs/formatters/windowsToIanaTable.js +164 -0
- package/lib/commonjs/geolocation/index.js +1 -1
- package/lib/commonjs/permissions/index.js +128 -129
- package/lib/commonjs/smsRetriever/index.js +91 -0
- package/lib/commonjs/specs/NativeSmsRetriever.js +15 -0
- package/lib/commonjs/sqlite/index.js +12 -30
- package/lib/module/formatters/dateMath.js +4 -4
- package/lib/module/formatters/windowsToIanaTable.js +160 -0
- package/lib/module/geolocation/index.js +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/permissions/index.js +129 -130
- package/lib/module/smsRetriever/index.js +86 -0
- package/lib/module/specs/NativeSmsRetriever.js +13 -0
- package/lib/module/sqlite/index.js +12 -30
- package/lib/typescript/commonjs/formatters/windowsToIanaTable.d.ts +18 -0
- package/lib/typescript/commonjs/index.d.ts +3 -2
- package/lib/typescript/commonjs/permissions/index.d.ts +14 -36
- 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/index.d.ts +10 -18
- package/lib/typescript/module/formatters/windowsToIanaTable.d.ts +18 -0
- package/lib/typescript/module/index.d.ts +3 -2
- package/lib/typescript/module/permissions/index.d.ts +14 -36
- 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/index.d.ts +10 -18
- package/package.json +31 -49
- package/lib/commonjs/sqlite/adapters/op.js +0 -43
- package/lib/commonjs/sqlite/adapters/rows.js +0 -33
- package/lib/commonjs/sqlite/adapters/storage.js +0 -50
- package/lib/commonjs/sqlite/adapters/sync.js +0 -45
- package/lib/commonjs/sqlite/nitro.js +0 -17
- package/lib/commonjs/sqlite/op.js +0 -18
- package/lib/commonjs/sqlite/quick.js +0 -14
- package/lib/commonjs/sqlite/storage.js +0 -14
- package/lib/module/sqlite/adapters/op.js +0 -38
- package/lib/module/sqlite/adapters/rows.js +0 -28
- package/lib/module/sqlite/adapters/storage.js +0 -46
- package/lib/module/sqlite/adapters/sync.js +0 -41
- package/lib/module/sqlite/nitro.js +0 -12
- package/lib/module/sqlite/op.js +0 -13
- package/lib/module/sqlite/quick.js +0 -9
- package/lib/module/sqlite/storage.js +0 -9
- package/lib/typescript/commonjs/sqlite/adapters/op.d.ts +0 -27
- package/lib/typescript/commonjs/sqlite/adapters/rows.d.ts +0 -7
- package/lib/typescript/commonjs/sqlite/adapters/storage.d.ts +0 -30
- package/lib/typescript/commonjs/sqlite/adapters/sync.d.ts +0 -31
- package/lib/typescript/commonjs/sqlite/nitro.d.ts +0 -7
- package/lib/typescript/commonjs/sqlite/op.d.ts +0 -8
- package/lib/typescript/commonjs/sqlite/quick.d.ts +0 -4
- package/lib/typescript/commonjs/sqlite/storage.d.ts +0 -4
- package/lib/typescript/module/sqlite/adapters/op.d.ts +0 -27
- package/lib/typescript/module/sqlite/adapters/rows.d.ts +0 -7
- package/lib/typescript/module/sqlite/adapters/storage.d.ts +0 -30
- package/lib/typescript/module/sqlite/adapters/sync.d.ts +0 -31
- package/lib/typescript/module/sqlite/nitro.d.ts +0 -7
- package/lib/typescript/module/sqlite/op.d.ts +0 -8
- package/lib/typescript/module/sqlite/quick.d.ts +0 -4
- package/lib/typescript/module/sqlite/storage.d.ts +0 -4
|
@@ -5,40 +5,25 @@ import { Logger } from "../logger/index.js";
|
|
|
5
5
|
import { adaptExpoSqlite } from "./adapters/expo.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* setSqliteImplementation(opSqliteDriver());
|
|
16
|
-
*
|
|
17
|
-
* Supported entry points: /sqlite/op, /sqlite/nitro, /sqlite/quick,
|
|
18
|
-
* /sqlite/storage. Any object matching SqliteDriver also works.
|
|
8
|
+
* expo-sqlite is the fleet's only sanctioned SQLite driver (react-native.md:
|
|
9
|
+
* "we will always use expo-sqlite, what Expo gives, we don't look elsewhere
|
|
10
|
+
* ever") — this module resolves it automatically, with no app-side wiring.
|
|
11
|
+
* `setSqliteImplementation` still exists, narrowed to tests and the showcase:
|
|
12
|
+
* it injects a denying/failing backend to reach error paths a healthy device
|
|
13
|
+
* never takes, the same pattern every other injectable surface in this
|
|
14
|
+
* library follows. It is not a way to pick an alternate real driver.
|
|
19
15
|
*/
|
|
20
16
|
|
|
21
17
|
/** Only what a test or an app injected; null means use expo-sqlite. */
|
|
22
18
|
let backend = null;
|
|
23
19
|
|
|
24
|
-
/**
|
|
25
|
-
* expo-sqlite, adapted once and memoised.
|
|
26
|
-
*
|
|
27
|
-
* Unlike the other surfaces this one keeps a real reason to inject: an app with
|
|
28
|
-
* an existing database on another driver (op-sqlite, nitro, quick,
|
|
29
|
-
* sqlite-storage) can hand it over, and those entry points stay published for
|
|
30
|
-
* exactly that. expo-sqlite is simply what happens when nobody does.
|
|
31
|
-
*/
|
|
20
|
+
/** expo-sqlite, adapted once and memoised. The only driver this module resolves. */
|
|
32
21
|
let expoDriver;
|
|
33
22
|
|
|
34
23
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* and defines only this interface. Wire a driver once at startup:
|
|
39
|
-
*
|
|
40
|
-
* import { opSqliteDriver } from '@webority-technologies/mobile-core/sqlite/op';
|
|
41
|
-
* setSqliteImplementation(opSqliteDriver());
|
|
24
|
+
* Test/showcase-only injection point — see the module header. Not a way to
|
|
25
|
+
* pick an alternate real driver; `@webority-technologies/mobile-core` always
|
|
26
|
+
* resolves expo-sqlite when nothing is injected. Pass `null` to clear it.
|
|
42
27
|
*/
|
|
43
28
|
export const setSqliteImplementation = impl => {
|
|
44
29
|
backend = impl;
|
|
@@ -56,10 +41,7 @@ export const isSqliteAvailable = () => resolveDriver() !== null;
|
|
|
56
41
|
const requireBackend = op => {
|
|
57
42
|
const b = resolveDriver();
|
|
58
43
|
if (!b) {
|
|
59
|
-
|
|
60
|
-
// installing a driver alone does nothing here, and the previous wording
|
|
61
|
-
// ("Install one of ...") sent people to fix a thing that was not broken.
|
|
62
|
-
const err = new Error(`[@webority-technologies/mobile-core] No SQLite driver injected; cannot ${op}. ` + 'Install a driver and wire it once at startup, e.g. ' + "`import { opSqliteDriver } from '@webority-technologies/mobile-core/sqlite/op'` " + 'then `setSqliteImplementation(opSqliteDriver())`. Drivers: @op-engineering/op-sqlite ' + '(recommended), expo-sqlite, react-native-nitro-sqlite, react-native-quick-sqlite, ' + 'react-native-sqlite-storage.');
|
|
44
|
+
const err = new Error(`[@webority-technologies/mobile-core] No SQLite driver available; cannot ${op}. ` + 'Install expo-sqlite (the only sanctioned driver) in the consuming app.');
|
|
63
45
|
Logger.error(err.message);
|
|
64
46
|
throw err;
|
|
65
47
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .NET-style Windows time zone ID → IANA time zone name, one entry per
|
|
3
|
+
* Windows zone, generated from CLDR's `windowsZones.xml` (the same
|
|
4
|
+
* upstream source the retired `windows-iana` npm package derived its own
|
|
5
|
+
* table from). Only the `territory="001"` (world-default) row is kept per
|
|
6
|
+
* Windows zone — `formatTimeInWindowsZone` only ever reads the first IANA
|
|
7
|
+
* candidate, and CLDR's `001` row is exactly that default candidate, so
|
|
8
|
+
* per-country territory variants (`US`, `CA`, `ZZ`, …) carry no information
|
|
9
|
+
* this table's one caller uses.
|
|
10
|
+
*
|
|
11
|
+
* Regenerate with `node packages/core/scripts/generate-windows-to-iana-table.mjs
|
|
12
|
+
* <path-to-windowsZones.xml>` (CLDR: `common/supplemental/windowsZones.xml` in
|
|
13
|
+
* https://github.com/unicode-org/cldr) whenever CLDR adds/renames a zone —
|
|
14
|
+
* this is a committed, static table; nothing fetches CLDR at build or test
|
|
15
|
+
* time.
|
|
16
|
+
*/
|
|
17
|
+
export declare const WINDOWS_TO_IANA: Readonly<Record<string, string>>;
|
|
18
|
+
//# sourceMappingURL=windowsToIanaTable.d.ts.map
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* for anyone importing anything at all. Those live behind their own import
|
|
6
6
|
* paths instead:
|
|
7
7
|
*
|
|
8
|
-
* @webority-technologies/mobile-core/permissions
|
|
8
|
+
* @webority-technologies/mobile-core/permissions per kind, its own Expo module
|
|
9
9
|
* @webority-technologies/mobile-core/compressor react-native-compressor
|
|
10
10
|
* @webority-technologies/mobile-core/geolocation a geolocation provider
|
|
11
|
-
* @webority-technologies/mobile-core/sqlite
|
|
11
|
+
* @webority-technologies/mobile-core/sqlite expo-sqlite
|
|
12
12
|
* @webority-technologies/mobile-core/download a filesystem module
|
|
13
|
+
* @webority-technologies/mobile-core/smsRetriever Android only, own TurboModule
|
|
13
14
|
*
|
|
14
15
|
* react-native-keychain is the exception and is a REQUIRED peer: the HTTP client
|
|
15
16
|
* reads the bearer token, so it is reachable from the main barrel by design.
|
|
@@ -1,46 +1,25 @@
|
|
|
1
1
|
export type PermissionKind = 'camera' | 'microphone' | 'photos' | 'photosAdd' | 'mediaLibrary' | 'location' | 'locationAlways' | 'contacts' | 'calendar' | 'reminders' | 'notifications' | 'bluetooth' | 'storage';
|
|
2
2
|
export type PermissionStatus = 'unavailable' | 'denied' | 'limited' | 'granted' | 'blocked';
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ANDROID: Record<string, string>;
|
|
7
|
-
};
|
|
8
|
-
RESULTS: {
|
|
9
|
-
UNAVAILABLE: string;
|
|
10
|
-
DENIED: string;
|
|
11
|
-
LIMITED: string;
|
|
12
|
-
GRANTED: string;
|
|
13
|
-
BLOCKED: string;
|
|
14
|
-
};
|
|
15
|
-
check: (permission: string) => Promise<string>;
|
|
16
|
-
request: (permission: string) => Promise<string>;
|
|
17
|
-
openSettings: () => Promise<void>;
|
|
3
|
+
export interface PermissionsBackend {
|
|
4
|
+
check: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
5
|
+
request: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
18
6
|
}
|
|
19
7
|
/**
|
|
20
|
-
* Inject a custom permissions
|
|
21
|
-
*
|
|
8
|
+
* Inject a custom permissions backend at runtime. Pass `null` to reset to the
|
|
9
|
+
* default per-kind Expo resolution.
|
|
22
10
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* documented contract. That exact bug shipped once, in the storage seam.
|
|
27
|
-
*
|
|
28
|
-
* THIS MODULE IS THE EXPO-FIRST EXCEPTION, and deliberately keeps the old
|
|
29
|
-
* shape. Expo ships no permissions package: each module carries its own
|
|
30
|
-
* (expo-location's requestForegroundPermissionsAsync, expo-image-picker's, and
|
|
31
|
-
* so on), so there is no single object to adapt and the library must not guess
|
|
32
|
-
* which Expo modules an app installed. react-native-permissions stays, behind
|
|
33
|
-
* this module's own import path so an app that never asks for permissions
|
|
34
|
-
* never names the package to Metro.
|
|
11
|
+
* Two legitimate reasons to call this: tests/the showcase reaching a denied,
|
|
12
|
+
* blocked or unavailable path a healthy device never takes; and an app that
|
|
13
|
+
* genuinely needs `bluetooth` or `storage`, which no Expo module covers.
|
|
35
14
|
*/
|
|
36
|
-
export declare const setPermissionsImplementation: (impl:
|
|
15
|
+
export declare const setPermissionsImplementation: (impl: PermissionsBackend | null) => void;
|
|
37
16
|
/**
|
|
38
17
|
* Cross-platform permissions wrapper. Maps an abstract `PermissionKind`
|
|
39
|
-
* (camera, photos, location, notifications, …) to the
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
18
|
+
* (camera, photos, location, notifications, …) to the Expo module that owns
|
|
19
|
+
* it under the hood — expo-camera, expo-image-picker, expo-location,
|
|
20
|
+
* expo-contacts, expo-calendar, expo-notifications, expo-media-library. Every
|
|
21
|
+
* one is an optional peer, required lazily; an app installs only the modules
|
|
22
|
+
* whose kinds it actually asks for.
|
|
44
23
|
*/
|
|
45
24
|
export declare const Permissions: {
|
|
46
25
|
check: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
@@ -51,5 +30,4 @@ export declare const Permissions: {
|
|
|
51
30
|
ensure: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
52
31
|
openSettings: () => Promise<boolean>;
|
|
53
32
|
};
|
|
54
|
-
export type { RNPermissionsModule as PermissionsLike };
|
|
55
33
|
//# 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
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* setSqliteImplementation(opSqliteDriver());
|
|
10
|
-
*
|
|
11
|
-
* Supported entry points: /sqlite/op, /sqlite/nitro, /sqlite/quick,
|
|
12
|
-
* /sqlite/storage. Any object matching SqliteDriver also works.
|
|
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.
|
|
13
9
|
*/
|
|
14
10
|
export interface SqliteResultSet {
|
|
15
11
|
rows: Record<string, unknown>[];
|
|
@@ -26,13 +22,9 @@ export interface SqliteDriver {
|
|
|
26
22
|
}) => Promise<SqliteDatabase>;
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* and defines only this interface. Wire a driver once at startup:
|
|
33
|
-
*
|
|
34
|
-
* import { opSqliteDriver } from '@webority-technologies/mobile-core/sqlite/op';
|
|
35
|
-
* setSqliteImplementation(opSqliteDriver());
|
|
25
|
+
* Test/showcase-only injection point — see the module header. Not a way to
|
|
26
|
+
* pick an alternate real driver; `@webority-technologies/mobile-core` always
|
|
27
|
+
* resolves expo-sqlite when nothing is injected. Pass `null` to clear it.
|
|
36
28
|
*/
|
|
37
29
|
export declare const setSqliteImplementation: (impl: SqliteDriver | null) => void;
|
|
38
30
|
export declare const isSqliteAvailable: () => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .NET-style Windows time zone ID → IANA time zone name, one entry per
|
|
3
|
+
* Windows zone, generated from CLDR's `windowsZones.xml` (the same
|
|
4
|
+
* upstream source the retired `windows-iana` npm package derived its own
|
|
5
|
+
* table from). Only the `territory="001"` (world-default) row is kept per
|
|
6
|
+
* Windows zone — `formatTimeInWindowsZone` only ever reads the first IANA
|
|
7
|
+
* candidate, and CLDR's `001` row is exactly that default candidate, so
|
|
8
|
+
* per-country territory variants (`US`, `CA`, `ZZ`, …) carry no information
|
|
9
|
+
* this table's one caller uses.
|
|
10
|
+
*
|
|
11
|
+
* Regenerate with `node packages/core/scripts/generate-windows-to-iana-table.mjs
|
|
12
|
+
* <path-to-windowsZones.xml>` (CLDR: `common/supplemental/windowsZones.xml` in
|
|
13
|
+
* https://github.com/unicode-org/cldr) whenever CLDR adds/renames a zone —
|
|
14
|
+
* this is a committed, static table; nothing fetches CLDR at build or test
|
|
15
|
+
* time.
|
|
16
|
+
*/
|
|
17
|
+
export declare const WINDOWS_TO_IANA: Readonly<Record<string, string>>;
|
|
18
|
+
//# sourceMappingURL=windowsToIanaTable.d.ts.map
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* for anyone importing anything at all. Those live behind their own import
|
|
6
6
|
* paths instead:
|
|
7
7
|
*
|
|
8
|
-
* @webority-technologies/mobile-core/permissions
|
|
8
|
+
* @webority-technologies/mobile-core/permissions per kind, its own Expo module
|
|
9
9
|
* @webority-technologies/mobile-core/compressor react-native-compressor
|
|
10
10
|
* @webority-technologies/mobile-core/geolocation a geolocation provider
|
|
11
|
-
* @webority-technologies/mobile-core/sqlite
|
|
11
|
+
* @webority-technologies/mobile-core/sqlite expo-sqlite
|
|
12
12
|
* @webority-technologies/mobile-core/download a filesystem module
|
|
13
|
+
* @webority-technologies/mobile-core/smsRetriever Android only, own TurboModule
|
|
13
14
|
*
|
|
14
15
|
* react-native-keychain is the exception and is a REQUIRED peer: the HTTP client
|
|
15
16
|
* reads the bearer token, so it is reachable from the main barrel by design.
|
|
@@ -1,46 +1,25 @@
|
|
|
1
1
|
export type PermissionKind = 'camera' | 'microphone' | 'photos' | 'photosAdd' | 'mediaLibrary' | 'location' | 'locationAlways' | 'contacts' | 'calendar' | 'reminders' | 'notifications' | 'bluetooth' | 'storage';
|
|
2
2
|
export type PermissionStatus = 'unavailable' | 'denied' | 'limited' | 'granted' | 'blocked';
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ANDROID: Record<string, string>;
|
|
7
|
-
};
|
|
8
|
-
RESULTS: {
|
|
9
|
-
UNAVAILABLE: string;
|
|
10
|
-
DENIED: string;
|
|
11
|
-
LIMITED: string;
|
|
12
|
-
GRANTED: string;
|
|
13
|
-
BLOCKED: string;
|
|
14
|
-
};
|
|
15
|
-
check: (permission: string) => Promise<string>;
|
|
16
|
-
request: (permission: string) => Promise<string>;
|
|
17
|
-
openSettings: () => Promise<void>;
|
|
3
|
+
export interface PermissionsBackend {
|
|
4
|
+
check: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
5
|
+
request: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
18
6
|
}
|
|
19
7
|
/**
|
|
20
|
-
* Inject a custom permissions
|
|
21
|
-
*
|
|
8
|
+
* Inject a custom permissions backend at runtime. Pass `null` to reset to the
|
|
9
|
+
* default per-kind Expo resolution.
|
|
22
10
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* documented contract. That exact bug shipped once, in the storage seam.
|
|
27
|
-
*
|
|
28
|
-
* THIS MODULE IS THE EXPO-FIRST EXCEPTION, and deliberately keeps the old
|
|
29
|
-
* shape. Expo ships no permissions package: each module carries its own
|
|
30
|
-
* (expo-location's requestForegroundPermissionsAsync, expo-image-picker's, and
|
|
31
|
-
* so on), so there is no single object to adapt and the library must not guess
|
|
32
|
-
* which Expo modules an app installed. react-native-permissions stays, behind
|
|
33
|
-
* this module's own import path so an app that never asks for permissions
|
|
34
|
-
* never names the package to Metro.
|
|
11
|
+
* Two legitimate reasons to call this: tests/the showcase reaching a denied,
|
|
12
|
+
* blocked or unavailable path a healthy device never takes; and an app that
|
|
13
|
+
* genuinely needs `bluetooth` or `storage`, which no Expo module covers.
|
|
35
14
|
*/
|
|
36
|
-
export declare const setPermissionsImplementation: (impl:
|
|
15
|
+
export declare const setPermissionsImplementation: (impl: PermissionsBackend | null) => void;
|
|
37
16
|
/**
|
|
38
17
|
* Cross-platform permissions wrapper. Maps an abstract `PermissionKind`
|
|
39
|
-
* (camera, photos, location, notifications, …) to the
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
18
|
+
* (camera, photos, location, notifications, …) to the Expo module that owns
|
|
19
|
+
* it under the hood — expo-camera, expo-image-picker, expo-location,
|
|
20
|
+
* expo-contacts, expo-calendar, expo-notifications, expo-media-library. Every
|
|
21
|
+
* one is an optional peer, required lazily; an app installs only the modules
|
|
22
|
+
* whose kinds it actually asks for.
|
|
44
23
|
*/
|
|
45
24
|
export declare const Permissions: {
|
|
46
25
|
check: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
@@ -51,5 +30,4 @@ export declare const Permissions: {
|
|
|
51
30
|
ensure: (kind: PermissionKind) => Promise<PermissionStatus>;
|
|
52
31
|
openSettings: () => Promise<boolean>;
|
|
53
32
|
};
|
|
54
|
-
export type { RNPermissionsModule as PermissionsLike };
|
|
55
33
|
//# 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
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* setSqliteImplementation(opSqliteDriver());
|
|
10
|
-
*
|
|
11
|
-
* Supported entry points: /sqlite/op, /sqlite/nitro, /sqlite/quick,
|
|
12
|
-
* /sqlite/storage. Any object matching SqliteDriver also works.
|
|
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.
|
|
13
9
|
*/
|
|
14
10
|
export interface SqliteResultSet {
|
|
15
11
|
rows: Record<string, unknown>[];
|
|
@@ -26,13 +22,9 @@ export interface SqliteDriver {
|
|
|
26
22
|
}) => Promise<SqliteDatabase>;
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* and defines only this interface. Wire a driver once at startup:
|
|
33
|
-
*
|
|
34
|
-
* import { opSqliteDriver } from '@webority-technologies/mobile-core/sqlite/op';
|
|
35
|
-
* setSqliteImplementation(opSqliteDriver());
|
|
25
|
+
* Test/showcase-only injection point — see the module header. Not a way to
|
|
26
|
+
* pick an alternate real driver; `@webority-technologies/mobile-core` always
|
|
27
|
+
* resolves expo-sqlite when nothing is injected. Pass `null` to clear it.
|
|
36
28
|
*/
|
|
37
29
|
export declare const setSqliteImplementation: (impl: SqliteDriver | null) => void;
|
|
38
30
|
export declare const isSqliteAvailable: () => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority-technologies/mobile-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Platform layer for Webority React Native apps: HTTP clients, auth/token storage, config, logging, formatters, validators, network status, permissions, storage and version checks. No UI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -71,44 +71,14 @@
|
|
|
71
71
|
"default": "./lib/commonjs/download/index.js"
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
"./
|
|
74
|
+
"./smsRetriever": {
|
|
75
75
|
"import": {
|
|
76
|
-
"types": "./lib/typescript/module/
|
|
77
|
-
"default": "./lib/module/
|
|
76
|
+
"types": "./lib/typescript/module/smsRetriever/index.d.ts",
|
|
77
|
+
"default": "./lib/module/smsRetriever/index.js"
|
|
78
78
|
},
|
|
79
79
|
"require": {
|
|
80
|
-
"types": "./lib/typescript/commonjs/
|
|
81
|
-
"default": "./lib/commonjs/
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
"./sqlite/nitro": {
|
|
85
|
-
"import": {
|
|
86
|
-
"types": "./lib/typescript/module/sqlite/nitro.d.ts",
|
|
87
|
-
"default": "./lib/module/sqlite/nitro.js"
|
|
88
|
-
},
|
|
89
|
-
"require": {
|
|
90
|
-
"types": "./lib/typescript/commonjs/sqlite/nitro.d.ts",
|
|
91
|
-
"default": "./lib/commonjs/sqlite/nitro.js"
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
"./sqlite/quick": {
|
|
95
|
-
"import": {
|
|
96
|
-
"types": "./lib/typescript/module/sqlite/quick.d.ts",
|
|
97
|
-
"default": "./lib/module/sqlite/quick.js"
|
|
98
|
-
},
|
|
99
|
-
"require": {
|
|
100
|
-
"types": "./lib/typescript/commonjs/sqlite/quick.d.ts",
|
|
101
|
-
"default": "./lib/commonjs/sqlite/quick.js"
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
"./sqlite/storage": {
|
|
105
|
-
"import": {
|
|
106
|
-
"types": "./lib/typescript/module/sqlite/storage.d.ts",
|
|
107
|
-
"default": "./lib/module/sqlite/storage.js"
|
|
108
|
-
},
|
|
109
|
-
"require": {
|
|
110
|
-
"types": "./lib/typescript/commonjs/sqlite/storage.d.ts",
|
|
111
|
-
"default": "./lib/commonjs/sqlite/storage.js"
|
|
80
|
+
"types": "./lib/typescript/commonjs/smsRetriever/index.d.ts",
|
|
81
|
+
"default": "./lib/commonjs/smsRetriever/index.js"
|
|
112
82
|
}
|
|
113
83
|
},
|
|
114
84
|
"./package.json": "./package.json"
|
|
@@ -119,11 +89,20 @@
|
|
|
119
89
|
"types": "./lib/typescript/commonjs/index.d.ts",
|
|
120
90
|
"files": [
|
|
121
91
|
"lib",
|
|
92
|
+
"android",
|
|
122
93
|
"!**/__tests__",
|
|
123
94
|
"!**/*.test.*",
|
|
124
95
|
"!**/*.spec.*",
|
|
125
96
|
"!**/*.map"
|
|
126
97
|
],
|
|
98
|
+
"codegenConfig": {
|
|
99
|
+
"name": "RNMobileCoreSmsRetrieverSpec",
|
|
100
|
+
"type": "modules",
|
|
101
|
+
"jsSrcsDir": "./src/specs",
|
|
102
|
+
"android": {
|
|
103
|
+
"javaPackageName": "com.webority.mobilecore.smsretriever"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
127
106
|
"scripts": {
|
|
128
107
|
"build": "bob build",
|
|
129
108
|
"clean": "rimraf lib",
|
|
@@ -134,40 +113,43 @@
|
|
|
134
113
|
},
|
|
135
114
|
"dependencies": {
|
|
136
115
|
"axios": "^1.19.0",
|
|
137
|
-
"libphonenumber-js": "^1.12.41"
|
|
138
|
-
"windows-iana": "^5.1.0"
|
|
116
|
+
"libphonenumber-js": "^1.12.41"
|
|
139
117
|
},
|
|
140
118
|
"peerDependencies": {
|
|
141
|
-
"@op-engineering/op-sqlite": "*",
|
|
142
119
|
"expo": ">=57.0.0",
|
|
143
120
|
"expo-application": ">=57.0.0",
|
|
121
|
+
"expo-calendar": ">=57.0.0",
|
|
122
|
+
"expo-camera": ">=57.0.0",
|
|
123
|
+
"expo-contacts": ">=57.0.0",
|
|
144
124
|
"expo-file-system": ">=57.0.0",
|
|
145
125
|
"expo-image-manipulator": ">=57.0.0",
|
|
126
|
+
"expo-image-picker": ">=57.0.0",
|
|
146
127
|
"expo-location": ">=57.0.0",
|
|
128
|
+
"expo-media-library": ">=57.0.0",
|
|
147
129
|
"expo-network": ">=57.0.0",
|
|
130
|
+
"expo-notifications": ">=57.0.0",
|
|
148
131
|
"expo-secure-store": ">=57.0.0",
|
|
149
132
|
"expo-sqlite": ">=57.0.0",
|
|
150
133
|
"react": "^19.1.0",
|
|
151
|
-
"react-native": ">=0.81.0"
|
|
152
|
-
"react-native-nitro-sqlite": "*",
|
|
153
|
-
"react-native-permissions": ">=4.0.0",
|
|
154
|
-
"react-native-quick-sqlite": "*",
|
|
155
|
-
"react-native-sqlite-storage": "*"
|
|
134
|
+
"react-native": ">=0.81.0"
|
|
156
135
|
},
|
|
157
136
|
"peerDependenciesMeta": {
|
|
158
|
-
"
|
|
137
|
+
"expo-calendar": {
|
|
138
|
+
"optional": true
|
|
139
|
+
},
|
|
140
|
+
"expo-camera": {
|
|
159
141
|
"optional": true
|
|
160
142
|
},
|
|
161
|
-
"
|
|
143
|
+
"expo-contacts": {
|
|
162
144
|
"optional": true
|
|
163
145
|
},
|
|
164
|
-
"
|
|
146
|
+
"expo-image-picker": {
|
|
165
147
|
"optional": true
|
|
166
148
|
},
|
|
167
|
-
"
|
|
149
|
+
"expo-media-library": {
|
|
168
150
|
"optional": true
|
|
169
151
|
},
|
|
170
|
-
"
|
|
152
|
+
"expo-notifications": {
|
|
171
153
|
"optional": true
|
|
172
154
|
}
|
|
173
155
|
},
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.adaptOpSqlite = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* @op-engineering/op-sqlite. Shape verified against 18.1.4 rather than assumed:
|
|
9
|
-
* `open({ name, location })` is synchronous and returns a DB whose `execute` is
|
|
10
|
-
* ASYNC, and whose `rows` is already a plain array of objects rather than the
|
|
11
|
-
* `{ _array, item() }` shape the older drivers use. Both differences are why it
|
|
12
|
-
* cannot share the sync adapter.
|
|
13
|
-
*
|
|
14
|
-
* The REQUIRE lives in the driver entry point beside this file, never here.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const adaptOpSqlite = mod => ({
|
|
18
|
-
open: async (name, options) => {
|
|
19
|
-
const db = mod.open({
|
|
20
|
-
name,
|
|
21
|
-
location: options?.location
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
execute: async (sql, params) => {
|
|
25
|
-
const result = await db.execute(sql, params ? [...params] : undefined);
|
|
26
|
-
return {
|
|
27
|
-
rows: result.rows ?? [],
|
|
28
|
-
rowsAffected: result.rowsAffected ?? 0,
|
|
29
|
-
insertId: result.insertId
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
close: async () => {
|
|
33
|
-
if (db.closeAsync) {
|
|
34
|
-
await db.closeAsync();
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
db.close();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
exports.adaptOpSqlite = adaptOpSqlite;
|
|
43
|
-
//# sourceMappingURL=op.js.map
|