eoss-ui 0.7.53 → 0.7.55

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.
Files changed (306) hide show
  1. package/lib/button-group.js +2 -2
  2. package/lib/button.js +2 -2
  3. package/lib/calogin.js +235 -235
  4. package/lib/checkbox-group.js +2 -2
  5. package/lib/config/api.js +1 -1
  6. package/lib/data-table-form.js +2 -2
  7. package/lib/data-table.js +2 -2
  8. package/lib/date-picker.js +2 -2
  9. package/lib/dialog.js +2 -2
  10. package/lib/eoss-ui.common.js +882 -795
  11. package/lib/flow-group.js +2 -2
  12. package/lib/flow-list.js +83 -83
  13. package/lib/flow.js +294 -292
  14. package/lib/form.js +2 -2
  15. package/lib/handle-user.js +2 -2
  16. package/lib/handler.js +2 -2
  17. package/lib/icon.js +2 -2
  18. package/lib/icons.js +1 -1
  19. package/lib/index.js +1 -1
  20. package/lib/input-number.js +2 -2
  21. package/lib/input.js +2 -2
  22. package/lib/login.js +6 -6
  23. package/lib/main.js +238 -153
  24. package/lib/nav.js +2 -2
  25. package/lib/notify.js +2 -2
  26. package/lib/page.js +2 -2
  27. package/lib/pagination.js +2 -2
  28. package/lib/player.js +2 -2
  29. package/lib/qr-code.js +15 -15
  30. package/lib/radio-group.js +2 -2
  31. package/lib/retrial-auth.js +2 -2
  32. package/lib/select-ganged.js +2 -2
  33. package/lib/select.js +2 -2
  34. package/lib/selector-panel.js +2 -2
  35. package/lib/selector.js +2 -2
  36. package/lib/sizer.js +2 -2
  37. package/lib/steps.js +2 -2
  38. package/lib/switch.js +2 -2
  39. package/lib/table-form.js +2 -2
  40. package/lib/tabs.js +2 -2
  41. package/lib/theme-chalk/base.css +1 -1
  42. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  43. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  44. package/lib/theme-chalk/icon.css +1 -1
  45. package/lib/theme-chalk/index.css +1 -1
  46. package/lib/theme-chalk/main.css +1 -1
  47. package/lib/theme-chalk/menu.css +1 -1
  48. package/lib/theme-chalk/simplicity.css +1 -1
  49. package/lib/theme-chalk/sizer.css +1 -1
  50. package/lib/theme-chalk/upload.css +1 -1
  51. package/lib/tips.js +2 -2
  52. package/lib/tree-group.js +2 -2
  53. package/lib/tree.js +2 -2
  54. package/lib/upload.js +15 -15
  55. package/lib/wujie.js +2 -2
  56. package/lib/wxlogin.js +2 -2
  57. package/package.json +160 -160
  58. package/packages/.DS_Store +0 -0
  59. package/packages/button/index.js +5 -5
  60. package/packages/button/src/main.vue +418 -418
  61. package/packages/button-group/index.js +5 -5
  62. package/packages/button-group/src/main.vue +346 -346
  63. package/packages/calendar/index.js +5 -5
  64. package/packages/calogin/.DS_Store +0 -0
  65. package/packages/calogin/index.js +5 -5
  66. package/packages/calogin/src/main.vue +412 -412
  67. package/packages/calogin/src/plugin.js +915 -915
  68. package/packages/card/index.js +5 -5
  69. package/packages/card/src/main.vue +156 -156
  70. package/packages/cascader/index.js +5 -5
  71. package/packages/cascader/src/main.vue +168 -168
  72. package/packages/checkbox-group/index.js +5 -5
  73. package/packages/checkbox-group/src/main.vue +333 -333
  74. package/packages/clients/index.js +5 -5
  75. package/packages/clients/src/main.vue +151 -151
  76. package/packages/data-table/index.js +5 -5
  77. package/packages/data-table/src/children.vue +39 -39
  78. package/packages/data-table/src/column.vue +992 -992
  79. package/packages/data-table/src/main.vue +1840 -1840
  80. package/packages/data-table/src/sizer.vue +195 -195
  81. package/packages/data-table-form/index.js +5 -5
  82. package/packages/data-table-form/src/checkbox.vue +101 -101
  83. package/packages/data-table-form/src/colgroup.vue +17 -17
  84. package/packages/data-table-form/src/main.vue +181 -181
  85. package/packages/data-table-form/src/radio.vue +65 -65
  86. package/packages/data-table-form/src/table.vue +233 -233
  87. package/packages/data-table-form/src/tbody.vue +336 -336
  88. package/packages/data-table-form/src/thead.vue +68 -68
  89. package/packages/date-picker/.DS_Store +0 -0
  90. package/packages/date-picker/index.js +5 -5
  91. package/packages/date-picker/src/.DS_Store +0 -0
  92. package/packages/date-picker/src/main.vue +236 -236
  93. package/packages/dialog/.DS_Store +0 -0
  94. package/packages/dialog/index.js +5 -5
  95. package/packages/enable-drag/index.js +5 -5
  96. package/packages/enterprise/index.js +5 -5
  97. package/packages/enterprise/src/main.vue +66 -66
  98. package/packages/error-page/index.js +5 -5
  99. package/packages/error-page/src/main.vue +44 -44
  100. package/packages/flow/.DS_Store +0 -0
  101. package/packages/flow/index.js +5 -5
  102. package/packages/flow/src/.DS_Store +0 -0
  103. package/packages/flow/src/component/Circulate.vue +413 -413
  104. package/packages/flow/src/component/CommonOpinions.vue +373 -373
  105. package/packages/flow/src/component/CustomPreset.vue +322 -322
  106. package/packages/flow/src/component/FileList.vue +97 -97
  107. package/packages/flow/src/component/FreeCirculation.vue +241 -240
  108. package/packages/flow/src/component/Preset.vue +255 -255
  109. package/packages/flow/src/component/SendMsg.vue +242 -242
  110. package/packages/flow/src/component/TimeLimit.vue +190 -190
  111. package/packages/flow/src/component/taskUnionExamine.vue +756 -756
  112. package/packages/flow/src/form.vue +121 -121
  113. package/packages/flow/src/freeStartFlow.vue +2846 -2846
  114. package/packages/flow/src/main.vue +3878 -3878
  115. package/packages/flow/src/processForm.vue +1365 -1365
  116. package/packages/flow/src/processReject.vue +309 -309
  117. package/packages/flow/src/reset.vue +942 -942
  118. package/packages/flow/src/startTaskRead.vue +692 -692
  119. package/packages/flow/src/supervise.vue +159 -159
  120. package/packages/flow/src/table.vue +58 -58
  121. package/packages/flow-group/index.js +5 -5
  122. package/packages/flow-group/src/main.vue +717 -717
  123. package/packages/flow-list/.DS_Store +0 -0
  124. package/packages/flow-list/index.js +5 -5
  125. package/packages/flow-list/src/main.vue +1801 -1801
  126. package/packages/form/.DS_Store +0 -0
  127. package/packages/form/index.js +5 -5
  128. package/packages/form/src/main.vue +3901 -3901
  129. package/packages/form/src/table.vue +1512 -1512
  130. package/packages/handle-user/index.js +5 -5
  131. package/packages/handle-user/src/main.vue +137 -137
  132. package/packages/handler/index.js +5 -5
  133. package/packages/handler/src/main.vue +496 -496
  134. package/packages/icon/.DS_Store +0 -0
  135. package/packages/icon/index.js +5 -5
  136. package/packages/icon/src/main.vue +104 -104
  137. package/packages/icons/index.js +5 -5
  138. package/packages/icons/src/icon.json +1 -1
  139. package/packages/icons/src/main.vue +81 -81
  140. package/packages/input/index.js +5 -5
  141. package/packages/input/src/main.vue +356 -356
  142. package/packages/input-number/index.js +5 -5
  143. package/packages/input-number/src/main.vue +106 -106
  144. package/packages/label/index.js +5 -5
  145. package/packages/label/src/main.vue +457 -457
  146. package/packages/layout/index.js +5 -5
  147. package/packages/layout/src/item.vue +152 -152
  148. package/packages/layout/src/main.vue +31 -31
  149. package/packages/login/.DS_Store +0 -0
  150. package/packages/login/index.js +5 -5
  151. package/packages/login/src/main.vue +2082 -2082
  152. package/packages/login/src/resetPassword.vue +557 -557
  153. package/packages/main/.DS_Store +0 -0
  154. package/packages/main/index.js +5 -5
  155. package/packages/main/src/.DS_Store +0 -0
  156. package/packages/main/src/default/message.vue +249 -249
  157. package/packages/main/src/default/notice.vue +157 -157
  158. package/packages/main/src/default/userinfo.vue +503 -503
  159. package/packages/main/src/public/online.vue +89 -89
  160. package/packages/main/src/public/search.vue +464 -464
  161. package/packages/main/src/public/settings.vue +227 -227
  162. package/packages/main/src/simplicity/apps.vue +388 -388
  163. package/packages/main/src/simplicity/avatar.vue +82 -82
  164. package/packages/main/src/simplicity/handler.vue +160 -160
  165. package/packages/main/src/simplicity/index.vue +2307 -2277
  166. package/packages/main/src/simplicity/lists.vue +84 -84
  167. package/packages/main/src/simplicity/menu-list.vue +135 -135
  168. package/packages/main/src/simplicity/message.vue +293 -293
  169. package/packages/main/src/simplicity/notice.vue +222 -222
  170. package/packages/main/src/simplicity/router-page.vue +45 -45
  171. package/packages/main/src/simplicity/sub-menu.vue +274 -274
  172. package/packages/main/src/simplicity/user.vue +259 -259
  173. package/packages/main/src/simplicity/userinfo.vue +401 -401
  174. package/packages/menu/.DS_Store +0 -0
  175. package/packages/menu/index.js +5 -5
  176. package/packages/menu/src/main.vue +595 -595
  177. package/packages/nav/index.js +5 -5
  178. package/packages/nav/src/main.vue +351 -351
  179. package/packages/notify/index.js +5 -5
  180. package/packages/notify/src/main.vue +538 -538
  181. package/packages/page/index.js +5 -5
  182. package/packages/page/src/main.vue +167 -167
  183. package/packages/pagination/index.js +5 -5
  184. package/packages/pagination/src/main.vue +96 -96
  185. package/packages/player/index.js +5 -5
  186. package/packages/player/src/main.vue +194 -194
  187. package/packages/qr-code/index.js +5 -5
  188. package/packages/qr-code/src/main.vue +170 -170
  189. package/packages/radio-group/index.js +6 -6
  190. package/packages/radio-group/src/main.vue +319 -319
  191. package/packages/retrial-auth/index.js +5 -5
  192. package/packages/retrial-auth/src/main.vue +280 -280
  193. package/packages/select/.DS_Store +0 -0
  194. package/packages/select/index.js +5 -5
  195. package/packages/select/src/main.vue +782 -782
  196. package/packages/select-ganged/index.js +5 -5
  197. package/packages/select-ganged/src/main.vue +724 -724
  198. package/packages/selector/.DS_Store +0 -0
  199. package/packages/selector/index.js +5 -5
  200. package/packages/selector/src/main.vue +761 -761
  201. package/packages/selector-panel/.DS_Store +0 -0
  202. package/packages/selector-panel/index.js +5 -5
  203. package/packages/selector-panel/src/main.vue +1027 -1027
  204. package/packages/selector-panel/src/selection.vue +170 -170
  205. package/packages/selector-panel/src/tree.vue +129 -129
  206. package/packages/sizer/index.js +5 -5
  207. package/packages/sizer/src/main.vue +254 -254
  208. package/packages/steps/index.js +5 -5
  209. package/packages/steps/src/main.vue +181 -181
  210. package/packages/switch/index.js +5 -5
  211. package/packages/switch/src/main.vue +170 -170
  212. package/packages/table-form/index.js +5 -5
  213. package/packages/tabs/index.js +5 -5
  214. package/packages/tabs/src/main.vue +788 -788
  215. package/packages/tabs-panel/index.js +5 -5
  216. package/packages/tabs-panel/src/main.vue +29 -29
  217. package/packages/theme-chalk/lib/base.css +1 -1
  218. package/packages/theme-chalk/lib/fonts/iconfont.ttf +0 -0
  219. package/packages/theme-chalk/lib/fonts/iconfont.woff +0 -0
  220. package/packages/theme-chalk/lib/icon.css +1 -1
  221. package/packages/theme-chalk/lib/index.css +1 -1
  222. package/packages/theme-chalk/lib/main.css +1 -1
  223. package/packages/theme-chalk/lib/menu.css +1 -1
  224. package/packages/theme-chalk/lib/simplicity.css +1 -1
  225. package/packages/theme-chalk/lib/sizer.css +1 -1
  226. package/packages/theme-chalk/lib/upload.css +1 -1
  227. package/packages/theme-chalk/src/.DS_Store +0 -0
  228. package/packages/theme-chalk/src/base.scss +261 -261
  229. package/packages/theme-chalk/src/button-group.scss +176 -176
  230. package/packages/theme-chalk/src/button.scss +24 -24
  231. package/packages/theme-chalk/src/calendar.scss +113 -113
  232. package/packages/theme-chalk/src/card.scss +99 -99
  233. package/packages/theme-chalk/src/checkbox-group.scss +8 -8
  234. package/packages/theme-chalk/src/clients.scss +87 -87
  235. package/packages/theme-chalk/src/data-table-form.scss +67 -67
  236. package/packages/theme-chalk/src/data-table.scss +297 -297
  237. package/packages/theme-chalk/src/date-picker.scss +7 -7
  238. package/packages/theme-chalk/src/dialog.scss +77 -77
  239. package/packages/theme-chalk/src/enable-drag.scss +181 -181
  240. package/packages/theme-chalk/src/enterprise.scss +5 -5
  241. package/packages/theme-chalk/src/error-page.scss +18 -18
  242. package/packages/theme-chalk/src/flow-group.scss +110 -110
  243. package/packages/theme-chalk/src/flow-list.scss +39 -39
  244. package/packages/theme-chalk/src/flow.scss +351 -351
  245. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  246. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  247. package/packages/theme-chalk/src/form.scss +501 -501
  248. package/packages/theme-chalk/src/handle-user.scss +40 -40
  249. package/packages/theme-chalk/src/handler.scss +148 -148
  250. package/packages/theme-chalk/src/icon.scss +1608 -1540
  251. package/packages/theme-chalk/src/icons.scss +99 -99
  252. package/packages/theme-chalk/src/input.scss +9 -9
  253. package/packages/theme-chalk/src/label.scss +24 -24
  254. package/packages/theme-chalk/src/layout.scss +46 -46
  255. package/packages/theme-chalk/src/login.scss +1006 -1006
  256. package/packages/theme-chalk/src/main.scss +663 -663
  257. package/packages/theme-chalk/src/menu.scss +224 -224
  258. package/packages/theme-chalk/src/mixins/color.scss +117 -117
  259. package/packages/theme-chalk/src/nav.scss +111 -111
  260. package/packages/theme-chalk/src/page.scss +3 -3
  261. package/packages/theme-chalk/src/pagination.scss +29 -29
  262. package/packages/theme-chalk/src/player.scss +9 -9
  263. package/packages/theme-chalk/src/qr-code.scss +17 -17
  264. package/packages/theme-chalk/src/radio-group.scss +9 -9
  265. package/packages/theme-chalk/src/retrial-auth.scss +38 -38
  266. package/packages/theme-chalk/src/select-ganged.scss +8 -8
  267. package/packages/theme-chalk/src/select.scss +8 -8
  268. package/packages/theme-chalk/src/selector-panel.scss +204 -204
  269. package/packages/theme-chalk/src/selector.scss +114 -114
  270. package/packages/theme-chalk/src/simplicity.scss +1404 -1395
  271. package/packages/theme-chalk/src/sizer.scss +36 -36
  272. package/packages/theme-chalk/src/steps.scss +88 -88
  273. package/packages/theme-chalk/src/switch.scss +3 -3
  274. package/packages/theme-chalk/src/table-form.scss +1 -1
  275. package/packages/theme-chalk/src/tabs.scss +87 -87
  276. package/packages/theme-chalk/src/tips.scss +7 -7
  277. package/packages/theme-chalk/src/toolbar.scss +179 -179
  278. package/packages/theme-chalk/src/tree-group.scss +72 -72
  279. package/packages/theme-chalk/src/tree.scss +165 -165
  280. package/packages/theme-chalk/src/upload.scss +172 -172
  281. package/packages/theme-chalk/src/wxlogin.scss +3 -3
  282. package/packages/tips/index.js +5 -5
  283. package/packages/tips/src/main.vue +141 -141
  284. package/packages/toolbar/index.js +5 -5
  285. package/packages/toolbar/src/main.vue +430 -430
  286. package/packages/tree/index.js +5 -5
  287. package/packages/tree-group/index.js +5 -5
  288. package/packages/upload/.DS_Store +0 -0
  289. package/packages/upload/index.js +5 -5
  290. package/packages/upload/src/main.vue +1344 -1344
  291. package/packages/upload/src/picture.js +15 -15
  292. package/packages/wujie/index.js +5 -5
  293. package/packages/wujie/src/main.vue +145 -145
  294. package/packages/wxlogin/index.js +5 -5
  295. package/packages/wxlogin/src/main.vue +128 -128
  296. package/src/.DS_Store +0 -0
  297. package/src/config/api.js +317 -317
  298. package/src/config/image.js +2 -2
  299. package/src/index.js +163 -163
  300. package/src/utils/.DS_Store +0 -0
  301. package/src/utils/bus.js +3 -3
  302. package/src/utils/date-util.js +312 -312
  303. package/src/utils/http.js +50 -50
  304. package/src/utils/rules.js +18 -18
  305. package/src/utils/store.js +21 -21
  306. package/src/utils/webSocket.js +107 -107
@@ -1,915 +1,915 @@
1
- /**
2
- * JIT_GW_ExtInterface 模块,提供与客户端交互的功能
3
- */
4
- class CA_ExtInterface {
5
- constructor() {
6
- this.currentSessionWSURL = '';
7
- this.useActioveX = false;
8
- this.options = {};
9
- this.webSocket = null;
10
- this.init();
11
- }
12
-
13
- /**
14
- * 简单的 Object.assign 兼容 IE <= 11 的 polyfill
15
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
16
- * @param {Object} target - 目标对象
17
- * @param {Object} options - 新的选项对象
18
- */
19
- extendOptions(target, options) {
20
- if (typeof Object.assign === 'function') {
21
- Object.assign(target, options);
22
- } else {
23
- // 兼容 IE < 11
24
- for (const key in options) {
25
- target[key] = options[key];
26
- }
27
- }
28
- }
29
-
30
- /**
31
- * 检查当前会话的 WebSocket URL
32
- */
33
- checkSessionWSURL() {
34
- if (this.currentSessionWSURL === '') {
35
- if (document.location.protocol === 'https:') {
36
- this.currentSessionWSURL = this.sendAndWaitMessage('https://127.0.0.1:10087/', 'QueryService');
37
- } else {
38
- this.currentSessionWSURL = this.sendAndWaitMessage('http://127.0.0.1:10086/', 'QueryService');
39
- }
40
- }
41
- }
42
-
43
- /**
44
- * 检查是否使用 ActiveX
45
- */
46
- isUseActioveX() {
47
- if (!!window.ActiveXObject || 'ActiveXObject' in window) {
48
- this.useActioveX = true;
49
- } else {
50
- this.useActioveX = false;
51
- }
52
- }
53
-
54
- /**
55
- * 扩展发送消息并等待响应
56
- * @param {string} operatorCmd - 操作命令
57
- * @param {string} sendMsg - 发送的消息
58
- * @returns {string} 响应消息
59
- */
60
- sendAndWaitMessageEx(operatorCmd, sendMsg) {
61
- this.checkSessionWSURL();
62
- const strSendMsg = operatorCmd + ':' + sendMsg;
63
- return this.sendAndWaitMessage(this.currentSessionWSURL, strSendMsg);
64
- }
65
-
66
- /**
67
- * 发送消息并等待响应
68
- * @param {string} wsurl - WebSocket URL
69
- * @param {string} sendMsg - 发送的消息
70
- * @returns {string} 响应消息
71
- */
72
- sendAndWaitMessage(wsurl, sendMsg) {
73
- let ResultMsg = '{"value":""}';
74
- if (ResultMsg === wsurl) {
75
- return;
76
- }
77
- try {
78
- const globalXmlHttpRequest = new XMLHttpRequest();
79
- globalXmlHttpRequest.open('POST', wsurl, false);
80
- globalXmlHttpRequest.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');
81
- globalXmlHttpRequest.send(sendMsg);
82
- ResultMsg = globalXmlHttpRequest.responseText;
83
- } catch (e) {
84
- this.currentSessionWSURL = '';
85
- if (this.options.onError) {
86
- this.options.onError.call(undefined, e);
87
- }
88
- }
89
- return ResultMsg;
90
- }
91
-
92
- /**
93
- * 配置选项
94
- * @param {Object} extendOption - 扩展选项
95
- */
96
- config(extendOption) {
97
- if (extendOption && typeof extendOption === 'object') {
98
- this.extendOptions(this.options, extendOption);
99
- }
100
- }
101
-
102
- /**
103
- * 初始化
104
- */
105
- init() {
106
- this.isUseActioveX();
107
- }
108
-
109
- /**
110
- * 返回客户端的版本
111
- * @returns {string} 客户端版本
112
- */
113
- getClientVersion() {
114
- if (this.useActioveX) {
115
- return window.PNXClient.GetClientVersion();
116
- } else {
117
- const result = JSON.parse(this.sendAndWaitMessageEx('GetClientVersion', ''));
118
- return result.value;
119
- }
120
- }
121
-
122
- /**
123
- * 下载客户端程序并安装
124
- * @param {string} bstrURL - 下载地址
125
- * @param {string} bstrHashValue - 哈希值
126
- * @param {boolean} bSync - 是否同步安装
127
- * @param {boolean} bOnlySSO - 是否仅安装 SSO
128
- * @returns {number} 安装结果
129
- */
130
- setupClient(bstrURL, bstrHashValue, bSync, bOnlySSO) {
131
- if (this.useActioveX) {
132
- return window.PNXClient.SetupClient(bstrURL, bstrHashValue, bSync, bOnlySSO);
133
- } else {
134
- const jsonstr = { 'strURL': bstrURL, 'strHashValue': bstrHashValue, 'bSync': bSync, 'bOnlySSO': bOnlySSO };
135
- const result = JSON.parse(this.sendAndWaitMessageEx('SetupClient', JSON.stringify(jsonstr)));
136
- return result.value;
137
- }
138
- }
139
-
140
- /**
141
- * 获取硬件指纹信息
142
- * @param {number} dwSign - 签名
143
- * @param {string} strGateWayIP - 网关 IP
144
- * @returns {string} 硬件指纹信息
145
- */
146
- getFinger(dwSign, strGateWayIP) {
147
- if (this.useActioveX) {
148
- return window.PNXClient.GetFinger(dwSign, strGateWayIP);
149
- } else {
150
- const jsonstr = { 'dwSign': dwSign, 'strGateWayIP': strGateWayIP };
151
- const result = JSON.parse(this.sendAndWaitMessageEx('GetFinger', JSON.stringify(jsonstr)));
152
- return result.value;
153
- }
154
- }
155
-
156
- /**
157
- * 设置转发策略和代填策略
158
- * @param {string} strProxyPolicy - 转发策略
159
- * @param {string} strSSOPolicy - 代填策略
160
- * @param {string} strGatewayAddress - 网关地址
161
- * @returns {number} 设置结果
162
- */
163
- setPolicy(strProxyPolicy, strSSOPolicy, strGatewayAddress) {
164
- if (this.useActioveX) {
165
- return window.PNXClient.SetPolicy(strProxyPolicy, strSSOPolicy, strGatewayAddress);
166
- } else {
167
- const jsonstr = { 'strProxyPolicy': strProxyPolicy, 'strSSOPolicy': strSSOPolicy, 'strGatewayAddress': strGatewayAddress };
168
- const result = JSON.parse(this.sendAndWaitMessageEx('SetPolicy', JSON.stringify(jsonstr)));
169
- return result.value;
170
- }
171
- }
172
-
173
- /**
174
- * 启动认证信息模块
175
- * @param {string} strFileName - 文件名
176
- * @param {string} strXmlData - XML 数据
177
- * @returns {string} 认证信息
178
- */
179
- getAuthToken(strFileName, strXmlData) {
180
- if (this.useActioveX) {
181
- return window.PNXClient.GetAuthToken(strFileName, strXmlData);
182
- } else {
183
- const jsonstr = { 'strFileName': strFileName, 'strXmlData': strXmlData };
184
- const result = JSON.parse(this.sendAndWaitMessageEx('GetAuthToken', JSON.stringify(jsonstr)));
185
- return result.value;
186
- }
187
- }
188
-
189
- /**
190
- * 打开 BS 应用
191
- * @param {string} strUrl - 应用 URL
192
- * @returns {number} 打开结果
193
- */
194
- navigateURL(strUrl) {
195
- if (this.useActioveX) {
196
- return window.PNXClient.NavigateURL(strUrl);
197
- } else {
198
- const jsonstr = { 'strUrl': strUrl };
199
- const result = JSON.parse(this.sendAndWaitMessageEx('NavigateURL', JSON.stringify(jsonstr)));
200
- return result.value;
201
- }
202
- }
203
-
204
- /**
205
- * 打开 CS 应用
206
- * @param {string} strGatewayAddress - 网关地址
207
- * @param {string} strAppFlag - 应用标识
208
- * @param {string} strAppPath - 应用路径
209
- * @returns {number} 打开结果
210
- */
211
- executeCS(strGatewayAddress, strAppFlag, strAppPath) {
212
- if (this.useActioveX) {
213
- return window.PNXClient.ExecuteCS(strGatewayAddress, strAppFlag, strAppPath);
214
- } else {
215
- const jsonstr = { 'strGatewayAddress': strGatewayAddress, 'strAppFlag': strAppFlag, 'strAppPath': strAppPath };
216
- const result = JSON.parse(this.sendAndWaitMessageEx('ExecuteCS', JSON.stringify(jsonstr)));
217
- return result.value;
218
- }
219
- }
220
-
221
- /**
222
- * 设置自动更新策略
223
- * @param {string} strGatewayAddress - 网关地址
224
- * @param {number} nGatewayPort - 网关端口
225
- * @param {string} strUserToken - 用户令牌
226
- * @param {number} updatedelay - 更新延迟
227
- * @returns {number} 设置结果
228
- */
229
- setUpdatePolicy(strGatewayAddress, nGatewayPort, strUserToken, updatedelay) {
230
- if (this.useActioveX) {
231
- return window.PNXClient.SetUpdatePolicy(strGatewayAddress, nGatewayPort, strUserToken, updatedelay);
232
- } else {
233
- const jsonstr = { 'strGatewayAddress': strGatewayAddress, 'nGatewayPort': nGatewayPort, 'strUserToken': strUserToken, 'ulUpdateDelay': updatedelay };
234
- const result = JSON.parse(this.sendAndWaitMessageEx('SetUpdatePolicy', JSON.stringify(jsonstr)));
235
- return result.value;
236
- }
237
- }
238
-
239
- /**
240
- * 获取客户端 IP
241
- * @param {string} strGatewayIP - 网关 IP
242
- * @returns {string} 客户端 IP
243
- */
244
- getClientIP(strGatewayIP) {
245
- if (this.useActioveX) {
246
- return window.PNXClient.GetClientIP(strGatewayIP);
247
- } else {
248
- const jsonstr = { 'strGatewayIP': strGatewayIP };
249
- const result = JSON.parse(this.sendAndWaitMessageEx('GetClientIP', JSON.stringify(jsonstr)));
250
- return result.value;
251
- }
252
- }
253
-
254
- /**
255
- * 登出网关
256
- * @param {string} strServerIP - 服务器 IP
257
- * @returns {number} 登出结果
258
- */
259
- gwLogout(strServerIP) {
260
- if (this.useActioveX) {
261
- return window.PNXClient.GWLogout(strServerIP);
262
- } else {
263
- const jsonstr = { 'strServerIP': strServerIP };
264
- const result = JSON.parse(this.sendAndWaitMessageEx('GWLogout', JSON.stringify(jsonstr)));
265
- return result.value;
266
- }
267
- }
268
-
269
- /**
270
- * 运行安装包
271
- * @param {number} lRunType - 运行类型
272
- * @param {boolean} bIsOnlySSO - 是否仅安装 SSO
273
- * @returns {number} 运行结果
274
- */
275
- runSetup(lRunType, bIsOnlySSO) {
276
- if (this.useActioveX) {
277
- return window.PNXClient.RunSetup(lRunType, bIsOnlySSO);
278
- } else {
279
- const jsonstr = { 'lRunType': lRunType, 'bIsOnlySSO': bIsOnlySSO };
280
- const result = JSON.parse(this.sendAndWaitMessageEx('RunSetup', JSON.stringify(jsonstr)));
281
- return result.value;
282
- }
283
- }
284
-
285
- /**
286
- * 获取下载进度
287
- * @returns {number} 下载进度
288
- */
289
- getDownloadProgress() {
290
- if (this.useActioveX) {
291
- return window.PNXClient.GetDownloadProgress();
292
- } else {
293
- const jsonstr = '';
294
- const result = JSON.parse(this.sendAndWaitMessageEx('GetDownloadProgress', jsonstr));
295
- return result.value;
296
- }
297
- }
298
-
299
- /**
300
- * 是否安装完成
301
- * @returns {boolean} 安装完成状态
302
- */
303
- isInstallComplete() {
304
- if (this.useActioveX) {
305
- return window.PNXClient.IsInstallComplete();
306
- } else {
307
- const jsonstr = '';
308
- const result = JSON.parse(this.sendAndWaitMessageEx('IsInstallComplete', jsonstr));
309
- return result.value;
310
- }
311
- }
312
-
313
- /**
314
- * 初始化签包对象
315
- * @param {string} strAlgType - 算法类型
316
- * @param {string} strAuxParam - 辅助参数
317
- * @returns {number} 初始化结果
318
- */
319
- initialize(strAlgType, strAuxParam) {
320
- if (this.useActioveX) {
321
- return window.PNXClient.Initialize(strAlgType, strAuxParam);
322
- } else {
323
- const jsonstr = { 'strAlgType': strAlgType, 'strAuxParam': strAuxParam };
324
- const result = JSON.parse(this.sendAndWaitMessageEx('Initialize', JSON.stringify(jsonstr)));
325
- return result.value;
326
- }
327
- }
328
-
329
- /**
330
- * 设置摘要算法
331
- * @param {string} strDigestAlg - 摘要算法
332
- * @returns {number} 设置结果
333
- */
334
- setDigestAlg(strDigestAlg) {
335
- if (this.useActioveX) {
336
- return window.PNXClient.SetDigestAlg(strDigestAlg);
337
- } else {
338
- const jsonstr = { 'strDigestAlg': strDigestAlg };
339
- const result = JSON.parse(this.sendAndWaitMessageEx('SetDigestAlg', JSON.stringify(jsonstr)));
340
- return result.value;
341
- }
342
- }
343
-
344
- /**
345
- * 设置单证书是否弹出对话框
346
- * @param {number} isChoose - 是否弹出对话框
347
- * @returns {number} 设置结果
348
- */
349
- setChooseSingleCert(isChoose) {
350
- if (this.useActioveX) {
351
- return window.PNXClient.SetChooseSingleCert(isChoose);
352
- } else {
353
- const jsonstr = { 'isChoose': isChoose };
354
- const result = JSON.parse(this.sendAndWaitMessageEx('SetChooseSingleCert', JSON.stringify(jsonstr)));
355
- return result.value;
356
- }
357
- }
358
-
359
- /**
360
- * 添加证书过滤条件
361
- * @param {number} ulType - 过滤类型
362
- * @param {string} strValue - 过滤值
363
- * @returns {number} 添加结果
364
- */
365
- addFilter(ulType, strValue) {
366
- if (this.useActioveX) {
367
- return window.PNXClient.AddFilter(ulType, strValue);
368
- } else {
369
- const jsonstr = { 'ulType': ulType, 'strValue': strValue };
370
- const result = JSON.parse(this.sendAndWaitMessageEx('AddFilter', JSON.stringify(jsonstr)));
371
- return result.value;
372
- }
373
- }
374
-
375
- /**
376
- * 清除所有过滤条件
377
- * @returns {number} 清除结果
378
- */
379
- clearFilter() {
380
- if (this.useActioveX) {
381
- return window.PNXClient.ClearFilter();
382
- } else {
383
- const jsonstr = '';
384
- const result = JSON.parse(this.sendAndWaitMessageEx('ClearFilter', jsonstr));
385
- return result.value;
386
- }
387
- }
388
-
389
- /**
390
- * P1 签名
391
- * @param {string} strValueBase64 - 待签名的 Base64 字符串
392
- * @returns {string} 签名结果
393
- */
394
- p1Sign(strValueBase64) {
395
- if (this.useActioveX) {
396
- return window.PNXClient.P1Sign(strValueBase64);
397
- } else {
398
- const jsonstr = { 'strValueBase64': strValueBase64 };
399
- const result = JSON.parse(this.sendAndWaitMessageEx('P1Sign', JSON.stringify(jsonstr)));
400
- return result.value;
401
- }
402
- }
403
-
404
- /**
405
- * P1 签名字符串
406
- * @param {string} strValue - 待签名的字符串
407
- * @returns {string} 签名结果
408
- */
409
- p1SignString(strValue) {
410
- if (this.useActioveX) {
411
- return window.PNXClient.P1SignString(strValue);
412
- } else {
413
- const jsonstr = { 'strValue': strValue };
414
- const result = JSON.parse(this.sendAndWaitMessageEx('P1SignString', JSON.stringify(jsonstr)));
415
- return result.value;
416
- }
417
- }
418
-
419
- /**
420
- * P7 签名
421
- * @param {string} strValueBase64 - 待签名的 Base64 字符串
422
- * @param {boolean} isDetach - 是否分离签名
423
- * @param {boolean} isIncludeCert - 是否包含证书
424
- * @returns {string} 签名结果
425
- */
426
- p7Sign(strValueBase64, isDetach, isIncludeCert) {
427
- if (this.useActioveX) {
428
- return window.PNXClient.P7Sign(strValueBase64, isDetach, isIncludeCert);
429
- } else {
430
- const jsonstr = { 'strValueBase64': strValueBase64, 'isDetach': isDetach, 'isIncludeCert': isIncludeCert };
431
- const result = JSON.parse(this.sendAndWaitMessageEx('P7Sign', JSON.stringify(jsonstr)));
432
- return result.value;
433
- }
434
- }
435
-
436
- /**
437
- * P7 签名字符串
438
- * @param {string} strValue - 待签名的字符串
439
- * @param {boolean} isDetach - 是否分离签名
440
- * @param {boolean} isIncludeCert - 是否包含证书
441
- * @returns {string} 签名结果
442
- */
443
- p7SignString(strValue, isDetach, isIncludeCert) {
444
- if (this.useActioveX) {
445
- return window.PNXClient.P7SignString(strValue, isDetach, isIncludeCert);
446
- } else {
447
- const jsonstr = { 'strValue': strValue, 'isDetach': isDetach, 'isIncludeCert': isIncludeCert };
448
- const result = JSON.parse(this.sendAndWaitMessageEx('P7SignString', JSON.stringify(jsonstr)));
449
- return result.value;
450
- }
451
- }
452
-
453
- /**
454
- * 释放签名对象
455
- * @returns {number} 释放结果
456
- */
457
- finalize() {
458
- if (this.useActioveX) {
459
- return window.PNXClient.Finalize();
460
- } else {
461
- const jsonstr = '';
462
- const result = JSON.parse(this.sendAndWaitMessageEx('Finalize', jsonstr));
463
- return result.value;
464
- }
465
- }
466
-
467
- /**
468
- * 获取签名版本
469
- * @returns {string} 签名版本
470
- */
471
- getSignVersion() {
472
- if (this.useActioveX) {
473
- return window.PNXClient.GetSignVersion();
474
- } else {
475
- const jsonstr = '';
476
- const result = JSON.parse(this.sendAndWaitMessageEx('GetSignVersion', jsonstr));
477
- return result.value;
478
- }
479
- }
480
-
481
- /**
482
- * 获取签名证书
483
- * @returns {string} 签名证书
484
- */
485
- getSignCert() {
486
- if (this.useActioveX) {
487
- return window.PNXClient.GetSignCert();
488
- } else {
489
- const jsonstr = '';
490
- const result = JSON.parse(this.sendAndWaitMessageEx('GetSignCert', jsonstr));
491
- return result.value;
492
- }
493
- }
494
-
495
- /**
496
- * 获取错误码
497
- * @returns {number} 错误码
498
- */
499
- getLastError() {
500
- if (this.useActioveX) {
501
- return window.PNXClient.GetLastError();
502
- } else {
503
- const jsonstr = '';
504
- const result = JSON.parse(this.sendAndWaitMessageEx('GetLastError', jsonstr));
505
- return result.value;
506
- }
507
- }
508
-
509
- /**
510
- * 获取错误信息
511
- * @returns {string} 错误信息
512
- */
513
- getLastErrorMessage() {
514
- if (this.useActioveX) {
515
- return window.PNXClient.GetLastErrorMessage();
516
- } else {
517
- const jsonstr = '';
518
- const result = JSON.parse(this.sendAndWaitMessageEx('GetLastErrorMessage', jsonstr));
519
- return result.value;
520
- }
521
- }
522
-
523
- /**
524
- * 销毁认证对象
525
- * @returns {number} 销毁结果
526
- */
527
- destoryAuth() {
528
- if (this.useActioveX) {
529
- return window.PNXClient.DestoryAuth();
530
- } else {
531
- const jsonstr = '';
532
- const result = JSON.parse(this.sendAndWaitMessageEx('DestoryAuth', jsonstr));
533
- return result.value;
534
- }
535
- }
536
-
537
- /**
538
- * 获取证书类型
539
- * @returns {string} 证书类型
540
- */
541
- getSignCertType() {
542
- if (this.useActioveX) {
543
- return window.PNXClient.GetSignCertType();
544
- } else {
545
- const jsonstr = '';
546
- const result = JSON.parse(this.sendAndWaitMessageEx('GetSignCertType', jsonstr));
547
- return result.value;
548
- }
549
- }
550
-
551
- /**
552
- * 获取签名摘要算法
553
- * @returns {string} 签名摘要算法
554
- */
555
- getSignHash() {
556
- if (this.useActioveX) {
557
- return window.PNXClient.GetSignHash();
558
- } else {
559
- const jsonstr = '';
560
- const result = JSON.parse(this.sendAndWaitMessageEx('GetSignHash', jsonstr));
561
- return result.value;
562
- }
563
- }
564
-
565
- /**
566
- * 使能调用序列
567
- * @param {boolean} bCallQueueEnable - 是否使能调用序列
568
- * @param {boolean} bHeadInfoEnable - 是否使能头部信息
569
- * @returns {number} 使能结果
570
- */
571
- callQueueEnable(bCallQueueEnable, bHeadInfoEnable) {
572
- if (this.useActioveX) {
573
- return window.PNXClient.CallQueueEnable(bCallQueueEnable, bHeadInfoEnable);
574
- } else {
575
- const jsonstr = { 'bCallQueueEnable': bCallQueueEnable, 'bHeadInfoEnable': bHeadInfoEnable };
576
- const result = JSON.parse(this.sendAndWaitMessageEx('CallQueueEnable', JSON.stringify(jsonstr)));
577
- return result.value;
578
- }
579
- }
580
-
581
- /**
582
- * 清空调用序列结果
583
- * @returns {number} 清空调用序列结果
584
- */
585
- callQueueClear() {
586
- if (this.useActioveX) {
587
- return window.PNXClient.CallQueueClear();
588
- } else {
589
- const jsonstr = '';
590
- const result = JSON.parse(this.sendAndWaitMessageEx('CallQueueClear', jsonstr));
591
- return result.value;
592
- }
593
- }
594
-
595
- /**
596
- * 获取调用序列结果
597
- * @returns {string} 调用序列结果
598
- */
599
- callQueueGet() {
600
- if (this.useActioveX) {
601
- return window.PNXClient.CallQueueGet();
602
- } else {
603
- const jsonstr = '';
604
- const result = JSON.parse(this.sendAndWaitMessageEx('CallQueueGet', jsonstr));
605
- return result.value;
606
- }
607
- }
608
-
609
- /**
610
- * 客户端安全策略检查
611
- * @param {string} strGatewayAddress - 网关地址
612
- * @param {number} usGatewayPort - 网关端口
613
- * @param {string} strSecurityPolicys - 安全策略
614
- * @returns {boolean} 检查结果
615
- */
616
- doClientSecurityCheck(strGatewayAddress, usGatewayPort, strSecurityPolicys) {
617
- if (this.useActioveX) {
618
- return window.PNXClient.DoClientSecurityCheck(strGatewayAddress, usGatewayPort, strSecurityPolicys);
619
- } else {
620
- const jsonstr = { 'strGatewayAddress': strGatewayAddress, 'usGatewayPort': usGatewayPort, 'strSecurityPolicys': strSecurityPolicys };
621
- const result = JSON.parse(this.sendAndWaitMessageEx('DoClientSecurityCheck', JSON.stringify(jsonstr)));
622
- return result.value;
623
- }
624
- }
625
-
626
- /**
627
- * 获取通讯协议版本
628
- * @returns {string} 通讯协议版本
629
- */
630
- getProtocolVersion() {
631
- if (this.useActioveX) {
632
- return window.PNXClient.GetProtocolVersion();
633
- } else {
634
- const jsonstr = '';
635
- const result = JSON.parse(this.sendAndWaitMessageEx('GetProtocolVersion', jsonstr));
636
- return result.value;
637
- }
638
- }
639
-
640
- /**
641
- * 修改 Key 的 Pin 码
642
- * @param {string} strCertSn - 证书序列号
643
- * @param {number} lPinCodeType - Pin 码类型
644
- * @param {string} strCurPinCode - 当前 Pin 码
645
- * @param {string} strNewPinCode - 新 Pin 码
646
- * @returns {number} 修改结果
647
- */
648
- changePinCode(strCertSn, lPinCodeType, strCurPinCode, strNewPinCode) {
649
- if (this.useActioveX) {
650
- return window.PNXClient.ChangePinCode(strCertSn, lPinCodeType, strCurPinCode, strNewPinCode);
651
- } else {
652
- const jsonstr = { 'strCertSn': strCertSn, 'lPinCodeType': lPinCodeType, 'strCurPinCode': strCurPinCode, 'strNewPinCode': strNewPinCode };
653
- const result = JSON.parse(this.sendAndWaitMessageEx('ChangePinCode', JSON.stringify(jsonstr)));
654
- return result.value;
655
- }
656
- }
657
-
658
- /**
659
- * 等待策略设置完毕
660
- * @param {string} strGatewayAddress - 网关地址
661
- * @returns {number} 等待结果
662
- */
663
- waitSetPolicyFinish(strGatewayAddress) {
664
- if (this.useActioveX) {
665
- return window.PNXClient.WaitSetPolicyFinish(strGatewayAddress);
666
- } else {
667
- const jsonstr = { 'strGatewayAddress': strGatewayAddress };
668
- const result = JSON.parse(this.sendAndWaitMessageEx('WaitSetPolicyFinish', JSON.stringify(jsonstr)));
669
- return result.value;
670
- }
671
- }
672
-
673
- /**
674
- * 获取会话 Token
675
- * @param {string} strGatewayAddress - 网关地址
676
- * @returns {string} 会话 Token
677
- */
678
- getSessionToken(strGatewayAddress) {
679
- if (this.useActioveX) {
680
- return window.PNXClient.GetSessionToken(strGatewayAddress);
681
- } else {
682
- const jsonstr = { 'strGatewayAddress': strGatewayAddress };
683
- const result = JSON.parse(this.sendAndWaitMessageEx('GetSessionToken', JSON.stringify(jsonstr)));
684
- return result.value;
685
- }
686
- }
687
-
688
- /**
689
- * 获取控件版本
690
- * @returns {string} 控件版本
691
- */
692
- getVersion() {
693
- if (this.useActioveX) {
694
- return window.PNXClient.GetVersion();
695
- } else {
696
- const jsonstr = '';
697
- const result = JSON.parse(this.sendAndWaitMessageEx('GetVersion', jsonstr));
698
- return result.value;
699
- }
700
- }
701
-
702
- /**
703
- * 设置语言资源
704
- * @param {string} strLanguage - 语言资源
705
- * @returns {number} 设置结果
706
- */
707
- setLanguage(strLanguage) {
708
- if (this.useActioveX) {
709
- return window.PNXClient.SetLanguage(strLanguage);
710
- } else {
711
- const jsonstr = { 'strLanguage': strLanguage };
712
- const result = JSON.parse(this.sendAndWaitMessageEx('SetLanguage', JSON.stringify(jsonstr)));
713
- return result.value;
714
- }
715
- }
716
-
717
- /**
718
- * 获取用户属性
719
- * @param {string} strGatewayAddress - 网关地址
720
- * @param {string} strAppFlag - 应用标识
721
- * @param {string} strAttributeName - 属性名称
722
- * @returns {string} 用户属性值
723
- */
724
- getAttribute(strGatewayAddress, strAppFlag, strAttributeName) {
725
- if (this.useActioveX) {
726
- return window.PNXClient.GetAttribute(strGatewayAddress, strAppFlag, strAttributeName);
727
- } else {
728
- const jsonstr = { 'strGatewayAddress': strGatewayAddress, 'strAppFlag': strAppFlag, 'strAttributeName': strAttributeName };
729
- const result = JSON.parse(this.sendAndWaitMessageEx('GetAttribute', JSON.stringify(jsonstr)));
730
- return result.value;
731
- }
732
- }
733
-
734
- /**
735
- * 获取签名加密 PIN 码
736
- * @returns {string} 签名加密 PIN 码
737
- */
738
- getPinCode() {
739
- if (this.useActioveX) {
740
- return window.PNXClient.GetPinCode();
741
- } else {
742
- const jsonstr = '';
743
- const result = JSON.parse(this.sendAndWaitMessageEx('GetPinCode', jsonstr));
744
- return result.value;
745
- }
746
- }
747
- /*
748
- *曙光四川CA
749
- *'SOF_GetUserList' 证书列表
750
- *'SOF_ExportUserCert' 导出证书
751
- *'SOF_GetCertInfo': 获取证书信息
752
- *'SOF_GenRandom': 生成随机数
753
- *'SOF_SignData': 获取证书签名
754
- *'SOF_Login': 登录证书
755
- *'SOF_GetPinRetryCount': 剩余次数
756
- */
757
- /**
758
- *
759
- * 获取webSocket消息
760
- * @returns {string}
761
- */
762
- getMessage({ action, params = [] }) {
763
- return new Promise((resolve, reject) => {
764
- var obj = JSON.stringify({
765
- 'action': action,
766
- 'params': params
767
- });
768
- if (!this.webSocket) {
769
- this.webSocket = new WebSocket('wss://localhost:36171');
770
- this.webSocket.onerror = (event) => {
771
- this.webSocket = null;
772
- reject(event);
773
- };
774
- this.webSocket.onopen = () => {
775
- this.webSocket.send(obj);
776
- };
777
- } else {
778
- this.webSocket.send(obj);
779
- }
780
- this.webSocket.onclose = (event) => {
781
- this.webSocket = null;
782
- };
783
- this.webSocket.onmessage = (event) => {
784
- resolve(JSON.parse(event.data));
785
- };
786
- });
787
- }
788
- /**
789
- *
790
- * base64解码
791
- * @returns {string} base64解码后的字符串
792
- */
793
- base64Decode(res) {
794
- let _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
795
- let val = '';
796
- let chr1;
797
- let chr2;
798
- let chr3;
799
- let enc1;
800
- let enc2;
801
- let enc3;
802
- let enc4;
803
- let i = 0;
804
- res = res.replace(/[^A-Za-z0-9\+\/\=]/g, '');
805
- while (i < res.length) {
806
- enc1 = _keyStr.indexOf(res.charAt(i++));
807
- enc2 = _keyStr.indexOf(res.charAt(i++));
808
- enc3 = _keyStr.indexOf(res.charAt(i++));
809
- enc4 = _keyStr.indexOf(res.charAt(i++));
810
- chr1 = (enc1 << 2) | (enc2 >> 4);
811
- chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
812
- chr3 = ((enc3 & 3) << 6) | enc4;
813
- val = val + String.fromCharCode(chr1);
814
- if (enc3 !== 64) {
815
- val = val + String.fromCharCode(chr2);
816
- }
817
- if (enc4 !== 64) {
818
- val = val + String.fromCharCode(chr3);
819
- }
820
- }
821
- val = this.utf8_decode(val);
822
- return val;
823
- }
824
- /**
825
- *
826
- * base64编码
827
- * @returns {string} base64编码后的字符串
828
- */
829
- base64Encode(res) {
830
- let _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
831
- let val = '';
832
- let chr1;
833
- let chr2;
834
- let chr3;
835
- let enc1;
836
- let enc2;
837
- let enc3;
838
- let enc4;
839
- let i = 0;
840
- res = this.utf8_encode(res);
841
- while (i < res.length) {
842
- chr1 = res.charCodeAt(i++);
843
- chr2 = res.charCodeAt(i++);
844
- chr3 = res.charCodeAt(i++);
845
- enc1 = chr1 >> 2;
846
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
847
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
848
- enc4 = chr3 & 63;
849
- if (isNaN(chr2)) {
850
- enc3 = enc4 = 64;
851
- } else if (isNaN(chr3)) {
852
- enc4 = 64;
853
- }
854
- val = val + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
855
- }
856
- return val;
857
- }
858
- /**
859
- *
860
- * utf8解码
861
- * @returns {string} utf8解码后的字符串
862
- */
863
- utf8_decode(utftext) {
864
- let string = '';
865
- let i = 0;
866
- let c = 0;
867
- // let c1 = 0;
868
- let c2 = 0;
869
- let c3 = 0;
870
- while (i < utftext.length) {
871
- c = utftext.charCodeAt(i);
872
- if (c < 128) {
873
- string += String.fromCharCode(c);
874
- i++;
875
- } else if ((c > 191) && (c < 224)) {
876
- c2 = utftext.charCodeAt(i + 1);
877
- string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
878
- i += 2;
879
- } else {
880
- c2 = utftext.charCodeAt(i + 1);
881
- c3 = utftext.charCodeAt(i + 2);
882
- string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
883
- i += 3;
884
- }
885
- }
886
- return string;
887
- }
888
- /**
889
- *
890
- * utf8编码
891
- * @returns {string} utf8编码后的字符串
892
- */
893
- utf8_encode(string) {
894
- string = string.replace(/\r\n/g, '\n');
895
- var utftext = '';
896
- for (var n = 0; n < string.length; n++) {
897
- var c = string.charCodeAt(n);
898
- if (c < 128) {
899
- utftext += String.fromCharCode(c);
900
- } else if ((c > 127) && (c < 2048)) {
901
- utftext += String.fromCharCode((c >> 6) | 192);
902
- utftext += String.fromCharCode((c & 63) | 128);
903
- } else {
904
- utftext += String.fromCharCode((c >> 12) | 224);
905
- utftext += String.fromCharCode(((c >> 6) & 63) | 128);
906
- utftext += String.fromCharCode((c & 63) | 128);
907
- }
908
-
909
- }
910
- return utftext;
911
- }
912
- }
913
-
914
- const caPlugin = new CA_ExtInterface();
915
- export default caPlugin;
1
+ /**
2
+ * JIT_GW_ExtInterface 模块,提供与客户端交互的功能
3
+ */
4
+ class CA_ExtInterface {
5
+ constructor() {
6
+ this.currentSessionWSURL = '';
7
+ this.useActioveX = false;
8
+ this.options = {};
9
+ this.webSocket = null;
10
+ this.init();
11
+ }
12
+
13
+ /**
14
+ * 简单的 Object.assign 兼容 IE <= 11 的 polyfill
15
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
16
+ * @param {Object} target - 目标对象
17
+ * @param {Object} options - 新的选项对象
18
+ */
19
+ extendOptions(target, options) {
20
+ if (typeof Object.assign === 'function') {
21
+ Object.assign(target, options);
22
+ } else {
23
+ // 兼容 IE < 11
24
+ for (const key in options) {
25
+ target[key] = options[key];
26
+ }
27
+ }
28
+ }
29
+
30
+ /**
31
+ * 检查当前会话的 WebSocket URL
32
+ */
33
+ checkSessionWSURL() {
34
+ if (this.currentSessionWSURL === '') {
35
+ if (document.location.protocol === 'https:') {
36
+ this.currentSessionWSURL = this.sendAndWaitMessage('https://127.0.0.1:10087/', 'QueryService');
37
+ } else {
38
+ this.currentSessionWSURL = this.sendAndWaitMessage('http://127.0.0.1:10086/', 'QueryService');
39
+ }
40
+ }
41
+ }
42
+
43
+ /**
44
+ * 检查是否使用 ActiveX
45
+ */
46
+ isUseActioveX() {
47
+ if (!!window.ActiveXObject || 'ActiveXObject' in window) {
48
+ this.useActioveX = true;
49
+ } else {
50
+ this.useActioveX = false;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * 扩展发送消息并等待响应
56
+ * @param {string} operatorCmd - 操作命令
57
+ * @param {string} sendMsg - 发送的消息
58
+ * @returns {string} 响应消息
59
+ */
60
+ sendAndWaitMessageEx(operatorCmd, sendMsg) {
61
+ this.checkSessionWSURL();
62
+ const strSendMsg = operatorCmd + ':' + sendMsg;
63
+ return this.sendAndWaitMessage(this.currentSessionWSURL, strSendMsg);
64
+ }
65
+
66
+ /**
67
+ * 发送消息并等待响应
68
+ * @param {string} wsurl - WebSocket URL
69
+ * @param {string} sendMsg - 发送的消息
70
+ * @returns {string} 响应消息
71
+ */
72
+ sendAndWaitMessage(wsurl, sendMsg) {
73
+ let ResultMsg = '{"value":""}';
74
+ if (ResultMsg === wsurl) {
75
+ return;
76
+ }
77
+ try {
78
+ const globalXmlHttpRequest = new XMLHttpRequest();
79
+ globalXmlHttpRequest.open('POST', wsurl, false);
80
+ globalXmlHttpRequest.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');
81
+ globalXmlHttpRequest.send(sendMsg);
82
+ ResultMsg = globalXmlHttpRequest.responseText;
83
+ } catch (e) {
84
+ this.currentSessionWSURL = '';
85
+ if (this.options.onError) {
86
+ this.options.onError.call(undefined, e);
87
+ }
88
+ }
89
+ return ResultMsg;
90
+ }
91
+
92
+ /**
93
+ * 配置选项
94
+ * @param {Object} extendOption - 扩展选项
95
+ */
96
+ config(extendOption) {
97
+ if (extendOption && typeof extendOption === 'object') {
98
+ this.extendOptions(this.options, extendOption);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * 初始化
104
+ */
105
+ init() {
106
+ this.isUseActioveX();
107
+ }
108
+
109
+ /**
110
+ * 返回客户端的版本
111
+ * @returns {string} 客户端版本
112
+ */
113
+ getClientVersion() {
114
+ if (this.useActioveX) {
115
+ return window.PNXClient.GetClientVersion();
116
+ } else {
117
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetClientVersion', ''));
118
+ return result.value;
119
+ }
120
+ }
121
+
122
+ /**
123
+ * 下载客户端程序并安装
124
+ * @param {string} bstrURL - 下载地址
125
+ * @param {string} bstrHashValue - 哈希值
126
+ * @param {boolean} bSync - 是否同步安装
127
+ * @param {boolean} bOnlySSO - 是否仅安装 SSO
128
+ * @returns {number} 安装结果
129
+ */
130
+ setupClient(bstrURL, bstrHashValue, bSync, bOnlySSO) {
131
+ if (this.useActioveX) {
132
+ return window.PNXClient.SetupClient(bstrURL, bstrHashValue, bSync, bOnlySSO);
133
+ } else {
134
+ const jsonstr = { 'strURL': bstrURL, 'strHashValue': bstrHashValue, 'bSync': bSync, 'bOnlySSO': bOnlySSO };
135
+ const result = JSON.parse(this.sendAndWaitMessageEx('SetupClient', JSON.stringify(jsonstr)));
136
+ return result.value;
137
+ }
138
+ }
139
+
140
+ /**
141
+ * 获取硬件指纹信息
142
+ * @param {number} dwSign - 签名
143
+ * @param {string} strGateWayIP - 网关 IP
144
+ * @returns {string} 硬件指纹信息
145
+ */
146
+ getFinger(dwSign, strGateWayIP) {
147
+ if (this.useActioveX) {
148
+ return window.PNXClient.GetFinger(dwSign, strGateWayIP);
149
+ } else {
150
+ const jsonstr = { 'dwSign': dwSign, 'strGateWayIP': strGateWayIP };
151
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetFinger', JSON.stringify(jsonstr)));
152
+ return result.value;
153
+ }
154
+ }
155
+
156
+ /**
157
+ * 设置转发策略和代填策略
158
+ * @param {string} strProxyPolicy - 转发策略
159
+ * @param {string} strSSOPolicy - 代填策略
160
+ * @param {string} strGatewayAddress - 网关地址
161
+ * @returns {number} 设置结果
162
+ */
163
+ setPolicy(strProxyPolicy, strSSOPolicy, strGatewayAddress) {
164
+ if (this.useActioveX) {
165
+ return window.PNXClient.SetPolicy(strProxyPolicy, strSSOPolicy, strGatewayAddress);
166
+ } else {
167
+ const jsonstr = { 'strProxyPolicy': strProxyPolicy, 'strSSOPolicy': strSSOPolicy, 'strGatewayAddress': strGatewayAddress };
168
+ const result = JSON.parse(this.sendAndWaitMessageEx('SetPolicy', JSON.stringify(jsonstr)));
169
+ return result.value;
170
+ }
171
+ }
172
+
173
+ /**
174
+ * 启动认证信息模块
175
+ * @param {string} strFileName - 文件名
176
+ * @param {string} strXmlData - XML 数据
177
+ * @returns {string} 认证信息
178
+ */
179
+ getAuthToken(strFileName, strXmlData) {
180
+ if (this.useActioveX) {
181
+ return window.PNXClient.GetAuthToken(strFileName, strXmlData);
182
+ } else {
183
+ const jsonstr = { 'strFileName': strFileName, 'strXmlData': strXmlData };
184
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetAuthToken', JSON.stringify(jsonstr)));
185
+ return result.value;
186
+ }
187
+ }
188
+
189
+ /**
190
+ * 打开 BS 应用
191
+ * @param {string} strUrl - 应用 URL
192
+ * @returns {number} 打开结果
193
+ */
194
+ navigateURL(strUrl) {
195
+ if (this.useActioveX) {
196
+ return window.PNXClient.NavigateURL(strUrl);
197
+ } else {
198
+ const jsonstr = { 'strUrl': strUrl };
199
+ const result = JSON.parse(this.sendAndWaitMessageEx('NavigateURL', JSON.stringify(jsonstr)));
200
+ return result.value;
201
+ }
202
+ }
203
+
204
+ /**
205
+ * 打开 CS 应用
206
+ * @param {string} strGatewayAddress - 网关地址
207
+ * @param {string} strAppFlag - 应用标识
208
+ * @param {string} strAppPath - 应用路径
209
+ * @returns {number} 打开结果
210
+ */
211
+ executeCS(strGatewayAddress, strAppFlag, strAppPath) {
212
+ if (this.useActioveX) {
213
+ return window.PNXClient.ExecuteCS(strGatewayAddress, strAppFlag, strAppPath);
214
+ } else {
215
+ const jsonstr = { 'strGatewayAddress': strGatewayAddress, 'strAppFlag': strAppFlag, 'strAppPath': strAppPath };
216
+ const result = JSON.parse(this.sendAndWaitMessageEx('ExecuteCS', JSON.stringify(jsonstr)));
217
+ return result.value;
218
+ }
219
+ }
220
+
221
+ /**
222
+ * 设置自动更新策略
223
+ * @param {string} strGatewayAddress - 网关地址
224
+ * @param {number} nGatewayPort - 网关端口
225
+ * @param {string} strUserToken - 用户令牌
226
+ * @param {number} updatedelay - 更新延迟
227
+ * @returns {number} 设置结果
228
+ */
229
+ setUpdatePolicy(strGatewayAddress, nGatewayPort, strUserToken, updatedelay) {
230
+ if (this.useActioveX) {
231
+ return window.PNXClient.SetUpdatePolicy(strGatewayAddress, nGatewayPort, strUserToken, updatedelay);
232
+ } else {
233
+ const jsonstr = { 'strGatewayAddress': strGatewayAddress, 'nGatewayPort': nGatewayPort, 'strUserToken': strUserToken, 'ulUpdateDelay': updatedelay };
234
+ const result = JSON.parse(this.sendAndWaitMessageEx('SetUpdatePolicy', JSON.stringify(jsonstr)));
235
+ return result.value;
236
+ }
237
+ }
238
+
239
+ /**
240
+ * 获取客户端 IP
241
+ * @param {string} strGatewayIP - 网关 IP
242
+ * @returns {string} 客户端 IP
243
+ */
244
+ getClientIP(strGatewayIP) {
245
+ if (this.useActioveX) {
246
+ return window.PNXClient.GetClientIP(strGatewayIP);
247
+ } else {
248
+ const jsonstr = { 'strGatewayIP': strGatewayIP };
249
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetClientIP', JSON.stringify(jsonstr)));
250
+ return result.value;
251
+ }
252
+ }
253
+
254
+ /**
255
+ * 登出网关
256
+ * @param {string} strServerIP - 服务器 IP
257
+ * @returns {number} 登出结果
258
+ */
259
+ gwLogout(strServerIP) {
260
+ if (this.useActioveX) {
261
+ return window.PNXClient.GWLogout(strServerIP);
262
+ } else {
263
+ const jsonstr = { 'strServerIP': strServerIP };
264
+ const result = JSON.parse(this.sendAndWaitMessageEx('GWLogout', JSON.stringify(jsonstr)));
265
+ return result.value;
266
+ }
267
+ }
268
+
269
+ /**
270
+ * 运行安装包
271
+ * @param {number} lRunType - 运行类型
272
+ * @param {boolean} bIsOnlySSO - 是否仅安装 SSO
273
+ * @returns {number} 运行结果
274
+ */
275
+ runSetup(lRunType, bIsOnlySSO) {
276
+ if (this.useActioveX) {
277
+ return window.PNXClient.RunSetup(lRunType, bIsOnlySSO);
278
+ } else {
279
+ const jsonstr = { 'lRunType': lRunType, 'bIsOnlySSO': bIsOnlySSO };
280
+ const result = JSON.parse(this.sendAndWaitMessageEx('RunSetup', JSON.stringify(jsonstr)));
281
+ return result.value;
282
+ }
283
+ }
284
+
285
+ /**
286
+ * 获取下载进度
287
+ * @returns {number} 下载进度
288
+ */
289
+ getDownloadProgress() {
290
+ if (this.useActioveX) {
291
+ return window.PNXClient.GetDownloadProgress();
292
+ } else {
293
+ const jsonstr = '';
294
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetDownloadProgress', jsonstr));
295
+ return result.value;
296
+ }
297
+ }
298
+
299
+ /**
300
+ * 是否安装完成
301
+ * @returns {boolean} 安装完成状态
302
+ */
303
+ isInstallComplete() {
304
+ if (this.useActioveX) {
305
+ return window.PNXClient.IsInstallComplete();
306
+ } else {
307
+ const jsonstr = '';
308
+ const result = JSON.parse(this.sendAndWaitMessageEx('IsInstallComplete', jsonstr));
309
+ return result.value;
310
+ }
311
+ }
312
+
313
+ /**
314
+ * 初始化签包对象
315
+ * @param {string} strAlgType - 算法类型
316
+ * @param {string} strAuxParam - 辅助参数
317
+ * @returns {number} 初始化结果
318
+ */
319
+ initialize(strAlgType, strAuxParam) {
320
+ if (this.useActioveX) {
321
+ return window.PNXClient.Initialize(strAlgType, strAuxParam);
322
+ } else {
323
+ const jsonstr = { 'strAlgType': strAlgType, 'strAuxParam': strAuxParam };
324
+ const result = JSON.parse(this.sendAndWaitMessageEx('Initialize', JSON.stringify(jsonstr)));
325
+ return result.value;
326
+ }
327
+ }
328
+
329
+ /**
330
+ * 设置摘要算法
331
+ * @param {string} strDigestAlg - 摘要算法
332
+ * @returns {number} 设置结果
333
+ */
334
+ setDigestAlg(strDigestAlg) {
335
+ if (this.useActioveX) {
336
+ return window.PNXClient.SetDigestAlg(strDigestAlg);
337
+ } else {
338
+ const jsonstr = { 'strDigestAlg': strDigestAlg };
339
+ const result = JSON.parse(this.sendAndWaitMessageEx('SetDigestAlg', JSON.stringify(jsonstr)));
340
+ return result.value;
341
+ }
342
+ }
343
+
344
+ /**
345
+ * 设置单证书是否弹出对话框
346
+ * @param {number} isChoose - 是否弹出对话框
347
+ * @returns {number} 设置结果
348
+ */
349
+ setChooseSingleCert(isChoose) {
350
+ if (this.useActioveX) {
351
+ return window.PNXClient.SetChooseSingleCert(isChoose);
352
+ } else {
353
+ const jsonstr = { 'isChoose': isChoose };
354
+ const result = JSON.parse(this.sendAndWaitMessageEx('SetChooseSingleCert', JSON.stringify(jsonstr)));
355
+ return result.value;
356
+ }
357
+ }
358
+
359
+ /**
360
+ * 添加证书过滤条件
361
+ * @param {number} ulType - 过滤类型
362
+ * @param {string} strValue - 过滤值
363
+ * @returns {number} 添加结果
364
+ */
365
+ addFilter(ulType, strValue) {
366
+ if (this.useActioveX) {
367
+ return window.PNXClient.AddFilter(ulType, strValue);
368
+ } else {
369
+ const jsonstr = { 'ulType': ulType, 'strValue': strValue };
370
+ const result = JSON.parse(this.sendAndWaitMessageEx('AddFilter', JSON.stringify(jsonstr)));
371
+ return result.value;
372
+ }
373
+ }
374
+
375
+ /**
376
+ * 清除所有过滤条件
377
+ * @returns {number} 清除结果
378
+ */
379
+ clearFilter() {
380
+ if (this.useActioveX) {
381
+ return window.PNXClient.ClearFilter();
382
+ } else {
383
+ const jsonstr = '';
384
+ const result = JSON.parse(this.sendAndWaitMessageEx('ClearFilter', jsonstr));
385
+ return result.value;
386
+ }
387
+ }
388
+
389
+ /**
390
+ * P1 签名
391
+ * @param {string} strValueBase64 - 待签名的 Base64 字符串
392
+ * @returns {string} 签名结果
393
+ */
394
+ p1Sign(strValueBase64) {
395
+ if (this.useActioveX) {
396
+ return window.PNXClient.P1Sign(strValueBase64);
397
+ } else {
398
+ const jsonstr = { 'strValueBase64': strValueBase64 };
399
+ const result = JSON.parse(this.sendAndWaitMessageEx('P1Sign', JSON.stringify(jsonstr)));
400
+ return result.value;
401
+ }
402
+ }
403
+
404
+ /**
405
+ * P1 签名字符串
406
+ * @param {string} strValue - 待签名的字符串
407
+ * @returns {string} 签名结果
408
+ */
409
+ p1SignString(strValue) {
410
+ if (this.useActioveX) {
411
+ return window.PNXClient.P1SignString(strValue);
412
+ } else {
413
+ const jsonstr = { 'strValue': strValue };
414
+ const result = JSON.parse(this.sendAndWaitMessageEx('P1SignString', JSON.stringify(jsonstr)));
415
+ return result.value;
416
+ }
417
+ }
418
+
419
+ /**
420
+ * P7 签名
421
+ * @param {string} strValueBase64 - 待签名的 Base64 字符串
422
+ * @param {boolean} isDetach - 是否分离签名
423
+ * @param {boolean} isIncludeCert - 是否包含证书
424
+ * @returns {string} 签名结果
425
+ */
426
+ p7Sign(strValueBase64, isDetach, isIncludeCert) {
427
+ if (this.useActioveX) {
428
+ return window.PNXClient.P7Sign(strValueBase64, isDetach, isIncludeCert);
429
+ } else {
430
+ const jsonstr = { 'strValueBase64': strValueBase64, 'isDetach': isDetach, 'isIncludeCert': isIncludeCert };
431
+ const result = JSON.parse(this.sendAndWaitMessageEx('P7Sign', JSON.stringify(jsonstr)));
432
+ return result.value;
433
+ }
434
+ }
435
+
436
+ /**
437
+ * P7 签名字符串
438
+ * @param {string} strValue - 待签名的字符串
439
+ * @param {boolean} isDetach - 是否分离签名
440
+ * @param {boolean} isIncludeCert - 是否包含证书
441
+ * @returns {string} 签名结果
442
+ */
443
+ p7SignString(strValue, isDetach, isIncludeCert) {
444
+ if (this.useActioveX) {
445
+ return window.PNXClient.P7SignString(strValue, isDetach, isIncludeCert);
446
+ } else {
447
+ const jsonstr = { 'strValue': strValue, 'isDetach': isDetach, 'isIncludeCert': isIncludeCert };
448
+ const result = JSON.parse(this.sendAndWaitMessageEx('P7SignString', JSON.stringify(jsonstr)));
449
+ return result.value;
450
+ }
451
+ }
452
+
453
+ /**
454
+ * 释放签名对象
455
+ * @returns {number} 释放结果
456
+ */
457
+ finalize() {
458
+ if (this.useActioveX) {
459
+ return window.PNXClient.Finalize();
460
+ } else {
461
+ const jsonstr = '';
462
+ const result = JSON.parse(this.sendAndWaitMessageEx('Finalize', jsonstr));
463
+ return result.value;
464
+ }
465
+ }
466
+
467
+ /**
468
+ * 获取签名版本
469
+ * @returns {string} 签名版本
470
+ */
471
+ getSignVersion() {
472
+ if (this.useActioveX) {
473
+ return window.PNXClient.GetSignVersion();
474
+ } else {
475
+ const jsonstr = '';
476
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetSignVersion', jsonstr));
477
+ return result.value;
478
+ }
479
+ }
480
+
481
+ /**
482
+ * 获取签名证书
483
+ * @returns {string} 签名证书
484
+ */
485
+ getSignCert() {
486
+ if (this.useActioveX) {
487
+ return window.PNXClient.GetSignCert();
488
+ } else {
489
+ const jsonstr = '';
490
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetSignCert', jsonstr));
491
+ return result.value;
492
+ }
493
+ }
494
+
495
+ /**
496
+ * 获取错误码
497
+ * @returns {number} 错误码
498
+ */
499
+ getLastError() {
500
+ if (this.useActioveX) {
501
+ return window.PNXClient.GetLastError();
502
+ } else {
503
+ const jsonstr = '';
504
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetLastError', jsonstr));
505
+ return result.value;
506
+ }
507
+ }
508
+
509
+ /**
510
+ * 获取错误信息
511
+ * @returns {string} 错误信息
512
+ */
513
+ getLastErrorMessage() {
514
+ if (this.useActioveX) {
515
+ return window.PNXClient.GetLastErrorMessage();
516
+ } else {
517
+ const jsonstr = '';
518
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetLastErrorMessage', jsonstr));
519
+ return result.value;
520
+ }
521
+ }
522
+
523
+ /**
524
+ * 销毁认证对象
525
+ * @returns {number} 销毁结果
526
+ */
527
+ destoryAuth() {
528
+ if (this.useActioveX) {
529
+ return window.PNXClient.DestoryAuth();
530
+ } else {
531
+ const jsonstr = '';
532
+ const result = JSON.parse(this.sendAndWaitMessageEx('DestoryAuth', jsonstr));
533
+ return result.value;
534
+ }
535
+ }
536
+
537
+ /**
538
+ * 获取证书类型
539
+ * @returns {string} 证书类型
540
+ */
541
+ getSignCertType() {
542
+ if (this.useActioveX) {
543
+ return window.PNXClient.GetSignCertType();
544
+ } else {
545
+ const jsonstr = '';
546
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetSignCertType', jsonstr));
547
+ return result.value;
548
+ }
549
+ }
550
+
551
+ /**
552
+ * 获取签名摘要算法
553
+ * @returns {string} 签名摘要算法
554
+ */
555
+ getSignHash() {
556
+ if (this.useActioveX) {
557
+ return window.PNXClient.GetSignHash();
558
+ } else {
559
+ const jsonstr = '';
560
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetSignHash', jsonstr));
561
+ return result.value;
562
+ }
563
+ }
564
+
565
+ /**
566
+ * 使能调用序列
567
+ * @param {boolean} bCallQueueEnable - 是否使能调用序列
568
+ * @param {boolean} bHeadInfoEnable - 是否使能头部信息
569
+ * @returns {number} 使能结果
570
+ */
571
+ callQueueEnable(bCallQueueEnable, bHeadInfoEnable) {
572
+ if (this.useActioveX) {
573
+ return window.PNXClient.CallQueueEnable(bCallQueueEnable, bHeadInfoEnable);
574
+ } else {
575
+ const jsonstr = { 'bCallQueueEnable': bCallQueueEnable, 'bHeadInfoEnable': bHeadInfoEnable };
576
+ const result = JSON.parse(this.sendAndWaitMessageEx('CallQueueEnable', JSON.stringify(jsonstr)));
577
+ return result.value;
578
+ }
579
+ }
580
+
581
+ /**
582
+ * 清空调用序列结果
583
+ * @returns {number} 清空调用序列结果
584
+ */
585
+ callQueueClear() {
586
+ if (this.useActioveX) {
587
+ return window.PNXClient.CallQueueClear();
588
+ } else {
589
+ const jsonstr = '';
590
+ const result = JSON.parse(this.sendAndWaitMessageEx('CallQueueClear', jsonstr));
591
+ return result.value;
592
+ }
593
+ }
594
+
595
+ /**
596
+ * 获取调用序列结果
597
+ * @returns {string} 调用序列结果
598
+ */
599
+ callQueueGet() {
600
+ if (this.useActioveX) {
601
+ return window.PNXClient.CallQueueGet();
602
+ } else {
603
+ const jsonstr = '';
604
+ const result = JSON.parse(this.sendAndWaitMessageEx('CallQueueGet', jsonstr));
605
+ return result.value;
606
+ }
607
+ }
608
+
609
+ /**
610
+ * 客户端安全策略检查
611
+ * @param {string} strGatewayAddress - 网关地址
612
+ * @param {number} usGatewayPort - 网关端口
613
+ * @param {string} strSecurityPolicys - 安全策略
614
+ * @returns {boolean} 检查结果
615
+ */
616
+ doClientSecurityCheck(strGatewayAddress, usGatewayPort, strSecurityPolicys) {
617
+ if (this.useActioveX) {
618
+ return window.PNXClient.DoClientSecurityCheck(strGatewayAddress, usGatewayPort, strSecurityPolicys);
619
+ } else {
620
+ const jsonstr = { 'strGatewayAddress': strGatewayAddress, 'usGatewayPort': usGatewayPort, 'strSecurityPolicys': strSecurityPolicys };
621
+ const result = JSON.parse(this.sendAndWaitMessageEx('DoClientSecurityCheck', JSON.stringify(jsonstr)));
622
+ return result.value;
623
+ }
624
+ }
625
+
626
+ /**
627
+ * 获取通讯协议版本
628
+ * @returns {string} 通讯协议版本
629
+ */
630
+ getProtocolVersion() {
631
+ if (this.useActioveX) {
632
+ return window.PNXClient.GetProtocolVersion();
633
+ } else {
634
+ const jsonstr = '';
635
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetProtocolVersion', jsonstr));
636
+ return result.value;
637
+ }
638
+ }
639
+
640
+ /**
641
+ * 修改 Key 的 Pin 码
642
+ * @param {string} strCertSn - 证书序列号
643
+ * @param {number} lPinCodeType - Pin 码类型
644
+ * @param {string} strCurPinCode - 当前 Pin 码
645
+ * @param {string} strNewPinCode - 新 Pin 码
646
+ * @returns {number} 修改结果
647
+ */
648
+ changePinCode(strCertSn, lPinCodeType, strCurPinCode, strNewPinCode) {
649
+ if (this.useActioveX) {
650
+ return window.PNXClient.ChangePinCode(strCertSn, lPinCodeType, strCurPinCode, strNewPinCode);
651
+ } else {
652
+ const jsonstr = { 'strCertSn': strCertSn, 'lPinCodeType': lPinCodeType, 'strCurPinCode': strCurPinCode, 'strNewPinCode': strNewPinCode };
653
+ const result = JSON.parse(this.sendAndWaitMessageEx('ChangePinCode', JSON.stringify(jsonstr)));
654
+ return result.value;
655
+ }
656
+ }
657
+
658
+ /**
659
+ * 等待策略设置完毕
660
+ * @param {string} strGatewayAddress - 网关地址
661
+ * @returns {number} 等待结果
662
+ */
663
+ waitSetPolicyFinish(strGatewayAddress) {
664
+ if (this.useActioveX) {
665
+ return window.PNXClient.WaitSetPolicyFinish(strGatewayAddress);
666
+ } else {
667
+ const jsonstr = { 'strGatewayAddress': strGatewayAddress };
668
+ const result = JSON.parse(this.sendAndWaitMessageEx('WaitSetPolicyFinish', JSON.stringify(jsonstr)));
669
+ return result.value;
670
+ }
671
+ }
672
+
673
+ /**
674
+ * 获取会话 Token
675
+ * @param {string} strGatewayAddress - 网关地址
676
+ * @returns {string} 会话 Token
677
+ */
678
+ getSessionToken(strGatewayAddress) {
679
+ if (this.useActioveX) {
680
+ return window.PNXClient.GetSessionToken(strGatewayAddress);
681
+ } else {
682
+ const jsonstr = { 'strGatewayAddress': strGatewayAddress };
683
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetSessionToken', JSON.stringify(jsonstr)));
684
+ return result.value;
685
+ }
686
+ }
687
+
688
+ /**
689
+ * 获取控件版本
690
+ * @returns {string} 控件版本
691
+ */
692
+ getVersion() {
693
+ if (this.useActioveX) {
694
+ return window.PNXClient.GetVersion();
695
+ } else {
696
+ const jsonstr = '';
697
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetVersion', jsonstr));
698
+ return result.value;
699
+ }
700
+ }
701
+
702
+ /**
703
+ * 设置语言资源
704
+ * @param {string} strLanguage - 语言资源
705
+ * @returns {number} 设置结果
706
+ */
707
+ setLanguage(strLanguage) {
708
+ if (this.useActioveX) {
709
+ return window.PNXClient.SetLanguage(strLanguage);
710
+ } else {
711
+ const jsonstr = { 'strLanguage': strLanguage };
712
+ const result = JSON.parse(this.sendAndWaitMessageEx('SetLanguage', JSON.stringify(jsonstr)));
713
+ return result.value;
714
+ }
715
+ }
716
+
717
+ /**
718
+ * 获取用户属性
719
+ * @param {string} strGatewayAddress - 网关地址
720
+ * @param {string} strAppFlag - 应用标识
721
+ * @param {string} strAttributeName - 属性名称
722
+ * @returns {string} 用户属性值
723
+ */
724
+ getAttribute(strGatewayAddress, strAppFlag, strAttributeName) {
725
+ if (this.useActioveX) {
726
+ return window.PNXClient.GetAttribute(strGatewayAddress, strAppFlag, strAttributeName);
727
+ } else {
728
+ const jsonstr = { 'strGatewayAddress': strGatewayAddress, 'strAppFlag': strAppFlag, 'strAttributeName': strAttributeName };
729
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetAttribute', JSON.stringify(jsonstr)));
730
+ return result.value;
731
+ }
732
+ }
733
+
734
+ /**
735
+ * 获取签名加密 PIN 码
736
+ * @returns {string} 签名加密 PIN 码
737
+ */
738
+ getPinCode() {
739
+ if (this.useActioveX) {
740
+ return window.PNXClient.GetPinCode();
741
+ } else {
742
+ const jsonstr = '';
743
+ const result = JSON.parse(this.sendAndWaitMessageEx('GetPinCode', jsonstr));
744
+ return result.value;
745
+ }
746
+ }
747
+ /*
748
+ *曙光四川CA
749
+ *'SOF_GetUserList' 证书列表
750
+ *'SOF_ExportUserCert' 导出证书
751
+ *'SOF_GetCertInfo': 获取证书信息
752
+ *'SOF_GenRandom': 生成随机数
753
+ *'SOF_SignData': 获取证书签名
754
+ *'SOF_Login': 登录证书
755
+ *'SOF_GetPinRetryCount': 剩余次数
756
+ */
757
+ /**
758
+ *
759
+ * 获取webSocket消息
760
+ * @returns {string}
761
+ */
762
+ getMessage({ action, params = [] }) {
763
+ return new Promise((resolve, reject) => {
764
+ var obj = JSON.stringify({
765
+ 'action': action,
766
+ 'params': params
767
+ });
768
+ if (!this.webSocket) {
769
+ this.webSocket = new WebSocket('wss://localhost:36171');
770
+ this.webSocket.onerror = (event) => {
771
+ this.webSocket = null;
772
+ reject(event);
773
+ };
774
+ this.webSocket.onopen = () => {
775
+ this.webSocket.send(obj);
776
+ };
777
+ } else {
778
+ this.webSocket.send(obj);
779
+ }
780
+ this.webSocket.onclose = (event) => {
781
+ this.webSocket = null;
782
+ };
783
+ this.webSocket.onmessage = (event) => {
784
+ resolve(JSON.parse(event.data));
785
+ };
786
+ });
787
+ }
788
+ /**
789
+ *
790
+ * base64解码
791
+ * @returns {string} base64解码后的字符串
792
+ */
793
+ base64Decode(res) {
794
+ let _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
795
+ let val = '';
796
+ let chr1;
797
+ let chr2;
798
+ let chr3;
799
+ let enc1;
800
+ let enc2;
801
+ let enc3;
802
+ let enc4;
803
+ let i = 0;
804
+ res = res.replace(/[^A-Za-z0-9\+\/\=]/g, '');
805
+ while (i < res.length) {
806
+ enc1 = _keyStr.indexOf(res.charAt(i++));
807
+ enc2 = _keyStr.indexOf(res.charAt(i++));
808
+ enc3 = _keyStr.indexOf(res.charAt(i++));
809
+ enc4 = _keyStr.indexOf(res.charAt(i++));
810
+ chr1 = (enc1 << 2) | (enc2 >> 4);
811
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
812
+ chr3 = ((enc3 & 3) << 6) | enc4;
813
+ val = val + String.fromCharCode(chr1);
814
+ if (enc3 !== 64) {
815
+ val = val + String.fromCharCode(chr2);
816
+ }
817
+ if (enc4 !== 64) {
818
+ val = val + String.fromCharCode(chr3);
819
+ }
820
+ }
821
+ val = this.utf8_decode(val);
822
+ return val;
823
+ }
824
+ /**
825
+ *
826
+ * base64编码
827
+ * @returns {string} base64编码后的字符串
828
+ */
829
+ base64Encode(res) {
830
+ let _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
831
+ let val = '';
832
+ let chr1;
833
+ let chr2;
834
+ let chr3;
835
+ let enc1;
836
+ let enc2;
837
+ let enc3;
838
+ let enc4;
839
+ let i = 0;
840
+ res = this.utf8_encode(res);
841
+ while (i < res.length) {
842
+ chr1 = res.charCodeAt(i++);
843
+ chr2 = res.charCodeAt(i++);
844
+ chr3 = res.charCodeAt(i++);
845
+ enc1 = chr1 >> 2;
846
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
847
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
848
+ enc4 = chr3 & 63;
849
+ if (isNaN(chr2)) {
850
+ enc3 = enc4 = 64;
851
+ } else if (isNaN(chr3)) {
852
+ enc4 = 64;
853
+ }
854
+ val = val + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
855
+ }
856
+ return val;
857
+ }
858
+ /**
859
+ *
860
+ * utf8解码
861
+ * @returns {string} utf8解码后的字符串
862
+ */
863
+ utf8_decode(utftext) {
864
+ let string = '';
865
+ let i = 0;
866
+ let c = 0;
867
+ // let c1 = 0;
868
+ let c2 = 0;
869
+ let c3 = 0;
870
+ while (i < utftext.length) {
871
+ c = utftext.charCodeAt(i);
872
+ if (c < 128) {
873
+ string += String.fromCharCode(c);
874
+ i++;
875
+ } else if ((c > 191) && (c < 224)) {
876
+ c2 = utftext.charCodeAt(i + 1);
877
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
878
+ i += 2;
879
+ } else {
880
+ c2 = utftext.charCodeAt(i + 1);
881
+ c3 = utftext.charCodeAt(i + 2);
882
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
883
+ i += 3;
884
+ }
885
+ }
886
+ return string;
887
+ }
888
+ /**
889
+ *
890
+ * utf8编码
891
+ * @returns {string} utf8编码后的字符串
892
+ */
893
+ utf8_encode(string) {
894
+ string = string.replace(/\r\n/g, '\n');
895
+ var utftext = '';
896
+ for (var n = 0; n < string.length; n++) {
897
+ var c = string.charCodeAt(n);
898
+ if (c < 128) {
899
+ utftext += String.fromCharCode(c);
900
+ } else if ((c > 127) && (c < 2048)) {
901
+ utftext += String.fromCharCode((c >> 6) | 192);
902
+ utftext += String.fromCharCode((c & 63) | 128);
903
+ } else {
904
+ utftext += String.fromCharCode((c >> 12) | 224);
905
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
906
+ utftext += String.fromCharCode((c & 63) | 128);
907
+ }
908
+
909
+ }
910
+ return utftext;
911
+ }
912
+ }
913
+
914
+ const caPlugin = new CA_ExtInterface();
915
+ export default caPlugin;