@glomopay/react-native-sdk 2.0.2 → 3.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.
- package/CHANGELOG.md +79 -0
- package/MIGRATION.md +50 -0
- package/README.md +348 -316
- package/lib/config/base.d.ts +17 -11
- package/lib/config/base.d.ts.map +1 -1
- package/lib/config/base.js +19 -7
- package/lib/config/segment.js +3 -3
- package/lib/glomo-checkout.d.ts +8 -0
- package/lib/glomo-checkout.d.ts.map +1 -0
- package/lib/glomo-checkout.js +106 -0
- package/lib/glomo-lrs-checkout.js +9 -9
- package/lib/glomo-standard-checkout.d.ts +25 -0
- package/lib/glomo-standard-checkout.d.ts.map +1 -0
- package/lib/glomo-standard-checkout.js +229 -0
- package/lib/glomo-subscriptions-checkout.d.ts +8 -0
- package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
- package/lib/glomo-subscriptions-checkout.js +85 -0
- package/lib/index.d.ts +5 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -5
- package/lib/injections/index.d.ts +1 -0
- package/lib/injections/index.d.ts.map +1 -1
- package/lib/injections/index.js +2 -0
- package/lib/injections/webview-flow.injection.d.ts.map +1 -1
- package/lib/injections/webview-flow.injection.js +106 -69
- package/lib/injections/webview-main.injection.d.ts.map +1 -1
- package/lib/injections/webview-main.injection.js +112 -77
- package/lib/injections/webview-standard.injection.d.ts +3 -0
- package/lib/injections/webview-standard.injection.d.ts.map +1 -0
- package/lib/injections/webview-standard.injection.js +214 -0
- package/lib/services/order-type-fetcher.d.ts +28 -0
- package/lib/services/order-type-fetcher.d.ts.map +1 -0
- package/lib/services/order-type-fetcher.js +99 -0
- package/lib/types/checkout.d.ts +65 -0
- package/lib/types/checkout.d.ts.map +1 -0
- package/lib/types/checkout.js +3 -0
- package/lib/types/standard-checkout.d.ts +40 -0
- package/lib/types/standard-checkout.d.ts.map +1 -0
- package/lib/types/standard-checkout.js +3 -0
- package/lib/types/subscriptions-checkout.d.ts +29 -0
- package/lib/types/subscriptions-checkout.d.ts.map +1 -0
- package/lib/types/subscriptions-checkout.js +3 -0
- package/lib/use-glomo-checkout.d.ts +54 -0
- package/lib/use-glomo-checkout.d.ts.map +1 -0
- package/lib/use-glomo-checkout.js +261 -0
- package/lib/use-lrs-checkout.d.ts +9 -4
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-lrs-checkout.js +76 -93
- package/lib/use-standard-checkout.d.ts +74 -0
- package/lib/use-standard-checkout.d.ts.map +1 -0
- package/lib/use-standard-checkout.js +849 -0
- package/lib/utils/analytics.d.ts +188 -2
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +636 -22
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +3 -4
- package/lib/utils/validation.d.ts.map +1 -1
- package/lib/utils/validation.js +7 -6
- package/package.json +17 -5
- package/src/config/base.ts +36 -17
- package/src/config/segment.ts +3 -3
- package/src/glomo-checkout.tsx +147 -0
- package/src/glomo-lrs-checkout.tsx +9 -9
- package/src/glomo-standard-checkout.tsx +353 -0
- package/src/glomo-subscriptions-checkout.tsx +83 -0
- package/src/index.ts +13 -7
- package/src/injections/index.ts +2 -0
- package/src/injections/webview-flow.injection.ts +106 -69
- package/src/injections/webview-main.injection.ts +112 -77
- package/src/injections/webview-standard.injection.ts +211 -0
- package/src/services/order-type-fetcher.ts +86 -0
- package/src/types/checkout.ts +72 -0
- package/src/types/standard-checkout.ts +49 -0
- package/src/types/subscriptions-checkout.ts +31 -0
- package/src/use-glomo-checkout.tsx +369 -0
- package/src/use-lrs-checkout.tsx +91 -111
- package/src/use-standard-checkout.tsx +1203 -0
- package/src/utils/analytics.ts +908 -34
- package/src/utils/device-compliance.ts +3 -4
- package/src/utils/validation.ts +7 -8
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GlomoSubscriptionsCheckout - thin wrapper around GlomoStandardCheckout
|
|
4
|
+
* that accepts a subscriptionId (sub_*) instead of an orderId (order_*).
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.GlomoSubscriptionsCheckout = void 0;
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const glomo_standard_checkout_1 = require("./glomo-standard-checkout");
|
|
43
|
+
const analytics_1 = require("./utils/analytics");
|
|
44
|
+
const validation_1 = require("./utils/validation");
|
|
45
|
+
function GlomoSubscriptionsCheckoutComponent(props, ref) {
|
|
46
|
+
const { subscriptionId: rawSubscriptionId, onSdkError, devMode = false, ...rest } = props;
|
|
47
|
+
const innerRef = (0, react_1.useRef)(null);
|
|
48
|
+
const onSdkErrorRef = (0, react_1.useRef)(onSdkError);
|
|
49
|
+
onSdkErrorRef.current = onSdkError;
|
|
50
|
+
const subscriptionId = rawSubscriptionId.trim();
|
|
51
|
+
/** Validating subscriptionId - firing onSdkError via useEffect to avoid side effects during render */
|
|
52
|
+
const validationError = (() => {
|
|
53
|
+
if (subscriptionId.length === 0) {
|
|
54
|
+
return "subscriptionId must not be empty";
|
|
55
|
+
}
|
|
56
|
+
if (!subscriptionId.startsWith("sub_")) {
|
|
57
|
+
return "subscriptionId must start with 'sub_'";
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
})();
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
if (validationError) {
|
|
63
|
+
(0, validation_1.safeCallback)(onSdkErrorRef.current, [[{ type: "validation_error", message: validationError }]], "onSdkError", devMode);
|
|
64
|
+
}
|
|
65
|
+
}, [validationError, devMode]);
|
|
66
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
67
|
+
start: () => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
if (validationError) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return (_b = (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.start()) !== null && _b !== void 0 ? _b : false;
|
|
73
|
+
},
|
|
74
|
+
getStatus: () => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return (_b = (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.getStatus()) !== null && _b !== void 0 ? _b : "ready";
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
79
|
+
if (validationError) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return (<glomo_standard_checkout_1.GlomoStandardCheckoutInternal ref={innerRef} {...rest} orderId={subscriptionId} onSdkError={onSdkError} devMode={devMode} _analyticsTrackers={analytics_1.subscriptionCheckoutTrackers} _skipOrderIdValidation={true}/>);
|
|
83
|
+
}
|
|
84
|
+
exports.GlomoSubscriptionsCheckout = (0, react_1.forwardRef)(GlomoSubscriptionsCheckoutComponent);
|
|
85
|
+
exports.GlomoSubscriptionsCheckout.displayName = "GlomoSubscriptionsCheckout";
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/** The GlomoPay RN SDK exports */
|
|
2
|
-
export {
|
|
1
|
+
/** The GlomoPay RN SDK v3 exports */
|
|
2
|
+
export { GlomoCheckout } from "./glomo-checkout";
|
|
3
|
+
export { type GlomoCheckoutRef, type GlomoCheckoutProps, type GlomoCheckoutPayload, type CheckoutStatus, type GlomoBankTransferPayload, type GlomoPayViaBankConnectionPayload, } from "./types/checkout";
|
|
4
|
+
export { type GlomoServer } from "./config/base";
|
|
3
5
|
export { type SdkError } from "./utils/analytics";
|
|
4
|
-
export { type
|
|
5
|
-
export { GlomoLrsCheckout, type GlomoLrsCheckoutProps, type GlomoLrsCheckoutRef } from "./glomo-lrs-checkout";
|
|
6
|
+
export { useGlomoCheckout, type UseGlomoCheckoutReturn } from "./use-glomo-checkout";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,gCAAgC,GACxC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/** The GlomoPay RN SDK exports */
|
|
2
|
+
/** The GlomoPay RN SDK v3 exports */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
//
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "
|
|
4
|
+
exports.useGlomoCheckout = exports.GlomoCheckout = void 0;
|
|
5
|
+
// v3 public API - unified checkout
|
|
6
|
+
var glomo_checkout_1 = require("./glomo-checkout");
|
|
7
|
+
Object.defineProperty(exports, "GlomoCheckout", { enumerable: true, get: function () { return glomo_checkout_1.GlomoCheckout; } });
|
|
8
|
+
var use_glomo_checkout_1 = require("./use-glomo-checkout");
|
|
9
|
+
Object.defineProperty(exports, "useGlomoCheckout", { enumerable: true, get: function () { return use_glomo_checkout_1.useGlomoCheckout; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/injections/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/injections/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gBAAgB;;;;;CAK5B,CAAC"}
|
package/lib/injections/index.js
CHANGED
|
@@ -7,8 +7,10 @@ exports.InjectionScripts = void 0;
|
|
|
7
7
|
const webview_main_injection_1 = require("./webview-main.injection");
|
|
8
8
|
const webview_flow_injection_1 = require("./webview-flow.injection");
|
|
9
9
|
const webview_education_carousel_injection_1 = require("./webview-education-carousel.injection");
|
|
10
|
+
const webview_standard_injection_1 = require("./webview-standard.injection");
|
|
10
11
|
exports.InjectionScripts = {
|
|
11
12
|
main: webview_main_injection_1.injectedScript,
|
|
12
13
|
flow: webview_flow_injection_1.injectedScript,
|
|
13
14
|
educationCarousel: webview_education_carousel_injection_1.injectedScript,
|
|
15
|
+
standard: webview_standard_injection_1.injectedScript,
|
|
14
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webview-flow.injection.d.ts","sourceRoot":"","sources":["../../src/injections/webview-flow.injection.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"webview-flow.injection.d.ts","sourceRoot":"","sources":["../../src/injections/webview-flow.injection.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,eAAO,MAAM,cAAc,EAAE,MAiN5B,CAAC"}
|
|
@@ -4,114 +4,149 @@ exports.injectedScript = void 0;
|
|
|
4
4
|
/** Injection JavaScript for the Secondary WebView */
|
|
5
5
|
exports.injectedScript = `
|
|
6
6
|
(function() {
|
|
7
|
-
//
|
|
7
|
+
// Log prefix for all messages originating from the flow WebView
|
|
8
|
+
const LOG_PREFIX = 'FLOW_WEBVIEW: ';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Formats an array of arguments into a single prefixed string for posting back to React Native.
|
|
12
|
+
* Objects are JSON-stringified; primitives are coerced to strings.
|
|
13
|
+
*/
|
|
14
|
+
function formatMessage(args) {
|
|
15
|
+
return args.map(function(arg) {
|
|
16
|
+
if (typeof arg === 'object') {
|
|
17
|
+
try {
|
|
18
|
+
return LOG_PREFIX + JSON.stringify(arg, null, 2);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
return LOG_PREFIX + '[unserializable object]';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return LOG_PREFIX + String(arg);
|
|
24
|
+
}).join(' ');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Saving original console methods before overriding (must be declared before safePostMessage references them)
|
|
8
28
|
const originalLog = console.log;
|
|
9
29
|
const originalWarn = console.warn;
|
|
10
30
|
const originalError = console.error;
|
|
11
31
|
const originalInfo = console.info;
|
|
12
|
-
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Safely posts a message to ReactNativeWebView with a guard check.
|
|
35
|
+
* Prevents crashes if the WebView bridge is not yet ready or has been torn down.
|
|
36
|
+
*/
|
|
37
|
+
function safePostMessage(payload) {
|
|
38
|
+
try {
|
|
39
|
+
if (window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === 'function') {
|
|
40
|
+
window.ReactNativeWebView.postMessage(JSON.stringify(payload));
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
originalError && originalError.call(console, LOG_PREFIX + 'Failed to post message to ReactNativeWebView', error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Overriding console methods to forward logs back to React Native
|
|
13
48
|
console.log = function(...args) {
|
|
14
49
|
originalLog.apply(console, args);
|
|
15
|
-
|
|
50
|
+
safePostMessage({
|
|
16
51
|
type: 'console',
|
|
17
52
|
level: 'log',
|
|
18
|
-
message: args
|
|
19
|
-
})
|
|
53
|
+
message: formatMessage(args)
|
|
54
|
+
});
|
|
20
55
|
};
|
|
21
|
-
|
|
56
|
+
|
|
22
57
|
console.warn = function(...args) {
|
|
23
58
|
originalWarn.apply(console, args);
|
|
24
|
-
|
|
59
|
+
safePostMessage({
|
|
25
60
|
type: 'console',
|
|
26
61
|
level: 'warn',
|
|
27
|
-
message: args
|
|
28
|
-
})
|
|
62
|
+
message: formatMessage(args)
|
|
63
|
+
});
|
|
29
64
|
};
|
|
30
|
-
|
|
65
|
+
|
|
31
66
|
console.error = function(...args) {
|
|
32
67
|
originalError.apply(console, args);
|
|
33
|
-
|
|
68
|
+
safePostMessage({
|
|
34
69
|
type: 'console',
|
|
35
70
|
level: 'error',
|
|
36
|
-
message: args
|
|
37
|
-
})
|
|
71
|
+
message: formatMessage(args)
|
|
72
|
+
});
|
|
38
73
|
};
|
|
39
|
-
|
|
74
|
+
|
|
40
75
|
console.info = function(...args) {
|
|
41
76
|
originalInfo.apply(console, args);
|
|
42
|
-
|
|
77
|
+
safePostMessage({
|
|
43
78
|
type: 'console',
|
|
44
79
|
level: 'info',
|
|
45
|
-
message: args
|
|
46
|
-
})
|
|
80
|
+
message: formatMessage(args)
|
|
81
|
+
});
|
|
47
82
|
};
|
|
48
|
-
|
|
49
|
-
// Intercepting fetch requests
|
|
83
|
+
|
|
84
|
+
// Intercepting fetch requests to log network activity
|
|
50
85
|
const originalFetch = window.fetch;
|
|
51
86
|
window.fetch = function(...args) {
|
|
52
87
|
const url = typeof args[0] === 'string' ? args[0] : args[0]?.url || 'Unknown URL';
|
|
53
|
-
|
|
88
|
+
safePostMessage({
|
|
54
89
|
type: 'console',
|
|
55
90
|
level: 'network',
|
|
56
|
-
message:
|
|
57
|
-
})
|
|
58
|
-
|
|
91
|
+
message: LOG_PREFIX + 'FETCH REQUEST: ' + url
|
|
92
|
+
});
|
|
93
|
+
|
|
59
94
|
return originalFetch.apply(this, args)
|
|
60
95
|
.then(response => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
96
|
+
safePostMessage({
|
|
97
|
+
type: 'console',
|
|
98
|
+
level: 'network',
|
|
99
|
+
message: LOG_PREFIX + 'FETCH RESPONSE: ' + url + ' - Status: ' + response.status
|
|
100
|
+
});
|
|
66
101
|
return response;
|
|
67
102
|
})
|
|
68
103
|
.catch(error => {
|
|
69
|
-
|
|
104
|
+
safePostMessage({
|
|
70
105
|
type: 'console',
|
|
71
106
|
level: 'error',
|
|
72
|
-
message:
|
|
73
|
-
})
|
|
107
|
+
message: LOG_PREFIX + 'FETCH ERROR: ' + url + ' - ' + error.message
|
|
108
|
+
});
|
|
74
109
|
throw error;
|
|
75
110
|
});
|
|
76
111
|
};
|
|
77
|
-
|
|
78
|
-
// Intercepting XMLHttpRequest
|
|
112
|
+
|
|
113
|
+
// Intercepting XMLHttpRequest to log network activity
|
|
79
114
|
const originalOpen = XMLHttpRequest.prototype.open;
|
|
80
115
|
const originalSend = XMLHttpRequest.prototype.send;
|
|
81
|
-
|
|
116
|
+
|
|
82
117
|
XMLHttpRequest.prototype.open = function(method, url) {
|
|
83
118
|
this._url = url;
|
|
84
119
|
this._method = method;
|
|
85
120
|
return originalOpen.apply(this, arguments);
|
|
86
121
|
};
|
|
87
|
-
|
|
122
|
+
|
|
88
123
|
XMLHttpRequest.prototype.send = function() {
|
|
89
|
-
|
|
124
|
+
safePostMessage({
|
|
90
125
|
type: 'console',
|
|
91
126
|
level: 'network',
|
|
92
|
-
message:
|
|
93
|
-
})
|
|
94
|
-
|
|
127
|
+
message: LOG_PREFIX + 'XHR REQUEST: ' + this._method + ' ' + this._url
|
|
128
|
+
});
|
|
129
|
+
|
|
95
130
|
this.addEventListener('load', function() {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
131
|
+
safePostMessage({
|
|
132
|
+
type: 'console',
|
|
133
|
+
level: 'network',
|
|
134
|
+
message: LOG_PREFIX + 'XHR RESPONSE: ' + this._url + ' - Status: ' + this.status
|
|
135
|
+
});
|
|
101
136
|
});
|
|
102
|
-
|
|
137
|
+
|
|
103
138
|
this.addEventListener('error', function() {
|
|
104
|
-
|
|
139
|
+
safePostMessage({
|
|
105
140
|
type: 'console',
|
|
106
141
|
level: 'error',
|
|
107
|
-
message:
|
|
108
|
-
})
|
|
142
|
+
message: LOG_PREFIX + 'XHR ERROR: ' + this._url
|
|
143
|
+
});
|
|
109
144
|
});
|
|
110
|
-
|
|
145
|
+
|
|
111
146
|
return originalSend.apply(this, arguments);
|
|
112
147
|
};
|
|
113
|
-
|
|
114
|
-
// Intercepting programmatic form.submit()
|
|
148
|
+
|
|
149
|
+
// Intercepting programmatic form.submit() - force target="_blank" to "_self"
|
|
115
150
|
// This prevents forms from trying to open new windows (which fail silently in WebView)
|
|
116
151
|
const originalSubmit = HTMLFormElement.prototype.submit;
|
|
117
152
|
HTMLFormElement.prototype.submit = function() {
|
|
@@ -124,54 +159,56 @@ exports.injectedScript = `
|
|
|
124
159
|
// Intercepting window.open
|
|
125
160
|
const originalWindowOpen = window.open;
|
|
126
161
|
window.open = function(url, target, features) {
|
|
127
|
-
|
|
162
|
+
safePostMessage({
|
|
128
163
|
type: 'window.open',
|
|
129
164
|
url: url,
|
|
130
165
|
target: target,
|
|
131
166
|
features: features
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
// Returning a
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Returning a mock window object to prevent JS errors
|
|
135
170
|
return {
|
|
136
171
|
closed: false,
|
|
137
172
|
close: function() {
|
|
138
|
-
|
|
173
|
+
safePostMessage({
|
|
139
174
|
type: 'window.close'
|
|
140
|
-
})
|
|
175
|
+
});
|
|
141
176
|
},
|
|
142
177
|
focus: function() {},
|
|
143
178
|
blur: function() {}
|
|
144
179
|
};
|
|
145
180
|
};
|
|
146
|
-
|
|
181
|
+
|
|
147
182
|
// Listening for unhandled errors
|
|
148
183
|
window.addEventListener('error', function(event) {
|
|
149
|
-
|
|
184
|
+
safePostMessage({
|
|
150
185
|
type: 'console',
|
|
151
186
|
level: 'error',
|
|
152
|
-
message:
|
|
153
|
-
})
|
|
187
|
+
message: LOG_PREFIX + 'Unhandled Error: ' + event.message + ' at ' + event.filename + ':' + event.lineno
|
|
188
|
+
});
|
|
154
189
|
});
|
|
155
|
-
|
|
190
|
+
|
|
156
191
|
// Listening for unhandled promise rejections
|
|
157
192
|
window.addEventListener('unhandledrejection', function(event) {
|
|
158
|
-
|
|
193
|
+
safePostMessage({
|
|
159
194
|
type: 'console',
|
|
160
195
|
level: 'error',
|
|
161
|
-
message:
|
|
162
|
-
})
|
|
196
|
+
message: LOG_PREFIX + 'Unhandled Promise Rejection: ' + (event.reason?.toString() || 'Unknown')
|
|
197
|
+
});
|
|
163
198
|
});
|
|
164
199
|
|
|
165
200
|
// Listening for messages from the WebView
|
|
166
201
|
window.addEventListener('message', function(event) {
|
|
167
|
-
console.log(
|
|
168
|
-
|
|
202
|
+
console.log(LOG_PREFIX + 'Message received: ' + event.data);
|
|
203
|
+
safePostMessage({
|
|
169
204
|
type: 'message',
|
|
170
205
|
message: event.data
|
|
171
|
-
})
|
|
206
|
+
});
|
|
172
207
|
});
|
|
173
208
|
|
|
174
209
|
// Logging that injection is complete
|
|
175
|
-
console.log(
|
|
210
|
+
console.log(LOG_PREFIX + 'GlomoPay WebView JavaScript injection complete');
|
|
211
|
+
|
|
212
|
+
true; // Required for injected JavaScript
|
|
176
213
|
})();
|
|
177
214
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webview-main.injection.d.ts","sourceRoot":"","sources":["../../src/injections/webview-main.injection.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"webview-main.injection.d.ts","sourceRoot":"","sources":["../../src/injections/webview-main.injection.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,eAAO,MAAM,cAAc,EAAE,MAuN5B,CAAC"}
|