@glomopay/react-native-sdk 2.0.2 → 3.0.1

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 (70) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +261 -310
  3. package/lib/config/base.d.ts +17 -11
  4. package/lib/config/base.d.ts.map +1 -1
  5. package/lib/config/base.js +19 -7
  6. package/lib/config/segment.js +3 -3
  7. package/lib/glomo-checkout.d.ts +8 -0
  8. package/lib/glomo-checkout.d.ts.map +1 -0
  9. package/lib/glomo-checkout.js +69 -0
  10. package/lib/glomo-lrs-checkout.js +9 -9
  11. package/lib/glomo-standard-checkout.d.ts +5 -0
  12. package/lib/glomo-standard-checkout.d.ts.map +1 -0
  13. package/lib/glomo-standard-checkout.js +218 -0
  14. package/lib/index.d.ts +5 -4
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/index.js +7 -5
  17. package/lib/injections/index.d.ts +1 -0
  18. package/lib/injections/index.d.ts.map +1 -1
  19. package/lib/injections/index.js +2 -0
  20. package/lib/injections/webview-flow.injection.d.ts.map +1 -1
  21. package/lib/injections/webview-flow.injection.js +106 -69
  22. package/lib/injections/webview-main.injection.d.ts.map +1 -1
  23. package/lib/injections/webview-main.injection.js +112 -77
  24. package/lib/injections/webview-standard.injection.d.ts +3 -0
  25. package/lib/injections/webview-standard.injection.d.ts.map +1 -0
  26. package/lib/injections/webview-standard.injection.js +214 -0
  27. package/lib/services/order-type-fetcher.d.ts +28 -0
  28. package/lib/services/order-type-fetcher.d.ts.map +1 -0
  29. package/lib/services/order-type-fetcher.js +99 -0
  30. package/lib/types/checkout.d.ts +53 -0
  31. package/lib/types/checkout.d.ts.map +1 -0
  32. package/lib/types/checkout.js +3 -0
  33. package/lib/types/standard-checkout.d.ts +40 -0
  34. package/lib/types/standard-checkout.d.ts.map +1 -0
  35. package/lib/types/standard-checkout.js +3 -0
  36. package/lib/use-glomo-checkout.d.ts +24 -0
  37. package/lib/use-glomo-checkout.d.ts.map +1 -0
  38. package/lib/use-glomo-checkout.js +182 -0
  39. package/lib/use-lrs-checkout.d.ts +9 -4
  40. package/lib/use-lrs-checkout.d.ts.map +1 -1
  41. package/lib/use-lrs-checkout.js +76 -93
  42. package/lib/use-standard-checkout.d.ts +65 -0
  43. package/lib/use-standard-checkout.d.ts.map +1 -0
  44. package/lib/use-standard-checkout.js +832 -0
  45. package/lib/utils/analytics.d.ts +102 -1
  46. package/lib/utils/analytics.d.ts.map +1 -1
  47. package/lib/utils/analytics.js +294 -21
  48. package/lib/utils/device-compliance.js +3 -3
  49. package/lib/utils/validation.d.ts.map +1 -1
  50. package/lib/utils/validation.js +7 -6
  51. package/package.json +3 -2
  52. package/src/config/base.ts +36 -17
  53. package/src/config/segment.ts +3 -3
  54. package/src/glomo-checkout.tsx +73 -0
  55. package/src/glomo-lrs-checkout.tsx +9 -9
  56. package/src/glomo-standard-checkout.tsx +324 -0
  57. package/src/index.ts +13 -7
  58. package/src/injections/index.ts +2 -0
  59. package/src/injections/webview-flow.injection.ts +106 -69
  60. package/src/injections/webview-main.injection.ts +112 -77
  61. package/src/injections/webview-standard.injection.ts +211 -0
  62. package/src/services/order-type-fetcher.ts +86 -0
  63. package/src/types/checkout.ts +65 -0
  64. package/src/types/standard-checkout.ts +49 -0
  65. package/src/use-glomo-checkout.tsx +228 -0
  66. package/src/use-lrs-checkout.tsx +91 -111
  67. package/src/use-standard-checkout.tsx +1185 -0
  68. package/src/utils/analytics.ts +431 -22
  69. package/src/utils/device-compliance.ts +3 -3
  70. package/src/utils/validation.ts +7 -8
@@ -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"}
@@ -4,182 +4,217 @@ exports.injectedScript = void 0;
4
4
  /** Injection JavaScript for the Primary WebView */
5
5
  exports.injectedScript = `
6
6
  (function() {
7
- // Overriding console methods
7
+ // Log prefix for all messages originating from the main WebView
8
+ const LOG_PREFIX = 'MAIN_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' ? JSON.stringify(a, null, 2) : 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' ? JSON.stringify(a, null, 2) : 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' ? JSON.stringify(a, null, 2) : 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' ? JSON.stringify(a, null, 2) : 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: '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: '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: '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: '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
131
  try {
97
- window.ReactNativeWebView.postMessage(JSON.stringify({
98
- type: 'console',
99
- level: 'network',
100
- message: 'XHR RESPONSE LOAD: ' + this._url + ' - Status: ' + this.status
101
- }));
132
+ safePostMessage({
133
+ type: 'console',
134
+ level: 'network',
135
+ message: LOG_PREFIX + 'XHR RESPONSE LOAD: ' + this._url + ' - Status: ' + this.status
136
+ });
102
137
  } catch (e) {
103
- window.ReactNativeWebView.postMessage(JSON.stringify({
138
+ safePostMessage({
104
139
  type: 'console',
105
140
  level: 'network',
106
- message: 'XHR RESPONSE ERROR: ' + this._url + ' - Status: ' + this.status
107
- }));
141
+ message: LOG_PREFIX + 'XHR RESPONSE ERROR: ' + this._url + ' - Status: ' + this.status
142
+ });
108
143
  }
109
144
  });
110
-
145
+
111
146
  this.addEventListener('error', function() {
112
- window.ReactNativeWebView.postMessage(JSON.stringify({
147
+ safePostMessage({
113
148
  type: 'console',
114
149
  level: 'error',
115
- message: 'XHR ERROR: ' + this._url
116
- }));
150
+ message: LOG_PREFIX + 'XHR ERROR: ' + this._url
151
+ });
117
152
  });
118
-
153
+
119
154
  return originalSend.apply(this, arguments);
120
155
  };
121
-
156
+
122
157
  // Intercepting window.open
123
158
  const originalWindowOpen = window.open;
124
159
  window.open = function(url, target, features) {
125
- window.ReactNativeWebView.postMessage(JSON.stringify({
160
+ safePostMessage({
126
161
  type: 'window.open',
127
162
  url: url,
128
163
  target: target,
129
164
  features: features
130
- }));
131
-
132
- // Returning a dummy window object to prevent JS errors
165
+ });
166
+
167
+ // Returning a mock window object to prevent JS errors
133
168
  return {
134
169
  closed: false,
135
170
  close: function() {
136
- window.ReactNativeWebView.postMessage(JSON.stringify({
171
+ safePostMessage({
137
172
  type: 'window.close'
138
- }));
173
+ });
139
174
  },
140
175
  focus: function() {
141
- window.ReactNativeWebView.postMessage(JSON.stringify({
176
+ safePostMessage({
142
177
  type: 'window.focus'
143
- }));
178
+ });
144
179
  },
145
180
  blur: function() {
146
- window.ReactNativeWebView.postMessage(JSON.stringify({
181
+ safePostMessage({
147
182
  type: 'window.blur'
148
- }));
183
+ });
149
184
  }
150
185
  };
151
186
  };
152
-
187
+
153
188
  // Listening for unhandled errors
154
189
  window.addEventListener('error', function(event) {
155
- window.ReactNativeWebView.postMessage(JSON.stringify({
190
+ safePostMessage({
156
191
  type: 'console',
157
192
  level: 'error',
158
- message: 'Unhandled Error: ' + event.message + ' at ' + event.filename + ':' + event.lineno
159
- }));
193
+ message: LOG_PREFIX + 'Unhandled Error: ' + event.message + ' at ' + event.filename + ':' + event.lineno
194
+ });
160
195
  });
161
-
196
+
162
197
  // Listening for unhandled promise rejections
163
198
  window.addEventListener('unhandledrejection', function(event) {
164
- window.ReactNativeWebView.postMessage(JSON.stringify({
199
+ safePostMessage({
165
200
  type: 'console',
166
201
  level: 'error',
167
- message: 'Unhandled Promise Rejection: ' + (event.reason?.toString() || 'Unknown')
168
- }));
202
+ message: LOG_PREFIX + 'Unhandled Promise Rejection: ' + (event.reason?.toString() || 'Unknown')
203
+ });
169
204
  });
170
205
 
171
206
  // Listening for messages from the WebView
172
207
  window.addEventListener('message', function(event) {
173
- console.log("MAIN_WEBVIEW: " + 'Message received: ' + event.data);
174
- window.ReactNativeWebView.postMessage(JSON.stringify({
208
+ console.log(LOG_PREFIX + 'Message received: ' + event.data);
209
+ safePostMessage({
175
210
  type: 'message',
176
211
  message: event.data
177
- }));
212
+ });
178
213
  });
179
-
214
+
180
215
  // Logging that injection is complete
181
- console.log('GlomoPay WebView JavaScript injection complete');
182
-
216
+ console.log(LOG_PREFIX + 'GlomoPay WebView JavaScript injection complete');
217
+
183
218
  true; // Required for injected JavaScript
184
219
  })();
185
220
  `;
@@ -0,0 +1,3 @@
1
+ /** Injection JavaScript for the Standard Checkout WebView */
2
+ export declare const injectedScript: string;
3
+ //# sourceMappingURL=webview-standard.injection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-standard.injection.d.ts","sourceRoot":"","sources":["../../src/injections/webview-standard.injection.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,eAAO,MAAM,cAAc,EAAE,MAiN5B,CAAC"}