cassproject 5.0.22 → 5.0.23

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 (105) hide show
  1. package/package.json +47 -50
  2. package/src/com/eduworks/ec/array/EcArray.js +1 -1
  3. package/src/com/eduworks/ec/array/EcAsyncHelper.js +1 -1
  4. package/src/com/eduworks/ec/array/EcObject.js +1 -1
  5. package/src/com/eduworks/ec/crypto/EcAes.js +1 -1
  6. package/src/com/eduworks/ec/crypto/EcAesCtrAsync.js +20 -22
  7. package/src/com/eduworks/ec/crypto/EcCrypto.js +8 -4
  8. package/src/com/eduworks/ec/crypto/EcPk.js +7 -7
  9. package/src/com/eduworks/ec/crypto/EcPpk.js +7 -7
  10. package/src/com/eduworks/ec/crypto/EcRsaOaepAsync.js +20 -19
  11. package/src/com/eduworks/ec/crypto/EcRsaOaepAsyncWorker.js +7 -6
  12. package/src/com/eduworks/ec/crypto/forgeAsyncNode.js +8 -8
  13. package/src/com/eduworks/ec/graph/EcDirectedGraph.js +1 -2
  14. package/src/com/eduworks/ec/graph/EcFrameworkGraph.js +18 -24
  15. package/src/com/eduworks/ec/promises/helpers.js +1 -3
  16. package/src/com/eduworks/ec/remote/EcRemote.js +9 -9
  17. package/src/com/eduworks/ec/task/EcAsyncTask.js +5 -20
  18. package/src/com/eduworks/ec/task/EcAsyncTaskManager.js +3 -4
  19. package/src/com/eduworks/ec/task/EcAsyncTaskWorker.js +9 -11
  20. package/src/com/eduworks/schema/cfd/competency/CfdFramework.js +36 -37
  21. package/src/com/eduworks/schema/ebac/EbacContact.js +3 -9
  22. package/src/com/eduworks/schema/ebac/EbacContactGrant.js +3 -9
  23. package/src/com/eduworks/schema/ebac/EbacCredential.js +3 -9
  24. package/src/com/eduworks/schema/ebac/EbacCredentialCommit.js +3 -9
  25. package/src/com/eduworks/schema/ebac/EbacCredentialRequest.js +3 -9
  26. package/src/com/eduworks/schema/ebac/EbacCredentials.js +3 -9
  27. package/src/com/eduworks/schema/ebac/EbacEncryptedSecret.js +3 -9
  28. package/src/com/eduworks/schema/ebac/EbacEncryptedValue.js +5 -12
  29. package/src/com/eduworks/schema/ebac/EbacSignature.js +1 -6
  30. package/src/index/env.js +6 -3
  31. package/src/index/polyfills.js +13 -27
  32. package/src/org/angles/schema/angles/VideoStory.js +1 -1
  33. package/src/org/cass/competency/EcCompetency.js +1 -2
  34. package/src/org/cass/competency/EcDirectory.js +1 -2
  35. package/src/org/cass/competency/EcFramework.js +9 -12
  36. package/src/org/cass/exporter/CSVExport.js +12 -13
  37. package/src/org/cass/importer/ASNImport.js +3 -6
  38. package/src/org/cass/importer/CSVImport.js +9 -17
  39. package/src/org/cass/importer/CTDLASNCSVConceptImport.js +25 -121
  40. package/src/org/cass/importer/CTDLASNCSVImport.js +88 -133
  41. package/src/org/cass/importer/FrameworkImport.js +16 -30
  42. package/src/org/cass/importer/MedbiqImport.js +3 -4
  43. package/src/org/cass/importer/TabStructuredImport.js +6 -6
  44. package/src/org/cass/profile/EcAssertion.js +40 -51
  45. package/src/org/cassproject/ebac/identity/EcContactGrant.js +2 -2
  46. package/src/org/cassproject/ebac/identity/EcIdentityManager.js +56 -62
  47. package/src/org/cassproject/ebac/identity/remote/EcRemoteIdentityManager.js +51 -62
  48. package/src/org/cassproject/ebac/identity/remote/OAuth2FileBasedRemoteIdentityManager.js +56 -70
  49. package/src/org/cassproject/ebac/identity/remote/RemoteIdentityManagerInterface.js +3 -3
  50. package/src/org/cassproject/ebac/repository/EcEncryptedValue.js +51 -44
  51. package/src/org/cassproject/ebac/repository/EcRepository.js +228 -301
  52. package/src/org/cassproject/general/repository/GeneralFile.js +8 -9
  53. package/src/org/cassproject/schema/cass/competency/Competency.js +10 -11
  54. package/src/org/cassproject/schema/cass/competency/Framework.js +10 -11
  55. package/src/org/cassproject/schema/cass/competency/Level.js +10 -11
  56. package/src/org/cassproject/schema/cass/competency/Relation.js +10 -11
  57. package/src/org/cassproject/schema/cass/competency/RollupRule.js +7 -7
  58. package/src/org/cassproject/schema/cass/profile/Assertion.js +20 -27
  59. package/src/org/cassproject/schema/cass/profile/AssertionEnvelope.js +3 -5
  60. package/src/org/cassproject/schema/general/EcRemoteLinkedData.js +41 -44
  61. package/src/org/json/ld/EcLinkedData.js +10 -12
  62. package/src/org/schema/EcOrganization.js +10 -10
  63. package/src/org/schema/EcQuestion.js +8 -8
  64. package/src/org/w3/skos/Concept.js +6 -6
  65. package/src/org/w3/skos/ConceptScheme.js +6 -6
  66. package/src/org/w3/skos/EcConcept.js +1 -2
  67. package/src/org/w3/skos/EcConceptScheme.js +1 -2
  68. package/src/test/0.start.test.js +1 -1
  69. package/src/test/0.testLibraries.test.js +172 -0
  70. package/src/test/1.ASNImport.test.js +122 -0
  71. package/src/test/1.CSVExport.test.js +57 -0
  72. package/src/test/1.CSVImport.test.js +185 -0
  73. package/src/test/1.CTDLASNCSVConceptImport.test.js +348 -0
  74. package/src/test/1.CTDLASNCSVImport.import.test.js +497 -0
  75. package/src/test/1.Ebac.schema.test.js +107 -0
  76. package/src/test/1.EcAssertion.decrypt.test.js +98 -0
  77. package/src/test/1.EcAssertion.pinned.test.js +160 -0
  78. package/src/test/1.EcCrypto.formats.test.js +293 -0
  79. package/src/test/1.EcCrypto.generateUUID.test.js +47 -0
  80. package/src/test/1.EcEncryptedValue.helpers.test.js +236 -0
  81. package/src/test/1.EcHelpers.misc.test.js +259 -0
  82. package/src/test/1.EcIdentityManager.keys.test.js +439 -0
  83. package/src/test/1.EcOrganization.rekey.test.js +68 -0
  84. package/src/test/1.EcRemote.responses.test.js +155 -0
  85. package/src/test/1.EcRemoteIdentityManager.flows.test.js +326 -0
  86. package/src/test/1.EcRemoteLinkedData.pinned.test.js +473 -0
  87. package/src/test/1.EcRepository.l0.test.js +14 -5
  88. package/src/test/1.EcRepository.l1.test.js +16 -7
  89. package/src/test/1.EcRepository.l2.test.js +20 -11
  90. package/src/test/1.EcRepository.unit.test.js +961 -0
  91. package/src/test/1.EcRsaOaep.test.js +2 -12
  92. package/src/test/1.EcRsaOaepAsync.test.js +2 -12
  93. package/src/test/1.EcRsaOaepAsyncWorker.test.js +2 -12
  94. package/src/test/1.EcRsaOaepAsyncWorker.workers.test.js +147 -0
  95. package/src/test/1.FrameworkImport.test.js +170 -0
  96. package/src/test/1.MedbiqImport.test.js +92 -0
  97. package/src/test/1.OAuth2FileBasedRemoteIdentityManager.test.js +399 -0
  98. package/src/test/1.TabStructuredImport.test.js +61 -0
  99. package/src/test/1.polyfills.test.js +89 -0
  100. package/src/test/1.schema.competency.pinned.test.js +384 -0
  101. package/src/test/3.EcFrameworkGraph.test.js +3 -2
  102. package/src/test/4.schema.test.js +33 -28
  103. package/src/test/4.skyId.test.js +4 -2
  104. package/src/test/cypressValue.js +9 -0
  105. package/src/test/2.EcCompetency.test.js +0 -17
@@ -14,6 +14,26 @@ const EcPk = require("../../../../com/eduworks/ec/crypto/EcPk");
14
14
  const EcLinkedData = require("../../../json/ld/EcLinkedData.js");
15
15
  require("../../general/AuditLogger.js")
16
16
 
17
+ /**
18
+ * Resolves to null for the errors that mean an object was not found; rethrows anything else.
19
+ * An error without a toString (null, undefined) fails the second check with a TypeError.
20
+ */
21
+ const nullIfNotFound = (error) => {
22
+ if (error?.toString !== undefined && error.toString().includes("Could not locate object. May be due to EcRepository.alwaysTryUrl flag."))
23
+ return null;
24
+ if (error.toString().includes("Object not found or you did not supply sufficient permissions to access the object."))
25
+ return null;
26
+ throw error;
27
+ };
28
+
29
+ /**
30
+ * Looks each URL up in the cache, separately, and returns the values found.
31
+ */
32
+ const cachedValues = async (urls) => {
33
+ const values = await Promise.all(urls.map(url => module.exports.cacheGet(url)));
34
+ return values.filter(Boolean);
35
+ };
36
+
17
37
  /**
18
38
  * Repository object used to interact with the CASS Repository web services.
19
39
  * Should be used for all CRUD and search operations
@@ -61,13 +81,13 @@ module.exports = class EcRepository {
61
81
  static cacheDB = null;
62
82
  static cacheGet = async (prop, transaction, objectStore) => {
63
83
  if (EcArray.isArray(prop)) {
64
- if (EcRepository.cachingL2 == true && EcRepository.cacheDB != null && transaction == null)
84
+ if (EcRepository.cachingL2 && EcRepository.cacheDB != null && transaction == null)
65
85
  transaction = EcRepository.cacheDB.transaction(EcRepository.LONGIDS, "readonly");
66
- if (EcRepository.cachingL2 == true && transaction != null && objectStore == null)
86
+ if (EcRepository.cachingL2 && transaction != null && objectStore == null)
67
87
  objectStore = transaction.objectStore(EcRepository.LONGIDS);
68
88
  return await Promise.all(prop.map(p => EcRepository.cacheGet(p, transaction, objectStore)));
69
89
  }
70
- if (EcRepository.cachingL2 == false)
90
+ if (!EcRepository.cachingL2)
71
91
  return EcRepository.cache[prop];
72
92
  if (EcRepository.cacheDB == null)
73
93
  return EcRepository.cache[prop];
@@ -98,7 +118,7 @@ module.exports = class EcRepository {
98
118
  return Reflect.get(...arguments);
99
119
  },
100
120
  set: function (target, prop, value) {
101
- if (EcRepository.cachingL2 == false)
121
+ if (!EcRepository.cachingL2)
102
122
  return Reflect.set(...arguments);
103
123
  if (EcRepository.cacheDB == null)
104
124
  return Reflect.set(...arguments);
@@ -119,7 +139,7 @@ module.exports = class EcRepository {
119
139
  return Reflect.set(...arguments);
120
140
  },
121
141
  deleteProperty: function (target, prop) {
122
- if (EcRepository.cachingL2 == false)
142
+ if (!EcRepository.cachingL2)
123
143
  return Reflect.deleteProperty(...arguments);
124
144
  if (EcRepository.cacheDB == null)
125
145
  return Reflect.deleteProperty(...arguments);
@@ -143,7 +163,7 @@ module.exports = class EcRepository {
143
163
  static clearCache = () => {
144
164
  for (let prop of Object.keys(EcRepository.cacheBacking))
145
165
  delete EcRepository.cacheBacking[prop];
146
- if (EcRepository.cachingL2 == true && EcRepository.cacheDB != null) {
166
+ if (EcRepository.cachingL2 && EcRepository.cacheDB != null) {
147
167
  const transaction = EcRepository.cacheDB.transaction(EcRepository.LONGIDS, "readwrite");
148
168
  transaction.objectStore(EcRepository.LONGIDS).clear();
149
169
  }
@@ -167,8 +187,7 @@ module.exports = class EcRepository {
167
187
  negotiateTimeOffset = function (success, failure, loginObjectCallback) {
168
188
  let oldTimeout = EcRemote.timeout;
169
189
  EcRemote.timeout = 500;
170
- let me = this;
171
- let successCheck = function (p1) {
190
+ let successCheck = (p1) => {
172
191
  if (p1 != null) {
173
192
  if (p1.ssoPublicKey != null) {
174
193
  let identity = new EcIdentity();
@@ -180,17 +199,17 @@ module.exports = class EcRepository {
180
199
  EcRepository.defaultPlugins = JSON.parse(p1["plugins"]);
181
200
  }
182
201
  if (p1["postMaxSize"]) {
183
- me.postMaxSize = p1["postMaxSize"];
202
+ this.postMaxSize = p1["postMaxSize"];
184
203
  }
185
204
  if (p1["signatureSheetHashAlgorithm"]) {
186
- me.signatureSheetHashAlgorithm = p1["signatureSheetHashAlgorithm"];
205
+ this.signatureSheetHashAlgorithm = p1["signatureSheetHashAlgorithm"];
187
206
  }
188
207
  if (p1["ping"] == "pong") {
189
208
  if (loginObjectCallback != null)
190
209
  loginObjectCallback(p1);
191
210
  if (p1["time"] != null)
192
- me.timeOffset = p1["time"] - new Date().getTime();
193
- return me.buildKeyForwardingTable(success, failure);
211
+ this.timeOffset = p1["time"] - Date.now();
212
+ return this.buildKeyForwardingTable(success, failure);
194
213
  }
195
214
  }
196
215
  };
@@ -214,8 +233,8 @@ module.exports = class EcRepository {
214
233
  null,
215
234
  params, eim
216
235
  ).then(async (rekeyRequests) => {
217
- for (let i = 0; i < rekeyRequests.length; i++) {
218
- await rekeyRequests[i].addRekeyRequestToForwardingTable();
236
+ for (let rekeyRequest of rekeyRequests) {
237
+ await rekeyRequest.addRekeyRequestToForwardingTable();
219
238
  }
220
239
  global.auditLogger.report(global.auditLogger.LogCategory.SYSTEM, global.auditLogger.Severity.INFO, "EcRepoBuildKeyForwTable", EcObject.keys(EcRemoteLinkedData.forwardingTable).length + " records now in forwarding table.");
221
240
  }),
@@ -261,14 +280,11 @@ module.exports = class EcRepository {
261
280
  p = p.then((data) => {
262
281
  return data.map(d => { let rld = new EcRemoteLinkedData(); rld.copyFrom(d); return rld; });
263
282
  }).catch((error) => {
264
- if (
265
- error != null &&
266
- error.toString != undefined
267
- ) {
268
- if (error.toString().indexOf("Could not locate object. May be due to EcRepository.alwaysTryUrl flag.") != -1) {
283
+ if (error?.toString != undefined) {
284
+ if (error.toString().includes("Could not locate object. May be due to EcRepository.alwaysTryUrl flag.")) {
269
285
  return null;
270
286
  }
271
- if (error.toString().indexOf("Object not found or you did not supply sufficient permissions to access the object.") != -1) {
287
+ if (error.toString().includes("Object not found or you did not supply sufficient permissions to access the object.")) {
272
288
  return null;
273
289
  }
274
290
  }
@@ -294,7 +310,7 @@ module.exports = class EcRepository {
294
310
  if (url == null) {
295
311
  throw new Error("URL is null. Cannot EcRepository.get");
296
312
  }
297
- if (url.toLowerCase().indexOf("http") != 0) {
313
+ if (!url.toLowerCase().startsWith("http")) {
298
314
  throw new Error("URL does not begin with http. Cannot EcRepository.get " + url);
299
315
  }
300
316
 
@@ -347,20 +363,7 @@ module.exports = class EcRepository {
347
363
  0,
348
364
  success,
349
365
  failure, eim
350
- ).catch((error) => {
351
- if (
352
- error !== undefined &&
353
- error != null &&
354
- error.toString !== undefined
355
- )
356
- if (error.toString().indexOf("Could not locate object. May be due to EcRepository.alwaysTryUrl flag.") != -1) {
357
- return null;
358
- }
359
- if (error.toString().indexOf("Object not found or you did not supply sufficient permissions to access the object.") != -1) {
360
- return null;
361
- }
362
- throw error;
363
- });
366
+ ).catch(nullIfNotFound);
364
367
  }
365
368
  }
366
369
  if (EcRepository.caching) {
@@ -411,36 +414,11 @@ module.exports = class EcRepository {
411
414
  0,
412
415
  success,
413
416
  failure, eim
414
- ).catch((error) => {
415
- if (
416
- error !== undefined &&
417
- error != null &&
418
- error.toString !== undefined
419
- )
420
- if (error.toString().indexOf("Could not locate object. May be due to EcRepository.alwaysTryUrl flag.") != -1) {
421
- return null;
422
- }
423
- if (error.toString().indexOf("Object not found or you did not supply sufficient permissions to access the object.") != -1) {
424
- return null;
425
- }
426
- throw error;
427
- });
428
- } else {
429
- if (this.caching) this.cache[url] = null;
430
- return cassReturnAsPromise(null, success, failure, error).catch((error) => {
431
- if (
432
- error !== undefined &&
433
- error != null &&
434
- error.toString !== undefined
435
- )
436
- if (error.toString().indexOf("Could not locate object. May be due to EcRepository.alwaysTryUrl flag.") != -1)
437
- return null;
438
- if (error.toString().indexOf("Object not found or you did not supply sufficient permissions to access the object.") != -1)
439
- return null;
440
- throw error;
441
- });
417
+ );
442
418
  }
443
- }).finally(
419
+ if (this.caching) this.cache[url] = null;
420
+ return cassReturnAsPromise(null, success, failure, error);
421
+ }).catch(nullIfNotFound).finally(
444
422
  (result) => {
445
423
  delete EcRepository.fetching[originalUrl + eim.eimId];
446
424
  return result;
@@ -451,9 +429,9 @@ module.exports = class EcRepository {
451
429
  }
452
430
  static setOffset = function (url) {
453
431
  let offset = 0;
454
- for (let i = 0; i < this.repos.length; i++) {
455
- if (url.indexOf(this.repos[i].selectedServer) != -1) {
456
- offset = this.repos[i].timeOffset;
432
+ for (let repo of this.repos) {
433
+ if (url.includes(repo.selectedServer)) {
434
+ offset = repo.timeOffset;
457
435
  }
458
436
  }
459
437
  return offset;
@@ -504,8 +482,8 @@ module.exports = class EcRepository {
504
482
  if (this.alwaysTryUrl) return true;
505
483
  if (this.repos.length == 0) return true;
506
484
  let validUrlFound = false;
507
- for (let i = 0; i < this.repos.length; i++) {
508
- if (this.repos[i].selectedServer == null) continue;
485
+ for (let repo of this.repos) {
486
+ if (repo.selectedServer == null) continue;
509
487
  validUrlFound = true;
510
488
  }
511
489
  if (!validUrlFound) return true;
@@ -513,7 +491,7 @@ module.exports = class EcRepository {
513
491
  };
514
492
  static find(url, error, history, counter, success, failure, eim) {
515
493
  if (
516
- isNaN(counter) ||
494
+ Number.isNaN(Number(counter)) ||
517
495
  counter == undefined ||
518
496
  counter > this.repos.length ||
519
497
  this.repos[counter] == null
@@ -533,7 +511,7 @@ module.exports = class EcRepository {
533
511
  failure, eim
534
512
  );
535
513
  }
536
- if (history[repo.selectedServer] == true) {
514
+ if (history[repo.selectedServer]) {
537
515
  return this.find(
538
516
  url,
539
517
  error,
@@ -557,38 +535,22 @@ module.exports = class EcRepository {
557
535
  failure, eim
558
536
  );
559
537
  else {
560
- let done = false;
561
- for (let i = 0; i < strings.length; i++) {
538
+ for (let found of strings) {
562
539
  if (
563
- strings[i].id == url ||
564
- strings[i].shortId() == url
540
+ found.id == url ||
541
+ found.shortId() == url
565
542
  ) {
566
- if (done)
567
- log(
568
- "Searching for exact ID:" +
569
- url +
570
- ", found more than one@:" +
571
- repo.selectedServer
572
- );
573
- done = true;
574
543
  delete EcRepository.fetching[url];
575
544
  if (EcRepository.caching) {
576
- EcRepository.cache[url] = strings[i];
545
+ EcRepository.cache[url] = found;
577
546
  }
578
547
  return cassReturnAsPromise(
579
- strings[i],
548
+ found,
580
549
  success,
581
550
  failure
582
551
  );
583
552
  }
584
553
  }
585
- if (done)
586
- return cassReturnAsPromise(
587
- null,
588
- success,
589
- failure,
590
- error
591
- );
592
554
  return this.find(
593
555
  url,
594
556
  error,
@@ -599,10 +561,10 @@ module.exports = class EcRepository {
599
561
  );
600
562
  }
601
563
  })
602
- .catch((s) => {
564
+ .catch((error_) => {
603
565
  return this.find(
604
566
  url,
605
- s,
567
+ error_,
606
568
  history,
607
569
  counter + 1,
608
570
  success,
@@ -622,28 +584,28 @@ module.exports = class EcRepository {
622
584
  */
623
585
  static escapeSearch = function (query) {
624
586
  let s = null;
625
- s = query.split("\\").join("\\\\");
626
- s = s.split("-").join("\\-");
627
- s = s.split("=").join("\\=");
628
- s = s.split("&&").join("\\&&");
629
- s = s.split("||").join("\\||");
630
- s = s.split("<").join("\\<");
631
- s = s.split(">").join("\\>");
632
- s = s.split("|").join("\\|");
633
- s = s.split("(").join("\\(");
634
- s = s.split(")").join("\\)");
635
- s = s.split("{").join("\\{");
636
- s = s.split("}").join("\\}");
637
- s = s.split("[").join("\\[");
638
- s = s.split("]").join("\\]");
639
- s = s.split("^").join("\\^");
640
- s = s.split('"').join('\\"');
641
- s = s.split("~").join("\\~");
642
- s = s.split("*").join("\\*");
643
- s = s.split("?").join("\\?");
644
- s = s.split(":").join("\\:");
645
- s = s.split("/").join("\\/");
646
- s = s.split("+").join("\\+");
587
+ s = query.replaceAll("\\", String.raw`\\`);
588
+ s = s.replaceAll("-", String.raw`\-`);
589
+ s = s.replaceAll("=", String.raw`\=`);
590
+ s = s.replaceAll("&&", String.raw`\&&`);
591
+ s = s.replaceAll("||", String.raw`\||`);
592
+ s = s.replaceAll("<", String.raw`\<`);
593
+ s = s.replaceAll(">", String.raw`\>`);
594
+ s = s.replaceAll("|", String.raw`\|`);
595
+ s = s.replaceAll("(", String.raw`\(`);
596
+ s = s.replaceAll(")", String.raw`\)`);
597
+ s = s.replaceAll("{", String.raw`\{`);
598
+ s = s.replaceAll("}", String.raw`\}`);
599
+ s = s.replaceAll("[", String.raw`\[`);
600
+ s = s.replaceAll("]", String.raw`\]`);
601
+ s = s.replaceAll("^", String.raw`\^`);
602
+ s = s.replaceAll('"', String.raw`\"`);
603
+ s = s.replaceAll("~", String.raw`\~`);
604
+ s = s.replaceAll("*", String.raw`\*`);
605
+ s = s.replaceAll("?", String.raw`\?`);
606
+ s = s.replaceAll(":", String.raw`\:`);
607
+ s = s.replaceAll("/", String.raw`\/`);
608
+ s = s.replaceAll("+", String.raw`\+`);
647
609
  return s;
648
610
  };
649
611
  /**
@@ -700,10 +662,10 @@ module.exports = class EcRepository {
700
662
  let msg = "Cannot save data. It is missing a vital component.";
701
663
  throw msg;
702
664
  }
703
- if (data.reader != null && data.reader.length == 0) {
665
+ if (data.reader?.length == 0) {
704
666
  delete data["reader"];
705
667
  }
706
- if (data.owner != null && data.owner.length == 0) {
668
+ if (data.owner?.length == 0) {
707
669
  delete data["owner"];
708
670
  }
709
671
  if (eim === undefined || eim == null)
@@ -777,15 +739,15 @@ module.exports = class EcRepository {
777
739
  }
778
740
  if (data.invalid()) {
779
741
  if (failure != null) failure("Data is malformed.");
780
- else throw "Data is malformed.";
742
+ else throw "Data is malformed."; // NOSONAR - Callers may catch and compare this string; an Error would change what they get.
781
743
  }
782
744
  // Update timestamp if it is an object that originated on a CaSS instance.
783
745
  if (
784
746
  this.alwaysTryUrl ||
785
747
  repo == null ||
786
748
  this.shouldTryUrl(data.id) ||
787
- data.id.indexOf("/api/data/") != -1 ||
788
- repo != null && data.id.indexOf(repo.selectedServer.replace(/https?/, "")) != -1
749
+ data.id.includes("/api/data/") ||
750
+ repo != null && data.id.includes(repo.selectedServer.replace(/https?/, ""))
789
751
  )
790
752
  data.updateTimestamp();
791
753
 
@@ -804,7 +766,7 @@ module.exports = class EcRepository {
804
766
  fd.append("signatureSheet", signatureSheet);
805
767
  if (!this.alwaysTryUrl) {
806
768
  if (repo != null) {
807
- if (data.id.indexOf(repo.selectedServer) != -1) {
769
+ if (data.id.includes(repo.selectedServer)) {
808
770
  return EcRemote.postExpectingString(
809
771
  data.id,
810
772
  "",
@@ -815,7 +777,7 @@ module.exports = class EcRepository {
815
777
  }
816
778
  if (
817
779
  !this.shouldTryUrl(data.id) ||
818
- data.id.indexOf(repo.selectedServer) == -1
780
+ !data.id.includes(repo.selectedServer)
819
781
  ) {
820
782
  return EcRemote.postExpectingString(
821
783
  EcRemote.urlAppend(
@@ -952,7 +914,7 @@ module.exports = class EcRepository {
952
914
  let targetUrl;
953
915
  if (
954
916
  EcRepository.shouldTryUrl(data.id) ||
955
- data.id.indexOf(this.selectedServerProxy != null ? this.selectedServerProxy : this.selectedServer) != -1
917
+ data.id.includes(this.selectedServerProxy ?? this.selectedServer)
956
918
  )
957
919
  targetUrl = EcRemote.urlAppend(
958
920
  this.selectedServer,
@@ -1001,17 +963,17 @@ module.exports = class EcRepository {
1001
963
  for (let d of data) {
1002
964
  if (d.invalid())
1003
965
  throw new Error("Cannot save data. It is missing a vital component.");
1004
- if (d.reader != null && d.reader.length == 0) {
966
+ if (d.reader?.length == 0) {
1005
967
  delete d["reader"];
1006
968
  }
1007
- if (d.owner != null && d.owner.length == 0) {
969
+ if (d.owner?.length == 0) {
1008
970
  delete d["owner"];
1009
971
  }
1010
972
  if (
1011
973
  EcRepository.alwaysTryUrl ||
1012
974
  EcRepository.shouldTryUrl(d.id) ||
1013
- d.id.indexOf("/api/data/") != -1 ||
1014
- d.id.indexOf(this.selectedServer.replace(/https?/, "")) != -1
975
+ d.id.includes("/api/data/") ||
976
+ d.id.includes(this.selectedServer.replace(/https?/, ""))
1015
977
  )
1016
978
  d.updateTimestamp();
1017
979
  if (EcRepository.caching) {
@@ -1100,7 +1062,6 @@ module.exports = class EcRepository {
1100
1062
  * @method precache
1101
1063
  */
1102
1064
  precache = async function (urls, success, failure, eim, skipIds, versionedUrls) {
1103
- let me = this;
1104
1065
  if (eim === undefined || eim == null)
1105
1066
  eim = EcIdentityManager.default;
1106
1067
  if (urls == null) {
@@ -1108,7 +1069,7 @@ module.exports = class EcRepository {
1108
1069
  }
1109
1070
  urls = [...urls];
1110
1071
  let originals = [...urls];
1111
- if (EcRepository.caching == true) {
1072
+ if (EcRepository.caching) {
1112
1073
  for (let i = 0; i < urls.length; i++)
1113
1074
  if (await EcRepository.cacheGet(urls[i]) !== undefined)
1114
1075
  urls.splice(i--, 1);
@@ -1127,17 +1088,13 @@ module.exports = class EcRepository {
1127
1088
  return "data//" + EcCrypto.md5(EcRemoteLinkedData.trimVersionFromUrl(url)) + (version != null ? ("/" + version) : "");
1128
1089
  }
1129
1090
  );
1130
- if (EcRepository.caching == true) {
1091
+ if (EcRepository.caching) {
1131
1092
  for (let i = 0; i < urls.length; i++)
1132
1093
  if (await EcRepository.cacheGet(urls[i]) !== undefined)
1133
1094
  urls.splice(i--, 1);
1134
1095
  }
1135
1096
  if (urls.length == 0) {
1136
- return cassPromisify(new Promise((resolve, reject) => {
1137
- resolve(
1138
- EcRepository.cacheGet(originals).then(c => c.filter(x => x))
1139
- )
1140
- }), success, failure);
1097
+ return cassPromisify(EcRepository.cacheGet(originals).then(c => c.filter(Boolean)), success, failure);
1141
1098
  }
1142
1099
 
1143
1100
  let fd = new FormData();
@@ -1145,15 +1102,13 @@ module.exports = class EcRepository {
1145
1102
  if (EcRepository.cachingL2 && !skipIds) {
1146
1103
  fd.append("ids", "true");
1147
1104
  }
1148
- let p = new Promise((resolve, reject) => resolve());
1105
+ let p = Promise.resolve();
1149
1106
  if (!EcRepository.unsigned)
1150
- p = p.then(() => {
1151
- return eim.signatureSheet(
1152
- 300000 + this.timeOffset,
1153
- this.selectedServer, null, null, this.signatureSheetHashAlgorithm
1154
- ).then((signatureSheet) => {
1155
- fd.append("signatureSheet", signatureSheet);
1156
- });
1107
+ p = p.then(() => eim.signatureSheet(
1108
+ 300000 + this.timeOffset,
1109
+ this.selectedServer, null, null, this.signatureSheetHashAlgorithm
1110
+ )).then((signatureSheet) => {
1111
+ fd.append("signatureSheet", signatureSheet);
1157
1112
  });
1158
1113
  p = p
1159
1114
  .then(() => {
@@ -1187,16 +1142,16 @@ module.exports = class EcRepository {
1187
1142
  EcRepository.cacheBacking[cached.id] = cached;
1188
1143
  }
1189
1144
  }
1190
- let objResults = await me.precache.call(me, results, null, null, eim, true, versionedUrls);
1145
+ let objResults = await this.precache(results, null, null, eim, true, versionedUrls);
1191
1146
  if (objResults.length == results.length)
1192
1147
  return objResults;
1193
1148
  //Second attempt, in case the indexed object URL doesn't match the permanent URL.
1194
1149
  let missingUris = results
1195
- .filter(r => originals.indexOf(r) == -1) //Filter out URLs that were originally longIds.
1196
- .filter(r => !objResults.some(rr => r.indexOf(rr.shortId()) != -1)) //Filter out URLs that were found in the first pass.
1150
+ .filter(r => !originals.includes(r)) //Filter out URLs that were originally longIds.
1151
+ .filter(r => !objResults.some(rr => r.includes(rr.shortId()))) //Filter out URLs that were found in the first pass.
1197
1152
  .map(u => EcRemoteLinkedData.trimVersionFromUrl(u)); //NOSONAR - Nesting functions to perform filters is normal.
1198
1153
  if (missingUris.length > 0)
1199
- objResults.push(...await me.precache.call(me, missingUris, null, null, eim, true));
1154
+ objResults.push(...await this.precache(missingUris, null, null, eim, true));
1200
1155
  return cassPromisify(objResults, success, failure);
1201
1156
  }
1202
1157
  for (let i = 0; i < results.length; i++) {
@@ -1222,7 +1177,7 @@ module.exports = class EcRepository {
1222
1177
  }
1223
1178
  EcRepository.cache[d.id] = d;
1224
1179
  }
1225
- return cassPromisify(new Promise((resolve, reject) => { resolve(Promise.all(originals.map(url => EcRepository.cacheGet(url))).then(c => c.filter(x => x))) }), success, failure);
1180
+ return cassPromisify(cachedValues(originals), success, failure);
1226
1181
  });
1227
1182
  return cassPromisify(p, success, failure);
1228
1183
  };
@@ -1270,15 +1225,13 @@ module.exports = class EcRepository {
1270
1225
  );
1271
1226
  let fd = new FormData();
1272
1227
  fd.append("data", JSON.stringify(urls));
1273
- let p = new Promise((resolve, reject) => resolve());
1228
+ let p = Promise.resolve();
1274
1229
  if (!EcRepository.unsigned)
1275
- p = p.then(() => {
1276
- return (eim || EcIdentityManager.default).signatureSheet(
1277
- 300000 + this.timeOffset,
1278
- this.selectedServer, null, null, this.signatureSheetHashAlgorithm
1279
- ).then((signatureSheet) => {
1280
- fd.append("signatureSheet", signatureSheet);
1281
- });
1230
+ p = p.then(() => (eim || EcIdentityManager.default).signatureSheet(
1231
+ 300000 + this.timeOffset,
1232
+ this.selectedServer, null, null, this.signatureSheetHashAlgorithm
1233
+ )).then((signatureSheet) => {
1234
+ fd.append("signatureSheet", signatureSheet);
1282
1235
  });
1283
1236
  p = p.then(() => EcRemote.postExpectingObject(
1284
1237
  this.selectedServer,
@@ -1304,11 +1257,9 @@ module.exports = class EcRepository {
1304
1257
  * @method multiget
1305
1258
  */
1306
1259
  multiget = function (urls, success, failure, eim) {
1307
- let p = this.precache(urls, null, null, eim).then(() =>
1308
- Promise.all(
1309
- urls.map((url) => EcRepository.get(url, null, null, this, eim))
1310
- ).then((things) => things.filter((r) => r))
1311
- );
1260
+ let p = this.precache(urls, null, null, eim)
1261
+ .then(() => Promise.all(urls.map((url) => EcRepository.get(url, null, null, this, eim))))
1262
+ .then((things) => things.filter(Boolean));
1312
1263
  return cassPromisify(p, success, failure);
1313
1264
  };
1314
1265
  /**
@@ -1361,7 +1312,6 @@ module.exports = class EcRepository {
1361
1312
  failure,
1362
1313
  eim
1363
1314
  ) {
1364
- let me = this;
1365
1315
  if (eim === undefined || eim == null)
1366
1316
  eim = EcIdentityManager.default;
1367
1317
  let query = originalQuery;
@@ -1397,67 +1347,62 @@ module.exports = class EcRepository {
1397
1347
  if (params != null) {
1398
1348
  fd.append("searchParams", JSON.stringify(params));
1399
1349
  }
1400
- let p = new Promise((resolve, reject) => {
1401
- resolve();
1402
- });
1403
- if (EcRepository.unsigned == true || paramObj["unsigned"] == true) {
1350
+ let p = Promise.resolve();
1351
+ // paramObj comes from the caller and may hold a non-boolean such as 1, so keep the loose comparison.
1352
+ if (EcRepository.unsigned || paramObj["unsigned"] == true) { // NOSONAR - See above.
1404
1353
  p = p.then(() => fd.append("signatureSheet", []));
1405
1354
  } else {
1406
- p = p.then(() =>
1407
- eim.signatureSheet(
1408
- 300000 + this.timeOffset,
1409
- this.selectedServer, null, null, this.signatureSheetHashAlgorithm
1410
- ).then((signatureSheet) => {
1411
- fd.append("signatureSheet", signatureSheet);
1412
- })
1413
- );
1355
+ p = p.then(() => eim.signatureSheet(
1356
+ 300000 + this.timeOffset,
1357
+ this.selectedServer, null, null, this.signatureSheetHashAlgorithm
1358
+ )).then((signatureSheet) => {
1359
+ fd.append("signatureSheet", signatureSheet);
1360
+ });
1414
1361
  }
1415
- p = p.then(() => {
1416
- return EcRemote.postExpectingObject(
1417
- this.selectedServer,
1418
- "sky/repo/search",
1419
- fd
1420
- ).then(async (results) => {
1421
- if (results == null) {
1422
- throw "Error in search. See HTTP request for more details.";
1423
- }
1424
- //If we got an array of strings, multiget it.
1425
- if (results.length > 0 && typeof (results[0]) == 'string') {
1426
- let objResults = await me.precache.call(me, results, null, null, eim, true);
1427
- if (eachSuccess) {
1428
- for (let each of objResults) {
1429
- eachSuccess(each);
1430
- }
1362
+ p = p.then(() => EcRemote.postExpectingObject(
1363
+ this.selectedServer,
1364
+ "sky/repo/search",
1365
+ fd
1366
+ )).then(async (results) => {
1367
+ if (results == null) {
1368
+ throw "Error in search. See HTTP request for more details."; // NOSONAR - Callers may catch and compare this string; an Error would change what they get.
1369
+ }
1370
+ //If we got an array of strings, multiget it.
1371
+ if (results.length > 0 && typeof (results[0]) == 'string') {
1372
+ let objResults = await this.precache(results, null, null, eim, true);
1373
+ if (eachSuccess) {
1374
+ for (let each of objResults) {
1375
+ eachSuccess(each);
1431
1376
  }
1432
- if (objResults.length == results.length)
1433
- return objResults;
1434
- //Second attempt, in case the indexed object URL doesn't match the permanent URL.
1435
- let missingUris = results
1436
- .filter(r => !objResults.some(rr => r.indexOf(rr.shortId()) != -1))
1437
- .map(u => EcRemoteLinkedData.trimVersionFromUrl(u)); //NOSONAR - Nesting functions to perform filters is normal.
1438
- if (missingUris.length > 0)
1439
- objResults.push(...await me.precache.call(me, missingUris, null, null, eim, true));
1377
+ }
1378
+ if (objResults.length == results.length)
1440
1379
  return objResults;
1441
- } else {
1442
- results = results
1443
- .map((result) => {
1444
- let d = new EcRemoteLinkedData(null, null);
1445
- d.copyFrom(result);
1446
- if (EcRepository.caching) {
1447
- EcRepository.cache[d.shortId()] = EcRepository.cache[d.id] = EcRepository.cache[EcRemoteLinkedData.veryShortId(this.selectedServer, d.getGuid())] = d;
1448
- }
1449
- if (eachSuccess != null) {
1450
- eachSuccess(d);
1451
- }
1452
- return d;
1453
- })
1454
- .filter((n) => n);
1455
- if (EcRepository.cachingSearch) {
1456
- EcRepository.cache[cacheKey] = results;
1457
- }
1458
- return results;
1380
+ //Second attempt, in case the indexed object URL doesn't match the permanent URL.
1381
+ let missingUris = results
1382
+ .filter(r => !objResults.some(rr => r.includes(rr.shortId())))
1383
+ .map(u => EcRemoteLinkedData.trimVersionFromUrl(u)); //NOSONAR - Nesting functions to perform filters is normal.
1384
+ if (missingUris.length > 0)
1385
+ objResults.push(...await this.precache(missingUris, null, null, eim, true));
1386
+ return objResults;
1387
+ } else {
1388
+ results = results
1389
+ .map((result) => {
1390
+ let d = new EcRemoteLinkedData(null, null);
1391
+ d.copyFrom(result);
1392
+ if (EcRepository.caching) {
1393
+ EcRepository.cache[d.shortId()] = EcRepository.cache[d.id] = EcRepository.cache[EcRemoteLinkedData.veryShortId(this.selectedServer, d.getGuid())] = d;
1394
+ }
1395
+ if (eachSuccess != null) {
1396
+ eachSuccess(d);
1397
+ }
1398
+ return d;
1399
+ })
1400
+ .filter(Boolean);
1401
+ if (EcRepository.cachingSearch) {
1402
+ EcRepository.cache[cacheKey] = results;
1459
1403
  }
1460
- });
1404
+ return results;
1405
+ }
1461
1406
  });
1462
1407
  return cassPromisify(p, success, failure);
1463
1408
  };
@@ -1498,7 +1443,7 @@ module.exports = class EcRepository {
1498
1443
  query += " OR ";
1499
1444
  }
1500
1445
  let id = eim.ids[i];
1501
- query += '\\*owner:"' + id.ppk.toPk().toPem() + '"';
1446
+ query += String.raw`\*owner:"` + id.ppk.toPk().toPem() + '"';
1502
1447
  }
1503
1448
  query += ")";
1504
1449
  }
@@ -1526,14 +1471,12 @@ module.exports = class EcRepository {
1526
1471
  if (window != null) {
1527
1472
  if (window.location != null) {
1528
1473
  if (window.location.protocol == "http:") {
1529
- protocols.push("http:");
1530
- protocols.push("https:");
1474
+ protocols.push("http:", "https:");
1531
1475
  }
1532
1476
  }
1533
1477
  }
1534
1478
  if (protocols.length == 0) {
1535
- protocols.push("https:");
1536
- protocols.push("http:");
1479
+ protocols.push("https:", "http:");
1537
1480
  }
1538
1481
  let hostnames = [];
1539
1482
  let servicePrefixes = [];
@@ -1568,46 +1511,41 @@ module.exports = class EcRepository {
1568
1511
  "/api/"
1569
1512
  );
1570
1513
  EcArray.removeDuplicates(servicePrefixes);
1571
- let me = this;
1572
- me.autoDetectFound = false;
1573
- for (let j = 0; j < hostnames.length; j++) {
1574
- for (let k = 0; k < servicePrefixes.length; k++) {
1575
- for (let i = 0; i < protocols.length; i++) {
1514
+ this.autoDetectFound = false;
1515
+ for (let hostname of hostnames) {
1516
+ for (let servicePrefix of servicePrefixes) {
1517
+ for (let protocol of protocols) {
1576
1518
  this.autoDetectRepositoryActualAsync(
1577
- protocols[i] +
1519
+ protocol +
1578
1520
  "//" +
1579
- hostnames[j] +
1580
- servicePrefixes[k].replace(/\/\//g, "/"),
1521
+ hostname +
1522
+ servicePrefix.replaceAll("//", "/"),
1581
1523
  success,
1582
1524
  failure
1583
1525
  );
1584
- setTimeout(function () {
1585
- if (me.autoDetectFound == false) {
1586
- let servicePrefixes = [];
1587
- servicePrefixes.push(
1526
+ setTimeout(() => {
1527
+ if (!this.autoDetectFound) {
1528
+ let customPrefixes = [];
1529
+ customPrefixes.push(
1588
1530
  "/" +
1589
1531
  window.location.pathname.split("/")[1] +
1590
1532
  "/api/custom/",
1591
1533
  "/api/custom/"
1592
1534
  );
1593
- EcArray.removeDuplicates(servicePrefixes);
1594
- for (let j = 0; j < hostnames.length; j++) {
1595
- for (
1596
- let k = 0;
1597
- k < servicePrefixes.length;
1598
- k++
1599
- ) {
1600
- for (let i = 0; i < protocols.length; i++) {
1601
- me.autoDetectRepositoryActualAsync(
1602
- protocols[i] +
1535
+ EcArray.removeDuplicates(customPrefixes);
1536
+ for (let customHostname of hostnames) {
1537
+ for (let customPrefix of customPrefixes) {
1538
+ for (let customProtocol of protocols) {
1539
+ this.autoDetectRepositoryActualAsync(
1540
+ customProtocol +
1603
1541
  "//" +
1604
- hostnames[j] +
1605
- servicePrefixes[k].replace(/\/\//g, "/"),
1542
+ customHostname +
1543
+ customPrefix.replaceAll("//", "/"),
1606
1544
  success,
1607
1545
  failure
1608
1546
  );
1609
- setTimeout(function () {
1610
- if (me.autoDetectFound == false)
1547
+ setTimeout(() => {
1548
+ if (!this.autoDetectFound)
1611
1549
  failure(
1612
1550
  "Could not find service."
1613
1551
  );
@@ -1643,21 +1581,18 @@ module.exports = class EcRepository {
1643
1581
  if (window != null) {
1644
1582
  if (window.location != null) {
1645
1583
  if (window.location.protocol == "http:") {
1646
- protocols.push("http:");
1647
- protocols.push("https:");
1584
+ protocols.push("http:", "https:");
1648
1585
  }
1649
1586
  }
1650
1587
  }
1651
1588
  if (protocols.length == 0) {
1652
- protocols.push("https:");
1653
- protocols.push("http:");
1589
+ protocols.push("https:", "http:");
1654
1590
  }
1655
1591
  let hostnames = [];
1656
1592
  let servicePrefixes = [];
1657
1593
  if (
1658
1594
  this.selectedServer != null &&
1659
- window != null &&
1660
- window.document != null
1595
+ window?.document != null
1661
1596
  ) {
1662
1597
  let e = window.document.createElement("a");
1663
1598
  if (e != null) {
@@ -1665,7 +1600,7 @@ module.exports = class EcRepository {
1665
1600
  hostnames.push(e["host"]);
1666
1601
  servicePrefixes.push(e["pathname"]);
1667
1602
  }
1668
- } else if (window != null && window.location != null) {
1603
+ } else if (window?.location != null) {
1669
1604
  if (window.location.host != null) {
1670
1605
  hostnames.push(
1671
1606
  window.location.host,
@@ -1687,9 +1622,7 @@ module.exports = class EcRepository {
1687
1622
  if (window != null) {
1688
1623
  if (window.location != null) {
1689
1624
  servicePrefixes.push(
1690
- "/" + window.location.pathname.split("/")[1] + "/api/"
1691
- );
1692
- servicePrefixes.push(
1625
+ "/" + window.location.pathname.split("/")[1] + "/api/",
1693
1626
  "/" +
1694
1627
  window.location.pathname.split("/")[1] +
1695
1628
  "/api/custom/"
@@ -1699,19 +1632,16 @@ module.exports = class EcRepository {
1699
1632
  if (hostnames.length == 0) {
1700
1633
  hostnames.push("localhost", "localhost:8080");
1701
1634
  }
1702
- servicePrefixes.push("/");
1703
- servicePrefixes.push("/service/");
1704
- servicePrefixes.push("/api/");
1705
- servicePrefixes.push("/api/custom/");
1706
- for (let j = 0; j < hostnames.length; j++) {
1707
- for (let k = 0; k < servicePrefixes.length; k++) {
1708
- for (let i = 0; i < protocols.length; i++) {
1635
+ servicePrefixes.push("/", "/service/", "/api/", "/api/custom/");
1636
+ for (let hostname of hostnames) {
1637
+ for (let servicePrefix of servicePrefixes) {
1638
+ for (let protocol of protocols) {
1709
1639
  if (
1710
1640
  this.autoDetectRepositoryActual(
1711
- protocols[i] +
1641
+ protocol +
1712
1642
  "//" +
1713
- hostnames[j] +
1714
- servicePrefixes[k].replace(/\/\//g, "/")
1643
+ hostname +
1644
+ servicePrefix.replaceAll("//", "/")
1715
1645
  )
1716
1646
  ) {
1717
1647
  EcRemote.async = true;
@@ -1732,28 +1662,27 @@ module.exports = class EcRepository {
1732
1662
  * @private
1733
1663
  */
1734
1664
  autoDetectRepositoryActualAsync = function (guess, success, failure) {
1735
- let me = this;
1736
- let successCheck = function (p1) {
1665
+ let successCheck = (p1) => {
1737
1666
  if (p1 != null) {
1738
1667
  if (p1["ping"] == "pong") {
1739
1668
  if (p1["time"] != null)
1740
- me.timeOffset = p1["time"] - new Date().getTime();
1741
- if (me.autoDetectFound == false) {
1742
- me.selectedServer = guess;
1743
- me.autoDetectFound = true;
1669
+ this.timeOffset = p1["time"] - Date.now();
1670
+ if (!this.autoDetectFound) {
1671
+ this.selectedServer = guess;
1672
+ this.autoDetectFound = true;
1744
1673
  success();
1745
1674
  }
1746
1675
  }
1747
1676
  }
1748
1677
  };
1749
- let failureCheck = function (p1) {
1678
+ let failureCheck = (p1) => {
1750
1679
  if (p1 != null) {
1751
- if (!(p1 == "")) {
1680
+ if (p1 != "") {
1752
1681
  try {
1753
- if (p1.indexOf("pong") != -1) {
1754
- if (me.autoDetectFound == false) {
1755
- me.selectedServer = guess;
1756
- me.autoDetectFound = true;
1682
+ if (p1.includes("pong")) {
1683
+ if (!this.autoDetectFound) {
1684
+ this.selectedServer = guess;
1685
+ this.autoDetectFound = true;
1757
1686
  success();
1758
1687
  }
1759
1688
  }
@@ -1789,24 +1718,23 @@ module.exports = class EcRepository {
1789
1718
  autoDetectRepositoryActual = function (guess) {
1790
1719
  let oldTimeout = EcRemote.timeout;
1791
1720
  EcRemote.timeout = 500;
1792
- let me = this;
1793
- let successCheck = function (p1) {
1721
+ let successCheck = (p1) => {
1794
1722
  if (p1 != null) {
1795
1723
  if (p1["ping"] == "pong") {
1796
1724
  if (p1["time"] != null)
1797
- me.timeOffset = p1["time"] - new Date().getTime();
1798
- me.selectedServer = guess;
1799
- me.autoDetectFound = true;
1725
+ this.timeOffset = p1["time"] - Date.now();
1726
+ this.selectedServer = guess;
1727
+ this.autoDetectFound = true;
1800
1728
  }
1801
1729
  }
1802
1730
  };
1803
- let failureCheck = function (p1) {
1731
+ let failureCheck = (p1) => {
1804
1732
  if (p1 != null) {
1805
1733
  if (p1 != "") {
1806
1734
  try {
1807
- if (p1.indexOf("pong") != -1) {
1808
- me.selectedServer = guess;
1809
- me.autoDetectFound = true;
1735
+ if (p1.includes("pong")) {
1736
+ this.selectedServer = guess;
1737
+ this.autoDetectFound = true;
1810
1738
  }
1811
1739
  } catch (ex) {
1812
1740
  // eat quietly
@@ -1933,15 +1861,14 @@ module.exports = class EcRepository {
1933
1861
  } else {
1934
1862
  service = "/sky/admin";
1935
1863
  }
1936
- let me = this;
1937
1864
  return EcRemote.getExpectingObject(
1938
1865
  this.selectedServer,
1939
1866
  service,
1940
- function (p1) {
1867
+ (p1) => {
1941
1868
  let ary = p1;
1942
- me.adminKeys = [];
1943
- for (let i = 0; i < ary.length; i++) {
1944
- me.adminKeys.push(ary[i]);
1869
+ this.adminKeys = [];
1870
+ for (let key of ary) {
1871
+ this.adminKeys.push(key);
1945
1872
  }
1946
1873
  if (success != null)
1947
1874
  success(ary);
@@ -2006,8 +1933,8 @@ module.exports = class EcRepository {
2006
1933
  if (query == null || query == "") query = queryAdd;
2007
1934
  else query = "(" + query + ") AND " + queryAdd;
2008
1935
  return cassPromisify(
2009
- repo.searchWithParams(query, paramObj, null, null, null, eim).then((p1s) => {
2010
- return Promise.all(
1936
+ repo.searchWithParams(query, paramObj, null, null, null, eim)
1937
+ .then((p1s) => Promise.all(
2011
1938
  p1s.map(
2012
1939
  async (p1) => {
2013
1940
  try {
@@ -2018,10 +1945,10 @@ module.exports = class EcRepository {
2018
1945
  }
2019
1946
  }
2020
1947
  )
2021
- ).then((results) =>
2022
- results.filter(x => x).map((result) => factory().copyFrom(result))
2023
- );
2024
- }),
1948
+ ))
1949
+ .then((results) =>
1950
+ results.filter(Boolean).map((result) => factory().copyFrom(result))
1951
+ ),
2025
1952
  success,
2026
1953
  failure
2027
1954
  );