@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.
Files changed (80) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/MIGRATION.md +50 -0
  3. package/README.md +348 -316
  4. package/lib/config/base.d.ts +17 -11
  5. package/lib/config/base.d.ts.map +1 -1
  6. package/lib/config/base.js +19 -7
  7. package/lib/config/segment.js +3 -3
  8. package/lib/glomo-checkout.d.ts +8 -0
  9. package/lib/glomo-checkout.d.ts.map +1 -0
  10. package/lib/glomo-checkout.js +106 -0
  11. package/lib/glomo-lrs-checkout.js +9 -9
  12. package/lib/glomo-standard-checkout.d.ts +25 -0
  13. package/lib/glomo-standard-checkout.d.ts.map +1 -0
  14. package/lib/glomo-standard-checkout.js +229 -0
  15. package/lib/glomo-subscriptions-checkout.d.ts +8 -0
  16. package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
  17. package/lib/glomo-subscriptions-checkout.js +85 -0
  18. package/lib/index.d.ts +5 -4
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/index.js +7 -5
  21. package/lib/injections/index.d.ts +1 -0
  22. package/lib/injections/index.d.ts.map +1 -1
  23. package/lib/injections/index.js +2 -0
  24. package/lib/injections/webview-flow.injection.d.ts.map +1 -1
  25. package/lib/injections/webview-flow.injection.js +106 -69
  26. package/lib/injections/webview-main.injection.d.ts.map +1 -1
  27. package/lib/injections/webview-main.injection.js +112 -77
  28. package/lib/injections/webview-standard.injection.d.ts +3 -0
  29. package/lib/injections/webview-standard.injection.d.ts.map +1 -0
  30. package/lib/injections/webview-standard.injection.js +214 -0
  31. package/lib/services/order-type-fetcher.d.ts +28 -0
  32. package/lib/services/order-type-fetcher.d.ts.map +1 -0
  33. package/lib/services/order-type-fetcher.js +99 -0
  34. package/lib/types/checkout.d.ts +65 -0
  35. package/lib/types/checkout.d.ts.map +1 -0
  36. package/lib/types/checkout.js +3 -0
  37. package/lib/types/standard-checkout.d.ts +40 -0
  38. package/lib/types/standard-checkout.d.ts.map +1 -0
  39. package/lib/types/standard-checkout.js +3 -0
  40. package/lib/types/subscriptions-checkout.d.ts +29 -0
  41. package/lib/types/subscriptions-checkout.d.ts.map +1 -0
  42. package/lib/types/subscriptions-checkout.js +3 -0
  43. package/lib/use-glomo-checkout.d.ts +54 -0
  44. package/lib/use-glomo-checkout.d.ts.map +1 -0
  45. package/lib/use-glomo-checkout.js +261 -0
  46. package/lib/use-lrs-checkout.d.ts +9 -4
  47. package/lib/use-lrs-checkout.d.ts.map +1 -1
  48. package/lib/use-lrs-checkout.js +76 -93
  49. package/lib/use-standard-checkout.d.ts +74 -0
  50. package/lib/use-standard-checkout.d.ts.map +1 -0
  51. package/lib/use-standard-checkout.js +849 -0
  52. package/lib/utils/analytics.d.ts +188 -2
  53. package/lib/utils/analytics.d.ts.map +1 -1
  54. package/lib/utils/analytics.js +636 -22
  55. package/lib/utils/device-compliance.d.ts.map +1 -1
  56. package/lib/utils/device-compliance.js +3 -4
  57. package/lib/utils/validation.d.ts.map +1 -1
  58. package/lib/utils/validation.js +7 -6
  59. package/package.json +17 -5
  60. package/src/config/base.ts +36 -17
  61. package/src/config/segment.ts +3 -3
  62. package/src/glomo-checkout.tsx +147 -0
  63. package/src/glomo-lrs-checkout.tsx +9 -9
  64. package/src/glomo-standard-checkout.tsx +353 -0
  65. package/src/glomo-subscriptions-checkout.tsx +83 -0
  66. package/src/index.ts +13 -7
  67. package/src/injections/index.ts +2 -0
  68. package/src/injections/webview-flow.injection.ts +106 -69
  69. package/src/injections/webview-main.injection.ts +112 -77
  70. package/src/injections/webview-standard.injection.ts +211 -0
  71. package/src/services/order-type-fetcher.ts +86 -0
  72. package/src/types/checkout.ts +72 -0
  73. package/src/types/standard-checkout.ts +49 -0
  74. package/src/types/subscriptions-checkout.ts +31 -0
  75. package/src/use-glomo-checkout.tsx +369 -0
  76. package/src/use-lrs-checkout.tsx +91 -111
  77. package/src/use-standard-checkout.tsx +1203 -0
  78. package/src/utils/analytics.ts +908 -34
  79. package/src/utils/device-compliance.ts +3 -4
  80. 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 { type GlomoLrsCheckoutPayload, type LrsCheckoutStatus } from "./use-lrs-checkout";
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 GlomoLrsServer } from "./config/base";
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAGlC,OAAO,EAAE,KAAK,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
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.GlomoLrsCheckout = void 0;
5
- // Main UI Component for the LRS Checkout flow
6
- var glomo_lrs_checkout_1 = require("./glomo-lrs-checkout");
7
- Object.defineProperty(exports, "GlomoLrsCheckout", { enumerable: true, get: function () { return glomo_lrs_checkout_1.GlomoLrsCheckout; } });
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; } });
@@ -2,5 +2,6 @@ export declare const InjectionScripts: {
2
2
  main: string;
3
3
  flow: string;
4
4
  educationCarousel: string;
5
+ standard: string;
5
6
  };
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/injections/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/injections/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gBAAgB;;;;;CAK5B,CAAC"}
@@ -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,MA4K5B,CAAC"}
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
- // Overriding console methods
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
- window.ReactNativeWebView.postMessage(JSON.stringify({
50
+ safePostMessage({
16
51
  type: 'console',
17
52
  level: 'log',
18
- message: args.map(a => typeof a === 'object' ? "FLOW_WEBVIEW: " + JSON.stringify(a, null, 2) : "FLOW_WEBVIEW: " + String(a)).join(' ')
19
- }));
53
+ message: formatMessage(args)
54
+ });
20
55
  };
21
-
56
+
22
57
  console.warn = function(...args) {
23
58
  originalWarn.apply(console, args);
24
- window.ReactNativeWebView.postMessage(JSON.stringify({
59
+ safePostMessage({
25
60
  type: 'console',
26
61
  level: 'warn',
27
- message: args.map(a => typeof a === 'object' ? "FLOW_WEBVIEW: " + JSON.stringify(a, null, 2) : "FLOW_WEBVIEW: " + String(a)).join(' ')
28
- }));
62
+ message: formatMessage(args)
63
+ });
29
64
  };
30
-
65
+
31
66
  console.error = function(...args) {
32
67
  originalError.apply(console, args);
33
- window.ReactNativeWebView.postMessage(JSON.stringify({
68
+ safePostMessage({
34
69
  type: 'console',
35
70
  level: 'error',
36
- message: args.map(a => typeof a === 'object' ? "FLOW_WEBVIEW: " + JSON.stringify(a, null, 2) : "FLOW_WEBVIEW: " + String(a)).join(' ')
37
- }));
71
+ message: formatMessage(args)
72
+ });
38
73
  };
39
-
74
+
40
75
  console.info = function(...args) {
41
76
  originalInfo.apply(console, args);
42
- window.ReactNativeWebView.postMessage(JSON.stringify({
77
+ safePostMessage({
43
78
  type: 'console',
44
79
  level: 'info',
45
- message: args.map(a => typeof a === 'object' ? "FLOW_WEBVIEW: " + JSON.stringify(a, null, 2) : "FLOW_WEBVIEW: " + String(a)).join(' ')
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
- window.ReactNativeWebView.postMessage(JSON.stringify({
88
+ safePostMessage({
54
89
  type: 'console',
55
90
  level: 'network',
56
- message: "FLOW_WEBVIEW: " + 'FETCH REQUEST: ' + url
57
- }));
58
-
91
+ message: LOG_PREFIX + 'FETCH REQUEST: ' + url
92
+ });
93
+
59
94
  return originalFetch.apply(this, args)
60
95
  .then(response => {
61
- window.ReactNativeWebView.postMessage(JSON.stringify({
62
- type: 'console',
63
- level: 'network',
64
- message: "FLOW_WEBVIEW: " + 'FETCH RESPONSE: ' + url + ' - Status: ' + response.status
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
- window.ReactNativeWebView.postMessage(JSON.stringify({
104
+ safePostMessage({
70
105
  type: 'console',
71
106
  level: 'error',
72
- message: "FLOW_WEBVIEW: " + 'FETCH ERROR: ' + url + ' - ' + error.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
- window.ReactNativeWebView.postMessage(JSON.stringify({
124
+ safePostMessage({
90
125
  type: 'console',
91
126
  level: 'network',
92
- message: "FLOW_WEBVIEW: " + 'XHR REQUEST: ' + this._method + ' ' + this._url
93
- }));
94
-
127
+ message: LOG_PREFIX + 'XHR REQUEST: ' + this._method + ' ' + this._url
128
+ });
129
+
95
130
  this.addEventListener('load', function() {
96
- window.ReactNativeWebView.postMessage(JSON.stringify({
97
- type: 'console',
98
- level: 'network',
99
- message: "FLOW_WEBVIEW: " + 'XHR RESPONSE: ' + this._url + ' - Status: ' + this.status
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
- window.ReactNativeWebView.postMessage(JSON.stringify({
139
+ safePostMessage({
105
140
  type: 'console',
106
141
  level: 'error',
107
- message: "FLOW_WEBVIEW: " + 'XHR ERROR: ' + this._url
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() force target="_blank" to "_self"
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
- window.ReactNativeWebView.postMessage(JSON.stringify({
162
+ safePostMessage({
128
163
  type: 'window.open',
129
164
  url: url,
130
165
  target: target,
131
166
  features: features
132
- }));
133
-
134
- // Returning a dummy window object to prevent JS errors
167
+ });
168
+
169
+ // Returning a mock window object to prevent JS errors
135
170
  return {
136
171
  closed: false,
137
172
  close: function() {
138
- window.ReactNativeWebView.postMessage(JSON.stringify({
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
- window.ReactNativeWebView.postMessage(JSON.stringify({
184
+ safePostMessage({
150
185
  type: 'console',
151
186
  level: 'error',
152
- message: "FLOW_WEBVIEW: " + 'Unhandled Error: ' + event.message + ' at ' + event.filename + ':' + event.lineno
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
- window.ReactNativeWebView.postMessage(JSON.stringify({
193
+ safePostMessage({
159
194
  type: 'console',
160
195
  level: 'error',
161
- message: "FLOW_WEBVIEW: " + 'Unhandled Promise Rejection: ' + (event.reason?.toString() || 'Unknown')
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("FLOW_WEBVIEW: " + 'Message received: ' + event.data);
168
- window.ReactNativeWebView.postMessage(JSON.stringify({
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("FLOW_WEBVIEW: " + 'GlomoPay WebView JavaScript injection complete');
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,MAoL5B,CAAC"}
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"}