@webority/mobile-core 0.0.29 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/lib/commonjs/api/baseUrl.js +1 -34
  2. package/lib/commonjs/api/curl.js +1 -109
  3. package/lib/commonjs/api/multipart.js +1 -21
  4. package/lib/commonjs/api/publicClient.js +1 -79
  5. package/lib/commonjs/api/responseBodyText.js +1 -0
  6. package/lib/commonjs/api/retry.js +1 -91
  7. package/lib/commonjs/api/tokenRefresh.js +1 -205
  8. package/lib/commonjs/api/userClient.js +1 -265
  9. package/lib/commonjs/auth/authStore.js +1 -265
  10. package/lib/commonjs/auth/index.js +1 -44
  11. package/lib/commonjs/auth/jwt.js +1 -112
  12. package/lib/commonjs/config/index.js +1 -72
  13. package/lib/commonjs/deepLink/index.js +1 -286
  14. package/lib/commonjs/download/adapters/expoFs.js +1 -69
  15. package/lib/commonjs/download/adapters/shared.js +1 -13
  16. package/lib/commonjs/download/index.js +1 -250
  17. package/lib/commonjs/formatters/currency.js +1 -70
  18. package/lib/commonjs/formatters/date.js +1 -167
  19. package/lib/commonjs/formatters/dateMath.js +1 -311
  20. package/lib/commonjs/formatters/index.js +1 -246
  21. package/lib/commonjs/formatters/initials.js +1 -32
  22. package/lib/commonjs/formatters/intlCache.js +1 -37
  23. package/lib/commonjs/formatters/number.js +1 -89
  24. package/lib/commonjs/formatters/phone.js +1 -369
  25. package/lib/commonjs/formatters/windowsToIanaTable.js +1 -164
  26. package/lib/commonjs/geolocation/adapters/expoLocation.js +1 -126
  27. package/lib/commonjs/geolocation/index.js +1 -355
  28. package/lib/commonjs/index.js +1 -644
  29. package/lib/commonjs/initSDK.js +1 -66
  30. package/lib/commonjs/initUserAuth.js +1 -37
  31. package/lib/commonjs/logger/crashlytics.js +1 -0
  32. package/lib/commonjs/logger/index.js +1 -301
  33. package/lib/commonjs/logger/redact.js +1 -50
  34. package/lib/commonjs/network/index.js +1 -31
  35. package/lib/commonjs/network/networkStatus.js +1 -171
  36. package/lib/commonjs/permissions/calendar.js +1 -14
  37. package/lib/commonjs/permissions/camera.js +1 -14
  38. package/lib/commonjs/permissions/contacts.js +1 -10
  39. package/lib/commonjs/permissions/index.js +1 -133
  40. package/lib/commonjs/permissions/location.js +1 -14
  41. package/lib/commonjs/permissions/mediaLibrary.js +1 -10
  42. package/lib/commonjs/permissions/notifications.js +1 -10
  43. package/lib/commonjs/permissions/photos.js +1 -14
  44. package/lib/commonjs/phone/countries.js +1 -265
  45. package/lib/commonjs/push/index.js +1 -61
  46. package/lib/commonjs/push/push.js +1 -468
  47. package/lib/commonjs/push/status.js +1 -0
  48. package/lib/commonjs/push/task.js +1 -43
  49. package/lib/commonjs/secureScreen/index.js +1 -0
  50. package/lib/commonjs/share/index.js +1 -70
  51. package/lib/commonjs/smsRetriever/index.js +1 -91
  52. package/lib/commonjs/specs/NativeSmsRetriever.js +1 -15
  53. package/lib/commonjs/sqlite/adapters/expo.js +1 -53
  54. package/lib/commonjs/sqlite/index.js +1 -604
  55. package/lib/commonjs/storage/index.js +1 -214
  56. package/lib/commonjs/types/axios.js +1 -4
  57. package/lib/commonjs/types/globals.d.js +1 -6
  58. package/lib/commonjs/utils/base64.js +1 -24
  59. package/lib/commonjs/utils/imageCompression.js +1 -389
  60. package/lib/commonjs/utils/index.js +1 -19
  61. package/lib/commonjs/validators/index.js +1 -227
  62. package/lib/commonjs/versionCheck/index.js +1 -419
  63. package/lib/module/api/baseUrl.js +1 -30
  64. package/lib/module/api/curl.js +1 -104
  65. package/lib/module/api/multipart.js +1 -16
  66. package/lib/module/api/publicClient.js +1 -75
  67. package/lib/module/api/responseBodyText.js +1 -0
  68. package/lib/module/api/retry.js +1 -85
  69. package/lib/module/api/tokenRefresh.js +1 -192
  70. package/lib/module/api/userClient.js +1 -243
  71. package/lib/module/auth/authStore.js +1 -257
  72. package/lib/module/auth/index.js +1 -5
  73. package/lib/module/auth/jwt.js +1 -106
  74. package/lib/module/config/index.js +1 -64
  75. package/lib/module/deepLink/index.js +1 -280
  76. package/lib/module/download/adapters/expoFs.js +1 -64
  77. package/lib/module/download/adapters/shared.js +1 -8
  78. package/lib/module/download/index.js +1 -242
  79. package/lib/module/formatters/currency.js +1 -65
  80. package/lib/module/formatters/date.js +1 -159
  81. package/lib/module/formatters/dateMath.js +1 -295
  82. package/lib/module/formatters/index.js +1 -9
  83. package/lib/module/formatters/initials.js +1 -27
  84. package/lib/module/formatters/intlCache.js +1 -30
  85. package/lib/module/formatters/number.js +1 -82
  86. package/lib/module/formatters/phone.js +1 -302
  87. package/lib/module/formatters/windowsToIanaTable.js +1 -160
  88. package/lib/module/geolocation/adapters/expoLocation.js +1 -121
  89. package/lib/module/geolocation/index.js +1 -347
  90. package/lib/module/index.js +1 -57
  91. package/lib/module/initSDK.js +1 -61
  92. package/lib/module/initUserAuth.js +1 -33
  93. package/lib/module/logger/crashlytics.js +1 -0
  94. package/lib/module/logger/index.js +1 -295
  95. package/lib/module/logger/redact.js +1 -44
  96. package/lib/module/network/index.js +1 -4
  97. package/lib/module/network/networkStatus.js +1 -161
  98. package/lib/module/permissions/calendar.js +1 -15
  99. package/lib/module/permissions/camera.js +1 -15
  100. package/lib/module/permissions/contacts.js +1 -11
  101. package/lib/module/permissions/index.js +1 -128
  102. package/lib/module/permissions/location.js +1 -15
  103. package/lib/module/permissions/mediaLibrary.js +1 -11
  104. package/lib/module/permissions/notifications.js +1 -11
  105. package/lib/module/permissions/photos.js +1 -15
  106. package/lib/module/phone/countries.js +1 -261
  107. package/lib/module/push/index.js +1 -4
  108. package/lib/module/push/push.js +1 -452
  109. package/lib/module/push/status.js +1 -0
  110. package/lib/module/push/task.js +1 -38
  111. package/lib/module/secureScreen/index.js +1 -0
  112. package/lib/module/share/index.js +1 -64
  113. package/lib/module/smsRetriever/index.js +1 -86
  114. package/lib/module/specs/NativeSmsRetriever.js +1 -13
  115. package/lib/module/sqlite/adapters/expo.js +1 -48
  116. package/lib/module/sqlite/index.js +1 -594
  117. package/lib/module/storage/index.js +1 -208
  118. package/lib/module/types/axios.js +1 -4
  119. package/lib/module/types/globals.d.js +1 -10
  120. package/lib/module/utils/base64.js +1 -19
  121. package/lib/module/utils/imageCompression.js +1 -383
  122. package/lib/module/utils/index.js +1 -4
  123. package/lib/module/validators/index.js +1 -205
  124. package/lib/module/versionCheck/index.js +1 -413
  125. package/lib/typescript/commonjs/api/responseBodyText.d.ts +6 -0
  126. package/lib/typescript/commonjs/index.d.ts +5 -0
  127. package/lib/typescript/commonjs/logger/crashlytics.d.ts +31 -0
  128. package/lib/typescript/commonjs/push/index.d.ts +3 -1
  129. package/lib/typescript/commonjs/push/push.d.ts +1 -1
  130. package/lib/typescript/commonjs/push/status.d.ts +9 -0
  131. package/lib/typescript/commonjs/secureScreen/index.d.ts +25 -0
  132. package/lib/typescript/module/api/responseBodyText.d.ts +6 -0
  133. package/lib/typescript/module/index.d.ts +5 -0
  134. package/lib/typescript/module/logger/crashlytics.d.ts +31 -0
  135. package/lib/typescript/module/push/index.d.ts +3 -1
  136. package/lib/typescript/module/push/push.d.ts +1 -1
  137. package/lib/typescript/module/push/status.d.ts +9 -0
  138. package/lib/typescript/module/secureScreen/index.d.ts +25 -0
  139. package/package.json +23 -4
@@ -0,0 +1,31 @@
1
+ import type { RemoteLogger } from './index';
2
+ /**
3
+ * The part of `@react-native-firebase/crashlytics`'s modular API the adapter
4
+ * calls. Typed here, never imported, so the library carries no Firebase
5
+ * dependency: the app passes the module it already installs.
6
+ */
7
+ export interface CrashlyticsModule<Instance = unknown> {
8
+ getCrashlytics: () => Instance;
9
+ log: (crashlytics: Instance, message: string) => void;
10
+ recordError: (crashlytics: Instance, error: Error, jsErrorName?: string) => void;
11
+ setUserId: (crashlytics: Instance, userId: string) => Promise<unknown>;
12
+ setAttribute: (crashlytics: Instance, name: string, value: string) => Promise<unknown>;
13
+ }
14
+ /**
15
+ * Builds the `setRemoteLogger` adapter for Firebase Crashlytics:
16
+ *
17
+ * ```ts
18
+ * import * as crashlytics from '@react-native-firebase/crashlytics';
19
+ * import { crashlyticsRemoteLogger, setRemoteLogger } from '@webority/mobile-core';
20
+ *
21
+ * setRemoteLogger(crashlyticsRemoteLogger(crashlytics));
22
+ * ```
23
+ *
24
+ * Breadcrumbs and log lines become Crashlytics log lines, errors become
25
+ * non-fatals with their context logged just before, and the user id and
26
+ * attributes are set as given. Every call swallows its own failure, sync or
27
+ * async: the adapter runs inside `Logger.error`, so a throw would recurse, and
28
+ * a build without its Firebase config files has no Firebase app to report to.
29
+ */
30
+ export declare const crashlyticsRemoteLogger: <Instance>(crashlytics: CrashlyticsModule<Instance>) => RemoteLogger;
31
+ //# sourceMappingURL=crashlytics.d.ts.map
@@ -1,3 +1,5 @@
1
- export type { PushAction, PushActionHandler, PushAndroidChannel, PushCategory, PushCategoryAction, PushConfig, PushDevice, PushLocalNotification, PushModules, PushNotificationsLike, PushPlatform, PushState, PushStatus } from './push';
1
+ export type { PushAction, PushActionHandler, PushAndroidChannel, PushCategory, PushCategoryAction, PushConfig, PushDevice, PushLocalNotification, PushModules, PushNotificationsLike, PushPlatform, PushState } from './push';
2
2
  export { disablePush, enablePush, initPush, notifyLocal, onAction, setBadgeCount, setCategories, setPushImplementation, usePush } from './push';
3
+ export type { PushStatus } from './status';
4
+ export { PUSH_STATUS } from './status';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,4 @@
1
+ import type { PushStatus } from './status';
1
2
  export type PushPlatform = 'Fcm' | 'Apns';
2
3
  export interface PushDevice {
3
4
  installationId: string;
@@ -62,7 +63,6 @@ export interface PushLocalNotification {
62
63
  body: string;
63
64
  data?: Record<string, string>;
64
65
  }
65
- export type PushStatus = 'unknown' | 'granted' | 'denied' | 'unavailable';
66
66
  export interface PushState {
67
67
  status: PushStatus;
68
68
  /** True once this process has registered the device, false after `disablePush`. */
@@ -0,0 +1,9 @@
1
+ /** The push permission values, as runtime constants an app can compare against. */
2
+ export declare const PUSH_STATUS: {
3
+ readonly unknown: "unknown";
4
+ readonly granted: "granted";
5
+ readonly denied: "denied";
6
+ readonly unavailable: "unavailable";
7
+ };
8
+ export type PushStatus = (typeof PUSH_STATUS)[keyof typeof PUSH_STATUS];
9
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1,25 @@
1
+ export interface SecureScreenOptions {
2
+ /**
3
+ * Whether the screen is the one on show. Pass React Navigation's
4
+ * `useIsFocused()`, so a secure screen left underneath a pushed screen stops
5
+ * blocking. Default `true`: block for as long as the component is mounted.
6
+ */
7
+ focused?: boolean;
8
+ }
9
+ /**
10
+ * Blocks capture while the calling screen is focused and releases it on blur
11
+ * or unmount. Each call holds its own claim, so two secure screens on the stack
12
+ * never release each other's protection.
13
+ *
14
+ * ```tsx
15
+ * import { useIsFocused } from '@react-navigation/native';
16
+ * import { useSecureScreen } from '@webority/mobile-core/secureScreen';
17
+ *
18
+ * const SignInScreen = () => {
19
+ * useSecureScreen({ focused: useIsFocused() });
20
+ * // ...
21
+ * };
22
+ * ```
23
+ */
24
+ export declare const useSecureScreen: (options?: SecureScreenOptions) => void;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A failed response's body as log text. A JSON error body is an object, which a
3
+ * template string prints as "[object Object]"; binary bodies are named by size.
4
+ */
5
+ export declare const responseBodyText: (body: unknown, fallback: string) => string;
6
+ //# sourceMappingURL=responseBodyText.d.ts.map
@@ -11,6 +11,7 @@
11
11
  * @webority/mobile-core/sqlite expo-sqlite
12
12
  * @webority/mobile-core/download a filesystem module
13
13
  * @webority/mobile-core/share expo-sharing
14
+ * @webority/mobile-core/secureScreen expo-screen-capture
14
15
  * @webority/mobile-core/smsRetriever Android only, own TurboModule
15
16
  *
16
17
  * One more path is separate for size, not for a native package:
@@ -44,8 +45,12 @@ export type { TokenRefreshConfig, TokenRefreshResult, UserAuthOptions } from './
44
45
  export { initUserAuth } from './initUserAuth.js';
45
46
  export type { DeviceContext, LoggerOptions, LoggerType, RemoteLogger } from './logger/index.js';
46
47
  export { configureLogger, getDeviceContext, Logger, setDeviceContext, setRemoteLogger } from './logger/index.js';
48
+ export type { CrashlyticsModule } from './logger/crashlytics.js';
49
+ export { crashlyticsRemoteLogger } from './logger/crashlytics.js';
47
50
  export type { NetworkConnectionType, NetworkStatus, NetworkStatusLike, NetworkStatusListener } from './network/index.js';
48
51
  export { addNetworkStatusListener, getNetworkStatus, setNetworkStatusImplementation, useNetworkStatus } from './network/index.js';
52
+ export type { PushStatus } from './push/status.js';
53
+ export { PUSH_STATUS } from './push/status.js';
49
54
  export type { AsyncStorageLike, StorageApi } from './storage/index.js';
50
55
  export { isStorageAvailable, Storage, setStorageImplementation } from './storage/index.js';
51
56
  export { encodeBase64 } from './utils/base64.js';
@@ -0,0 +1,31 @@
1
+ import type { RemoteLogger } from './index.js';
2
+ /**
3
+ * The part of `@react-native-firebase/crashlytics`'s modular API the adapter
4
+ * calls. Typed here, never imported, so the library carries no Firebase
5
+ * dependency: the app passes the module it already installs.
6
+ */
7
+ export interface CrashlyticsModule<Instance = unknown> {
8
+ getCrashlytics: () => Instance;
9
+ log: (crashlytics: Instance, message: string) => void;
10
+ recordError: (crashlytics: Instance, error: Error, jsErrorName?: string) => void;
11
+ setUserId: (crashlytics: Instance, userId: string) => Promise<unknown>;
12
+ setAttribute: (crashlytics: Instance, name: string, value: string) => Promise<unknown>;
13
+ }
14
+ /**
15
+ * Builds the `setRemoteLogger` adapter for Firebase Crashlytics:
16
+ *
17
+ * ```ts
18
+ * import * as crashlytics from '@react-native-firebase/crashlytics';
19
+ * import { crashlyticsRemoteLogger, setRemoteLogger } from '@webority/mobile-core';
20
+ *
21
+ * setRemoteLogger(crashlyticsRemoteLogger(crashlytics));
22
+ * ```
23
+ *
24
+ * Breadcrumbs and log lines become Crashlytics log lines, errors become
25
+ * non-fatals with their context logged just before, and the user id and
26
+ * attributes are set as given. Every call swallows its own failure, sync or
27
+ * async: the adapter runs inside `Logger.error`, so a throw would recurse, and
28
+ * a build without its Firebase config files has no Firebase app to report to.
29
+ */
30
+ export declare const crashlyticsRemoteLogger: <Instance>(crashlytics: CrashlyticsModule<Instance>) => RemoteLogger;
31
+ //# sourceMappingURL=crashlytics.d.ts.map
@@ -1,3 +1,5 @@
1
- export type { PushAction, PushActionHandler, PushAndroidChannel, PushCategory, PushCategoryAction, PushConfig, PushDevice, PushLocalNotification, PushModules, PushNotificationsLike, PushPlatform, PushState, PushStatus } from './push.js';
1
+ export type { PushAction, PushActionHandler, PushAndroidChannel, PushCategory, PushCategoryAction, PushConfig, PushDevice, PushLocalNotification, PushModules, PushNotificationsLike, PushPlatform, PushState } from './push.js';
2
2
  export { disablePush, enablePush, initPush, notifyLocal, onAction, setBadgeCount, setCategories, setPushImplementation, usePush } from './push.js';
3
+ export type { PushStatus } from './status.js';
4
+ export { PUSH_STATUS } from './status.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,4 @@
1
+ import type { PushStatus } from './status.js';
1
2
  export type PushPlatform = 'Fcm' | 'Apns';
2
3
  export interface PushDevice {
3
4
  installationId: string;
@@ -62,7 +63,6 @@ export interface PushLocalNotification {
62
63
  body: string;
63
64
  data?: Record<string, string>;
64
65
  }
65
- export type PushStatus = 'unknown' | 'granted' | 'denied' | 'unavailable';
66
66
  export interface PushState {
67
67
  status: PushStatus;
68
68
  /** True once this process has registered the device, false after `disablePush`. */
@@ -0,0 +1,9 @@
1
+ /** The push permission values, as runtime constants an app can compare against. */
2
+ export declare const PUSH_STATUS: {
3
+ readonly unknown: "unknown";
4
+ readonly granted: "granted";
5
+ readonly denied: "denied";
6
+ readonly unavailable: "unavailable";
7
+ };
8
+ export type PushStatus = (typeof PUSH_STATUS)[keyof typeof PUSH_STATUS];
9
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1,25 @@
1
+ export interface SecureScreenOptions {
2
+ /**
3
+ * Whether the screen is the one on show. Pass React Navigation's
4
+ * `useIsFocused()`, so a secure screen left underneath a pushed screen stops
5
+ * blocking. Default `true`: block for as long as the component is mounted.
6
+ */
7
+ focused?: boolean;
8
+ }
9
+ /**
10
+ * Blocks capture while the calling screen is focused and releases it on blur
11
+ * or unmount. Each call holds its own claim, so two secure screens on the stack
12
+ * never release each other's protection.
13
+ *
14
+ * ```tsx
15
+ * import { useIsFocused } from '@react-navigation/native';
16
+ * import { useSecureScreen } from '@webority/mobile-core/secureScreen';
17
+ *
18
+ * const SignInScreen = () => {
19
+ * useSecureScreen({ focused: useIsFocused() });
20
+ * // ...
21
+ * };
22
+ * ```
23
+ */
24
+ export declare const useSecureScreen: (options?: SecureScreenOptions) => void;
25
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-core",
3
- "version": "0.0.29",
3
+ "version": "0.1.0",
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",
@@ -161,6 +161,16 @@
161
161
  "default": "./lib/commonjs/share/index.js"
162
162
  }
163
163
  },
164
+ "./secureScreen": {
165
+ "import": {
166
+ "types": "./lib/typescript/module/secureScreen/index.d.ts",
167
+ "default": "./lib/module/secureScreen/index.js"
168
+ },
169
+ "require": {
170
+ "types": "./lib/typescript/commonjs/secureScreen/index.d.ts",
171
+ "default": "./lib/commonjs/secureScreen/index.js"
172
+ }
173
+ },
164
174
  "./push": {
165
175
  "import": {
166
176
  "types": "./lib/typescript/module/push/index.d.ts",
@@ -211,6 +221,9 @@
211
221
  "lib",
212
222
  "src/specs",
213
223
  "android",
224
+ "!android/build",
225
+ "!android/.gradle",
226
+ "!android/.cxx",
214
227
  "!**/__tests__",
215
228
  "!**/*.test.*",
216
229
  "!**/*.spec.*",
@@ -225,7 +238,7 @@
225
238
  }
226
239
  },
227
240
  "scripts": {
228
- "build": "bob build",
241
+ "build": "bob build && node ../../scripts/minify-lib.mjs",
229
242
  "clean": "rimraf lib",
230
243
  "lint": "biome lint ./src",
231
244
  "lint:fix": "biome lint --write ./src",
@@ -249,6 +262,7 @@
249
262
  "expo-media-library": ">=57.0.0",
250
263
  "expo-network": ">=57.0.0",
251
264
  "expo-notifications": ">=57.0.0",
265
+ "expo-screen-capture": ">=57.0.0",
252
266
  "expo-secure-store": ">=57.0.0",
253
267
  "expo-sharing": ">=57.0.0",
254
268
  "expo-sqlite": ">=57.0.0",
@@ -284,6 +298,9 @@
284
298
  "expo-notifications": {
285
299
  "optional": true
286
300
  },
301
+ "expo-screen-capture": {
302
+ "optional": true
303
+ },
287
304
  "expo-sharing": {
288
305
  "optional": true
289
306
  },
@@ -302,13 +319,15 @@
302
319
  [
303
320
  "commonjs",
304
321
  {
305
- "esm": true
322
+ "esm": true,
323
+ "sourceMaps": false
306
324
  }
307
325
  ],
308
326
  [
309
327
  "module",
310
328
  {
311
- "esm": true
329
+ "esm": true,
330
+ "sourceMaps": false
312
331
  }
313
332
  ],
314
333
  [