@expressms/smartapp-sdk 1.12.0-alpha.5 → 1.12.0-alpha.6
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/build/main/index.d.ts +9 -9
- package/build/main/index.js +24 -56
- package/build/main/lib/client/index.d.ts +14 -3
- package/build/main/lib/client/index.js +39 -9
- package/build/main/lib/devices/bluetooth.d.ts +52 -0
- package/build/main/lib/devices/bluetooth.js +160 -0
- package/build/main/lib/devices/gps.d.ts +5 -0
- package/build/main/lib/devices/gps.js +20 -0
- package/build/main/lib/devices/index.d.ts +5 -0
- package/build/main/lib/devices/index.js +35 -0
- package/build/main/lib/devices/nfc.d.ts +6 -0
- package/build/main/lib/devices/nfc.js +24 -0
- package/build/main/lib/helpers/helpers.d.ts +0 -1
- package/build/main/lib/helpers/helpers.js +2 -12
- package/build/main/lib/logging/index.js +5 -9
- package/build/main/lib/notification/index.d.ts +1 -2
- package/build/main/lib/notification/index.js +1 -1
- package/build/main/lib/routing/index.d.ts +6 -7
- package/build/main/lib/routing/index.js +2 -2
- package/build/main/types/bridge.d.ts +7 -32
- package/build/main/types/bridge.js +8 -4
- package/build/main/types/devices.d.ts +53 -0
- package/build/main/types/devices.js +3 -0
- package/build/main/types/index.d.ts +1 -0
- package/build/main/types/index.js +2 -1
- package/build/module/index.d.ts +9 -9
- package/build/module/index.js +10 -10
- package/build/module/lib/client/index.d.ts +14 -3
- package/build/module/lib/client/index.js +37 -8
- package/build/module/lib/devices/bluetooth.d.ts +52 -0
- package/build/module/lib/devices/bluetooth.js +148 -0
- package/build/module/lib/devices/gps.d.ts +5 -0
- package/build/module/lib/devices/gps.js +13 -0
- package/build/module/lib/devices/index.d.ts +5 -0
- package/build/module/lib/devices/index.js +6 -0
- package/build/module/lib/devices/nfc.d.ts +6 -0
- package/build/module/lib/devices/nfc.js +17 -0
- package/build/module/lib/helpers/helpers.d.ts +0 -1
- package/build/module/lib/helpers/helpers.js +1 -10
- package/build/module/lib/logging/index.js +4 -8
- package/build/module/lib/notification/index.d.ts +1 -2
- package/build/module/lib/notification/index.js +2 -3
- package/build/module/lib/routing/index.d.ts +6 -7
- package/build/module/lib/routing/index.js +7 -8
- package/build/module/types/bridge.d.ts +7 -32
- package/build/module/types/bridge.js +8 -4
- package/build/module/types/devices.d.ts +53 -0
- package/build/module/types/devices.js +2 -0
- package/build/module/types/index.d.ts +1 -0
- package/build/module/types/index.js +2 -1
- package/build/umd/index.js +222 -98
- package/package.json +1 -1
- package/build/main/lib/proxy/index.d.ts +0 -35
- package/build/main/lib/proxy/index.js +0 -102
- package/build/main/types/proxy.d.ts +0 -40
- package/build/main/types/proxy.js +0 -3
- package/build/module/lib/proxy/index.d.ts +0 -35
- package/build/module/lib/proxy/index.js +0 -91
- package/build/module/types/proxy.d.ts +0 -40
- package/build/module/types/proxy.js +0 -2
package/build/umd/index.js
CHANGED
|
@@ -1996,9 +1996,13 @@
|
|
|
1996
1996
|
METHODS["GET_SMARTAPP_LIST"] = "get_smartapp_list";
|
|
1997
1997
|
METHODS["SET_WEB_RESOURCE_COOKIES"] = "set_web_resource_cookies";
|
|
1998
1998
|
METHODS["SET_ALLOWED_NAVIGATION_DOMAINS"] = "set_allowed_navigation_domains";
|
|
1999
|
-
METHODS["
|
|
2000
|
-
METHODS["
|
|
2001
|
-
METHODS["
|
|
1999
|
+
METHODS["ENABLE_BLUETOOTH"] = "enable_bluetooth";
|
|
2000
|
+
METHODS["SCAN_BLE_DEVICES"] = "scan_ble_devices";
|
|
2001
|
+
METHODS["CONNECT_BLE_DEVICE"] = "connect_ble_device";
|
|
2002
|
+
METHODS["DISCONNECT_BLE_DEVICE"] = "disconnect_ble_device";
|
|
2003
|
+
METHODS["DISCOVER_BLE_GATT_SERVICES"] = "discover_ble_gatt_services";
|
|
2004
|
+
METHODS["READ_BLE_GATT_CHARACTERISTIC"] = "read_ble_gatt_characteristic";
|
|
2005
|
+
METHODS["READ_NFC_TAG"] = "read_nfc_tag";
|
|
2002
2006
|
})(METHODS || (METHODS = {}));
|
|
2003
2007
|
var STATUS;
|
|
2004
2008
|
(function (STATUS) {
|
|
@@ -2053,7 +2057,7 @@
|
|
|
2053
2057
|
const id = getSubscriptionId(eventType, payload);
|
|
2054
2058
|
return subscriptions.some(sub => sub.id == id);
|
|
2055
2059
|
};
|
|
2056
|
-
const installBridgeEventListener = () => {
|
|
2060
|
+
const installBridgeEventListener$1 = () => {
|
|
2057
2061
|
if (bridgeEventListenerInstalled || !bridge)
|
|
2058
2062
|
return;
|
|
2059
2063
|
bridgeEventListenerInstalled = true;
|
|
@@ -2092,7 +2096,7 @@
|
|
|
2092
2096
|
const id = getSubscriptionId(eventType, payload);
|
|
2093
2097
|
if (response.payload.status !== STATUS.SUCCESS)
|
|
2094
2098
|
return response;
|
|
2095
|
-
installBridgeEventListener();
|
|
2099
|
+
installBridgeEventListener$1();
|
|
2096
2100
|
subscriptions.push({ id, callback });
|
|
2097
2101
|
return response;
|
|
2098
2102
|
});
|
|
@@ -2242,12 +2246,6 @@
|
|
|
2242
2246
|
},
|
|
2243
2247
|
});
|
|
2244
2248
|
};
|
|
2245
|
-
const requestLocation = () => {
|
|
2246
|
-
return bridge?.sendClientEvent({
|
|
2247
|
-
method: METHODS.REQUEST_LOCATION,
|
|
2248
|
-
params: {},
|
|
2249
|
-
});
|
|
2250
|
-
};
|
|
2251
2249
|
/**
|
|
2252
2250
|
* Get client current connection status. It's based on client's WebSocket connection state.
|
|
2253
2251
|
* @returns Promise that'll be fullfilled with status data on success, otherwise rejected with reason
|
|
@@ -2387,6 +2385,41 @@
|
|
|
2387
2385
|
})
|
|
2388
2386
|
.then(event => event);
|
|
2389
2387
|
};
|
|
2388
|
+
/**
|
|
2389
|
+
* Set cookies for web resouce. It's needed for SSO auth cases.
|
|
2390
|
+
* @param cookies List of cookie strings !with domains!
|
|
2391
|
+
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
2392
|
+
*/
|
|
2393
|
+
const setWebResourceCookies = (cookies) => {
|
|
2394
|
+
if (!bridge)
|
|
2395
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2396
|
+
return bridge
|
|
2397
|
+
.sendClientEvent({
|
|
2398
|
+
method: METHODS.SET_WEB_RESOURCE_COOKIES,
|
|
2399
|
+
params: {
|
|
2400
|
+
cookies,
|
|
2401
|
+
},
|
|
2402
|
+
})
|
|
2403
|
+
.then(event => event);
|
|
2404
|
+
};
|
|
2405
|
+
/**
|
|
2406
|
+
* Allow WebView то open links inside, not in external browser
|
|
2407
|
+
* @param domains List domains without schema
|
|
2408
|
+
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
2409
|
+
*/
|
|
2410
|
+
const setAllowedNavigationDomains = (domains) => {
|
|
2411
|
+
if (!bridge)
|
|
2412
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2413
|
+
return bridge
|
|
2414
|
+
.sendClientEvent({
|
|
2415
|
+
method: METHODS.SET_ALLOWED_NAVIGATION_DOMAINS,
|
|
2416
|
+
params: {
|
|
2417
|
+
domains,
|
|
2418
|
+
},
|
|
2419
|
+
timeout: 1000,
|
|
2420
|
+
})
|
|
2421
|
+
.then(event => event);
|
|
2422
|
+
};
|
|
2390
2423
|
|
|
2391
2424
|
const FILE_LOAD_TIMEOUT = 60 * 60 * 1000;
|
|
2392
2425
|
/**
|
|
@@ -2501,15 +2534,6 @@
|
|
|
2501
2534
|
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
2502
2535
|
return Object.fromEntries(urlSearchParams.entries());
|
|
2503
2536
|
};
|
|
2504
|
-
const noop = (event) => {
|
|
2505
|
-
event.preventDefault();
|
|
2506
|
-
return false;
|
|
2507
|
-
};
|
|
2508
|
-
const disableCopy = () => {
|
|
2509
|
-
document.addEventListener('selectstart', noop);
|
|
2510
|
-
document.addEventListener('contextmenu', noop);
|
|
2511
|
-
document.addEventListener('copy', noop);
|
|
2512
|
-
};
|
|
2513
2537
|
|
|
2514
2538
|
const bridgeSendReady = (timeout) => {
|
|
2515
2539
|
const event = {
|
|
@@ -2520,15 +2544,12 @@
|
|
|
2520
2544
|
};
|
|
2521
2545
|
|
|
2522
2546
|
const ready = async (timeout) => {
|
|
2523
|
-
if (!bridge)
|
|
2524
|
-
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2525
2547
|
const response = await bridgeSendReady(timeout);
|
|
2526
2548
|
const isLogsEnabled = response?.payload?.logsEnabled;
|
|
2527
|
-
|
|
2549
|
+
if (!bridge)
|
|
2550
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2528
2551
|
if (isLogsEnabled)
|
|
2529
|
-
bridge.enableLogs();
|
|
2530
|
-
if (isCopyDisabled)
|
|
2531
|
-
disableCopy();
|
|
2552
|
+
bridge.enableLogs?.();
|
|
2532
2553
|
return response;
|
|
2533
2554
|
};
|
|
2534
2555
|
|
|
@@ -2545,135 +2566,241 @@
|
|
|
2545
2566
|
});
|
|
2546
2567
|
};
|
|
2547
2568
|
|
|
2569
|
+
const routingChanged = (isRoot) => {
|
|
2570
|
+
return bridge?.sendClientEvent({
|
|
2571
|
+
method: METHODS.ROUTING_CHANGED,
|
|
2572
|
+
params: {
|
|
2573
|
+
location: isRoot ? LOCATION.ROOT : LOCATION.NESTED,
|
|
2574
|
+
},
|
|
2575
|
+
});
|
|
2576
|
+
};
|
|
2577
|
+
const onBackPressed = (handleBackPressed) => {
|
|
2578
|
+
return bridge?.onReceive(event => {
|
|
2579
|
+
if (event.type === METHODS.BACK_PRESSED)
|
|
2580
|
+
handleBackPressed();
|
|
2581
|
+
});
|
|
2582
|
+
};
|
|
2583
|
+
const openSmartApp = ({ appId, meta }) => {
|
|
2584
|
+
return bridge?.sendClientEvent({
|
|
2585
|
+
method: METHODS.OPEN_SMART_APP,
|
|
2586
|
+
params: meta ? { appId, meta } : { appId },
|
|
2587
|
+
});
|
|
2588
|
+
};
|
|
2589
|
+
const closeSmartApp = () => {
|
|
2590
|
+
return bridge?.sendClientEvent({
|
|
2591
|
+
method: METHODS.CLOSE_SMART_APP,
|
|
2592
|
+
params: {},
|
|
2593
|
+
});
|
|
2594
|
+
};
|
|
2595
|
+
const onMoveToRoot = (handleMoveToRoot) => {
|
|
2596
|
+
return bridge?.onReceive(event => {
|
|
2597
|
+
if (event.type === METHODS.MOVE_TO_ROOT)
|
|
2598
|
+
handleMoveToRoot();
|
|
2599
|
+
});
|
|
2600
|
+
};
|
|
2601
|
+
const exitSmartAppToCatalog = () => {
|
|
2602
|
+
return bridge?.sendClientEvent({
|
|
2603
|
+
method: METHODS.OPEN_SMART_APP,
|
|
2604
|
+
params: { appId: '' },
|
|
2605
|
+
});
|
|
2606
|
+
};
|
|
2607
|
+
|
|
2608
|
+
const deviceCallbacks = [];
|
|
2548
2609
|
/**
|
|
2549
|
-
*
|
|
2550
|
-
* @param cookies List of cookie strings !with domains!
|
|
2551
|
-
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
2610
|
+
* Install bridge event listener for founded devices during scan
|
|
2552
2611
|
*/
|
|
2553
|
-
const
|
|
2612
|
+
const installBridgeEventListener = () => {
|
|
2613
|
+
if (!bridge)
|
|
2614
|
+
return;
|
|
2615
|
+
bridge.onReceive(event => {
|
|
2616
|
+
if (event.type !== 'ble_device_found')
|
|
2617
|
+
return;
|
|
2618
|
+
const { payload: { bleDevice }, } = event;
|
|
2619
|
+
deviceCallbacks.map(cb => cb(bleDevice));
|
|
2620
|
+
});
|
|
2621
|
+
};
|
|
2622
|
+
/**
|
|
2623
|
+
* Add callback to list
|
|
2624
|
+
*/
|
|
2625
|
+
const addDeviceCallback = (callback) => {
|
|
2626
|
+
if (callback)
|
|
2627
|
+
deviceCallbacks.push(callback);
|
|
2628
|
+
};
|
|
2629
|
+
/**
|
|
2630
|
+
* Remove callback from list
|
|
2631
|
+
*/
|
|
2632
|
+
const removeDeviceCallback = (callback) => {
|
|
2633
|
+
if (!callback)
|
|
2634
|
+
return;
|
|
2635
|
+
const index = deviceCallbacks.findIndex(cb => cb === callback);
|
|
2636
|
+
if (index !== -1)
|
|
2637
|
+
deviceCallbacks.splice(index, 1);
|
|
2638
|
+
};
|
|
2639
|
+
/**
|
|
2640
|
+
* Enable bluetooth
|
|
2641
|
+
* @returns Promise that'll be fullfilled on success, otherwise rejected with reason
|
|
2642
|
+
*/
|
|
2643
|
+
const enable = () => {
|
|
2554
2644
|
if (!bridge)
|
|
2555
2645
|
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2556
2646
|
return bridge
|
|
2557
2647
|
.sendClientEvent({
|
|
2558
|
-
method: METHODS.
|
|
2559
|
-
params: {
|
|
2560
|
-
cookies,
|
|
2561
|
-
},
|
|
2648
|
+
method: METHODS.ENABLE_BLUETOOTH,
|
|
2649
|
+
params: {},
|
|
2562
2650
|
})
|
|
2563
2651
|
.then(event => event);
|
|
2564
2652
|
};
|
|
2565
2653
|
/**
|
|
2566
|
-
*
|
|
2567
|
-
* @param
|
|
2568
|
-
* @
|
|
2654
|
+
* Scan BLE devices nearby
|
|
2655
|
+
* @param scanDuration Duration to scan devices in milliseconds
|
|
2656
|
+
* @param deviceCallback Callback that triggered on device found
|
|
2657
|
+
* @returns Promise that'll be fullfilled with `payload.bleDevices` on success, otherwise rejected with reason
|
|
2569
2658
|
*/
|
|
2570
|
-
const
|
|
2659
|
+
const scanBleDevices = ({ scanDuration, deviceCallback, }) => {
|
|
2571
2660
|
if (!bridge)
|
|
2572
2661
|
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2662
|
+
addDeviceCallback(deviceCallback);
|
|
2573
2663
|
return bridge
|
|
2574
2664
|
.sendClientEvent({
|
|
2575
|
-
method: METHODS.
|
|
2665
|
+
method: METHODS.SCAN_BLE_DEVICES,
|
|
2576
2666
|
params: {
|
|
2577
|
-
|
|
2667
|
+
scanDuration,
|
|
2578
2668
|
},
|
|
2579
|
-
timeout: 1000,
|
|
2580
2669
|
})
|
|
2581
|
-
.then(event =>
|
|
2670
|
+
.then(event => {
|
|
2671
|
+
removeDeviceCallback(deviceCallback);
|
|
2672
|
+
return event;
|
|
2673
|
+
})
|
|
2674
|
+
.catch(() => {
|
|
2675
|
+
removeDeviceCallback(deviceCallback);
|
|
2676
|
+
return Promise.reject();
|
|
2677
|
+
});
|
|
2582
2678
|
};
|
|
2583
2679
|
/**
|
|
2584
|
-
*
|
|
2585
|
-
* @
|
|
2680
|
+
* Connect bluetooth BLE device
|
|
2681
|
+
* @param bleDeviceAddress Address of the BLE device
|
|
2682
|
+
* @returns Promise that'll be fullfilled on success, otherwise rejected with reason
|
|
2586
2683
|
*/
|
|
2587
|
-
const
|
|
2684
|
+
const connectBleDevice = ({ bleDeviceAddress, }) => {
|
|
2588
2685
|
if (!bridge)
|
|
2589
2686
|
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2590
2687
|
return bridge
|
|
2591
2688
|
.sendClientEvent({
|
|
2592
|
-
method: METHODS.
|
|
2593
|
-
params: {
|
|
2594
|
-
|
|
2689
|
+
method: METHODS.CONNECT_BLE_DEVICE,
|
|
2690
|
+
params: {
|
|
2691
|
+
bleDeviceAddress,
|
|
2692
|
+
},
|
|
2595
2693
|
})
|
|
2596
2694
|
.then(event => event);
|
|
2597
2695
|
};
|
|
2598
2696
|
/**
|
|
2599
|
-
*
|
|
2600
|
-
* @param
|
|
2601
|
-
* @
|
|
2602
|
-
* @returns Promise that'll be fullfilled with credentials on success, otherwise rejected with reason
|
|
2697
|
+
* Disonnect bluetooth BLE device
|
|
2698
|
+
* @param bleDeviceAddress Address of the BLE device
|
|
2699
|
+
* @returns Promise that'll be fullfilled on success, otherwise rejected with reason
|
|
2603
2700
|
*/
|
|
2604
|
-
const
|
|
2701
|
+
const disconnectBleDevice = ({ bleDeviceAddress, }) => {
|
|
2605
2702
|
if (!bridge)
|
|
2606
2703
|
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2607
2704
|
return bridge
|
|
2608
2705
|
.sendClientEvent({
|
|
2609
|
-
method: METHODS.
|
|
2706
|
+
method: METHODS.DISCONNECT_BLE_DEVICE,
|
|
2610
2707
|
params: {
|
|
2611
|
-
|
|
2612
|
-
password,
|
|
2708
|
+
bleDeviceAddress,
|
|
2613
2709
|
},
|
|
2614
|
-
timeout: 10_000,
|
|
2615
2710
|
})
|
|
2616
2711
|
.then(event => event);
|
|
2617
2712
|
};
|
|
2618
2713
|
/**
|
|
2619
|
-
*
|
|
2620
|
-
* @param
|
|
2621
|
-
* @returns Promise that'll be fullfilled
|
|
2714
|
+
* Discover services and characteristics of the BLE device
|
|
2715
|
+
* @param bleDeviceAddress Address of the BLE device
|
|
2716
|
+
* @returns Promise that'll be fullfilled with `payload.gattServices` on success, otherwise rejected with reason
|
|
2622
2717
|
*/
|
|
2623
|
-
const
|
|
2718
|
+
const discoverGattServices = ({ bleDeviceAddress, }) => {
|
|
2624
2719
|
if (!bridge)
|
|
2625
2720
|
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2626
2721
|
return bridge
|
|
2627
2722
|
.sendClientEvent({
|
|
2628
|
-
method: METHODS.
|
|
2723
|
+
method: METHODS.DISCOVER_BLE_GATT_SERVICES,
|
|
2629
2724
|
params: {
|
|
2630
|
-
|
|
2725
|
+
bleDeviceAddress,
|
|
2631
2726
|
},
|
|
2632
|
-
timeout: 1000,
|
|
2633
2727
|
})
|
|
2634
2728
|
.then(event => event);
|
|
2635
2729
|
};
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2730
|
+
/**
|
|
2731
|
+
* Read BLE GATT characteristic
|
|
2732
|
+
* @param bleDeviceAddress Address of the BLE device
|
|
2733
|
+
* @param gattServiceUuid UUID of the GATT service
|
|
2734
|
+
* @param gattCharacteristicUuid UUID of the GATT characteristic
|
|
2735
|
+
* @returns Promise that'll be fullfilled with `payload.value` on success, otherwise rejected with reason
|
|
2736
|
+
*/
|
|
2737
|
+
const readBleGattCharacteristic = ({ bleDeviceAddress, gattServiceUuid, gattCharacteristicUuid, }) => {
|
|
2738
|
+
if (!bridge)
|
|
2739
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2740
|
+
return bridge
|
|
2741
|
+
.sendClientEvent({
|
|
2742
|
+
method: METHODS.READ_BLE_GATT_CHARACTERISTIC,
|
|
2640
2743
|
params: {
|
|
2641
|
-
|
|
2744
|
+
bleDeviceAddress,
|
|
2745
|
+
gattServiceUuid,
|
|
2746
|
+
gattCharacteristicUuid,
|
|
2642
2747
|
},
|
|
2643
|
-
})
|
|
2644
|
-
|
|
2645
|
-
const onBackPressed = (handleBackPressed) => {
|
|
2646
|
-
return bridge?.onReceive(event => {
|
|
2647
|
-
if (event.type === METHODS.BACK_PRESSED)
|
|
2648
|
-
handleBackPressed();
|
|
2649
|
-
});
|
|
2650
|
-
};
|
|
2651
|
-
const openSmartApp = ({ appId, meta }) => {
|
|
2652
|
-
return bridge?.sendClientEvent({
|
|
2653
|
-
method: METHODS.OPEN_SMART_APP,
|
|
2654
|
-
params: meta ? { appId, meta } : { appId },
|
|
2655
|
-
});
|
|
2748
|
+
})
|
|
2749
|
+
.then(event => event);
|
|
2656
2750
|
};
|
|
2657
|
-
|
|
2751
|
+
// Init device event listener
|
|
2752
|
+
installBridgeEventListener();
|
|
2753
|
+
|
|
2754
|
+
var bluetooth = /*#__PURE__*/Object.freeze({
|
|
2755
|
+
__proto__: null,
|
|
2756
|
+
enable: enable,
|
|
2757
|
+
scanBleDevices: scanBleDevices,
|
|
2758
|
+
connectBleDevice: connectBleDevice,
|
|
2759
|
+
disconnectBleDevice: disconnectBleDevice,
|
|
2760
|
+
discoverGattServices: discoverGattServices,
|
|
2761
|
+
readBleGattCharacteristic: readBleGattCharacteristic
|
|
2762
|
+
});
|
|
2763
|
+
|
|
2764
|
+
/**
|
|
2765
|
+
* Request GPS position
|
|
2766
|
+
* @returns Promise that'll be fullfilled with `payload.*` on success, otherwise rejected with reason
|
|
2767
|
+
*/
|
|
2768
|
+
const requestLocation = () => {
|
|
2658
2769
|
return bridge?.sendClientEvent({
|
|
2659
|
-
method: METHODS.
|
|
2770
|
+
method: METHODS.REQUEST_LOCATION,
|
|
2660
2771
|
params: {},
|
|
2661
2772
|
});
|
|
2662
2773
|
};
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2774
|
+
|
|
2775
|
+
var gps = /*#__PURE__*/Object.freeze({
|
|
2776
|
+
__proto__: null,
|
|
2777
|
+
requestLocation: requestLocation
|
|
2778
|
+
});
|
|
2779
|
+
|
|
2780
|
+
/**
|
|
2781
|
+
* Enable bluetooth
|
|
2782
|
+
* @returns Promise that'll be fullfilled with `payload.nfcTag` on success, otherwise rejected with reason
|
|
2783
|
+
*/
|
|
2784
|
+
const readTag = () => {
|
|
2785
|
+
if (!bridge)
|
|
2786
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2787
|
+
return bridge
|
|
2788
|
+
.sendClientEvent({
|
|
2789
|
+
method: METHODS.ENABLE_BLUETOOTH,
|
|
2790
|
+
params: {},
|
|
2791
|
+
})
|
|
2792
|
+
.then(event => event);
|
|
2674
2793
|
};
|
|
2675
2794
|
|
|
2795
|
+
var nfc = /*#__PURE__*/Object.freeze({
|
|
2796
|
+
__proto__: null,
|
|
2797
|
+
readTag: readTag
|
|
2798
|
+
});
|
|
2799
|
+
|
|
2800
|
+
exports.Bluetooth = bluetooth;
|
|
2676
2801
|
exports.Bridge = bridge;
|
|
2802
|
+
exports.GPS = gps;
|
|
2803
|
+
exports.NFC = nfc;
|
|
2677
2804
|
exports.addContact = addContact;
|
|
2678
2805
|
exports.cleanCache = cleanCache;
|
|
2679
2806
|
exports.clientStorageClear = clientStorageClear;
|
|
@@ -2688,7 +2815,6 @@
|
|
|
2688
2815
|
exports.getChats = getChats;
|
|
2689
2816
|
exports.getConnectionStatus = getConnectionStatus;
|
|
2690
2817
|
exports.getContact = getContact;
|
|
2691
|
-
exports.getCredentials = getCredentials;
|
|
2692
2818
|
exports.getLayoutType = getLayoutType;
|
|
2693
2819
|
exports.getSmartAppList = getSmartAppList;
|
|
2694
2820
|
exports.getUnreadCounter = getUnreadCounter;
|
|
@@ -2707,13 +2833,11 @@
|
|
|
2707
2833
|
exports.requestLocation = requestLocation;
|
|
2708
2834
|
exports.requestSelfProfile = requestSelfProfile;
|
|
2709
2835
|
exports.routingChanged = routingChanged;
|
|
2710
|
-
exports.runWebCommandsPipeline = runWebCommandsPipeline;
|
|
2711
2836
|
exports.searchCorporatePhonebook = searchCorporatePhonebook;
|
|
2712
2837
|
exports.searchLocalPhonebook = searchLocalPhonebook;
|
|
2713
2838
|
exports.sendBotCommand = sendBotCommand;
|
|
2714
2839
|
exports.sendMessage = sendMessage;
|
|
2715
2840
|
exports.setAllowedNavigationDomains = setAllowedNavigationDomains;
|
|
2716
|
-
exports.setCredentials = setCredentials;
|
|
2717
2841
|
exports.setWebResourceCookies = setWebResourceCookies;
|
|
2718
2842
|
exports.subscribeClientEvents = subscribeClientEvents;
|
|
2719
2843
|
exports.unsubscribeClientEvents = unsubscribeClientEvents;
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { CookieItem, StatusResponse } from '../../types';
|
|
2
|
-
import { GetCredentialsResponse, WebCommandsPipeline } from '../../types/proxy';
|
|
3
|
-
/**
|
|
4
|
-
* Set cookies for web resouce. It's needed for SSO auth cases.
|
|
5
|
-
* @param cookies List of cookie strings !with domains!
|
|
6
|
-
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
7
|
-
*/
|
|
8
|
-
export declare const setWebResourceCookies: (cookies: CookieItem[]) => Promise<StatusResponse>;
|
|
9
|
-
/**
|
|
10
|
-
* Allow WebView то open links inside, not in external browser
|
|
11
|
-
* @param domains List domains without schema
|
|
12
|
-
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
13
|
-
*/
|
|
14
|
-
export declare const setAllowedNavigationDomains: (domains: string[]) => Promise<StatusResponse>;
|
|
15
|
-
/**
|
|
16
|
-
* DRAFT: Get saved credentials of web resource
|
|
17
|
-
* @returns Promise that'll be fullfilled with credentials on success, otherwise rejected with reason
|
|
18
|
-
*/
|
|
19
|
-
export declare const getCredentials: () => Promise<GetCredentialsResponse>;
|
|
20
|
-
/**
|
|
21
|
-
* DRAFT: Save credentials of web resource
|
|
22
|
-
* @param login User login
|
|
23
|
-
* @param password User pass
|
|
24
|
-
* @returns Promise that'll be fullfilled with credentials on success, otherwise rejected with reason
|
|
25
|
-
*/
|
|
26
|
-
export declare const setCredentials: ({ login, password }: {
|
|
27
|
-
login: string;
|
|
28
|
-
password: string;
|
|
29
|
-
}) => Promise<StatusResponse>;
|
|
30
|
-
/**
|
|
31
|
-
* Run pipeline for manipulating web resource
|
|
32
|
-
* @param pipeline Pipeline with jobs & command
|
|
33
|
-
* @returns Promise that'll be fullfilled
|
|
34
|
-
*/
|
|
35
|
-
export declare const runWebCommandsPipeline: (pipeline: WebCommandsPipeline) => Promise<StatusResponse>;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runWebCommandsPipeline = exports.setCredentials = exports.getCredentials = exports.setAllowedNavigationDomains = exports.setWebResourceCookies = void 0;
|
|
7
|
-
const smartapp_bridge_1 = __importDefault(require("@expressms/smartapp-bridge"));
|
|
8
|
-
const types_1 = require("../../types");
|
|
9
|
-
/**
|
|
10
|
-
* Set cookies for web resouce. It's needed for SSO auth cases.
|
|
11
|
-
* @param cookies List of cookie strings !with domains!
|
|
12
|
-
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
13
|
-
*/
|
|
14
|
-
const setWebResourceCookies = (cookies) => {
|
|
15
|
-
if (!smartapp_bridge_1.default)
|
|
16
|
-
return Promise.reject(types_1.ERROR_CODES.NO_BRIDGE);
|
|
17
|
-
return smartapp_bridge_1.default
|
|
18
|
-
.sendClientEvent({
|
|
19
|
-
method: types_1.METHODS.SET_WEB_RESOURCE_COOKIES,
|
|
20
|
-
params: {
|
|
21
|
-
cookies,
|
|
22
|
-
},
|
|
23
|
-
})
|
|
24
|
-
.then(event => event);
|
|
25
|
-
};
|
|
26
|
-
exports.setWebResourceCookies = setWebResourceCookies;
|
|
27
|
-
/**
|
|
28
|
-
* Allow WebView то open links inside, not in external browser
|
|
29
|
-
* @param domains List domains without schema
|
|
30
|
-
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
31
|
-
*/
|
|
32
|
-
const setAllowedNavigationDomains = (domains) => {
|
|
33
|
-
if (!smartapp_bridge_1.default)
|
|
34
|
-
return Promise.reject(types_1.ERROR_CODES.NO_BRIDGE);
|
|
35
|
-
return smartapp_bridge_1.default
|
|
36
|
-
.sendClientEvent({
|
|
37
|
-
method: types_1.METHODS.SET_ALLOWED_NAVIGATION_DOMAINS,
|
|
38
|
-
params: {
|
|
39
|
-
domains,
|
|
40
|
-
},
|
|
41
|
-
timeout: 1000,
|
|
42
|
-
})
|
|
43
|
-
.then(event => event);
|
|
44
|
-
};
|
|
45
|
-
exports.setAllowedNavigationDomains = setAllowedNavigationDomains;
|
|
46
|
-
/**
|
|
47
|
-
* DRAFT: Get saved credentials of web resource
|
|
48
|
-
* @returns Promise that'll be fullfilled with credentials on success, otherwise rejected with reason
|
|
49
|
-
*/
|
|
50
|
-
const getCredentials = () => {
|
|
51
|
-
if (!smartapp_bridge_1.default)
|
|
52
|
-
return Promise.reject(types_1.ERROR_CODES.NO_BRIDGE);
|
|
53
|
-
return smartapp_bridge_1.default
|
|
54
|
-
.sendClientEvent({
|
|
55
|
-
method: types_1.METHODS.GET_CREDENTIALS,
|
|
56
|
-
params: {},
|
|
57
|
-
timeout: 10000,
|
|
58
|
-
})
|
|
59
|
-
.then(event => event);
|
|
60
|
-
};
|
|
61
|
-
exports.getCredentials = getCredentials;
|
|
62
|
-
/**
|
|
63
|
-
* DRAFT: Save credentials of web resource
|
|
64
|
-
* @param login User login
|
|
65
|
-
* @param password User pass
|
|
66
|
-
* @returns Promise that'll be fullfilled with credentials on success, otherwise rejected with reason
|
|
67
|
-
*/
|
|
68
|
-
const setCredentials = ({ login, password }) => {
|
|
69
|
-
if (!smartapp_bridge_1.default)
|
|
70
|
-
return Promise.reject(types_1.ERROR_CODES.NO_BRIDGE);
|
|
71
|
-
return smartapp_bridge_1.default
|
|
72
|
-
.sendClientEvent({
|
|
73
|
-
method: types_1.METHODS.SET_CREDENTIALS,
|
|
74
|
-
params: {
|
|
75
|
-
login,
|
|
76
|
-
password,
|
|
77
|
-
},
|
|
78
|
-
timeout: 10000,
|
|
79
|
-
})
|
|
80
|
-
.then(event => event);
|
|
81
|
-
};
|
|
82
|
-
exports.setCredentials = setCredentials;
|
|
83
|
-
/**
|
|
84
|
-
* Run pipeline for manipulating web resource
|
|
85
|
-
* @param pipeline Pipeline with jobs & command
|
|
86
|
-
* @returns Promise that'll be fullfilled
|
|
87
|
-
*/
|
|
88
|
-
const runWebCommandsPipeline = (pipeline) => {
|
|
89
|
-
if (!smartapp_bridge_1.default)
|
|
90
|
-
return Promise.reject(types_1.ERROR_CODES.NO_BRIDGE);
|
|
91
|
-
return smartapp_bridge_1.default
|
|
92
|
-
.sendClientEvent({
|
|
93
|
-
method: types_1.METHODS.RUN_WEB_COMMANDS_PIPELINE,
|
|
94
|
-
params: {
|
|
95
|
-
pipeline,
|
|
96
|
-
},
|
|
97
|
-
timeout: 1000,
|
|
98
|
-
})
|
|
99
|
-
.then(event => event);
|
|
100
|
-
};
|
|
101
|
-
exports.runWebCommandsPipeline = runWebCommandsPipeline;
|
|
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ztBQUNJLE1BQU0sc0JBQXNCLEdBQUcsQ0FBQyxRQUE2QixFQUEyQixFQUFFO0lBQy9GLElBQUksQ0FBQyx5QkFBTTtRQUFFLE9BQU8sT0FBTyxDQUFDLE1BQU0sQ0FBQyxtQkFBVyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBRXpELE9BQU8seUJBQU07U0FDVixlQUFlLENBQUM7UUFDZixNQUFNLEVBQUUsZUFBTyxDQUFDLHlCQUF5QjtRQUN6QyxNQUFNLEVBQUU7WUFDTixRQUFRO1NBQ1Q7UUFDRCxPQUFPLEVBQUUsSUFBSTtLQUNkLENBQUM7U0FDRCxJQUFJLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQyxLQUF1QixDQUFDLENBQUE7QUFDM0MsQ0FBQyxDQUFBO0FBWlksUUFBQSxzQkFBc0IsMEJBWWxDIn0=
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { EmitterEventPayload } from '@expressms/smartapp-bridge/build/main/types/eventEmitter';
|
|
2
|
-
import { STATUS } from './bridge';
|
|
3
|
-
export interface GetCredentialsResponse extends Omit<EmitterEventPayload, 'payload'> {
|
|
4
|
-
payload: {
|
|
5
|
-
status: STATUS;
|
|
6
|
-
errorCode?: string | null;
|
|
7
|
-
credentials: {
|
|
8
|
-
login: string;
|
|
9
|
-
password: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export type WebCommandSearchElement = {
|
|
14
|
-
type: 'search_element';
|
|
15
|
-
xpath: string;
|
|
16
|
-
};
|
|
17
|
-
export type WebCommandSetInputValue = {
|
|
18
|
-
type: 'set_input_value';
|
|
19
|
-
xpath: string;
|
|
20
|
-
value: string;
|
|
21
|
-
};
|
|
22
|
-
export type WebCommandClickElement = {
|
|
23
|
-
type: 'click_element';
|
|
24
|
-
xpath: string;
|
|
25
|
-
};
|
|
26
|
-
export type WebCommandOpenUrl = {
|
|
27
|
-
type: 'open_url';
|
|
28
|
-
value: string;
|
|
29
|
-
};
|
|
30
|
-
export type WebCommand = WebCommandSearchElement | WebCommandSetInputValue | WebCommandClickElement | WebCommandOpenUrl;
|
|
31
|
-
export interface WebCommandsJob {
|
|
32
|
-
commands: Array<WebCommand>;
|
|
33
|
-
interval: number;
|
|
34
|
-
retryCount: number;
|
|
35
|
-
onSuccess: Array<WebCommandsJob>;
|
|
36
|
-
onError: {
|
|
37
|
-
command: WebCommand;
|
|
38
|
-
} | null;
|
|
39
|
-
}
|
|
40
|
-
export type WebCommandsPipeline = Array<WebCommandsJob>;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJveHkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdHlwZXMvcHJveHkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|