@btsd/aitu-bridge 0.3.42 → 0.3.44

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/src/index.ts CHANGED
@@ -76,11 +76,6 @@ interface GetUserProfileResponse {
76
76
  avatarThumb?: string;
77
77
  }
78
78
 
79
- interface CheckBiometryResponse {
80
- data: boolean;
81
- error?: string
82
- }
83
-
84
79
  const MAX_HEADER_MENU_ITEMS_COUNT = 3;
85
80
 
86
81
  export enum HeaderMenuIcon {
@@ -155,7 +150,7 @@ export interface AituBridge {
155
150
  setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;
156
151
  openPayment: (transactionId: string) => Promise<ResponseType>;
157
152
  setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
158
- checkBiometry: () => Promise<CheckBiometryResponse>;
153
+ checkBiometry: () => Promise<ResponseType>;
159
154
  }
160
155
 
161
156
  const invokeMethod = 'invoke';
@@ -196,22 +191,6 @@ const buildBridge = (): AituBridge => {
196
191
  window.addEventListener('aituEvents', (e: any) => {
197
192
  [...subs].map((fn) => fn.call(null, e));
198
193
  })
199
-
200
- window.addEventListener('message', (e) => {
201
- if (typeof e.data !== 'string') {
202
- return;
203
- }
204
-
205
- const message = JSON.parse(e.data)
206
-
207
- if (message && message['method']) {
208
- if (message.method === 'setCustomBackArrowOnClickHandler') {
209
- (window as any).onAituBridgeBackArrowClick()
210
- } else if (message.method === 'setHeaderMenuItemClickHandler') {
211
- (window as any).onAituBridgeHeaderMenuItemClick(message.param)
212
- }
213
- }
214
- })
215
194
  }
216
195
 
217
196
  const invoke = (reqId, method, data = {}) => {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.3.42";
1
+ export const LIB_VERSION = "0.3.44";
package/src/webBridge.ts CHANGED
@@ -35,7 +35,28 @@ if (aituOrigin) {
35
35
  }
36
36
  window.addEventListener('message', event => {
37
37
  if (event.origin === aituOrigin && event.data) {
38
+
39
+ // dispatch aitu events
38
40
  window.dispatchEvent(new CustomEvent('aituEvents', { detail: event.data }));
41
+
42
+ // try to detect handler call
43
+ if (typeof event.data !== 'string' || event.data === '') {
44
+ return;
45
+ }
46
+
47
+ try {
48
+ const message = JSON.parse(event.data)
49
+
50
+ if (message && message['method']) {
51
+ if (message.method === 'setCustomBackArrowOnClickHandler') {
52
+ (window as any).onAituBridgeBackArrowClick()
53
+ } else if (message.method === 'setHeaderMenuItemClickHandler') {
54
+ (window as any).onAituBridgeHeaderMenuItemClick(message.param)
55
+ }
56
+ }
57
+ } catch (e) {
58
+ console.log('Error parsing message data: ' + e);
59
+ }
39
60
  }
40
61
  })
41
62
  }