dwt 17.2.0 → 17.2.1

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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Dynamic Web TWAIN SDK for Scanners
1
+ # Dynamic Web TWAIN SDK for Scanner and Camera
2
2
  ![version](https://img.shields.io/npm/v/dwt.svg)
3
3
  ![downloads](https://img.shields.io/npm/dm/dwt.svg)
4
4
  ![jsdelivr](https://img.shields.io/jsdelivr/npm/hm/dwt.svg)
@@ -1,4 +1,4 @@
1
- // @Fri 01/21/2022 101857
1
+ // @Tue 01/25/2022 142734
2
2
  /*
3
3
  * @name: dwt all-in-one package
4
4
  * @version: 17.2
@@ -357,28 +357,12 @@ Dynamsoft.AddonReady(function(c,b){if(!c.product.bHTML5Edition||Dynamsoft.navInf
357
357
  _this.DWT.CheckConnectToTheService(function () {
358
358
  Dynamsoft.DWT.ConnectToTheService();
359
359
  }, function () {
360
-
361
- if (!Dynamsoft.navInfoSync.bSSL && Dynamsoft._isChrome94plus()) {
362
- // check websocket
363
- var urls = Dynamsoft.Lib.detect.urls, ws;
364
-
365
- if (urls && urls.length > 0) {
366
- var o = urls[0];
367
- ws = Dynamsoft.Lib.getWS(o.host, o.port, o.ssl);
368
- } else {
369
- // default
370
- ws = Dynamsoft.Lib.getWS(Dynamsoft.Lib.product.host, 18622, false);
371
- }
372
- ws.onopen = function () {
373
- // alert must using https
374
- ws.close();
360
+ if (Dynamsoft._isInsecurePrivateNetwork() && Dynamsoft._isChrome94plus()) {
361
+ Dynamsoft._checkDWTByWebSocket(function(){
375
362
  Dynamsoft.OnHTTPCorsError();
376
- };
377
-
378
- ws.onerror = function () {
363
+ }, function(){
379
364
  setTimeout(Dynamsoft.DWT_Reconnect, 500);
380
- };
381
-
365
+ });
382
366
  return;
383
367
  }
384
368
  setTimeout(Dynamsoft.DWT_Reconnect, 500);
@@ -441,6 +425,54 @@ Dynamsoft.AddonReady(function(c,b){if(!c.product.bHTML5Edition||Dynamsoft.navInf
441
425
  return false;
442
426
  };
443
427
 
428
+ Dynamsoft._isInsecurePrivateNetwork = function() {
429
+ var _host = location.hostname;
430
+ if(_host == 'localhost' || _host == '127.0.0.1' || _host.indexOf('192.168.')==0 || _host.indexOf('172.16.')==0 || _host.indexOf('10.')==0) {
431
+ return false;
432
+ }
433
+ return !Dynamsoft.navInfoSync.bSSL;
434
+ }
435
+
436
+ Dynamsoft._checkDWTByWebSocket = function(callbackSuccess, callbackVersionFailed) {
437
+ var urls = Dynamsoft.Lib.detect.urls, ws;
438
+ if (urls && urls.length > 0) {
439
+ var o = urls[0];
440
+ ws = Dynamsoft.Lib.getWS(o.host, o.port, o.ssl);
441
+ } else {
442
+ // default
443
+ ws = Dynamsoft.Lib.getWS(Dynamsoft.Lib.product.host, 18622, false);
444
+ }
445
+
446
+ ws.onopen = function() {
447
+ if (ws.readyState == 1) {
448
+ ws.onopen = null;
449
+ var strPostStringData = ['{"id":"',new Date().getTime(),'","method":"VersionInfo","version":"',
450
+ Dynamsoft.Lib.product.getDWTPrefix(), Dynamsoft.Lib.product.getServerVersionInfo(),'"}'].join('');
451
+ ws.send(strPostStringData);
452
+ } else if (ws.readyState == 0) {
453
+ setTimeout(ws.onopen, 100);
454
+ }
455
+ };
456
+
457
+ ws.onmessage = function (msg) {
458
+ try {
459
+ ws.close();
460
+ if(msg.data.indexOf('Version not found')>=0)
461
+ callbackVersionFailed();
462
+ else
463
+ callbackSuccess();
464
+ } catch (exp) {
465
+ callbackVersionFailed();
466
+ ws.close();
467
+ }
468
+ msg = null;
469
+ };
470
+
471
+ ws.onerror = function () {
472
+ callbackVersionFailed();
473
+ };
474
+ }
475
+
444
476
  Dynamsoft._show_install_dialog = function (ProductName, objInstallerUrl, bHTML5, iPlatform, bIE, bSafari, bSSL, strIEVersion, bNeedCheckChrome) {
445
477
  var _this = Dynamsoft, ObjString, title, browserActionNeeded,
446
478
  EnumPlatform = Dynamsoft.DWT.EnumDWT_PlatformType,
@@ -458,27 +490,12 @@ Dynamsoft.AddonReady(function(c,b){if(!c.product.bHTML5Edition||Dynamsoft.navInf
458
490
 
459
491
  if (_this.DWT) {
460
492
 
461
- if (bNeedCheckChrome && !Dynamsoft.navInfoSync.bSSL && Dynamsoft._isChrome94plus()) {
462
- // check websocket
463
- var urls = Dynamsoft.Lib.detect.urls, ws;
464
-
465
- if (urls && urls.length > 0) {
466
- var o = urls[0];
467
- ws = Dynamsoft.Lib.getWS(o.host, o.port, o.ssl);
468
- } else {
469
- // default
470
- ws = Dynamsoft.Lib.getWS(Dynamsoft.Lib.product.host, 18622, false);
471
- }
472
- ws.onopen = function () {
473
- // alert must using https
474
- ws.close();
493
+ if (bNeedCheckChrome && Dynamsoft._isInsecurePrivateNetwork() && Dynamsoft._isChrome94plus()) {
494
+ Dynamsoft._checkDWTByWebSocket(function(){
475
495
  Dynamsoft.OnHTTPCorsError();
476
- };
477
-
478
- ws.onerror = function () {
496
+ }, function(){
479
497
  Dynamsoft._show_install_dialog(ProductName, objInstallerUrl, bHTML5, iPlatform, bIE, bSafari, bSSL, strIEVersion, false);
480
- };
481
-
498
+ });
482
499
  return;
483
500
  }
484
501
 
@@ -1,4 +1,4 @@
1
- // @Fri 01/21/2022 101857
1
+ // @Tue 01/25/2022 142734
2
2
  /*
3
3
  * @name: dwt all-in-one package
4
4
  * @version: 17.2
@@ -18,7 +18,7 @@
18
18
  * It's used as part of the barcode add-on when required.
19
19
  */
20
20
  import DSBarcodeReader from "dynamsoft-javascript-barcode";
21
-
21
+
22
22
  // @Wed 01/12/2022 100920_0120
23
23
  /*!
24
24
  * Dynamsoft JavaScript Library
@@ -362,28 +362,12 @@ Dynamsoft.AddonReady(function(c,b){if(!c.product.bHTML5Edition||Dynamsoft.navInf
362
362
  _this.DWT.CheckConnectToTheService(function () {
363
363
  Dynamsoft.DWT.ConnectToTheService();
364
364
  }, function () {
365
-
366
- if (!Dynamsoft.navInfoSync.bSSL && Dynamsoft._isChrome94plus()) {
367
- // check websocket
368
- var urls = Dynamsoft.Lib.detect.urls, ws;
369
-
370
- if (urls && urls.length > 0) {
371
- var o = urls[0];
372
- ws = Dynamsoft.Lib.getWS(o.host, o.port, o.ssl);
373
- } else {
374
- // default
375
- ws = Dynamsoft.Lib.getWS(Dynamsoft.Lib.product.host, 18622, false);
376
- }
377
- ws.onopen = function () {
378
- // alert must using https
379
- ws.close();
365
+ if (Dynamsoft._isInsecurePrivateNetwork() && Dynamsoft._isChrome94plus()) {
366
+ Dynamsoft._checkDWTByWebSocket(function(){
380
367
  Dynamsoft.OnHTTPCorsError();
381
- };
382
-
383
- ws.onerror = function () {
368
+ }, function(){
384
369
  setTimeout(Dynamsoft.DWT_Reconnect, 500);
385
- };
386
-
370
+ });
387
371
  return;
388
372
  }
389
373
  setTimeout(Dynamsoft.DWT_Reconnect, 500);
@@ -446,6 +430,54 @@ Dynamsoft.AddonReady(function(c,b){if(!c.product.bHTML5Edition||Dynamsoft.navInf
446
430
  return false;
447
431
  };
448
432
 
433
+ Dynamsoft._isInsecurePrivateNetwork = function() {
434
+ var _host = location.hostname;
435
+ if(_host == 'localhost' || _host == '127.0.0.1' || _host.indexOf('192.168.')==0 || _host.indexOf('172.16.')==0 || _host.indexOf('10.')==0) {
436
+ return false;
437
+ }
438
+ return !Dynamsoft.navInfoSync.bSSL;
439
+ }
440
+
441
+ Dynamsoft._checkDWTByWebSocket = function(callbackSuccess, callbackVersionFailed) {
442
+ var urls = Dynamsoft.Lib.detect.urls, ws;
443
+ if (urls && urls.length > 0) {
444
+ var o = urls[0];
445
+ ws = Dynamsoft.Lib.getWS(o.host, o.port, o.ssl);
446
+ } else {
447
+ // default
448
+ ws = Dynamsoft.Lib.getWS(Dynamsoft.Lib.product.host, 18622, false);
449
+ }
450
+
451
+ ws.onopen = function() {
452
+ if (ws.readyState == 1) {
453
+ ws.onopen = null;
454
+ var strPostStringData = ['{"id":"',new Date().getTime(),'","method":"VersionInfo","version":"',
455
+ Dynamsoft.Lib.product.getDWTPrefix(), Dynamsoft.Lib.product.getServerVersionInfo(),'"}'].join('');
456
+ ws.send(strPostStringData);
457
+ } else if (ws.readyState == 0) {
458
+ setTimeout(ws.onopen, 100);
459
+ }
460
+ };
461
+
462
+ ws.onmessage = function (msg) {
463
+ try {
464
+ ws.close();
465
+ if(msg.data.indexOf('Version not found')>=0)
466
+ callbackVersionFailed();
467
+ else
468
+ callbackSuccess();
469
+ } catch (exp) {
470
+ callbackVersionFailed();
471
+ ws.close();
472
+ }
473
+ msg = null;
474
+ };
475
+
476
+ ws.onerror = function () {
477
+ callbackVersionFailed();
478
+ };
479
+ }
480
+
449
481
  Dynamsoft._show_install_dialog = function (ProductName, objInstallerUrl, bHTML5, iPlatform, bIE, bSafari, bSSL, strIEVersion, bNeedCheckChrome) {
450
482
  var _this = Dynamsoft, ObjString, title, browserActionNeeded,
451
483
  EnumPlatform = Dynamsoft.DWT.EnumDWT_PlatformType,
@@ -463,27 +495,12 @@ Dynamsoft.AddonReady(function(c,b){if(!c.product.bHTML5Edition||Dynamsoft.navInf
463
495
 
464
496
  if (_this.DWT) {
465
497
 
466
- if (bNeedCheckChrome && !Dynamsoft.navInfoSync.bSSL && Dynamsoft._isChrome94plus()) {
467
- // check websocket
468
- var urls = Dynamsoft.Lib.detect.urls, ws;
469
-
470
- if (urls && urls.length > 0) {
471
- var o = urls[0];
472
- ws = Dynamsoft.Lib.getWS(o.host, o.port, o.ssl);
473
- } else {
474
- // default
475
- ws = Dynamsoft.Lib.getWS(Dynamsoft.Lib.product.host, 18622, false);
476
- }
477
- ws.onopen = function () {
478
- // alert must using https
479
- ws.close();
498
+ if (bNeedCheckChrome && Dynamsoft._isInsecurePrivateNetwork() && Dynamsoft._isChrome94plus()) {
499
+ Dynamsoft._checkDWTByWebSocket(function(){
480
500
  Dynamsoft.OnHTTPCorsError();
481
- };
482
-
483
- ws.onerror = function () {
501
+ }, function(){
484
502
  Dynamsoft._show_install_dialog(ProductName, objInstallerUrl, bHTML5, iPlatform, bIE, bSafari, bSSL, strIEVersion, false);
485
- };
486
-
503
+ });
487
504
  return;
488
505
  }
489
506
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dwt",
3
- "version": "17.2.0",
3
+ "version": "17.2.1",
4
4
  "author": {
5
5
  "name": "Dynamsoft",
6
6
  "url": "https://www.dynamsoft.com"