yc-ui2 0.2.2-beta2 → 0.2.2-beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/.env +0 -7
  3. package/babel.config.js +0 -5
  4. package/jsconfig.json +0 -19
  5. package/public/favicon.ico +0 -0
  6. package/public/index.html +0 -20
  7. package/src/App.vue +0 -70
  8. package/src/api/customerService.js +0 -56
  9. package/src/assets/ca/ca-bg.png +0 -0
  10. package/src/assets/ca/caBg.png +0 -0
  11. package/src/assets/customerService/admin.jpg +0 -0
  12. package/src/assets/customerService/chatTop.png +0 -0
  13. package/src/assets/customerService/ellipticalWenh.png +0 -0
  14. package/src/assets/customerService/enlarge.png +0 -0
  15. package/src/assets/customerService/personal.jpg +0 -0
  16. package/src/assets/customerService/personal1.jpg +0 -0
  17. package/src/assets/customerService/personal2.jpg +0 -0
  18. package/src/assets/slideVerify/1.jpg +0 -0
  19. package/src/assets/slideVerify/2.jpg +0 -0
  20. package/src/assets/slideVerify/3.jpg +0 -0
  21. package/src/assets/slideVerify/4.jpg +0 -0
  22. package/src/assets/slideVerify/5.jpg +0 -0
  23. package/src/assets/slideVerify/6.jpg +0 -0
  24. package/src/assets/slideVerify/7.jpg +0 -0
  25. package/src/assets/slideVerify/8.jpg +0 -0
  26. package/src/components/YcCA/index.vue +0 -536
  27. package/src/components/YcCustomerService/chat.vue +0 -337
  28. package/src/components/YcCustomerService/chatMixin.js +0 -128
  29. package/src/components/YcCustomerService/index.vue +0 -272
  30. package/src/components/YcQuestion/index.vue +0 -535
  31. package/src/components/YcSlideVerify/index.vue +0 -104
  32. package/src/main.js +0 -19
  33. package/src/packages/index.js +0 -29
  34. package/src/router/index.js +0 -20
  35. package/src/utils/auth.js +0 -6
  36. package/src/utils/mTokenPlugin/base64.js +0 -148
  37. package/src/utils/mTokenPlugin/base64_backups.js +0 -146
  38. package/src/utils/mTokenPlugin/hunca_mToken_core.js +0 -1447
  39. package/src/utils/mTokenPlugin/hunca_mToken_core2.js +0 -1455
  40. package/src/utils/mTokenPlugin/hunca_mToken_core_backups.js +0 -1425
  41. package/src/utils/mTokenPlugin/mToken.js +0 -3211
  42. package/src/utils/mTokenPlugin/mToken_backups.js +0 -3202
  43. package/src/utils/mTokenPluginBeijin/formateTime.js +0 -10
  44. package/src/utils/mTokenPluginBeijin/xtxasyn.js +0 -1156
  45. package/src/utils/request.js +0 -50
  46. package/src/views/question.vue +0 -32
  47. package/vue.config.js +0 -41
@@ -1,1156 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- /*
3
- --------------------------------------------------------------
4
- * FileName:xtxasyn.js
5
- * This Javascript provides asynchronous interfaces
6
- * Support bjca client version 3.4.1 and later
7
- * Author:BJCA-zys
8
- * Date: 2021-05-06
9
- *
10
- --------------------------------------------------------------
11
- */
12
-
13
- (function() {
14
- if (typeof xtxasyn === 'undefined') {
15
- // eslint-disable-next-line no-undef
16
- window.xtxasyn = {};
17
- }
18
- })();
19
-
20
- // initialize xtxasyn hashMap object
21
- (function() {
22
-
23
- function XTXAsynHashMap(){
24
- this.map = {};
25
- }
26
-
27
- XTXAsynHashMap.prototype = {
28
- put : function(key , value){
29
- this.map[key] = value;
30
- },
31
-
32
- get : function(key){
33
- // eslint-disable-next-line no-prototype-builtins
34
- if(this.map.hasOwnProperty(key)){
35
- return this.map[key];
36
- }
37
- return null;
38
- },
39
-
40
- remove : function(key){
41
- // eslint-disable-next-line no-prototype-builtins
42
- if(this.map.hasOwnProperty(key)){
43
- return delete this.map[key];
44
- }
45
- return false;
46
- },
47
-
48
- removeAll : function(){
49
- this.map = {};
50
- },
51
-
52
- keySet : function(){
53
- var _keys = [];
54
- for(var i in this.map){
55
- _keys.push(i);
56
- }
57
- return _keys;
58
- }
59
- };
60
-
61
- XTXAsynHashMap.prototype.constructor = XTXAsynHashMap;
62
-
63
- // eslint-disable-next-line no-undef
64
- xtxasyn.HashMap = XTXAsynHashMap;
65
- })();
66
-
67
- // initialize xtxasyn util object
68
- (function() {
69
-
70
- function initUtilObject(xtxasyn) {
71
-
72
- var util = xtxasyn.util = xtxasyn.util || {};
73
-
74
- util.checkBrowserISIE = function() {
75
- return (!!window.ActiveXObject || 'ActiveXObject' in window) ? true : false;
76
- }
77
-
78
- util.checkLocationIsHttps = function() {
79
- return 'https:' == document.location.protocol ? true: false;
80
- }
81
-
82
- util.evalFunction = function (func) {
83
- if (typeof func === 'function') {
84
- return func;
85
- } else if (typeof func === 'string') {
86
- // eslint-disable-next-line no-undef
87
- cb = eval(func);
88
- } else {
89
- return null;
90
- }
91
- }
92
-
93
- util.consolelog = function(param) {
94
- if (window.console == undefined || window.console.log == undefined) {
95
- return;
96
- }
97
- console.log(param);
98
- }
99
-
100
- util.isEmpty = function(param) {
101
- if (!param) {
102
- return true;
103
- }
104
- if (typeof param == 'string' && param == "") {
105
- return true;
106
- }
107
-
108
- return false;
109
- }
110
-
111
- util.loadIECtl = function(clsid, ctlName, checkFunc) {
112
- if (!util.checkBrowserISIE()) {
113
- return null;
114
- }
115
- var ctl = document.getElementById(ctlName);
116
- if (ctl) {
117
- return ctl;
118
- }
119
- try {
120
- var loadObjString = '<object id="' + ctlName + '" classid="CLSID:' + clsid + '" style="HEIGHT:0px; WIDTH:0px">';
121
- loadObjString += '</object>';
122
- document.write(loadObjString);
123
- if (checkFunc != null && checkFunc != "" && eval(ctlName + "." + checkFunc) == undefined) {
124
- return null;
125
- }
126
- } catch (e) {
127
- util.consolelog(e);
128
- return null;
129
- }
130
- return document.getElementById(ctlName);
131
- }
132
-
133
- util.getAutoExecFunctionString = function (func) {
134
- var ret = "(";
135
- ret += func.toString();
136
- ret += ")()";
137
-
138
- return ret;
139
- }
140
-
141
- util.attachIEEvent = function(ctlName, eventName, eventFunc) {
142
- var ctl;
143
- if (typeof ctlName === 'string') {
144
- ctl = eval(ctlName);
145
- } else {
146
- ctl = ctlName;
147
- }
148
- eventName = eventName.toLowerCase();
149
-
150
- var cb = util.evalFunction(eventFunc);
151
- if (cb == null) {
152
- return;
153
- }
154
-
155
- if (ctl.attachEvent) {
156
- ctl.attachEvent(eventName, cb);
157
- } else { // IE11 not support attachEvent, and addEventListener do not work well, so addEvent ourself
158
- var handler = document.createElement("script");
159
- handler.setAttribute("for", ctlName);
160
- handler.setAttribute("event", eventName);
161
- var eventScript = util.getAutoExecFunctionString(eventFunc);
162
- handler.appendChild(document.createTextNode(eventScript));
163
- document.getElementsByTagName("head")[0].appendChild(handler);
164
- }
165
- }
166
-
167
- util.loadWebSocketCtl = function(wsUrl, wssUrl) {
168
- if (xtxasyn.wsObject) {
169
- return xtxasyn.wsObject;
170
- }
171
- var url;
172
- if (util.checkLocationIsHttps()) {
173
- url = "wss://" + wssUrl;
174
- } else {
175
- url = "ws://" + wsUrl;
176
- }
177
-
178
- var wsObject = {
179
- socket : undefined,
180
- wsMessageQueue : new xtxasyn.HashMap(),
181
- wsMessageQueueId : 0,
182
- wsEventQueue : new xtxasyn.HashMap(),
183
- wsURL : url,
184
- wsCacheMessage : []
185
- };
186
- xtxasyn.wsObject = wsObject;
187
- xtxasyn.wsObject.wsEventQueue.put("onusbkeychange", util.evalFunction(xtxasyn.custom.defaultUsbkeyChange));
188
-
189
- try {
190
- wsObject.socket = new WebSocket(url);
191
- } catch (e) {
192
- util.consolelog(e);
193
- return null;
194
- }
195
-
196
- // eslint-disable-next-line no-unused-vars
197
- wsObject.socket.onopen = function(evt) {
198
- xtxasyn.util.consolelog("open websocket[" + url + "] ok...");
199
- xtxasyn.SOF_GetVersion(function(ret) {
200
- util.consolelog("SOF_GetVersion:(" + ret.retVal + ")");
201
- });
202
- while (xtxasyn.wsObject.wsCacheMessage.length > 0) {
203
- var tb_send = xtxasyn.wsObject.wsCacheMessage.shift();
204
- //alert(tb_send);
205
- xtxasyn.wsObject.socket.send(tb_send);
206
- }
207
- }
208
- // eslint-disable-next-line no-unused-vars
209
- wsObject.socket.onclose = function(evt) {
210
- util.consolelog("websocket[" + url + "] closed, reopen it...");
211
- xtxasyn.wsObject = undefined;
212
- xtxasyn.XTXAppWebSocket = xtxasyn.util.loadWebSocketCtl(wsUrl, wssUrl);
213
- };
214
- wsObject.socket.onmessage = function(evt) {
215
- // eslint-disable-next-line no-unused-vars
216
- var eventCmd = false;
217
- if (xtxasyn.util.isEmpty(evt.data)) {
218
- util.consolelog("onmessage evt.data is NULL or empty!!!");
219
- return;
220
- }
221
- try {
222
- var res = JSON.parse(evt.data);
223
- var cmdId = undefined;
224
- // eslint-disable-next-line no-prototype-builtins
225
- if (res.hasOwnProperty('call_cmd_id')) {
226
- cmdId = res['call_cmd_id'];
227
- } else {
228
- util.consolelog("return JSON not include call_cmd_id!!!");
229
- return;
230
- }
231
-
232
- var retVal = undefined;
233
- // eslint-disable-next-line no-prototype-builtins
234
- if (res.hasOwnProperty('retValue')) {
235
- retVal = res['retValue'];
236
- // eslint-disable-next-line no-prototype-builtins
237
- } else if (res.hasOwnProperty('retVal')) {
238
- retVal = res['retVal'];
239
- }
240
-
241
- var methodName = undefined;
242
- var eventName = cmdId.toLowerCase();
243
- var execFunc = xtxasyn.wsObject.wsEventQueue.get(eventName);
244
- if (execFunc && typeof execFunc == 'function') { // event
245
- execFunc(retVal);
246
- } else { // function
247
- var messageQueue = xtxasyn.wsObject.wsMessageQueue.get(cmdId);
248
- if (!messageQueue || !messageQueue.method) {
249
- util.consolelog("can't find call_cmd_id[" + res['call_cmd_id'] + "]'s method name!!!");
250
- return;
251
- }
252
- methodName = messageQueue.method;
253
- execFunc = messageQueue.cb;
254
- if (!execFunc || typeof execFunc != 'function') {
255
- util.consolelog("can't find call_cmd_id[" + res['call_cmd_id'] + "]'s call back function!!!");
256
- return;
257
- }
258
- var ctx = messageQueue.ctx;
259
- ctx = ctx || {returnType:"string"};
260
- var ret;
261
- if (ctx.returnType == "bool"){
262
- if (typeof(retVal) == 'string') {
263
- ret = retVal == "true" ? true : false;
264
- } else {
265
- ret = retVal;
266
- }
267
- if (ret == undefined) {
268
- ret = false;
269
- }
270
- } else if (ctx.returnType == "number"){
271
- if (typeof(retVal) == 'string') {
272
- ret = Number(retVal);
273
- } else {
274
- ret = retVal;
275
- }
276
- if (ret == undefined) {
277
- ret = -1;
278
- }
279
- } else{
280
- ret = retVal;
281
- if (ret == undefined) {
282
- ret = "";
283
- }
284
- }
285
- if (res.token) {
286
- //alert(res.token);
287
- xtxasyn.custom.setToken(res.token);
288
- }
289
- if (((methodName == 'SOF_Login' || methodName == 'SOF_LoginEx') && !ret) || (methodName == 'SOF_Logout' && ret)) {
290
- xtxasyn.custom.setToken("");
291
- }
292
- var retObj = {retVal:ret, ctx:ctx};
293
- execFunc(retObj);
294
- xtxasyn.wsObject.wsMessageQueue.remove(cmdId);
295
- }
296
- } catch (e) {
297
- return;
298
- }
299
- };
300
- wsObject.socket.onerror = function(evt) {
301
- xtxasyn.util.consolelog(evt.data);
302
- };
303
-
304
- return wsObject;
305
- }
306
-
307
- util.attachWebSocketEvent = function(wsObject, eventName, eventFunc) {
308
- if (wsObject == null) {
309
- return;
310
- }
311
- wsObject.wsEventQueue.put(eventName.toLowerCase(), util.evalFunction(eventFunc));
312
- }
313
-
314
- util.callWebSocketMethod = function (wsObject, clsid, method, cb, ctx, returnType, argsArray) {
315
- if (wsObject == null) {
316
- return;
317
- }
318
- wsObject.wsMessageQueueId++;
319
- if (typeof(cb) == 'function'){
320
- ctx = ctx || {};
321
- ctx.returnType = returnType;
322
- var messageQueue = {cb:cb, ctx:ctx, method:method};
323
- wsObject.wsMessageQueue.put('i_' + wsObject.wsMessageQueueId, messageQueue);
324
- }
325
-
326
- var sendArray = {
327
- 'call_cmd_id' : 'i_' + wsObject.wsMessageQueueId,
328
- 'CLSID' : clsid,
329
- 'xtx_func_name' : method,
330
- 'func' : method,
331
- 'URL' : window.location.href
332
- };
333
- if (arguments.length > 6) {
334
- for (var i = 1; i <= argsArray.length; i++) {
335
- var strParam = "param_" + i;
336
- sendArray[strParam] = argsArray[i - 1];
337
- }
338
- sendArray["param"] = argsArray;
339
- }
340
- var token = xtxasyn.custom.getToken();
341
- if (token && token != "") {
342
- sendArray.token = token;
343
- }
344
- if (wsObject.socket.readyState == WebSocket.OPEN) {
345
- wsObject.socket.send(JSON.stringify(sendArray));
346
- } else if (wsObject.socket.readyState == WebSocket.CONNECTING) {
347
- // The websocket connection has not been successfully created.
348
- // If the html page already has requested data, we will put it in the cache(wsObject.wsCacheMessage),
349
- // and then send the data one by one after the connection is successfully created.
350
- wsObject.wsCacheMessage.push(JSON.stringify(sendArray));
351
- } else {
352
- xtxasyn.util.consolelog("Can't connect to WebSocket server[" + wsObject.wsURL + "]!!!");
353
- }
354
- }
355
-
356
- util.SynToAsyn = function(retVal, cb, ctx)
357
- {
358
- if (typeof cb == 'function') {
359
- var retObj = {retVal:retVal, ctx:ctx};
360
- cb(retObj);
361
- }
362
- }
363
- }
364
-
365
- // eslint-disable-next-line no-undef
366
- return initUtilObject(xtxasyn);
367
- })();
368
-
369
- // initialize index page and other custom action
370
- (function() {
371
-
372
- function initCustomActions(xtxasyn) {
373
- var custom = xtxasyn.custom = xtxasyn.custom || {};
374
-
375
- custom.softCertListID = "";
376
- custom.hardCertListID = "";
377
- custom.allCertListID = "";
378
- custom.loginCertID = "";
379
- custom.logoutFunc = null;
380
- custom.UsbkeyChangeFunc = null;
381
- custom.loginToken = "";
382
-
383
- custom.errorReportFunc = function(msg) {
384
- alert(msg);
385
- }
386
-
387
- custom.setAutoLogoutParameter = function(strCertID, logoutFunc) {
388
- var custom = xtxasyn.custom;
389
- custom.loginCertID = strCertID;
390
- custom.logoutFunc = logoutFunc;
391
- }
392
-
393
- custom.clearDropList = function(dropListId) {
394
- if (dropListId == "") {
395
- return;
396
- }
397
-
398
- var obj = document.getElementById(dropListId);
399
- if (obj == undefined) {
400
- obj = eval(dropListId);
401
- }
402
- if (obj == undefined) {
403
- return;
404
- }
405
-
406
- var i, n = obj.length;
407
- for (i = 0; i < n; i++) {
408
- obj.remove(0);
409
- }
410
- }
411
-
412
- custom.pushOneDropListBox = function(userListArray, strListID)
413
- {
414
- var obj = document.getElementById(strListID);
415
- if (obj == undefined) {
416
- obj = eval(strListID);
417
- }
418
- if (obj == undefined) {
419
- return;
420
- }
421
-
422
- for (var i = 0; i < userListArray.length; i++) {
423
- var certObj = userListArray[i];
424
- var objItem = new Option(certObj.certName, certObj.certID);
425
- obj.options.add(objItem);
426
- }
427
- return;
428
- }
429
-
430
- custom.pushUserListToAllDroplist = function(retObj) {
431
- var custom = xtxasyn.custom;
432
-
433
- custom.clearDropList(custom.softCertListID);
434
- custom.clearDropList(custom.hardCertListID);
435
- custom.clearDropList(custom.allCertListID);
436
-
437
- var strUserList = retObj.retVal;
438
- var allListArray = [];
439
- // eslint-disable-next-line no-constant-condition
440
- while (true) {
441
- var i = strUserList.indexOf("&&&");
442
- if (i <= 0 ) {
443
- break;
444
- }
445
- var strOneUser = strUserList.substring(0, i);
446
- var strName = strOneUser.substring(0, strOneUser.indexOf("||"));
447
- var strCertID = strOneUser.substring(strOneUser.indexOf("||") + 2, strOneUser.length);
448
- allListArray.push({certName:strName, certID:strCertID});
449
-
450
- if (custom.hardCertListID != "") {
451
- xtxasyn.GetDeviceInfo(strCertID, 7, function(retObj) {
452
- if (retObj.retVal == "HARD") {
453
- custom.pushOneDropListBox([retObj.ctx], custom.hardCertListID);
454
- }
455
- }, {certName:strName, certID:strCertID});
456
- }
457
-
458
- if (custom.softCertListID != "") {
459
- xtxasyn.GetDeviceInfo(strCertID, 7, function(retObj) {
460
- if (retObj.retVal == "SOFT") {
461
- custom.pushOneDropListBox([retObj.ctx], custom.softCertListID);
462
- }
463
- }, {certName:strName, certID:strCertID});
464
- }
465
- var len = strUserList.length;
466
- strUserList = strUserList.substring(i + 3, len);
467
- }
468
-
469
- if (custom.allCertListID != "") {
470
- custom.pushOneDropListBox(allListArray, custom.allCertListID);
471
- }
472
- }
473
-
474
- custom.setUserCertList = function(certListId, certType) {
475
- var custom = xtxasyn.custom;
476
-
477
- if (certType == CERT_TYPE_ALL || certType == undefined) {
478
- custom.allCertListID = certListId;
479
- }
480
-
481
- if (certType == CERT_TYPE_HARD) {
482
- custom.hardCertListID = certListId;
483
- }
484
-
485
- if (certType == CERT_TYPE_SOFT) {
486
- custom.softCertListID = certListId;
487
- }
488
- xtxasyn.SOF_GetUserList(custom.pushUserListToAllDroplist);
489
- }
490
-
491
- custom.setOnUsbKeyChangeCallBack = function(callback) {
492
- var custom = xtxasyn.custom;
493
- custom.UsbkeyChangeFunc = callback;
494
- }
495
-
496
- custom.setErrorReportFunc = function(errFunc) {
497
- var custom = xtxasyn.custom;
498
- custom.errorReportFunc = errFunc;
499
- }
500
-
501
- custom.autoLogoutCallBack = function(retObj) {
502
- var custom = xtxasyn.custom;
503
- if (retObj.retVal.indexOf(custom.loginCertID) <= 0) {
504
- custom.logoutFunc();
505
- }
506
- }
507
-
508
- custom.defaultUsbkeyChange = function() {
509
- var custom = xtxasyn.custom;
510
- xtxasyn.SOF_GetUserList(custom.pushUserListToAllDroplist);
511
-
512
- if (typeof custom.UsbkeyChangeFunc == 'function') {
513
- custom.UsbkeyChangeFunc();
514
- }
515
-
516
- if (custom.loginCertID != "" && typeof custom.logoutFunc == 'function') {
517
- xtxasyn.SOF_GetUserList(custom.autoLogoutCallBack);
518
- }
519
- }
520
-
521
- custom.getToken = function() {
522
- return custom.loginToken;
523
- }
524
-
525
- custom.setToken = function(token) {
526
- custom.loginToken = token;
527
- }
528
- }
529
-
530
- // eslint-disable-next-line no-undef
531
- return initCustomActions(xtxasyn);
532
- })();
533
-
534
- // initialize xtxappcom object
535
- (function() {
536
-
537
- function initXTXAppCOM(xtxasyn) {
538
- var util = xtxasyn.util;
539
- var custom = xtxasyn.custom;
540
-
541
- xtxasyn.XTXAppCOM = util.loadIECtl(xtxasyn.xtx_clsid, "XTXAppObj", "SOF_GetVersion()");
542
- if (xtxasyn.XTXAppCOM == null) {
543
- custom.errorReportFunc("加载XTXAppCOM控件失败,请确认已正确安装BJCA证书应用环境!");
544
- return false;
545
- }
546
- var XTXAppCOM = xtxasyn.XTXAppCOM;
547
-
548
- util.attachIEEvent("XTXAppObj", "onUsbkeyChange", xtxasyn.custom.defaultUsbkeyChange);
549
-
550
- // get key pic interface
551
- var GetPicObj = util.loadIECtl(xtxasyn.getpic_clsid, "GetPicObj", "Hash('0')");
552
- if (GetPicObj == null) {
553
- //custom.errorReportFunc("加载GetKeyPic控件失败,请确认已正确安装GetKeyPic控件!");
554
- } else {
555
- XTXAppCOM.GetPic = function(strCertID) {
556
- return GetPicObj.GetPic(strCertID);
557
- }
558
- XTXAppCOM.Hash = function(inData) {
559
- return GetPicObj.Hash(inData);
560
- }
561
- XTXAppCOM.ConvertPicFormat = function(inData, type) {
562
- return GetPicObj.ConvertPicFormat(inData, type);
563
- }
564
- XTXAppCOM.ConvertGif2Jpg = function(inData) {
565
- return GetPicObj.ConvertGif2Jpg(inData);
566
- }
567
- XTXAppCOM.GetPic1 = function(strCertID) {
568
- return GetPicObj.GetPic1(strCertID);
569
- }
570
- XTXAppCOM.ConvertPicSize = function(strPicture, w, h) {
571
- return GetPicObj.ConvertPicSize(strPicture, w, h);
572
- }
573
- }
574
-
575
- // xtxversion interface
576
- var XTXVersionOBJ = util.loadIECtl(xtxasyn.xtx_version_clsid, "XTXVersionOBJ", "GetEnvVersion()");
577
- if (XTXVersionOBJ == null) {
578
- //custom.errorReportFunc("加载XTXVersion控件失败,请确认已正确安装证书应用环境!");
579
- } else {
580
- XTXAppCOM.GetEnvVersion = function() {
581
- return XTXVersionOBJ.GetEnvVersion();
582
- }
583
- }
584
-
585
- return true;
586
- }
587
-
588
- function initXTXAppWebSocket(xtxasyn) {
589
- xtxasyn.XTXAppWebSocket = xtxasyn.util.loadWebSocketCtl("127.0.0.1:21051/xtxapp/", "127.0.0.1:21061/xtxapp/");
590
- if (xtxasyn.XTXAppWebSocket == null) {
591
- // eslint-disable-next-line no-undef
592
- custom.errorReportFunc("连接XTXAppCOM服务失败,请确认已正确安装BJCA证书应用环境!");
593
- return false;
594
- }
595
-
596
- return true;
597
- }
598
-
599
- function initXTXAppObject(xtxasyn) {
600
- var util = xtxasyn.util;
601
- xtxasyn.xtx_clsid = "3F367B74-92D9-4C5E-AB93-234F8A91D5E6";
602
- xtxasyn.getpic_clsid = "3BC3C868-95B5-47ED-8686-E0E3E94EF366";
603
- xtxasyn.xtx_version_clsid = "574887FB-22A5-488B-A49C-2CF25F56BE68";
604
- var getImplmentFunction;
605
-
606
- if (util.checkBrowserISIE()) { // IE
607
- if (!initXTXAppCOM(xtxasyn)) {
608
- return false;
609
- }
610
- getImplmentFunction = function(methodInfo) {
611
- if (methodInfo.inParams == '') { // 0 input param
612
- window[methodInfo.funcName] = new Function('cb', 'ctx',
613
- 'xtxasyn.util.SynToAsyn(xtxasyn.XTXAppCOM.' + methodInfo.funcName + '(), cb, ctx);');
614
- } else {
615
- window[methodInfo.funcName] = new Function(methodInfo.inParams, 'cb', 'ctx',
616
- 'xtxasyn.util.SynToAsyn(xtxasyn.XTXAppCOM.' + methodInfo.funcName + '(' + methodInfo.inParams + '), cb, ctx);');
617
- }
618
- }
619
- } else { // other brower
620
- if (!initXTXAppWebSocket(xtxasyn)) {
621
- return false;
622
- }
623
- getImplmentFunction = function(methodInfo) {
624
- if (methodInfo.inParams == '') { // 0 input param
625
- window[methodInfo.funcName] = new Function('cb, ctx',
626
- "xtxasyn.util.callWebSocketMethod(xtxasyn.XTXAppWebSocket, '" + methodInfo.clsid + "', '" +
627
- methodInfo.funcName + "', cb, ctx, '" + methodInfo.outParamType + "', []);");
628
- } else {
629
- window[methodInfo.funcName] = new Function(methodInfo.inParams + ', cb, ctx',
630
- "xtxasyn.util.callWebSocketMethod(xtxasyn.XTXAppWebSocket, '" + methodInfo.clsid + "', '" +
631
- methodInfo.funcName + "', cb, ctx, '" + methodInfo.outParamType + "', [" + methodInfo.inParams + "]);");
632
- }
633
- }
634
- }
635
-
636
- var export_functions = [
637
- {funcName:'SOF_SetSignMethod', inParams:'SignMethod', outParamType:'number', clsid:xtxasyn.xtx_clsid, aliasName:'SetSignMethod'},
638
- {funcName:'SOF_GetSignMethod', inParams:'', outParamType:'number', clsid:xtxasyn.xtx_clsid},
639
- {funcName:'SOF_SetEncryptMethod', inParams:'EncryptMethod', outParamType:'number', clsid:xtxasyn.xtx_clsid},
640
- {funcName:'SOF_GetEncryptMethod', inParams:'', outParamType:'number', clsid:xtxasyn.xtx_clsid},
641
- {funcName:'SOF_GetUserList', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'GetUserList'},
642
- {funcName:'SOF_ExportUserCert', inParams:'CertID', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'GetSignCert'},
643
- {funcName:'SOF_Login', inParams:'CertID, PassWd', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'VerifyUserPIN'},
644
- {funcName:'SOF_GetPinRetryCount', inParams:'CertID', outParamType:'number', clsid:xtxasyn.xtx_clsid, aliasName:'GetUserPINRetryCount'},
645
- {funcName:'SOF_ChangePassWd', inParams:'CertID, oldPass, newPass', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'ChangeUserPassword'},
646
- {funcName:'SOF_GetCertInfo', inParams:'Cert, type', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'GetCertBasicinfo'},
647
- {funcName:'SOF_GetCertInfoByOid', inParams:'Cert, Oid', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'GetExtCertInfoByOID'},
648
- {funcName:'SOF_SignData', inParams:'CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'SignedData'},
649
- {funcName:'SOF_VerifySignedData', inParams:'Cert, InData, SignValue', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'VerifySignedData'},
650
- {funcName:'SOF_SignFile', inParams:'CertID, InFile', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'SOF_SignFile'},
651
- {funcName:'SOF_VerifySignedFile', inParams:'Cert, InFile, SignValue', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'VerifySignFile'},
652
- {funcName:'SOF_EncryptData', inParams:'Cert, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'EncodeP7Enveloped'},
653
- {funcName:'SOF_DecryptData', inParams:'CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'DecodeP7Enveloped'},
654
- {funcName:'SOF_EncryptFile', inParams:'Cert, InFile, OutFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
655
- {funcName:'SOF_DecryptFile', inParams:'CertID, InFile, OutFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
656
- {funcName:'SOF_SignMessage', inParams:'dwFlag, CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
657
- {funcName:'SOF_VerifySignedMessage', inParams:'MessageData, InData', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'VerifyDatabyP7'},
658
- {funcName:'SOF_GetInfoFromSignedMessage', inParams:'SignedMessage, type', outParamType:'string', clsid:xtxasyn.xtx_clsid},
659
- {funcName:'SOF_SignDataXML', inParams:'CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
660
- {funcName:'SOF_VerifySignedDataXML', inParams:'InData', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
661
- {funcName:'SOF_GetXMLSignatureInfo', inParams:'XMLSignedData, type', outParamType:'string', clsid:xtxasyn.xtx_clsid},
662
- {funcName:'SOF_GenRandom', inParams:'RandomLen', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'GenerateRandom'},
663
- {funcName:'SOF_PubKeyEncrypt', inParams:'Cert, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'PubKeyEncrypt'},
664
- {funcName:'SOF_PriKeyDecrypt', inParams:'CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'PriKeyDecrypt'},
665
- {funcName:'SOF_SecertSegment', inParams:'Secert, m, n, k', outParamType:'string', clsid:xtxasyn.xtx_clsid},
666
- {funcName:'SOF_SecertRecovery', inParams:'Seg', outParamType:'string', clsid:xtxasyn.xtx_clsid},
667
- {funcName:'SOF_GetLastError', inParams:'', outParamType:'number', clsid:xtxasyn.xtx_clsid},
668
- {funcName:'GetDeviceCount', inParams:'', outParamType:'number', clsid:xtxasyn.xtx_clsid},
669
- {funcName:'GetAllDeviceSN', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid},
670
- {funcName:'GetDeviceSNByIndex', inParams:'iIndex', outParamType:'string', clsid:xtxasyn.xtx_clsid},
671
- {funcName:'GetDeviceInfo', inParams:'sDeviceSN, iType', outParamType:'string', clsid:xtxasyn.xtx_clsid},
672
- {funcName:'ChangeAdminPass', inParams:'sDeviceSN, sOldPass, sNewPass', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
673
- {funcName:'UnlockUserPass', inParams:'sDeviceSN, sAdminPass, sNewUserPass', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
674
- {funcName:'GenerateKeyPair', inParams:'sDeviceSN, sContainerName, iKeyType, bSign', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
675
- {funcName:'ExportPubKey', inParams:'sDeviceSN, sContainerName, bSign', outParamType:'string', clsid:xtxasyn.xtx_clsid},
676
- {funcName:'ImportSignCert', inParams:'sDeviceSN, sContainerName, sCert', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
677
- {funcName:'ImportEncCert', inParams:'sDeviceSN, sContainerName, sCert, sPriKeyCipher', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
678
- {funcName:'ReadFile', inParams:'sDeviceSN, sFileName', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'readFile'},
679
- {funcName:'WriteFile', inParams:'sDeviceSN, sFileName, sContent, bPrivate', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'writeFile'},
680
- {funcName:'IsContainerExist', inParams:'sDeviceSN, sContainerName', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
681
- {funcName:'DeleteContainer', inParams:'sDeviceSN, sContainerName', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
682
- {funcName:'ExportPKCS10', inParams:'sDeviceSN, sContainerName, sDN, bSign', outParamType:'string', clsid:xtxasyn.xtx_clsid},
683
- {funcName:'InitDevice', inParams:'sDeviceSN, sAdminPass', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
684
- {funcName:'AddSignInfo', inParams:'sUserPass', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
685
- {funcName:'SOF_GetVersion', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid},
686
- {funcName:'SOF_ExportExChangeUserCert', inParams:'CertID', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'GetExchCert'},
687
- {funcName:'SOF_ValidateCert', inParams:'Cert', outParamType:'number', clsid:xtxasyn.xtx_clsid, aliasName:'ValidateCert'},
688
- {funcName:'GetENVSN', inParams:'sDeviceSN', outParamType:'string', clsid:xtxasyn.xtx_clsid},
689
- {funcName:'SetENVSN', inParams:'sDeviceSN, sEnvsn', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
690
- {funcName:'IsDeviceExist', inParams:'sDeviceSN', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
691
- {funcName:'GetContainerCount', inParams:'sDeviceSN', outParamType:'number', clsid:xtxasyn.xtx_clsid},
692
- {funcName:'SOF_SymEncryptData', inParams:'sKey, indata', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'EncryptData'},
693
- {funcName:'SOF_SymDecryptData', inParams:'sKey, indata', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'DecryptData'},
694
- {funcName:'SOF_SymEncryptFile', inParams:'sKey, inFile, outFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'EncryptFile'},
695
- {funcName:'SOF_SymDecryptFile', inParams:'sKey, inFile, outFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'DecryptFile'},
696
- {funcName:'SOF_GetLastErrMsg', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid},
697
- {funcName:'SOF_Base64Encode', inParams:'sIndata', outParamType:'string', clsid:xtxasyn.xtx_clsid},
698
- {funcName:'SOF_Base64Decode', inParams:'sIndata', outParamType:'string', clsid:xtxasyn.xtx_clsid},
699
- {funcName:'SOF_HashData', inParams:'hashAlg, sInData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
700
- {funcName:'SOF_HashFile', inParams:'hashAlg, inFile', outParamType:'string', clsid:xtxasyn.xtx_clsid},
701
- {funcName:'UnlockUserPassEx', inParams:'sDeviceSN, sAdminPin, sNewUserPass', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
702
- {funcName:'DeleteOldContainer', inParams:'sDeviceSN', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
703
- {funcName:'WriteFileEx', inParams:'sDeviceSN, sFileName, sContent', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
704
- {funcName:'ReadFileEx', inParams:'sDeviceSN, sFileName', outParamType:'string', clsid:xtxasyn.xtx_clsid},
705
- {funcName:'WriteFileBase64', inParams:'sDeviceSN, sFileName, sContent', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
706
- {funcName:'DeleteFile', inParams:'sDeviceSN, sFileName', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
707
- {funcName:'SOF_EncryptDataEx', inParams:'Cert, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
708
- {funcName:'Base64EncodeFile', inParams:'sInFile', outParamType:'string', clsid:xtxasyn.xtx_clsid},
709
- {funcName:'SOF_GetRetryCount', inParams:'CertID', outParamType:'number', clsid:xtxasyn.xtx_clsid},
710
- {funcName:'SOF_GetAllContainerName', inParams:'sDeviceSN', outParamType:'string', clsid:xtxasyn.xtx_clsid},
711
- {funcName:'CreateSoftDevice', inParams:'sDeviceSN, sLabel', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
712
- {funcName:'DeleteSoftDevice', inParams:'sDeviceSN, sPasswd', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
713
- {funcName:'EnableSoftDevice', inParams:'enable, sDeviceSN', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
714
- {funcName:'SoftDeviceBackup', inParams:'sDeviceSN, sPasswd', outParamType:'string', clsid:xtxasyn.xtx_clsid},
715
- {funcName:'SoftDeviceRestore', inParams:'sDeviceSN, sPasswd, sInFilePath', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
716
- {funcName:'SOF_Logout', inParams:'CertID', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'Logout'},
717
- {funcName:'SetUserConfig', inParams:'type, strConfig', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
718
- {funcName:'SOF_SignByteData', inParams:'CertID, byteLen', outParamType:'string', clsid:xtxasyn.xtx_clsid},
719
- {funcName:'SOF_VerifySignedByteData', inParams:'Cert, byteLen, SignValue', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
720
- {funcName:'OTP_GetChallengeCode', inParams:'sCertID', outParamType:'string', clsid:xtxasyn.xtx_clsid},
721
- {funcName:'ImportEncCertEx', inParams:'sDeviceSN, sContainerName, sCert, sPriKeyCipher, ulSymAlg', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
722
- {funcName:'SOF_GetCertEntity', inParams:'sCert', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'GetCertEntity'},
723
- {funcName:'SOF_HMAC', inParams:'hashid, key, indata', outParamType:'string', clsid:xtxasyn.xtx_clsid},
724
- {funcName:'SOF_SignDataByPriKey', inParams:'sPriKey, sCert, sInData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
725
- {funcName:'ImportKeyCertToSoftDevice', inParams:'sDeviceSN, sContainerName, sPriKey, sCert, bSign', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
726
- {funcName:'InitDeviceEx', inParams:'sDeviceSN, sAdminPass, sUserPin, sKeyLabel, adminPinMaxRetry, userPinMaxRetry', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
727
- {funcName:'SelectFile', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid},
728
- {funcName:'SOF_SignHashData', inParams:'CertID, b64ashData, hashAlg', outParamType:'string', clsid:xtxasyn.xtx_clsid, aliasName:'SignHashData'},
729
- {funcName:'SOF_VerifySignedHashData', inParams:'Cert, b64ashData, SignValue, hashAlg', outParamType:'bool', clsid:xtxasyn.xtx_clsid, aliasName:'VerifySignedHashData'},
730
- {funcName:'CheckSoftDeviceEnv', inParams:'', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
731
- {funcName:'ImportPfxToDevice', inParams:'sDeviceSN, sContainerName, bSign, strPfx, strPfxPass', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
732
- {funcName:'SOF_HashDataEx', inParams:'hashAlg, sInData, sCert, sID', outParamType:'string', clsid:xtxasyn.xtx_clsid},
733
- {funcName:'SOF_HashFileEx', inParams:'hashAlg, inFile, sCert, sID', outParamType:'string', clsid:xtxasyn.xtx_clsid},
734
- {funcName:'GetDeviceCountEx', inParams:'type', outParamType:'number', clsid:xtxasyn.xtx_clsid},
735
- {funcName:'GetAllDeviceSNEx', inParams:'type', outParamType:'string', clsid:xtxasyn.xtx_clsid},
736
- {funcName:'SOF_UpdateCert', inParams:'CertID, type', outParamType:'number', clsid:xtxasyn.xtx_clsid},
737
- {funcName:'OpenSpecifiedFolder', inParams:'backupFilePath', outParamType:'', clsid:xtxasyn.xtx_clsid},
738
- {funcName:'OTP_GetChallengeCodeEx', inParams:'sCertID, szAccount, money', outParamType:'string', clsid:xtxasyn.xtx_clsid},
739
- {funcName:'Base64DecodeFile', inParams:'sInData, sFilePath', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
740
- {funcName:'EnumFilesInDevice', inParams:'sDeviceSN', outParamType:'string', clsid:xtxasyn.xtx_clsid},
741
- {funcName:'OTP_Halt', inParams:'sCertID', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
742
- {funcName:'SOF_TSGenREQ', inParams:'b64Hash, hashAlg, bReqCert, policyID, b64Nonce, b64Extension', outParamType:'string', clsid:xtxasyn.xtx_clsid},
743
- {funcName:'SOF_TSCompareNonce', inParams:'b64TSReq, b64TSAResp', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
744
- {funcName:'SOF_TSGenPDFSignature', inParams:'b64TSAResp, b64OriPDFSignature', outParamType:'string', clsid:xtxasyn.xtx_clsid},
745
- {funcName:'SOF_TSVerifyPDFSignature', inParams:'b64TSPDFSignature', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
746
- {funcName:'SOF_TSGetPDFSignatureInfo', inParams:'b64TSPDFSignature, iType', outParamType:'string', clsid:xtxasyn.xtx_clsid},
747
- {funcName:'OTP_GetState', inParams:'sCertID, bCert', outParamType:'string', clsid:xtxasyn.xtx_clsid},
748
- {funcName:'OTP_GetSyncCode', inParams:'sCertID, ChallengeCode', outParamType:'string', clsid:xtxasyn.xtx_clsid},
749
- {funcName:'SOF_IsLogin', inParams:'CertID', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
750
- {funcName:'SOF_LoginEx', inParams:'CertID, PassWd, updateFlag', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
751
- {funcName:'EnumSupportDeviceList', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid},
752
- {funcName:'ExportPfxFromDevice', inParams:'sDeviceSN, sContainerName, bSign, strPfxPass', outParamType:'string', clsid:xtxasyn.xtx_clsid},
753
- {funcName:'SOF_SignHashMessage', inParams:'CertID, InHashData, hashAlg', outParamType:'string', clsid:xtxasyn.xtx_clsid},
754
- {funcName:'ExportPfxToFile', inParams:'sDeviceSN, sContainerName, bSign, strPfxPass', outParamType:'string', clsid:xtxasyn.xtx_clsid},
755
- {funcName:'SOF_SignAPK', inParams:'CertID, strOriSignature', outParamType:'string', clsid:xtxasyn.xtx_clsid},
756
- {funcName:'YZT_GenerateKeyPair', inParams:'sDeviceSN, sContainerName, iKeyTypeRSA, iKeyTypeSM2', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
757
- {funcName:'YZT_ExportPubKey', inParams:'sDeviceSN, sContainerName, bSign', outParamType:'string', clsid:xtxasyn.xtx_clsid},
758
- {funcName:'YZT_ImportSignCert', inParams:'sDeviceSN, sContainerName, sRSACert, sSM2Cert', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
759
- {funcName:'YZT_ImportEncCert', inParams:'sDeviceSN, sContainerName, sRSACert, sRSAPriKeyCipher, ulRSASymAlg, sSM2Cert, sSM2PriKeyCipher, ulSM2SymAlg', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
760
- {funcName:'SOF_ListenUKey', inParams:'Parm', outParamType:'string', clsid:xtxasyn.xtx_clsid},
761
- {funcName:'SOF_EnableLoginWindow', inParams:'Parm', outParamType:'string', clsid:xtxasyn.xtx_clsid},
762
- {funcName:'SOF_SignEnvelope', inParams:'CertID, Cert, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
763
- {funcName:'SOF_UnSignEnvelope', inParams:'CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
764
- {funcName:'BIO_MAKExportPKCS10', inParams:'sDeviceSN, iKeyType, sDN', outParamType:'string', clsid:xtxasyn.xtx_clsid},
765
- {funcName:'BIO_MAKImportSignEncCert', inParams:'sDeviceSN, sSignCert, sEncCert, sPriKeyCipher', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
766
- {funcName:'BIO_IssueDAKCert', inParams:'sDeviceSN, iKeyType, sDN', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
767
- {funcName:'BIO_InfoCollect', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid},
768
- {funcName:'BIO_GetBioInfo', inParams:'sDeviceSN', outParamType:'string', clsid:xtxasyn.xtx_clsid},
769
- {funcName:'SOF_GetLastLoginCertID', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid},
770
- {funcName:'SOF_ReadESealData', inParams:'CertID, ulKeyIndex, ulKeyAlgId, ulFlags', outParamType:'string', clsid:xtxasyn.xtx_clsid},
771
- {funcName:'SOF_ReadKFXESealData', inParams:'CertID, ulKeyIndex, ulKeyAlgId, ulFlags', outParamType:'string', clsid:xtxasyn.xtx_clsid},
772
- {funcName:'SOF_SymDecryptFileToData', inParams:'sKey, inFile', outParamType:'string', clsid:xtxasyn.xtx_clsid},
773
- {funcName:'SOF_SignMessageBase64', inParams:'dwFlag, CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
774
- {funcName:'SOF_VerifySignedMessageBase64', inParams:'MessageData, InData', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
775
- {funcName:'SOF_VerifySignedHashMessage', inParams:'MessageData, InHashData', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
776
- {funcName:'SOF_SignDataBase64', inParams:'CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
777
- {funcName:'SOF_VerifySignedDataBase64', inParams:'Cert, InData, SignValue', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
778
- {funcName:'SOF_HashDataExBase64', inParams:'hashAlg, sInData, sCert, sID', outParamType:'string', clsid:xtxasyn.xtx_clsid},
779
- {funcName:'SOF_GetProductVersion', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_clsid},
780
- {funcName:'SOF_UpdateCertEx', inParams:'CertID, PassWd', outParamType:'number', clsid:xtxasyn.xtx_clsid},
781
- {funcName:'SOF_GetLastSignDataCertID', inParams:'CertID', outParamType:'string', clsid:xtxasyn.xtx_clsid},
782
- {funcName:'BIO_SetUserConfig', inParams:'CertID, type, strConfig', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
783
- {funcName:'BIO_InvokeCommand', inParams:'CertID, bstrCommand', outParamType:'string', clsid:xtxasyn.xtx_clsid},
784
- {funcName:'SOF_ImportSymmKey', inParams:'CertID, ulKeyIndex, InData, ulFlags', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
785
- {funcName:'SOF_WriteESealData', inParams:'CertID, InData, ulFlags', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
786
- {funcName:'SOF_EPS_Encrypt', inParams:'CertID, ulKeyIndex, ulKeyAlgId, IVData, DivCount, DivComponent, InData, ulFlags', outParamType:'string', clsid:xtxasyn.xtx_clsid},
787
- {funcName:'SOF_EPS_Decrypt', inParams:'CertID, ulKeyIndex, ulKeyAlgId, IVData, DivCount, DivComponent, InData, ulFlags', outParamType:'string', clsid:xtxasyn.xtx_clsid},
788
- {funcName:'SOF_EPS_Mac', inParams:'CertID, ulKeyIndex, ulKeyAlgId, IVData, DivCount, DivComponent, InData, ulFlags', outParamType:'string', clsid:xtxasyn.xtx_clsid},
789
- {funcName:'SOF_PriKeyDecryptEx', inParams:'CertID, InData', outParamType:'string', clsid:xtxasyn.xtx_clsid},
790
- {funcName:'SOF_EPS_ReadESealData', inParams:'CertID, ulKeyIndex, ulKeyAlgId, ulFlags', outParamType:'string', clsid:xtxasyn.xtx_clsid},
791
- {funcName:'SOF_EPS_WriteESealData', inParams:'CertID, InData, ulFlags', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
792
- {funcName:'EnumESeal', inParams:'sDeviceSN', outParamType:'string', clsid:xtxasyn.xtx_clsid},
793
- {funcName:'GetPicture', inParams:'bstrConName', outParamType:'string', clsid:xtxasyn.xtx_clsid},
794
- {funcName:'SOF_SignEnvelopeFile', inParams:'CertID, Cert, InFile, OutFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
795
- {funcName:'SOF_UnSignEnvelopeFile', inParams:'CertID, InFile, OutFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
796
- {funcName:'SOFX_EncryptFile', inParams:'CertID, Cert, InFile, OutFile, ulFlags', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
797
- {funcName:'SOFX_DecryptFile', inParams:'CertID, InFile, OutFile, ulFlags', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
798
- {funcName:'GetPic', inParams:'bstrConName', outParamType:'string', clsid:xtxasyn.getpic_clsid},
799
- {funcName:'Hash', inParams:'inData', outParamType:'string', clsid:xtxasyn.getpic_clsid},
800
- {funcName:'ConvertPicFormat', inParams:'inData, type', outParamType:'string', clsid:xtxasyn.getpic_clsid},
801
- {funcName:'ConvertGif2Jpg', inParams:'inData', outParamType:'string', clsid:xtxasyn.getpic_clsid},
802
- {funcName:'GetPic1', inParams:'bstrConName', outParamType:'string', clsid:xtxasyn.getpic_clsid},
803
- {funcName:'ConvertPicSize', inParams:'bstrPic, w, h', outParamType:'string', clsid:xtxasyn.getpic_clsid},
804
- {funcName:'GetEnvVersion', inParams:'', outParamType:'string', clsid:xtxasyn.xtx_version_clsid},
805
- {funcName:'InitDeviceWithParam', inParams:'sDeviceSN, sAppName, sAdminPass, sUserPin, sKeyLabel, adminPinMaxRetry, userPinMaxRetry, createFileRights', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
806
- {funcName:'SOF_SignDataEx', inParams:'CertID, InData,signFlag', outParamType:'string', clsid:xtxasyn.xtx_clsid},
807
- {funcName:'SOF_VerifySignedDataEx', inParams:'Cert, InData, SignValue,signFlag', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
808
- {funcName:'SOF_SymEncryptDataEx', inParams:'sKey,sIV,indata', outParamType:'string', clsid:xtxasyn.xtx_clsid},
809
- {funcName:'SOF_SymDecryptDataEx', inParams:'sKey,sIV,indata', outParamType:'string', clsid:xtxasyn.xtx_clsid},
810
-
811
- // 3.8 added
812
- {funcName:'SOFX_InvokeCommand', inParams:'pluginName,InParam', outParamType:'string', clsid:xtxasyn.xtx_clsid},
813
-
814
- {funcName:'SOF_SymEncryptFileEx', inParams:'sKey,sIV,inFile, outFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
815
- {funcName:'SOF_SymDecryptFileEx', inParams:'sKey,sIV,inFile, outFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
816
- {funcName:'SOF_SymDecryptFileToDataEx', inParams:'sKey,sIV,inFile', outParamType:'string', clsid:xtxasyn.xtx_clsid},
817
- {funcName:'SOFX_SymEncryptDataWithPadding', inParams:'sKey,sIV,padding,indata', outParamType:'string', clsid:xtxasyn.xtx_clsid},
818
- {funcName:'SOFX_SymDecryptDataWithPadding', inParams:'sKey,sIV,padding,indata', outParamType:'string', clsid:xtxasyn.xtx_clsid},
819
- {funcName:'SOFX_SymEncryptFileWithPadding', inParams:'sKey,sIV,padding,inFile, outFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
820
- {funcName:'SOFX_SymDecryptFileWithPadding', inParams:'sKey,sIV,padding,inFile, outFile', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
821
- {funcName:'SOFX_VerifySignedDataWithID', inParams:'Cert, InData, SignValue,userId', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
822
- {funcName:'SOFX_VerifySignedFileWithID', inParams:'Cert, InFile, SignValue,userId', outParamType:'bool', clsid:xtxasyn.xtx_clsid},
823
- ];
824
-
825
- for (var i = 0; i < export_functions.length; i++) {
826
- getImplmentFunction(export_functions[i]);
827
- xtxasyn[export_functions[i].funcName] = window[export_functions[i].funcName];
828
- if (export_functions[i].aliasName) {
829
- window[export_functions[i].aliasName] = window[export_functions[i].funcName];
830
- xtxasyn[export_functions[i].aliasName] = window[export_functions[i].funcName];
831
- }
832
-
833
- }
834
-
835
- return true;
836
- }
837
-
838
- // eslint-disable-next-line no-undef
839
- return initXTXAppObject(xtxasyn);
840
- })();
841
-
842
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
843
- ////////////////////////////////////// EXPORT VAR AND FUNCTIONS ///////////////////////////////////////////
844
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
845
- // const var
846
- var CERT_TYPE_HARD = 1;
847
- var CERT_TYPE_SOFT = 2;
848
- var CERT_TYPE_ALL = 3;
849
-
850
- // set auto logout parameters
851
- function SetAutoLogoutParameter(strCertID, logoutFunc) {
852
- // eslint-disable-next-line no-undef
853
- xtxasyn.custom.setAutoLogoutParameter(strCertID, logoutFunc);
854
- }
855
-
856
- // set user cert list id
857
- function SetUserCertList(strListID, certType) {
858
- // eslint-disable-next-line no-undef
859
- xtxasyn.custom.setUserCertList(strListID, certType);
860
- }
861
-
862
- // set custom usbkeychange callback
863
- function SetOnUsbKeyChangeCallBack(callback) {
864
- // eslint-disable-next-line no-undef
865
- xtxasyn.custom.setOnUsbKeyChangeCallBack(callback);
866
- }
867
-
868
- // set custom alert function
869
- function SetAlertFunction(custom_alert) {
870
- // eslint-disable-next-line no-undef
871
- xtxasyn.custom.setErrorReportFunc(custom_alert);
872
- }
873
-
874
- // get custom userlogin token
875
- function GetLoginToken() {
876
- // eslint-disable-next-line no-undef
877
- return xtxasyn.custom.getToken();
878
- }
879
-
880
- function SetLoginToken(tokenData) {
881
- // eslint-disable-next-line no-undef
882
- return xtxasyn.custom.setToken(tokenData);
883
- }
884
-
885
- function GetUserListByType(strType, cb, ctx) { // strType is 'HARD' or 'SOFT'
886
- // eslint-disable-next-line no-undef
887
- SOF_GetUserList(function(retObj) {
888
- var strUserList = retObj.retVal;
889
- // eslint-disable-next-line no-constant-condition
890
- while (true) {
891
- var i = strUserList.indexOf("&&&");
892
- if (i <= 0 ) {
893
- break;
894
- }
895
- var strOneUser = strUserList.substring(0, i);
896
- var strName = strOneUser.substring(0, strOneUser.indexOf("||"));
897
- var strCertID = strOneUser.substring(strOneUser.indexOf("||") + 2, strOneUser.length);
898
- GetDeviceType(strCertID, function(retObj) {
899
- if (retObj.retVal == retObj.ctx.ctx.type) {
900
- if (typeof retObj.ctx.ctx.cb == 'function') {
901
- retObj.ctx.ctx.cb({retVal:retObj.ctx.userList, ctx:retObj.ctx.ctx.ctx})
902
- }
903
- }
904
- }, {userList:strOneUser, ctx:retObj.ctx});
905
- var len = strUserList.length;
906
- strUserList = strUserList.substring(i + 3, len);
907
- }
908
- }, {type:strType, cb:cb, ctx:ctx});
909
- }
910
-
911
- //get usbKey user list
912
- function GetUserList_USBKey(cb, ctx) {
913
- return GetUserListByType("HARD", cb, ctx);
914
- }
915
-
916
- //get soft user list
917
- function GetUserList_Soft() {
918
- // eslint-disable-next-line no-undef
919
- return GetUserListByType("SOFT", cb, ctx);
920
- }
921
-
922
- //sign data with pkcs7 format
923
- function SignByP7(strCertID, strInData, bDetach) {
924
- // eslint-disable-next-line no-undef
925
- return xtxasyn.SOF_SignMessage(bDetach ? 1 : 0, strCertID, strInData);
926
- }
927
-
928
- //get symmitric key length
929
- //because xtx and secxv2 secx default symmitric alg is no equal
930
- function GetSymKeyLength() {
931
- return 24;
932
- }
933
-
934
- //get device type return SOFT or HARD
935
- function GetDeviceType(strCertID) {
936
- // eslint-disable-next-line no-undef
937
- return xtxasyn.GetDeviceInfo(strCertID, 7);
938
- }
939
-
940
- // calculate file's hash
941
- function HashFile(strFilePath) {
942
- // eslint-disable-next-line no-undef
943
- return xtxasyn.SOF_HashFile(2/*sha1*/, strFilePath);
944
- }
945
-
946
- function ParseDateString(strDate) {
947
- var strYear = strDate.substring(0, 4);
948
- var strMonth = strDate.substring(4, 6);
949
- var strDay = strDate.substring(6, 8);
950
- var strHour = strDate.substring(8, 10);
951
- var strMin = strDate.substring(10, 12);
952
- var strSecond = strDate.substring(12, 14);
953
- var RtnDate = new Date();
954
- RtnDate.setFullYear(Number(strYear), Number(strMonth) - 1, Number(strDay));
955
- RtnDate.setHours(Number(strHour));
956
- RtnDate.setMinutes(Number(strMin));
957
- RtnDate.setSeconds(Number(strSecond));
958
- return RtnDate;
959
- }
960
-
961
- function __loginSignRandomCallBack(retObj) {
962
- if (retObj.retVal == "") {
963
- // eslint-disable-next-line no-undef
964
- xtxasyn.custom.errorReportFunc("客户端签名失败!");
965
- if (typeof retObj.ctx.cb === 'function') {
966
- retObj.ctx.cb(false);
967
- }
968
- return;
969
- }
970
- var objForm = retObj.ctx.objForm;
971
- objForm.UserSignedData.value = retObj.retVal;
972
- // eslint-disable-next-line no-undef
973
- objForm.LoginToken.value = xtxasyn.custom.getToken();
974
- if (typeof retObj.ctx.cb === 'function') {
975
- retObj.ctx.cb(true);
976
- } else {
977
- objForm.action = retObj.ctx.action;
978
- objForm.submit();
979
- }
980
- }
981
-
982
- function __loginVerifyServerSignatureCallBack(retObj) {
983
- if (!retObj.retVal) {
984
- // eslint-disable-next-line no-undef
985
- xtxasyn.custom.errorReportFunc("验证服务器端信息失败!");
986
- if (typeof retObj.ctx.cb === 'function') {
987
- retObj.ctx.cb(false);
988
- }
989
- return;
990
- }
991
-
992
- var strCertID = retObj.ctx.certID;
993
- // eslint-disable-next-line no-undef
994
- xtxasyn.SOF_SignData(strCertID, strServerRan, __loginSignRandomCallBack, retObj.ctx);
995
- }
996
- function __loginCheckCertValidNotAfter(retObj) {
997
- var notAfterDate = ParseDateString(retObj.retVal);
998
- var milliseconds = notAfterDate.getTime() - new Date().getTime();
999
- if (milliseconds < 0) {
1000
- // eslint-disable-next-line no-undef
1001
- xtxasyn.custom.errorReportFunc("您的证书已过期,请尽快到北京数字证书认证中心办理证书更新手续!");
1002
- if (typeof retObj.ctx.cb === 'function') {
1003
- retObj.ctx.cb(false);
1004
- }
1005
- return;
1006
- }
1007
-
1008
- // eslint-disable-next-line no-undef
1009
- days = parseInt(milliseconds / (1000*60*60*24));
1010
- // eslint-disable-next-line no-undef
1011
- if (days > 0 && days <= 60) {
1012
- // eslint-disable-next-line no-undef
1013
- xtxasyn.custom.errorReportFunc("您的证书还有" + days + "天过期\n请您尽快到北京数字证书认证中心办理证书更新手续!");
1014
- // eslint-disable-next-line no-undef
1015
- } else if (days == 0) { // 证书有效期天数小于1天
1016
- var hours = parseInt(milliseconds / (1000*60*60));
1017
- if (hours > 0) {
1018
- // eslint-disable-next-line no-undef
1019
- xtxasyn.custom.errorReportFunc("您的证书还有" + hours + "小时过期\n请您尽快到北京数字证书认证中心办理证书更新手续!");
1020
- }
1021
- // 证书有效期小于1小时
1022
- var minutes = parseInt(milliseconds / (1000*60));
1023
- if (minutes > 1) {
1024
- // eslint-disable-next-line no-undef
1025
- xtxasyn.custom.errorReportFunc("您的证书还有" + minutes + "分钟过期\n请您尽快到北京数字证书认证中心办理证书更新手续!");
1026
- } else {
1027
- // eslint-disable-next-line no-undef
1028
- xtxasyn.custom.errorReportFunc("您的证书已过期,请尽快到北京数字证书认证中心办理证书更新手续!");
1029
- if (typeof retObj.ctx.cb === 'function') {
1030
- retObj.ctx.cb(false);
1031
- }
1032
- return;
1033
- }
1034
- }
1035
-
1036
- // eslint-disable-next-line no-undef
1037
- xtxasyn.SOF_VerifySignedData(strServerCert, strServerRan, strServerSignedData,
1038
- __loginVerifyServerSignatureCallBack, retObj.ctx);
1039
- }
1040
-
1041
- function __loginCheckCertValidNotBefore(retObj) {
1042
- var notBeforeDate = ParseDateString(retObj.retVal);
1043
- var days = parseInt((notBeforeDate.getTime() - new Date().getTime()) / (1000*60*60*24));
1044
- if (days > 0) {
1045
- // eslint-disable-next-line no-undef
1046
- xtxasyn.custom.errorReportFunc("您的证书尚未生效!距离生效日期还剩" + days + "天!");
1047
- if (typeof retObj.ctx.cb === 'function') {
1048
- retObj.ctx.cb(false);
1049
- }
1050
- return;
1051
- }
1052
- var strUserCert = retObj.ctx.objForm.UserCert.value;
1053
- // eslint-disable-next-line no-undef
1054
- xtxasyn.SOF_GetCertInfo(strUserCert, 12, __loginCheckCertValidNotAfter, retObj.ctx);
1055
- }
1056
-
1057
- function __loginGetSignCertCallBack(retObj) {
1058
- var strUserCert = retObj.retVal;
1059
- if (strUserCert == "") {
1060
- // eslint-disable-next-line no-undef
1061
- xtxasyn.custom.errorReportFunc("导出用户证书失败!");
1062
- if (typeof retObj.ctx.cb === 'function') {
1063
- retObj.ctx.cb(false);
1064
- }
1065
- return;
1066
- }
1067
- retObj.ctx.objForm.UserCert.value = strUserCert;
1068
-
1069
- // eslint-disable-next-line no-undef
1070
- xtxasyn.SOF_GetCertInfo(strUserCert, 11, __loginCheckCertValidNotBefore, retObj.ctx);
1071
- }
1072
-
1073
- function __loginGetPINRetryCallBack(retObj) {
1074
- var retryCount = Number(retObj.retVal);
1075
- if (retryCount > 0) {
1076
- // eslint-disable-next-line no-undef
1077
- xtxasyn.custom.errorReportFunc("校验证书密码失败!您还有" + retryCount + "次机会重试!");
1078
- } else if (retryCount == 0) {
1079
- // eslint-disable-next-line no-undef
1080
- xtxasyn.custom.errorReportFunc("您的证书密码已被锁死,请联系BJCA进行解锁!");
1081
- } else {
1082
- // eslint-disable-next-line no-undef
1083
- xtxasyn.custom.errorReportFunc("登录失败!");
1084
- }
1085
- if (typeof retObj.ctx.cb === 'function') {
1086
- retObj.ctx.cb();
1087
- }
1088
- }
1089
-
1090
- function __loginVerifyPINCallBack(retObj) {
1091
- var strCertID = retObj.ctx.certID;
1092
- var objForm = retObj.ctx.objForm;
1093
- if (!retObj.retVal) {
1094
- // eslint-disable-next-line no-undef
1095
- xtxasyn.SOF_GetPinRetryCount(strCertID, __loginGetPINRetryCallBack, retObj.ctx);
1096
- return;
1097
- }
1098
- objForm.CertID.value = strCertID;
1099
- objForm.ContainerName.value = strCertID;
1100
-
1101
- // eslint-disable-next-line no-undef
1102
- xtxasyn.SOF_ExportUserCert(strCertID, __loginGetSignCertCallBack, retObj.ctx);
1103
- }
1104
-
1105
- //Form login
1106
- function Login(formName, strCertID, strPin, strAction, custom_cb) {
1107
- var objForm = eval(formName);
1108
- if (objForm == null) {
1109
- // eslint-disable-next-line no-undef
1110
- xtxasyn.custom.errorReportFunc("表单错误!");
1111
- if (typeof(custom_cb) === 'function') {
1112
- custom_cb(false);
1113
- }
1114
- return;
1115
- }
1116
- if (strCertID == null || strCertID == "") {
1117
- // eslint-disable-next-line no-undef
1118
- xtxasyn.custom.errorReportFunc("请输入证书密码!");
1119
- if (typeof(custom_cb) === 'function') {
1120
- custom_cb(false);
1121
- }
1122
- return;
1123
- }
1124
- if (strPin == null || strPin == "") {
1125
- // eslint-disable-next-line no-undef
1126
- xtxasyn.custom.errorReportFunc("请输入证书密码!");
1127
- if (typeof(custom_cb) === 'function') {
1128
- custom_cb(false);
1129
- }
1130
- return;
1131
- }
1132
-
1133
- //Add a hidden item ...
1134
- if (objForm.UserSignedData == null) {
1135
- objForm.insertAdjacentHTML("BeforeEnd", "<input type=\"hidden\" name=\"UserSignedData\" value=\"\">");
1136
- }
1137
- if (objForm.UserCert == null) {
1138
- objForm.insertAdjacentHTML("BeforeEnd", "<input type=\"hidden\" name=\"UserCert\" value=\"\">");
1139
- }
1140
- if (objForm.CertID == null) {
1141
- objForm.insertAdjacentHTML("BeforeEnd", "<input type=\"hidden\" name=\"CertID\" value=\"\">");
1142
- }
1143
- if (objForm.ContainerName == null) {
1144
- objForm.insertAdjacentHTML("BeforeEnd", "<input type=\"hidden\" name=\"ContainerName\" value=\"\">");
1145
- }
1146
- if (objForm.LoginToken == null) {
1147
- objForm.insertAdjacentHTML("BeforeEnd", "<input type=\"hidden\" name=\"LoginToken\" value=\"\">");
1148
- }
1149
-
1150
- var ctx = {certID:strCertID, objForm:objForm, action:strAction, cb:custom_cb};
1151
-
1152
- // eslint-disable-next-line no-undef
1153
- xtxasyn.SOF_Login(strCertID, strPin, __loginVerifyPINCallBack, ctx);
1154
-
1155
- return;
1156
- }