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

feat(App): configMTLS

上级 e3e8aa72
...@@ -17,7 +17,8 @@ const network = [ ...@@ -17,7 +17,8 @@ const network = [
'onSocketMessage', 'onSocketMessage',
'closeSocket', 'closeSocket',
'onSocketClose', 'onSocketClose',
'getUpdateManager' 'getUpdateManager',
'configMTLS'
] ]
const route = [ const route = [
...@@ -268,4 +269,4 @@ const apis = [ ...@@ -268,4 +269,4 @@ const apis = [
...ad ...ad
] ]
module.exports = apis module.exports = apis
import { import {
hasOwn, hasOwn,
isPlainObject isPlainObject,
toRawType
} from 'uni-shared' } from 'uni-shared'
const method = { const method = {
...@@ -108,3 +109,15 @@ export const request = { ...@@ -108,3 +109,15 @@ export const request = {
type: Number 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 { ...@@ -8,6 +8,10 @@ import {
base64ToArrayBuffer base64ToArrayBuffer
} from '../../bridge' } from '../../bridge'
import {
invoke
} from 'uni-core/service/bridge'
let requestTaskId = 0 let requestTaskId = 0
const requestTasks = {} const requestTasks = {}
...@@ -188,3 +192,23 @@ export function operateRequestTask ({ ...@@ -188,3 +192,23 @@ export function operateRequestTask ({
errMsg: 'operateRequestTask:fail' 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.
先完成此消息的编辑!
想要评论请 注册