@onekeyfe/hd-ble-sdk
Advanced tools
Comparing version 0.1.5 to 0.1.6
import * as _onekeyfe_hd_core from '@onekeyfe/hd-core'; | ||
import { Deferred } from '@onekeyfe/hd-core'; | ||
import { Deferred } from '@onekeyfe/hd-shared'; | ||
@@ -4,0 +4,0 @@ declare const messagePromises: { |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var HardwareSdk = require('@onekeyfe/hd-core'); | ||
var hdShared = require('@onekeyfe/hd-shared'); | ||
var ReactNativeTransport = require('@onekeyfe/hd-transport-react-native'); | ||
@@ -527,3 +528,3 @@ | ||
if (!_core) { | ||
throw HardwareSdk.ERRORS.TypedError('Init_NotInitialized'); | ||
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NotInitialized); | ||
} | ||
@@ -556,7 +557,7 @@ const { type, payload } = response; | ||
if (!_core) { | ||
throw HardwareSdk.ERRORS.TypedError('Runtime', 'postMessage: _core not found'); | ||
throw hdShared.ERRORS.TypedError('postMessage: _core not found'); | ||
} | ||
if (usePromise) { | ||
_messageID++; | ||
messagePromises[_messageID] = HardwareSdk.create(); | ||
messagePromises[_messageID] = hdShared.createDeferred(); | ||
const response = yield _core.handleMessage(Object.assign(Object.assign({}, message), { id: `${_messageID}` })); | ||
@@ -590,7 +591,6 @@ return response; | ||
if (!response.success) { | ||
if ((typeof response.payload === 'string' && response.payload.includes(ReactNativeTransport.PERMISSION_ERROR)) || | ||
((_a = response.payload.error) === null || _a === void 0 ? void 0 : _a.includes(ReactNativeTransport.PERMISSION_ERROR))) { | ||
if (((_a = response.payload) === null || _a === void 0 ? void 0 : _a.code) === hdShared.HardwareErrorCode.BlePermissionError) { | ||
postMessage(HardwareSdk.createUiMessage(HardwareSdk.UI_REQUEST.BLUETOOTH_PERMISSION), false); | ||
} | ||
if ((_b = response.payload.error) === null || _b === void 0 ? void 0 : _b.includes(ReactNativeTransport.LOCATION_ERROR)) { | ||
if (((_b = response.payload) === null || _b === void 0 ? void 0 : _b.code) === hdShared.HardwareErrorCode.BleLocationError) { | ||
postMessage(HardwareSdk.createUiMessage(HardwareSdk.UI_REQUEST.LOCATION_PERMISSION), false); | ||
@@ -601,3 +601,3 @@ } | ||
} | ||
return HardwareSdk.createErrorMessage(HardwareSdk.ERRORS.TypedError('Call_NotResponse')); | ||
return HardwareSdk.createErrorMessage(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodNotResponse)); | ||
} | ||
@@ -604,0 +604,0 @@ catch (error) { |
{ | ||
"name": "@onekeyfe/hd-ble-sdk", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"author": "OneKey", | ||
@@ -23,6 +23,7 @@ "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", | ||
"dependencies": { | ||
"@onekeyfe/hd-core": "^0.1.5", | ||
"@onekeyfe/hd-transport-react-native": "^0.1.5" | ||
"@onekeyfe/hd-core": "^0.1.6", | ||
"@onekeyfe/hd-shared": "^0.1.6", | ||
"@onekeyfe/hd-transport-react-native": "^0.1.6" | ||
}, | ||
"gitHead": "26a2b960d5e1917d3f2217cef449269200a1a376" | ||
"gitHead": "ebe2789fa24cbfb798c9be445678e71e67e33d71" | ||
} |
@@ -13,5 +13,2 @@ import EventEmitter from 'events'; | ||
CoreMessage, | ||
ERRORS, | ||
Deferred, | ||
create as createDeferred, | ||
IFRAME, | ||
@@ -22,6 +19,4 @@ UI_EVENT, | ||
} from '@onekeyfe/hd-core'; | ||
import ReactNativeTransport, { | ||
PERMISSION_ERROR, | ||
LOCATION_ERROR, | ||
} from '@onekeyfe/hd-transport-react-native'; | ||
import { ERRORS, createDeferred, Deferred, HardwareErrorCode } from '@onekeyfe/hd-shared'; | ||
import ReactNativeTransport from '@onekeyfe/hd-transport-react-native'; | ||
@@ -44,3 +39,3 @@ const eventEmitter = new EventEmitter(); | ||
if (!_core) { | ||
throw ERRORS.TypedError('Init_NotInitialized'); | ||
throw ERRORS.TypedError(HardwareErrorCode.NotInitialized); | ||
} | ||
@@ -76,3 +71,3 @@ const { type, payload } = response; | ||
if (!_core) { | ||
throw ERRORS.TypedError('Runtime', 'postMessage: _core not found'); | ||
throw ERRORS.TypedError('postMessage: _core not found'); | ||
} | ||
@@ -119,6 +114,3 @@ | ||
if (!response.success) { | ||
if ( | ||
(typeof response.payload === 'string' && response.payload.includes(PERMISSION_ERROR)) || | ||
response.payload.error?.includes(PERMISSION_ERROR) | ||
) { | ||
if (response.payload?.code === HardwareErrorCode.BlePermissionError) { | ||
/** | ||
@@ -130,3 +122,3 @@ * Send message notification when there is no Bluetooth access permission | ||
if (response.payload.error?.includes(LOCATION_ERROR)) { | ||
if (response.payload?.code === HardwareErrorCode.BleLocationError) { | ||
postMessage(createUiMessage(UI_REQUEST.LOCATION_PERMISSION), false); | ||
@@ -139,3 +131,3 @@ } | ||
return createErrorMessage(ERRORS.TypedError('Call_NotResponse')); | ||
return createErrorMessage(ERRORS.TypedError(HardwareErrorCode.CallMethodNotResponse)); | ||
} catch (error) { | ||
@@ -142,0 +134,0 @@ Log.error('__call error: ', error); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
254
1
85
24854
3
658