@glomopay/react-native-sdk 4.0.0 → 5.0.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.
- package/CHANGELOG.md +29 -0
- package/MIGRATION.md +112 -0
- package/README.md +173 -36
- package/lib/bridge/file-input-handler.d.ts +25 -0
- package/lib/bridge/file-input-handler.d.ts.map +1 -0
- package/lib/bridge/file-input-handler.js +38 -0
- package/lib/bridge/file-save-handler.d.ts +32 -0
- package/lib/bridge/file-save-handler.d.ts.map +1 -0
- package/lib/bridge/file-save-handler.js +92 -0
- package/lib/bridge/message-router.d.ts +44 -0
- package/lib/bridge/message-router.d.ts.map +1 -0
- package/lib/bridge/message-router.js +48 -0
- package/lib/bridge/payment-payload.d.ts +18 -0
- package/lib/bridge/payment-payload.d.ts.map +1 -0
- package/lib/bridge/payment-payload.js +31 -0
- package/lib/capabilities/file-save.d.ts +40 -0
- package/lib/capabilities/file-save.d.ts.map +1 -0
- package/lib/capabilities/file-save.js +101 -0
- package/lib/capabilities/index.d.ts +22 -0
- package/lib/capabilities/index.d.ts.map +1 -0
- package/lib/capabilities/index.js +34 -0
- package/lib/capabilities/use-capability-reporting.d.ts +24 -0
- package/lib/capabilities/use-capability-reporting.d.ts.map +1 -0
- package/lib/capabilities/use-capability-reporting.js +44 -0
- package/lib/config/base.d.ts +12 -0
- package/lib/config/base.d.ts.map +1 -1
- package/lib/config/base.js +13 -1
- package/lib/glomo-checkout.d.ts +9 -1
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +14 -5
- package/lib/glomo-lrs-checkout.d.ts +3 -0
- package/lib/glomo-lrs-checkout.d.ts.map +1 -1
- package/lib/glomo-lrs-checkout.js +34 -11
- package/lib/glomo-standard-checkout.d.ts +4 -1
- package/lib/glomo-standard-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.js +21 -13
- package/lib/glomo-subscriptions-checkout.d.ts.map +1 -1
- package/lib/glomo-subscriptions-checkout.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/injections/index.d.ts +24 -0
- package/lib/injections/index.d.ts.map +1 -1
- package/lib/injections/index.js +41 -0
- package/lib/injections/webview-flow.injection.d.ts.map +1 -1
- package/lib/injections/webview-flow.injection.js +76 -0
- package/lib/injections/webview-main.injection.d.ts.map +1 -1
- package/lib/injections/webview-main.injection.js +31 -0
- package/lib/injections/webview-standard.injection.d.ts.map +1 -1
- package/lib/injections/webview-standard.injection.js +31 -0
- package/lib/services/file-saver.d.ts +109 -0
- package/lib/services/file-saver.d.ts.map +1 -0
- package/lib/services/file-saver.js +416 -0
- package/lib/types/checkout.d.ts +67 -6
- package/lib/types/checkout.d.ts.map +1 -1
- package/lib/types/checkout.js +24 -2
- package/lib/types/standard-checkout.d.ts +6 -6
- package/lib/types/standard-checkout.d.ts.map +1 -1
- package/lib/types/subscriptions-checkout.d.ts +5 -3
- package/lib/types/subscriptions-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.d.ts +2 -2
- package/lib/use-glomo-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.js +25 -4
- package/lib/use-lrs-checkout.d.ts +18 -6
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-lrs-checkout.js +330 -171
- package/lib/use-standard-checkout.d.ts +18 -13
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +282 -206
- package/lib/utils/analytics.d.ts +177 -51
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +299 -81
- package/lib/utils/device-compliance.d.ts +57 -12
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +101 -37
- package/lib/utils/event-projections.d.ts +56 -0
- package/lib/utils/event-projections.d.ts.map +1 -0
- package/lib/utils/event-projections.js +42 -0
- package/lib/utils/file-metadata.d.ts +52 -0
- package/lib/utils/file-metadata.d.ts.map +1 -0
- package/lib/utils/file-metadata.js +134 -0
- package/lib/utils/use-sdk-session.d.ts +12 -0
- package/lib/utils/use-sdk-session.d.ts.map +1 -0
- package/lib/utils/use-sdk-session.js +37 -0
- package/lib/utils/validation.d.ts +37 -3
- package/lib/utils/validation.d.ts.map +1 -1
- package/lib/utils/validation.js +64 -8
- package/lib/webview/capability-props.d.ts +27 -0
- package/lib/webview/capability-props.d.ts.map +1 -0
- package/lib/webview/capability-props.js +61 -0
- package/lib/webview/use-permission-request.d.ts +33 -0
- package/lib/webview/use-permission-request.d.ts.map +1 -0
- package/lib/webview/use-permission-request.js +89 -0
- package/package.json +13 -3
- package/src/bridge/file-input-handler.ts +66 -0
- package/src/bridge/file-save-handler.ts +141 -0
- package/src/bridge/message-router.ts +92 -0
- package/src/bridge/payment-payload.ts +31 -0
- package/src/capabilities/file-save.ts +124 -0
- package/src/capabilities/index.ts +34 -0
- package/src/capabilities/use-capability-reporting.ts +55 -0
- package/src/config/base.ts +13 -0
- package/src/glomo-checkout.tsx +28 -11
- package/src/glomo-lrs-checkout.tsx +49 -27
- package/src/glomo-standard-checkout.tsx +33 -34
- package/src/glomo-subscriptions-checkout.tsx +1 -0
- package/src/index.ts +4 -2
- package/src/injections/index.ts +43 -0
- package/src/injections/webview-flow.injection.ts +76 -0
- package/src/injections/webview-main.injection.ts +31 -0
- package/src/injections/webview-standard.injection.ts +31 -0
- package/src/services/file-saver.ts +497 -0
- package/src/types/checkout.ts +72 -6
- package/src/types/standard-checkout.ts +6 -6
- package/src/types/subscriptions-checkout.ts +9 -3
- package/src/use-glomo-checkout.tsx +32 -7
- package/src/use-lrs-checkout.tsx +684 -366
- package/src/use-standard-checkout.tsx +731 -465
- package/src/utils/analytics.ts +422 -117
- package/src/utils/device-compliance.ts +148 -38
- package/src/utils/event-projections.ts +74 -0
- package/src/utils/file-metadata.ts +140 -0
- package/src/utils/use-sdk-session.ts +41 -0
- package/src/utils/validation.ts +70 -10
- package/src/webview/capability-props.ts +86 -0
- package/src/webview/use-permission-request.ts +114 -0
- package/src/jail-monkey.d.ts +0 -19
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** Shared WebView permission handling for every GlomoPay checkout flow */
|
|
2
|
+
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { Platform, PermissionsAndroid } from "react-native";
|
|
5
|
+
|
|
6
|
+
/** Android-only WebView permission request, not yet in react-native-webview type definitions */
|
|
7
|
+
export interface WebViewPermissionRequest {
|
|
8
|
+
nativeEvent: { resources: string[] };
|
|
9
|
+
grant: (resources: string[]) => void;
|
|
10
|
+
deny: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The options for the usePermissionRequest hook */
|
|
14
|
+
export interface UsePermissionRequestOptions {
|
|
15
|
+
/** Log prefix of the calling flow, e.g. "[Glomo-RN-SDK LRS]" */
|
|
16
|
+
logPrefix: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Called when the user refuses camera access, or when the request errors out.
|
|
20
|
+
* The caller owns what happens next - closing the checkout, moving its status,
|
|
21
|
+
* and notifying the merchant are all flow-level concerns and stay outside this hook.
|
|
22
|
+
*/
|
|
23
|
+
onDenied: () => void;
|
|
24
|
+
|
|
25
|
+
devMode?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Handler for WebView permission requests (e.g. camera access for bank authentication).
|
|
30
|
+
* On Android, prompts the user for camera permission via PermissionsAndroid.
|
|
31
|
+
* On iOS, grants camera access automatically (iOS handles its own permission prompt).
|
|
32
|
+
* Non-camera permissions are denied by default.
|
|
33
|
+
*
|
|
34
|
+
* Lives here rather than inside a flow hook so every flow gets the same behaviour.
|
|
35
|
+
* It previously existed only on the standard checkout, which left LRS with no camera
|
|
36
|
+
* support at all on either platform.
|
|
37
|
+
*/
|
|
38
|
+
export function usePermissionRequest({ logPrefix, onDenied, devMode = false }: UsePermissionRequestOptions) {
|
|
39
|
+
return useCallback(
|
|
40
|
+
async (request: WebViewPermissionRequest) => {
|
|
41
|
+
try {
|
|
42
|
+
const { resources } = request.nativeEvent;
|
|
43
|
+
// Checking if the requested permission is camera-related
|
|
44
|
+
const isCameraPermissionRequest = resources.some(
|
|
45
|
+
(resource: string) => resource === "camera" || resource.toLowerCase().includes("camera")
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (!isCameraPermissionRequest) {
|
|
49
|
+
if (devMode) {
|
|
50
|
+
console.log(`${logPrefix} Non-camera permission requested, denying:`, resources);
|
|
51
|
+
}
|
|
52
|
+
request.deny();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (devMode) {
|
|
57
|
+
console.log(`${logPrefix} Camera permission requested by webpage`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (Platform.OS === "android") {
|
|
61
|
+
try {
|
|
62
|
+
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA, {
|
|
63
|
+
title: "Camera Permission",
|
|
64
|
+
message: "This app needs camera access for identity verification during checkout",
|
|
65
|
+
buttonNeutral: "Ask Me Later",
|
|
66
|
+
buttonNegative: "Cancel",
|
|
67
|
+
buttonPositive: "OK",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
71
|
+
if (devMode) {
|
|
72
|
+
console.log(`${logPrefix} Camera permission granted`);
|
|
73
|
+
}
|
|
74
|
+
request.grant(resources);
|
|
75
|
+
} else {
|
|
76
|
+
if (devMode) {
|
|
77
|
+
console.log(`${logPrefix} Camera permission denied by user`);
|
|
78
|
+
}
|
|
79
|
+
onDenied();
|
|
80
|
+
request.deny();
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
if (devMode) {
|
|
84
|
+
console.error(`${logPrefix} Error requesting camera permission:`, err);
|
|
85
|
+
}
|
|
86
|
+
onDenied();
|
|
87
|
+
request.deny();
|
|
88
|
+
}
|
|
89
|
+
} else if (Platform.OS === "ios") {
|
|
90
|
+
/**
|
|
91
|
+
* Granting to the WebView, not to the user - WKWebView raises its own prompt
|
|
92
|
+
* from here and never reports the answer back, so the SDK cannot know whether
|
|
93
|
+
* the user allowed it. onDenied is unreachable on this path.
|
|
94
|
+
*/
|
|
95
|
+
if (devMode) {
|
|
96
|
+
console.log(`${logPrefix} Granting camera permission request on iOS`);
|
|
97
|
+
}
|
|
98
|
+
request.grant(resources);
|
|
99
|
+
} else {
|
|
100
|
+
if (devMode) {
|
|
101
|
+
console.warn(`${logPrefix} Unsupported platform for camera permissions`);
|
|
102
|
+
}
|
|
103
|
+
request.deny();
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (devMode) {
|
|
107
|
+
console.error(`${logPrefix} Error in handlePermissionRequest:`, error);
|
|
108
|
+
}
|
|
109
|
+
request.deny();
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[logPrefix, onDenied, devMode]
|
|
113
|
+
);
|
|
114
|
+
}
|
package/src/jail-monkey.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** Type definitions for jail-monkey library */
|
|
2
|
-
|
|
3
|
-
declare module "jail-monkey" {
|
|
4
|
-
interface JailMonkey {
|
|
5
|
-
isJailBroken(): boolean;
|
|
6
|
-
canMockLocation(): boolean;
|
|
7
|
-
trustFall(): boolean;
|
|
8
|
-
isOnExternalStorage(): boolean;
|
|
9
|
-
isDebuggingMode(): boolean;
|
|
10
|
-
hookDetected(): boolean;
|
|
11
|
-
isOnReadOnlyFileSystem(): boolean;
|
|
12
|
-
detectRootManagement(): boolean;
|
|
13
|
-
detectFrida(): boolean;
|
|
14
|
-
detectXposed(): boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const JailMonkey: JailMonkey;
|
|
18
|
-
export default JailMonkey;
|
|
19
|
-
}
|