fiftyone.devicedetection.onpremise 4.4.69 → 4.4.71

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/constants.js CHANGED
@@ -1,26 +1,29 @@
1
- /* *********************************************************************
2
- * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
4
- * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
- *
6
- * This Original Work is licensed under the European Union Public Licence
7
- * (EUPL) v.1.2 and is subject to its terms as set out below.
8
- *
9
- * If a copy of the EUPL was not distributed with this file, You can obtain
10
- * one at https://opensource.org/licenses/EUPL-1.2.
11
- *
12
- * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
- * amended by the European Commission) shall be deemed incompatible for
14
- * the purposes of the Work and the provisions of the compatibility
15
- * clause in Article 5 of the EUPL shall not apply.
16
- *
17
- * If using the Work as, or as part of, a network application, by
18
- * including the attribution notice(s) required under Article 5 of the EUPL
19
- * in the end user terms of the application under an appropriate heading,
20
- * such notice(s) shall fulfill the requirements of that article.
1
+ /* *********************************************************************
2
+ * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
+ * Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
+ *
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
+ *
9
+ * If a copy of the EUPL was not distributed with this file, You can obtain
10
+ * one at https://opensource.org/licenses/EUPL-1.2.
11
+ *
12
+ * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
+ * amended by the European Commission) shall be deemed incompatible for
14
+ * the purposes of the Work and the provisions of the compatibility
15
+ * clause in Article 5 of the EUPL shall not apply.
16
+ *
17
+ * If using the Work as, or as part of, a network application, by
18
+ * including the attribution notice(s) required under Article 5 of the EUPL
19
+ * in the end user terms of the application under an appropriate heading,
20
+ * such notice(s) shall fulfill the requirements of that article.
21
21
  * ********************************************************************* */
22
22
 
23
23
  module.exports = {
24
+ /* Default params */
25
+ dataUpdateUrl: 'https://distributor.51degrees.com/api/v2/download',
26
+
24
27
  /* Match metrics description */
25
28
  deviceIdDescription: 'Consists of four components separated by a ' +
26
29
  'hyphen symbol: Hardware-Platform-Browser-IsCrawler where each ' +
@@ -1,23 +1,23 @@
1
- /* *********************************************************************
2
- * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
4
- * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
- *
6
- * This Original Work is licensed under the European Union Public Licence
7
- * (EUPL) v.1.2 and is subject to its terms as set out below.
8
- *
9
- * If a copy of the EUPL was not distributed with this file, You can obtain
10
- * one at https://opensource.org/licenses/EUPL-1.2.
11
- *
12
- * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
- * amended by the European Commission) shall be deemed incompatible for
14
- * the purposes of the Work and the provisions of the compatibility
15
- * clause in Article 5 of the EUPL shall not apply.
16
- *
17
- * If using the Work as, or as part of, a network application, by
18
- * including the attribution notice(s) required under Article 5 of the EUPL
19
- * in the end user terms of the application under an appropriate heading,
20
- * such notice(s) shall fulfill the requirements of that article.
1
+ /* *********************************************************************
2
+ * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
+ * Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
+ *
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
+ *
9
+ * If a copy of the EUPL was not distributed with this file, You can obtain
10
+ * one at https://opensource.org/licenses/EUPL-1.2.
11
+ *
12
+ * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
+ * amended by the European Commission) shall be deemed incompatible for
14
+ * the purposes of the Work and the provisions of the compatibility
15
+ * clause in Article 5 of the EUPL shall not apply.
16
+ *
17
+ * If using the Work as, or as part of, a network application, by
18
+ * including the attribution notice(s) required under Article 5 of the EUPL
19
+ * in the end user terms of the application under an appropriate heading,
20
+ * such notice(s) shall fulfill the requirements of that article.
21
21
  * ********************************************************************* */
22
22
 
23
23
  const querystring = require('querystring');
@@ -31,8 +31,13 @@ const DataFile = engines.DataFile;
31
31
  * update url which contains the product, type and licensekeys.
32
32
  * These paramaters are passed in to the datafile constructor's
33
33
  * updateURLParams parameter
34
+ * @param {string} options.useUrlFormatter whether to append default URL params for Data File download
34
35
  **/
35
36
  class DeviceDetectionDataFile extends DataFile {
37
+ constructor ({ useUrlFormatter = true, ...rest}) {
38
+ super({...rest});
39
+ this.useUrlFormatter = useUrlFormatter;
40
+ }
36
41
  /**
37
42
  * Uses the product, type and licensekey parameters the datafile
38
43
  * was constructed with to generate a querystring used in the datafile
@@ -44,14 +49,19 @@ class DeviceDetectionDataFile extends DataFile {
44
49
  const queryParams = {
45
50
  Product: this.updateURLParams.product,
46
51
  Type: this.updateURLParams.Type
47
-
48
52
  };
49
53
 
54
+ let URL = this.updateURLParams.baseURL;
55
+
50
56
  if (this.updateURLParams.licenseKeys) {
51
57
  queryParams.licenseKeys = this.updateURLParams.licenseKeys;
52
58
  }
53
59
 
54
- return this.updateURLParams.baseURL + '?' + querystring.stringify(queryParams);
60
+ if(this.useUrlFormatter){
61
+ URL += '?' + querystring.stringify(queryParams);
62
+ }
63
+
64
+ return URL;
55
65
  }
56
66
  }
57
67
 
@@ -181,8 +181,10 @@ class DeviceDetectionOnPremise extends Engine {
181
181
  * @param {DataKeyedCache} options.cache an instance of the Cache class from
182
182
  * Fiftyone.Pipeline.Engines. NOTE: This is no longer supported for
183
183
  * on-premise engine.
184
- * @param {string} options.dataFileUpdateBaseUrl base url for the datafile
184
+ * @param {string} options.dataUpdateUrl base url for the datafile
185
185
  * update service
186
+ * @param {boolean} options.dataUpdateVerifyMd5 whether to check MD5 of datafile
187
+ * @param {boolean} options.dataUpdateUseUrlFormatter whether to append default URL params for Data File download
186
188
  * @param {Array} options.restrictedProperties list of properties the engine
187
189
  * will be restricted to
188
190
  * @param {string} options.licenceKeys license key(s) used by the
@@ -235,7 +237,9 @@ class DeviceDetectionOnPremise extends Engine {
235
237
  dataFilePath,
236
238
  autoUpdate,
237
239
  cache,
238
- dataFileUpdateBaseUrl = 'https://distributor.51degrees.com/api/v2/download',
240
+ dataUpdateUrl = constants.dataUpdateUrl,
241
+ dataUpdateVerifyMd5 = true,
242
+ dataUpdateUseUrlFormatter= true,
239
243
  restrictedProperties,
240
244
  licenceKeys,
241
245
  download,
@@ -457,18 +461,20 @@ class DeviceDetectionOnPremise extends Engine {
457
461
 
458
462
  // Disable features that require a license key if one was
459
463
  // not supplied.
460
- if (licenceKeys) {
461
- autoUpdate = autoUpdate && licenceKeys.length > 0;
462
- updateOnStart = updateOnStart && licenceKeys.length > 0;
463
- } else {
464
- autoUpdate = false;
465
- updateOnStart = false;
464
+ if(dataUpdateUrl === constants.dataUpdateUrl) {
465
+ if (licenceKeys) {
466
+ autoUpdate = autoUpdate && licenceKeys.length > 0;
467
+ updateOnStart = updateOnStart && licenceKeys.length > 0;
468
+ } else {
469
+ autoUpdate = false;
470
+ updateOnStart = false;
471
+ }
466
472
  }
467
473
 
468
474
  // Construct datafile
469
475
  const dataFileSettings = {
470
476
  flowElement: this,
471
- verifyMD5: true,
477
+ verifyMD5: dataUpdateVerifyMd5,
472
478
  autoUpdate,
473
479
  updateOnStart,
474
480
  decompress: true,
@@ -476,7 +482,8 @@ class DeviceDetectionOnPremise extends Engine {
476
482
  download,
477
483
  fileSystemWatcher,
478
484
  pollingInterval,
479
- updateTimeMaximumRandomisation
485
+ updateTimeMaximumRandomisation,
486
+ useUrlFormatter: dataUpdateUseUrlFormatter
480
487
  };
481
488
 
482
489
  dataFileSettings.getDatePublished = function () {
@@ -514,7 +521,7 @@ class DeviceDetectionOnPremise extends Engine {
514
521
  params.licenseKeys = licenceKeys;
515
522
  }
516
523
 
517
- params.baseURL = dataFileUpdateBaseUrl;
524
+ params.baseURL = dataUpdateUrl;
518
525
 
519
526
  dataFileSettings.updateURLParams = params;
520
527
 
@@ -1,28 +1,29 @@
1
- /* *********************************************************************
2
- * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
4
- * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
- *
6
- * This Original Work is licensed under the European Union Public Licence
7
- * (EUPL) v.1.2 and is subject to its terms as set out below.
8
- *
9
- * If a copy of the EUPL was not distributed with this file, You can obtain
10
- * one at https://opensource.org/licenses/EUPL-1.2.
11
- *
12
- * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
- * amended by the European Commission) shall be deemed incompatible for
14
- * the purposes of the Work and the provisions of the compatibility
15
- * clause in Article 5 of the EUPL shall not apply.
16
- *
17
- * If using the Work as, or as part of, a network application, by
18
- * including the attribution notice(s) required under Article 5 of the EUPL
19
- * in the end user terms of the application under an appropriate heading,
20
- * such notice(s) shall fulfill the requirements of that article.
1
+ /* *********************************************************************
2
+ * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
+ * Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
+ *
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
+ *
9
+ * If a copy of the EUPL was not distributed with this file, You can obtain
10
+ * one at https://opensource.org/licenses/EUPL-1.2.
11
+ *
12
+ * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
+ * amended by the European Commission) shall be deemed incompatible for
14
+ * the purposes of the Work and the provisions of the compatibility
15
+ * clause in Article 5 of the EUPL shall not apply.
16
+ *
17
+ * If using the Work as, or as part of, a network application, by
18
+ * including the attribution notice(s) required under Article 5 of the EUPL
19
+ * in the end user terms of the application under an appropriate heading,
20
+ * such notice(s) shall fulfill the requirements of that article.
21
21
  * ********************************************************************* */
22
22
 
23
23
  const os = require('os');
24
24
  const core = require('fiftyone.pipeline.core');
25
25
  const DeviceDetectionOnPremise = require('./deviceDetectionOnPremise');
26
+ const constants = require('./constants');
26
27
  const PipelineBuilder = core.PipelineBuilder;
27
28
  const ShareUsageElement = require('fiftyone.pipeline.engines.fiftyone').ShareUsage;
28
29
  const errorMessages = require('fiftyone.devicedetection.shared').errorMessages;
@@ -43,7 +44,10 @@ class DeviceDetectionOnPremisePipelineBuilder extends PipelineBuilder {
43
44
  * an empty string, but this will cause automatic updates
44
45
  * to be disabled.
45
46
  * @param {string} options.dataFile dataFile path for the on premise engine
47
+ * @param {boolean} options.dataUpdateVerifyMd5 whether to check MD5 of datafile
48
+ * @param {boolean} options.dataUpdateUseUrlFormatter whether to append default URL params for Data File download
46
49
  * @param {boolean} options.autoUpdate whether to autoUpdate the dataFile
50
+ * @param {string} options.dataUpdateUrl base url for the datafile
47
51
  * @param {number} options.pollingInterval How often to poll for
48
52
  * updates to the datafile (minutes)
49
53
  * @param {number} options.updateTimeMaximumRandomisation
@@ -101,7 +105,10 @@ class DeviceDetectionOnPremisePipelineBuilder extends PipelineBuilder {
101
105
  dataFileUpdateService = null,
102
106
  licenceKeys = null,
103
107
  dataFile = null,
108
+ dataUpdateVerifyMd5 = true,
109
+ dataUpdateUseUrlFormatter= true,
104
110
  autoUpdate = true,
111
+ dataUpdateUrl = null,
105
112
  pollingInterval = 30,
106
113
  updateTimeMaximumRandomisation = 10,
107
114
  shareUsage = true,
@@ -129,14 +136,20 @@ class DeviceDetectionOnPremisePipelineBuilder extends PipelineBuilder {
129
136
  this.flowElements.push(new ShareUsageElement());
130
137
  }
131
138
 
139
+ if (dataUpdateUrl == null) {
140
+ dataUpdateUrl = constants.dataUpdateUrl;
141
+ }
142
+
132
143
  if (cacheSize) {
133
144
  throw errorMessages.cacheNotSupport;
134
145
  }
135
-
136
146
  this.flowElements.push(new DeviceDetectionOnPremise(
137
147
  {
138
148
  dataFilePath: dataFile,
139
149
  autoUpdate,
150
+ dataUpdateUrl,
151
+ dataUpdateVerifyMd5,
152
+ dataUpdateUseUrlFormatter,
140
153
  fileSystemWatcher,
141
154
  pollingInterval,
142
155
  updateTimeMaximumRandomisation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fiftyone.devicedetection.onpremise",
3
- "version": "4.4.69",
3
+ "version": "4.4.71",
4
4
  "description": "Device detection on-premise services for the 51Degrees Pipeline API",
5
5
  "main": "index.js",
6
6
  "directories": {