@webority-technologies/mobile-core 0.0.6 → 0.0.8
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 +9 -1
- 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 +60 -150
- 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/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 +8 -1
- package/lib/module/index.js +3 -2
- 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 +59 -150
- 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/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/geolocation/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts +3 -2
- 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 +29 -36
- 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/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/geolocation/index.d.ts +1 -0
- package/lib/typescript/module/index.d.ts +3 -2
- 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 +29 -36
- 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/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 +101 -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
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* .NET-style Windows time zone ID → IANA time zone name, one entry per
|
|
5
|
+
* Windows zone, generated from CLDR's `windowsZones.xml` (the same
|
|
6
|
+
* upstream source the retired `windows-iana` npm package derived its own
|
|
7
|
+
* table from). Only the `territory="001"` (world-default) row is kept per
|
|
8
|
+
* Windows zone — `formatTimeInWindowsZone` only ever reads the first IANA
|
|
9
|
+
* candidate, and CLDR's `001` row is exactly that default candidate, so
|
|
10
|
+
* per-country territory variants (`US`, `CA`, `ZZ`, …) carry no information
|
|
11
|
+
* this table's one caller uses.
|
|
12
|
+
*
|
|
13
|
+
* Regenerate with `node packages/core/scripts/generate-windows-to-iana-table.mjs
|
|
14
|
+
* <path-to-windowsZones.xml>` (CLDR: `common/supplemental/windowsZones.xml` in
|
|
15
|
+
* https://github.com/unicode-org/cldr) whenever CLDR adds/renames a zone —
|
|
16
|
+
* this is a committed, static table; nothing fetches CLDR at build or test
|
|
17
|
+
* time.
|
|
18
|
+
*/
|
|
19
|
+
export const WINDOWS_TO_IANA = {
|
|
20
|
+
'AUS Central Standard Time': 'Australia/Darwin',
|
|
21
|
+
'AUS Eastern Standard Time': 'Australia/Sydney',
|
|
22
|
+
'Afghanistan Standard Time': 'Asia/Kabul',
|
|
23
|
+
'Alaskan Standard Time': 'America/Anchorage',
|
|
24
|
+
'Aleutian Standard Time': 'America/Adak',
|
|
25
|
+
'Altai Standard Time': 'Asia/Barnaul',
|
|
26
|
+
'Arab Standard Time': 'Asia/Riyadh',
|
|
27
|
+
'Arabian Standard Time': 'Asia/Dubai',
|
|
28
|
+
'Arabic Standard Time': 'Asia/Baghdad',
|
|
29
|
+
'Argentina Standard Time': 'America/Buenos_Aires',
|
|
30
|
+
'Astrakhan Standard Time': 'Europe/Astrakhan',
|
|
31
|
+
'Atlantic Standard Time': 'America/Halifax',
|
|
32
|
+
'Aus Central W. Standard Time': 'Australia/Eucla',
|
|
33
|
+
'Azerbaijan Standard Time': 'Asia/Baku',
|
|
34
|
+
'Azores Standard Time': 'Atlantic/Azores',
|
|
35
|
+
'Bahia Standard Time': 'America/Bahia',
|
|
36
|
+
'Bangladesh Standard Time': 'Asia/Dhaka',
|
|
37
|
+
'Belarus Standard Time': 'Europe/Minsk',
|
|
38
|
+
'Bougainville Standard Time': 'Pacific/Bougainville',
|
|
39
|
+
'Canada Central Standard Time': 'America/Regina',
|
|
40
|
+
'Cape Verde Standard Time': 'Atlantic/Cape_Verde',
|
|
41
|
+
'Caucasus Standard Time': 'Asia/Yerevan',
|
|
42
|
+
'Cen. Australia Standard Time': 'Australia/Adelaide',
|
|
43
|
+
'Central America Standard Time': 'America/Guatemala',
|
|
44
|
+
'Central Asia Standard Time': 'Asia/Almaty',
|
|
45
|
+
'Central Brazilian Standard Time': 'America/Cuiaba',
|
|
46
|
+
'Central Europe Standard Time': 'Europe/Budapest',
|
|
47
|
+
'Central European Standard Time': 'Europe/Warsaw',
|
|
48
|
+
'Central Pacific Standard Time': 'Pacific/Guadalcanal',
|
|
49
|
+
'Central Standard Time': 'America/Chicago',
|
|
50
|
+
'Central Standard Time (Mexico)': 'America/Mexico_City',
|
|
51
|
+
'Chatham Islands Standard Time': 'Pacific/Chatham',
|
|
52
|
+
'China Standard Time': 'Asia/Shanghai',
|
|
53
|
+
'Cuba Standard Time': 'America/Havana',
|
|
54
|
+
'Dateline Standard Time': 'Etc/GMT+12',
|
|
55
|
+
'E. Africa Standard Time': 'Africa/Nairobi',
|
|
56
|
+
'E. Australia Standard Time': 'Australia/Brisbane',
|
|
57
|
+
'E. Europe Standard Time': 'Europe/Chisinau',
|
|
58
|
+
'E. South America Standard Time': 'America/Sao_Paulo',
|
|
59
|
+
'Easter Island Standard Time': 'Pacific/Easter',
|
|
60
|
+
'Eastern Standard Time': 'America/New_York',
|
|
61
|
+
'Eastern Standard Time (Mexico)': 'America/Cancun',
|
|
62
|
+
'Egypt Standard Time': 'Africa/Cairo',
|
|
63
|
+
'Ekaterinburg Standard Time': 'Asia/Yekaterinburg',
|
|
64
|
+
'FLE Standard Time': 'Europe/Kiev',
|
|
65
|
+
'Fiji Standard Time': 'Pacific/Fiji',
|
|
66
|
+
'GMT Standard Time': 'Europe/London',
|
|
67
|
+
'GTB Standard Time': 'Europe/Bucharest',
|
|
68
|
+
'Georgian Standard Time': 'Asia/Tbilisi',
|
|
69
|
+
'Greenland Standard Time': 'America/Godthab',
|
|
70
|
+
'Greenwich Standard Time': 'Atlantic/Reykjavik',
|
|
71
|
+
'Haiti Standard Time': 'America/Port-au-Prince',
|
|
72
|
+
'Hawaiian Standard Time': 'Pacific/Honolulu',
|
|
73
|
+
'India Standard Time': 'Asia/Calcutta',
|
|
74
|
+
'Iran Standard Time': 'Asia/Tehran',
|
|
75
|
+
'Israel Standard Time': 'Asia/Jerusalem',
|
|
76
|
+
'Jordan Standard Time': 'Asia/Amman',
|
|
77
|
+
'Kaliningrad Standard Time': 'Europe/Kaliningrad',
|
|
78
|
+
'Korea Standard Time': 'Asia/Seoul',
|
|
79
|
+
'Libya Standard Time': 'Africa/Tripoli',
|
|
80
|
+
'Line Islands Standard Time': 'Pacific/Kiritimati',
|
|
81
|
+
'Lord Howe Standard Time': 'Australia/Lord_Howe',
|
|
82
|
+
'Magadan Standard Time': 'Asia/Magadan',
|
|
83
|
+
'Magallanes Standard Time': 'America/Punta_Arenas',
|
|
84
|
+
'Marquesas Standard Time': 'Pacific/Marquesas',
|
|
85
|
+
'Mauritius Standard Time': 'Indian/Mauritius',
|
|
86
|
+
'Middle East Standard Time': 'Asia/Beirut',
|
|
87
|
+
'Montevideo Standard Time': 'America/Montevideo',
|
|
88
|
+
'Morocco Standard Time': 'Africa/Casablanca',
|
|
89
|
+
'Mountain Standard Time': 'America/Denver',
|
|
90
|
+
'Mountain Standard Time (Mexico)': 'America/Chihuahua',
|
|
91
|
+
'Myanmar Standard Time': 'Asia/Rangoon',
|
|
92
|
+
'N. Central Asia Standard Time': 'Asia/Novosibirsk',
|
|
93
|
+
'Namibia Standard Time': 'Africa/Windhoek',
|
|
94
|
+
'Nepal Standard Time': 'Asia/Katmandu',
|
|
95
|
+
'New Zealand Standard Time': 'Pacific/Auckland',
|
|
96
|
+
'Newfoundland Standard Time': 'America/St_Johns',
|
|
97
|
+
'Norfolk Standard Time': 'Pacific/Norfolk',
|
|
98
|
+
'North Asia East Standard Time': 'Asia/Irkutsk',
|
|
99
|
+
'North Asia Standard Time': 'Asia/Krasnoyarsk',
|
|
100
|
+
'North Korea Standard Time': 'Asia/Pyongyang',
|
|
101
|
+
'Omsk Standard Time': 'Asia/Omsk',
|
|
102
|
+
'Pacific SA Standard Time': 'America/Santiago',
|
|
103
|
+
'Pacific Standard Time': 'America/Los_Angeles',
|
|
104
|
+
'Pacific Standard Time (Mexico)': 'America/Tijuana',
|
|
105
|
+
'Pakistan Standard Time': 'Asia/Karachi',
|
|
106
|
+
'Paraguay Standard Time': 'America/Asuncion',
|
|
107
|
+
'Qyzylorda Standard Time': 'Asia/Qyzylorda',
|
|
108
|
+
'Romance Standard Time': 'Europe/Paris',
|
|
109
|
+
'Russia Time Zone 10': 'Asia/Srednekolymsk',
|
|
110
|
+
'Russia Time Zone 11': 'Asia/Kamchatka',
|
|
111
|
+
'Russia Time Zone 3': 'Europe/Samara',
|
|
112
|
+
'Russian Standard Time': 'Europe/Moscow',
|
|
113
|
+
'SA Eastern Standard Time': 'America/Cayenne',
|
|
114
|
+
'SA Pacific Standard Time': 'America/Bogota',
|
|
115
|
+
'SA Western Standard Time': 'America/La_Paz',
|
|
116
|
+
'SE Asia Standard Time': 'Asia/Bangkok',
|
|
117
|
+
'Saint Pierre Standard Time': 'America/Miquelon',
|
|
118
|
+
'Sakhalin Standard Time': 'Asia/Sakhalin',
|
|
119
|
+
'Samoa Standard Time': 'Pacific/Apia',
|
|
120
|
+
'Sao Tome Standard Time': 'Africa/Sao_Tome',
|
|
121
|
+
'Saratov Standard Time': 'Europe/Saratov',
|
|
122
|
+
'Singapore Standard Time': 'Asia/Singapore',
|
|
123
|
+
'South Africa Standard Time': 'Africa/Johannesburg',
|
|
124
|
+
'South Sudan Standard Time': 'Africa/Juba',
|
|
125
|
+
'Sri Lanka Standard Time': 'Asia/Colombo',
|
|
126
|
+
'Sudan Standard Time': 'Africa/Khartoum',
|
|
127
|
+
'Syria Standard Time': 'Asia/Damascus',
|
|
128
|
+
'Taipei Standard Time': 'Asia/Taipei',
|
|
129
|
+
'Tasmania Standard Time': 'Australia/Hobart',
|
|
130
|
+
'Tocantins Standard Time': 'America/Araguaina',
|
|
131
|
+
'Tokyo Standard Time': 'Asia/Tokyo',
|
|
132
|
+
'Tomsk Standard Time': 'Asia/Tomsk',
|
|
133
|
+
'Tonga Standard Time': 'Pacific/Tongatapu',
|
|
134
|
+
'Transbaikal Standard Time': 'Asia/Chita',
|
|
135
|
+
'Turkey Standard Time': 'Europe/Istanbul',
|
|
136
|
+
'Turks And Caicos Standard Time': 'America/Grand_Turk',
|
|
137
|
+
'US Eastern Standard Time': 'America/Indianapolis',
|
|
138
|
+
'US Mountain Standard Time': 'America/Phoenix',
|
|
139
|
+
UTC: 'Etc/UTC',
|
|
140
|
+
'UTC+12': 'Etc/GMT-12',
|
|
141
|
+
'UTC+13': 'Etc/GMT-13',
|
|
142
|
+
'UTC-02': 'Etc/GMT+2',
|
|
143
|
+
'UTC-08': 'Etc/GMT+8',
|
|
144
|
+
'UTC-09': 'Etc/GMT+9',
|
|
145
|
+
'UTC-11': 'Etc/GMT+11',
|
|
146
|
+
'Ulaanbaatar Standard Time': 'Asia/Ulaanbaatar',
|
|
147
|
+
'Venezuela Standard Time': 'America/Caracas',
|
|
148
|
+
'Vladivostok Standard Time': 'Asia/Vladivostok',
|
|
149
|
+
'Volgograd Standard Time': 'Europe/Volgograd',
|
|
150
|
+
'W. Australia Standard Time': 'Australia/Perth',
|
|
151
|
+
'W. Central Africa Standard Time': 'Africa/Lagos',
|
|
152
|
+
'W. Europe Standard Time': 'Europe/Berlin',
|
|
153
|
+
'W. Mongolia Standard Time': 'Asia/Hovd',
|
|
154
|
+
'West Asia Standard Time': 'Asia/Tashkent',
|
|
155
|
+
'West Bank Standard Time': 'Asia/Hebron',
|
|
156
|
+
'West Pacific Standard Time': 'Pacific/Port_Moresby',
|
|
157
|
+
'Yakutsk Standard Time': 'Asia/Yakutsk',
|
|
158
|
+
'Yukon Standard Time': 'America/Whitehorse'
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=windowsToIanaTable.js.map
|
|
@@ -4,6 +4,13 @@ import * as ExpoLocation from 'expo-location';
|
|
|
4
4
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { Logger } from "../logger/index.js";
|
|
6
6
|
import { Permissions } from "../permissions/index.js";
|
|
7
|
+
// expo-location is a REQUIRED peer (unlike the other Expo permission
|
|
8
|
+
// packages, which are optional and registered only when an app opts in by
|
|
9
|
+
// importing their own entry point) — anything that reaches this module
|
|
10
|
+
// already forces Metro to resolve expo-location, so self-registering its
|
|
11
|
+
// permission kinds here costs nothing extra and makes Geolocation's
|
|
12
|
+
// permission gating work without a separate app-level import.
|
|
13
|
+
import "../permissions/location.js";
|
|
7
14
|
import { adaptExpoLocation } from "./adapters/expoLocation.js";
|
|
8
15
|
const PREFIX = '[@webority-technologies/mobile-core]';
|
|
9
16
|
export class GeolocationError extends Error {
|
|
@@ -131,7 +138,7 @@ const ensureLocationPermission = async () => {
|
|
|
131
138
|
return;
|
|
132
139
|
}
|
|
133
140
|
if (status === 'unavailable') {
|
|
134
|
-
Logger.warn(`${PREFIX} Location permission status is unavailable (
|
|
141
|
+
Logger.warn(`${PREFIX} Location permission status is unavailable (expo-location is not installed, ` + 'or the check failed); attempting the location request anyway.');
|
|
135
142
|
return;
|
|
136
143
|
}
|
|
137
144
|
throw new GeolocationError('permission-denied', `${PREFIX} Location permission is "${status}". Grant it before requesting a position` + (status === 'blocked' ? ', or call Permissions.openSettings() to let the user fix it.' : '.'));
|
package/lib/module/index.js
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* for anyone importing anything at all. Those live behind their own import
|
|
8
8
|
* paths instead:
|
|
9
9
|
*
|
|
10
|
-
* @webority-technologies/mobile-core/permissions
|
|
10
|
+
* @webority-technologies/mobile-core/permissions per kind, its own Expo module
|
|
11
11
|
* @webority-technologies/mobile-core/compressor react-native-compressor
|
|
12
12
|
* @webority-technologies/mobile-core/geolocation a geolocation provider
|
|
13
|
-
* @webority-technologies/mobile-core/sqlite
|
|
13
|
+
* @webority-technologies/mobile-core/sqlite expo-sqlite
|
|
14
14
|
* @webority-technologies/mobile-core/download a filesystem module
|
|
15
|
+
* @webority-technologies/mobile-core/smsRetriever Android only, own TurboModule
|
|
15
16
|
*
|
|
16
17
|
* react-native-keychain is the exception and is a REQUIRED peer: the HTTP client
|
|
17
18
|
* reads the bearer token, so it is reachable from the main barrel by design.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { registerPermissionAdapter } from "./index.js";
|
|
4
|
+
|
|
5
|
+
/** The one place `expo-calendar` is named. Import only if you use calendar/reminders. */
|
|
6
|
+
const m = require('expo-calendar');
|
|
7
|
+
registerPermissionAdapter('calendar', {
|
|
8
|
+
check: m.getCalendarPermissionsAsync,
|
|
9
|
+
request: m.requestCalendarPermissionsAsync
|
|
10
|
+
});
|
|
11
|
+
registerPermissionAdapter('reminders', {
|
|
12
|
+
check: m.getRemindersPermissionsAsync,
|
|
13
|
+
request: m.requestRemindersPermissionsAsync
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=calendar.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { registerPermissionAdapter } from "./index.js";
|
|
4
|
+
|
|
5
|
+
/** The one place `expo-camera` is named. Import only if you use camera/microphone. */
|
|
6
|
+
const m = require('expo-camera');
|
|
7
|
+
registerPermissionAdapter('camera', {
|
|
8
|
+
check: m.getCameraPermissionsAsync,
|
|
9
|
+
request: m.requestCameraPermissionsAsync
|
|
10
|
+
});
|
|
11
|
+
registerPermissionAdapter('microphone', {
|
|
12
|
+
check: m.getMicrophonePermissionsAsync,
|
|
13
|
+
request: m.requestMicrophonePermissionsAsync
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=camera.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { registerPermissionAdapter } from "./index.js";
|
|
4
|
+
|
|
5
|
+
/** The one place `expo-contacts` is named. Import only if you use contacts. */
|
|
6
|
+
const m = require('expo-contacts');
|
|
7
|
+
registerPermissionAdapter('contacts', {
|
|
8
|
+
check: m.getPermissionsAsync,
|
|
9
|
+
request: m.requestPermissionsAsync
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=contacts.js.map
|
|
@@ -1,202 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Linking
|
|
3
|
+
import { Linking } from 'react-native';
|
|
4
4
|
import { Logger } from "../logger/index.js";
|
|
5
5
|
|
|
6
6
|
// Android only — legacy WRITE_EXTERNAL_STORAGE
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (resolved) {
|
|
12
|
-
return permsModule;
|
|
13
|
-
}
|
|
14
|
-
resolved = true;
|
|
15
|
-
try {
|
|
16
|
-
const mod = require('react-native-permissions');
|
|
17
|
-
permsModule = mod.default ?? mod;
|
|
18
|
-
} catch {
|
|
19
|
-
Logger.warn('[permissions] react-native-permissions is not installed; ' + 'permission checks will report "unavailable".');
|
|
20
|
-
permsModule = null;
|
|
21
|
-
}
|
|
22
|
-
return permsModule;
|
|
23
|
-
};
|
|
8
|
+
/** The shared response shape every Expo permission function returns. */
|
|
9
|
+
|
|
10
|
+
let backend = null;
|
|
24
11
|
|
|
25
12
|
/**
|
|
26
|
-
* Inject a custom permissions
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* `resolved` goes FALSE on null, never true. Marking it resolved with a null
|
|
30
|
-
* backend would permanently disable permissions: the resolver short-circuits and the
|
|
31
|
-
* real module is never loaded again, which contradicts this function's own
|
|
32
|
-
* documented contract. That exact bug shipped once, in the storage seam.
|
|
13
|
+
* Inject a custom permissions backend at runtime. Pass `null` to reset to the
|
|
14
|
+
* default per-kind Expo resolution.
|
|
33
15
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* so on), so there is no single object to adapt and the library must not guess
|
|
38
|
-
* which Expo modules an app installed. react-native-permissions stays, behind
|
|
39
|
-
* this module's own import path so an app that never asks for permissions
|
|
40
|
-
* never names the package to Metro.
|
|
16
|
+
* Two legitimate reasons to call this: tests/the showcase reaching a denied,
|
|
17
|
+
* blocked or unavailable path a healthy device never takes; and an app that
|
|
18
|
+
* genuinely needs `bluetooth` or `storage`, which no Expo module covers.
|
|
41
19
|
*/
|
|
42
20
|
export const setPermissionsImplementation = impl => {
|
|
43
|
-
|
|
44
|
-
resolved = impl !== null;
|
|
21
|
+
backend = impl;
|
|
45
22
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return IOS.MEDIA_LIBRARY ?? null;
|
|
67
|
-
case 'location':
|
|
68
|
-
return IOS.LOCATION_WHEN_IN_USE ?? null;
|
|
69
|
-
case 'locationAlways':
|
|
70
|
-
return IOS.LOCATION_ALWAYS ?? null;
|
|
71
|
-
case 'contacts':
|
|
72
|
-
return IOS.CONTACTS ?? null;
|
|
73
|
-
case 'calendar':
|
|
74
|
-
return IOS.CALENDARS ?? null;
|
|
75
|
-
case 'reminders':
|
|
76
|
-
return IOS.REMINDERS ?? null;
|
|
77
|
-
case 'notifications':
|
|
78
|
-
return null;
|
|
79
|
-
// handled separately on iOS
|
|
80
|
-
case 'bluetooth':
|
|
81
|
-
return IOS.BLUETOOTH ?? null;
|
|
82
|
-
case 'storage':
|
|
83
|
-
return null;
|
|
84
|
-
default:
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
switch (kind) {
|
|
89
|
-
case 'camera':
|
|
90
|
-
return ANDROID.CAMERA ?? null;
|
|
91
|
-
case 'microphone':
|
|
92
|
-
return ANDROID.RECORD_AUDIO ?? null;
|
|
93
|
-
case 'photos':
|
|
94
|
-
case 'mediaLibrary':
|
|
95
|
-
return ANDROID.READ_MEDIA_IMAGES ?? ANDROID.READ_EXTERNAL_STORAGE ?? null;
|
|
96
|
-
case 'photosAdd':
|
|
97
|
-
return ANDROID.READ_MEDIA_IMAGES ?? null;
|
|
98
|
-
case 'location':
|
|
99
|
-
case 'locationAlways':
|
|
100
|
-
return ANDROID.ACCESS_FINE_LOCATION ?? null;
|
|
101
|
-
case 'contacts':
|
|
102
|
-
return ANDROID.READ_CONTACTS ?? null;
|
|
103
|
-
case 'calendar':
|
|
104
|
-
return ANDROID.READ_CALENDAR ?? null;
|
|
105
|
-
case 'reminders':
|
|
106
|
-
return null;
|
|
107
|
-
case 'notifications':
|
|
108
|
-
return ANDROID.POST_NOTIFICATIONS ?? null;
|
|
109
|
-
case 'bluetooth':
|
|
110
|
-
return ANDROID.BLUETOOTH_CONNECT ?? null;
|
|
111
|
-
case 'storage':
|
|
112
|
-
return ANDROID.WRITE_EXTERNAL_STORAGE ?? null;
|
|
113
|
-
default:
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Populated by the per-package entry points (`./camera`, `./photos`, …), never
|
|
26
|
+
* by this file. This module names NO Expo package — Metro resolves every
|
|
27
|
+
* literal require() reachable from the static import graph regardless of
|
|
28
|
+
* which switch branch would have run, so naming seven packages here would
|
|
29
|
+
* make each one a mandatory install for every consumer, whichever kinds they
|
|
30
|
+
* actually use. An app wires only the kinds it needs:
|
|
31
|
+
*
|
|
32
|
+
* import '@webority-technologies/mobile-core/permissions/camera';
|
|
33
|
+
* import '@webority-technologies/mobile-core/permissions/location';
|
|
34
|
+
*
|
|
35
|
+
* `bluetooth` and `storage` have no Expo module and are never registered here
|
|
36
|
+
* — they resolve through `setPermissionsImplementation` only.
|
|
37
|
+
*/
|
|
38
|
+
const registry = new Map();
|
|
39
|
+
|
|
40
|
+
/** Called by the per-package entry points to register their kind(s). Not for app code. */
|
|
41
|
+
export const registerPermissionAdapter = (kind, fns) => {
|
|
42
|
+
registry.set(kind, fns);
|
|
116
43
|
};
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
if (!
|
|
44
|
+
const resolveExpoModule = kind => registry.get(kind) ?? null;
|
|
45
|
+
const toStatus = response => {
|
|
46
|
+
if (!response) {
|
|
120
47
|
return 'unavailable';
|
|
121
48
|
}
|
|
122
|
-
|
|
123
|
-
RESULTS
|
|
124
|
-
} = m;
|
|
125
|
-
if (raw === RESULTS.GRANTED) {
|
|
126
|
-
return 'granted';
|
|
127
|
-
}
|
|
128
|
-
if (raw === RESULTS.DENIED) {
|
|
129
|
-
return 'denied';
|
|
130
|
-
}
|
|
131
|
-
if (raw === RESULTS.LIMITED) {
|
|
49
|
+
if (response.accessPrivileges === 'limited') {
|
|
132
50
|
return 'limited';
|
|
133
51
|
}
|
|
134
|
-
if (
|
|
135
|
-
return '
|
|
52
|
+
if (response.status === 'granted') {
|
|
53
|
+
return 'granted';
|
|
136
54
|
}
|
|
137
|
-
|
|
55
|
+
if (response.status === 'denied') {
|
|
56
|
+
return response.canAskAgain ? 'denied' : 'blocked';
|
|
57
|
+
}
|
|
58
|
+
// 'undetermined' — never asked yet. Treated as 'denied' so callers using
|
|
59
|
+
// Permissions.ensure() correctly trigger a request() rather than stalling.
|
|
60
|
+
return 'denied';
|
|
138
61
|
};
|
|
139
62
|
const checkPermission = async kind => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return 'unavailable';
|
|
63
|
+
if (backend) {
|
|
64
|
+
return backend.check(kind);
|
|
143
65
|
}
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
66
|
+
const fns = resolveExpoModule(kind);
|
|
67
|
+
if (!fns) {
|
|
146
68
|
return 'unavailable';
|
|
147
69
|
}
|
|
148
70
|
try {
|
|
149
|
-
|
|
150
|
-
return mapResult(raw);
|
|
71
|
+
return toStatus(await fns.check());
|
|
151
72
|
} catch (error) {
|
|
152
73
|
Logger.error(`[permissions] check(${kind}) failed`, error);
|
|
153
74
|
return 'unavailable';
|
|
154
75
|
}
|
|
155
76
|
};
|
|
156
77
|
const requestPermission = async kind => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return 'unavailable';
|
|
78
|
+
if (backend) {
|
|
79
|
+
return backend.request(kind);
|
|
160
80
|
}
|
|
161
|
-
const
|
|
162
|
-
if (!
|
|
81
|
+
const fns = resolveExpoModule(kind);
|
|
82
|
+
if (!fns) {
|
|
163
83
|
return 'unavailable';
|
|
164
84
|
}
|
|
165
85
|
try {
|
|
166
|
-
|
|
167
|
-
return mapResult(raw);
|
|
86
|
+
return toStatus(await fns.request());
|
|
168
87
|
} catch (error) {
|
|
169
88
|
Logger.error(`[permissions] request(${kind}) failed`, error);
|
|
170
89
|
return 'unavailable';
|
|
171
90
|
}
|
|
172
91
|
};
|
|
173
92
|
const openAppSettings = async () => {
|
|
174
|
-
const m = resolveModule();
|
|
175
|
-
if (!m) {
|
|
176
|
-
try {
|
|
177
|
-
await Linking.openSettings();
|
|
178
|
-
return true;
|
|
179
|
-
} catch (error) {
|
|
180
|
-
Logger.error('[permissions] openAppSettings fallback failed', error);
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
93
|
try {
|
|
185
|
-
await
|
|
94
|
+
await Linking.openSettings();
|
|
186
95
|
return true;
|
|
187
96
|
} catch (error) {
|
|
188
|
-
Logger.error('[permissions]
|
|
97
|
+
Logger.error('[permissions] openAppSettings failed', error);
|
|
189
98
|
return false;
|
|
190
99
|
}
|
|
191
100
|
};
|
|
192
101
|
|
|
193
102
|
/**
|
|
194
103
|
* Cross-platform permissions wrapper. Maps an abstract `PermissionKind`
|
|
195
|
-
* (camera, photos, location, notifications, …) to
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
104
|
+
* (camera, photos, location, notifications, …) to whichever Expo adapter an
|
|
105
|
+
* app has registered by importing that kind's entry point — expo-camera,
|
|
106
|
+
* expo-image-picker, expo-location, expo-contacts, expo-calendar,
|
|
107
|
+
* expo-notifications, expo-media-library. An app imports only the entry
|
|
108
|
+
* points for the kinds it actually asks for.
|
|
200
109
|
*/
|
|
201
110
|
export const Permissions = {
|
|
202
111
|
check: checkPermission,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { registerPermissionAdapter } from "./index.js";
|
|
4
|
+
|
|
5
|
+
/** The one place `expo-location` is named. Import only if you use location/locationAlways. */
|
|
6
|
+
const m = require('expo-location');
|
|
7
|
+
registerPermissionAdapter('location', {
|
|
8
|
+
check: m.getForegroundPermissionsAsync,
|
|
9
|
+
request: m.requestForegroundPermissionsAsync
|
|
10
|
+
});
|
|
11
|
+
registerPermissionAdapter('locationAlways', {
|
|
12
|
+
check: m.getBackgroundPermissionsAsync,
|
|
13
|
+
request: m.requestBackgroundPermissionsAsync
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=location.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { registerPermissionAdapter } from "./index.js";
|
|
4
|
+
|
|
5
|
+
/** The one place `expo-media-library` is named. Import only if you use mediaLibrary. */
|
|
6
|
+
const m = require('expo-media-library');
|
|
7
|
+
registerPermissionAdapter('mediaLibrary', {
|
|
8
|
+
check: m.getPermissionsAsync,
|
|
9
|
+
request: m.requestPermissionsAsync
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=mediaLibrary.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { registerPermissionAdapter } from "./index.js";
|
|
4
|
+
|
|
5
|
+
/** The one place `expo-notifications` is named. Import only if you use notifications. */
|
|
6
|
+
const m = require('expo-notifications');
|
|
7
|
+
registerPermissionAdapter('notifications', {
|
|
8
|
+
check: m.getPermissionsAsync,
|
|
9
|
+
request: m.requestPermissionsAsync
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { registerPermissionAdapter } from "./index.js";
|
|
4
|
+
|
|
5
|
+
/** The one place `expo-image-picker` is named. Import only if you use photos/photosAdd. */
|
|
6
|
+
const m = require('expo-image-picker');
|
|
7
|
+
registerPermissionAdapter('photos', {
|
|
8
|
+
check: () => m.getMediaLibraryPermissionsAsync(false),
|
|
9
|
+
request: () => m.requestMediaLibraryPermissionsAsync(false)
|
|
10
|
+
});
|
|
11
|
+
registerPermissionAdapter('photosAdd', {
|
|
12
|
+
check: () => m.getMediaLibraryPermissionsAsync(true),
|
|
13
|
+
request: () => m.requestMediaLibraryPermissionsAsync(true)
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=photos.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { DeviceEventEmitter, Platform } from 'react-native';
|
|
4
|
+
import { Logger } from "../logger/index.js";
|
|
5
|
+
const OTP_EVENT = 'WeborityMobileCoreSmsRetrieved';
|
|
6
|
+
const ERROR_EVENT = 'WeborityMobileCoreSmsRetrieverError';
|
|
7
|
+
let backend = null;
|
|
8
|
+
|
|
9
|
+
/** Test-only injection point. Pass `null` to reset to the native module. */
|
|
10
|
+
export const setSmsRetrieverImplementation = impl => {
|
|
11
|
+
backend = impl;
|
|
12
|
+
};
|
|
13
|
+
let nativeModule;
|
|
14
|
+
const resolveNativeModule = () => {
|
|
15
|
+
if (nativeModule !== undefined) {
|
|
16
|
+
return nativeModule;
|
|
17
|
+
}
|
|
18
|
+
if (Platform.OS !== 'android') {
|
|
19
|
+
nativeModule = null;
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
nativeModule = require('../specs/NativeSmsRetriever').default ?? null;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
Logger.warn('[smsRetriever] native module not available', error);
|
|
26
|
+
nativeModule = null;
|
|
27
|
+
}
|
|
28
|
+
return nativeModule ?? null;
|
|
29
|
+
};
|
|
30
|
+
const defaultBackend = {
|
|
31
|
+
getAppHash: async () => {
|
|
32
|
+
const m = resolveNativeModule();
|
|
33
|
+
if (!m) {
|
|
34
|
+
throw new Error('[smsRetriever] getAppHash: native module unavailable (Android only).');
|
|
35
|
+
}
|
|
36
|
+
return m.getAppHash();
|
|
37
|
+
},
|
|
38
|
+
startListening: (onMessage, onError) => {
|
|
39
|
+
const m = resolveNativeModule();
|
|
40
|
+
if (!m) {
|
|
41
|
+
onError?.({
|
|
42
|
+
type: 'SERVICE_UNAVAILABLE',
|
|
43
|
+
message: 'SMS Retriever is Android-only, or the native module is not linked.'
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
remove: () => undefined
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const messageSub = DeviceEventEmitter.addListener(OTP_EVENT, payload => onMessage(payload.message));
|
|
50
|
+
const errorSub = onError ? DeviceEventEmitter.addListener(ERROR_EVENT, payload => onError(payload)) : null;
|
|
51
|
+
try {
|
|
52
|
+
m.startSMSListener();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
Logger.error('[smsRetriever] startSMSListener failed', error);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
remove: () => {
|
|
58
|
+
messageSub.remove();
|
|
59
|
+
errorSub?.remove();
|
|
60
|
+
try {
|
|
61
|
+
m.stopSMSListener();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
Logger.error('[smsRetriever] stopSMSListener failed', error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The Play Services SMS Retriever API — auto-reads an incoming OTP SMS with
|
|
72
|
+
* no SMS permission, matched by an 11-character app-signature hash
|
|
73
|
+
* (`getAppHash`) the backend appends to the message. Android only; every
|
|
74
|
+
* method is safe to call on iOS and resolves/reports unavailable rather than
|
|
75
|
+
* throwing, so a caller doesn't need a platform check at every call site.
|
|
76
|
+
*
|
|
77
|
+
* OTP extraction is left to the caller — `onMessage` receives the raw SMS
|
|
78
|
+
* text, since the expected OTP format (digit count, prefix) is a backend
|
|
79
|
+
* concern, not this module's.
|
|
80
|
+
*/
|
|
81
|
+
export const SmsRetriever = {
|
|
82
|
+
isAvailable: () => resolveNativeModule() !== null,
|
|
83
|
+
getAppHash: () => (backend ?? defaultBackend).getAppHash(),
|
|
84
|
+
startListening: (onMessage, onError) => (backend ?? defaultBackend).startListening(onMessage, onError)
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=index.js.map
|