提交 3abb8b2a 编写于 作者: D DCloud_LXH

feat(App): configMTLS

上级 e3e8aa72
......@@ -17,7 +17,8 @@ const network = [
'onSocketMessage',
'closeSocket',
'onSocketClose',
'getUpdateManager'
'getUpdateManager',
'configMTLS'
]
const route = [
......@@ -268,4 +269,4 @@ const apis = [
...ad
]
module.exports = apis
module.exports = apis
import {
hasOwn,
isPlainObject
isPlainObject,
toRawType
} from 'uni-shared'
const method = {
......@@ -108,3 +109,15 @@ export const request = {
type: Number
}
}
export const configMTLS = {
certificates: {
type: Array,
required: true,
validator (value) {
if (value.some(item => toRawType(item.host) !== 'String')) {
return '参数配置错误,请确认后重试'
}
}
}
}
\ No newline at end of file
......@@ -8,6 +8,10 @@ import {
base64ToArrayBuffer
} from '../../bridge'
import {
invoke
} from 'uni-core/service/bridge'
let requestTaskId = 0
const requestTasks = {}
......@@ -188,3 +192,23 @@ export function operateRequestTask ({
errMsg: 'operateRequestTask:fail'
}
}
export function configMTLS ({certificates}, callbackId) {
const stream = requireNativePlugin('stream')
stream.configMTLS(certificates, ({type, code, message}) => {
switch (type) {
case 'success':
invoke(callbackId, {
errMsg: 'configMTLS:ok',
code
})
break;
case 'fail':
invoke(callbackId, {
errMsg: 'configMTLS:fail ' + message,
code
})
break;
}
});
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册