@btsd/aitu-bridge 0.3.4 → 0.3.5
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/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/index.ts +21 -16
- package/src/version.ts +1 -1
- package/src/webBridge.ts +21 -0
package/src/index.ts
CHANGED
|
@@ -37,6 +37,8 @@ interface GetMeResponse {
|
|
|
37
37
|
id: string;
|
|
38
38
|
avatar?: string;
|
|
39
39
|
avatarThumb?: string;
|
|
40
|
+
notifications_allowed: boolean;
|
|
41
|
+
private_messaging_enabled: boolean;
|
|
40
42
|
sign: string;
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -148,6 +150,7 @@ export interface AituBridge {
|
|
|
148
150
|
setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;
|
|
149
151
|
openPayment: (transactionId: string) => Promise<ResponseType>;
|
|
150
152
|
setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
|
|
153
|
+
checkBiometry: () => Promise<ResponseType>;
|
|
151
154
|
}
|
|
152
155
|
|
|
153
156
|
const invokeMethod = 'invoke';
|
|
@@ -175,6 +178,7 @@ const getCustomBackArrowModeMethod = 'getCustomBackArrowMode';
|
|
|
175
178
|
const setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';
|
|
176
179
|
const openPaymentMethod = 'openPayment'
|
|
177
180
|
const setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';
|
|
181
|
+
const checkBiometryMethod = 'checkBiometry';
|
|
178
182
|
|
|
179
183
|
const android = typeof window !== 'undefined' && (window as any).AndroidBridge;
|
|
180
184
|
const ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;
|
|
@@ -187,22 +191,6 @@ const buildBridge = (): AituBridge => {
|
|
|
187
191
|
window.addEventListener('aituEvents', (e: any) => {
|
|
188
192
|
[...subs].map((fn) => fn.call(null, e));
|
|
189
193
|
})
|
|
190
|
-
|
|
191
|
-
window.addEventListener('message', (e) => {
|
|
192
|
-
if(typeof e.data !== 'string') {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const message = JSON.parse(e.data)
|
|
197
|
-
|
|
198
|
-
if (message && message['method']) {
|
|
199
|
-
if (message.method === 'setCustomBackArrowOnClickHandler') {
|
|
200
|
-
(window as any).onAituBridgeBackArrowClick()
|
|
201
|
-
} else if (message.method === 'setHeaderMenuItemClickHandler') {
|
|
202
|
-
(window as any).onAituBridgeHeaderMenuItemClick(message.param)
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
})
|
|
206
194
|
}
|
|
207
195
|
|
|
208
196
|
const invoke = (reqId, method, data = {}) => {
|
|
@@ -619,6 +607,21 @@ const buildBridge = (): AituBridge => {
|
|
|
619
607
|
}
|
|
620
608
|
}
|
|
621
609
|
|
|
610
|
+
const checkBiometry = (reqId) => {
|
|
611
|
+
const isAndroid = android && android[checkBiometryMethod];
|
|
612
|
+
const isIos = ios && ios[checkBiometryMethod];
|
|
613
|
+
|
|
614
|
+
if (isAndroid) {
|
|
615
|
+
android[checkBiometryMethod](reqId);
|
|
616
|
+
} else if (isIos) {
|
|
617
|
+
ios[checkBiometryMethod].postMessage({ reqId });
|
|
618
|
+
} else if (web) {
|
|
619
|
+
web.execute(checkBiometryMethod, reqId);
|
|
620
|
+
} else if (typeof window !== 'undefined') {
|
|
621
|
+
console.log('--checkBiometry-isUnknown');
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
622
625
|
|
|
623
626
|
const invokePromise = promisifyInvoke(invoke, sub);
|
|
624
627
|
const storagePromise = promisifyStorage(storage, sub);
|
|
@@ -641,6 +644,7 @@ const buildBridge = (): AituBridge => {
|
|
|
641
644
|
const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);
|
|
642
645
|
const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);
|
|
643
646
|
const openPaymentPromise = promisifyMethod(openPayment, openPaymentMethod, sub);
|
|
647
|
+
const checkBiometryPromise = promisifyMethod(checkBiometry, checkBiometryMethod, sub);
|
|
644
648
|
|
|
645
649
|
return {
|
|
646
650
|
version: String(LIB_VERSION),
|
|
@@ -680,6 +684,7 @@ const buildBridge = (): AituBridge => {
|
|
|
680
684
|
setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,
|
|
681
685
|
openPayment: openPaymentPromise,
|
|
682
686
|
setCustomBackArrowOnClickHandler,
|
|
687
|
+
checkBiometry: checkBiometryPromise,
|
|
683
688
|
}
|
|
684
689
|
}
|
|
685
690
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.3.
|
|
1
|
+
export const LIB_VERSION = "0.3.5";
|
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
|
}
|