cassproject 1.5.7 → 1.5.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cassproject",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "description": "Competency and Skills Service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -71,11 +71,11 @@
71
71
  }
72
72
  ],
73
73
  "dependencies": {
74
- "axios": "^0.26.1",
74
+ "axios": "^0.27.2",
75
75
  "base64-arraybuffer": "^1.0.2",
76
76
  "forge": "^2.3.0",
77
77
  "form-data": "^4.0.0",
78
- "http2-wrapper": "^2.1.10",
78
+ "http2-wrapper": "^2.1.11",
79
79
  "jsonld": "^5.2.0",
80
80
  "node-forge": "^1.3.1",
81
81
  "papaparse": "^5.3.2",
@@ -106,22 +106,23 @@
106
106
  },
107
107
  "homepage": "https://github.com/cassproject/cass-npm#readme",
108
108
  "devDependencies": {
109
- "@babel/core": "^7.17.9",
110
- "@babel/preset-env": "^7.16.11",
109
+ "@babel/core": "^7.17.10",
110
+ "@babel/preset-env": "^7.17.10",
111
111
  "@cypress/browserify-preprocessor": "^3.0.2",
112
+ "@cypress/vite-dev-server": "^2.2.3",
112
113
  "@cypress/webpack-preprocessor": "^5.11.1",
113
114
  "babel-eslint": "^10.1.0",
114
- "babel-loader": "^8.2.4",
115
+ "babel-loader": "^8.2.5",
115
116
  "babel-plugin-transform-remove-strict-mode": "^0.0.2",
116
117
  "chai": "^4.3.6",
117
118
  "convert-hrtime": "^5.0.0",
118
- "cypress": "^9.5.4",
119
- "eslint": "^8.13.0",
120
- "mocha": "^9.2.2",
119
+ "cypress": "^9.6.1",
120
+ "eslint": "^8.15.0",
121
+ "mocha": "^10.0.0",
121
122
  "node-polyfill-webpack-plugin": "^1.1.4",
122
- "nodemon": "^2.0.15",
123
+ "nodemon": "^2.0.16",
123
124
  "wait-on": "^6.0.1",
124
- "webpack": "^5.72.0",
125
+ "webpack": "^5.72.1",
125
126
  "webpack-cli": "^4.9.2"
126
127
  }
127
128
  }
@@ -44,19 +44,29 @@ module.exports = class EcRsaOaepAsyncWorker {
44
44
  }
45
45
  static createWorker(index) {
46
46
  let wkr = null;
47
+ let me = this;
47
48
  try {
48
49
  wkr = new Worker(url.pathToFileURL(path.resolve(__dirname, 'forgeAsync.js')));
49
50
  } catch (e) {
50
51
  console.trace(e);
51
52
  try {
52
53
  wkr = new Worker(path.resolve(__dirname, 'forgeAsync.js'));
54
+ wkr.onerror = function(event) {
55
+ wkr = null;
56
+ console.log(event);
57
+ wkr = new Worker(path.resolve(__dirname, 'cass-editor/forgeAsync.js'));
58
+ if (wkr != null) {
59
+ // replace errored worker at index
60
+ me.w[index] = (new PromiseWorker(wkr));
61
+ }
62
+ }
53
63
  } catch (e) {
54
64
  console.trace(e);
55
65
  // Eat quietly.
56
66
  }
57
67
  }
58
68
  if (wkr != null)
59
- this.w.push(new PromiseWorker(wkr));
69
+ this.w[index] = (new PromiseWorker(wkr));
60
70
  }
61
71
  /**
62
72
  * Asynchronous form of {{#crossLink
@@ -73,7 +73,8 @@ module.exports = class EcFrameworkGraph extends EcDirectedGraph {
73
73
  failure, this.eim
74
74
  );
75
75
  }).catch((err) => {
76
- failure;
76
+ if (failure != null)
77
+ failure(err);
77
78
  });
78
79
  }
79
80
  async handleCacheElement(d, framework) {
@@ -873,6 +873,7 @@ describe("EcFrameworkGraph", () => {
873
873
  });
874
874
  return result;
875
875
  }).catch((err) => {
876
+ console.error(err);
876
877
  assert.fail(err);
877
878
  }).finally(async () => {
878
879
  await deleteById(f.shortId());
@@ -29,15 +29,16 @@ if (global.axios == null)
29
29
  let req;
30
30
  config.transport = {
31
31
  request: function request(options, handleResponse) {
32
- if (http2Enabled[options.hostname])
33
- req = http2.request(options, handleResponse);
34
- else
35
- {
36
- req = https.request(options, handleResponse);
37
- if (http2Enabled[options.hostname] == null)
38
- global.httpOptions.push(options);
39
- }
40
- return req;
32
+ options.ca = global.ca;
33
+ if (http2Enabled[options.hostname])
34
+ req = http2.request(options, handleResponse);
35
+ else
36
+ {
37
+ req = https.request(options, handleResponse);
38
+ if (http2Enabled[options.hostname] == null)
39
+ global.httpOptions.push(options);
40
+ }
41
+ return req;
41
42
  },
42
43
  };
43
44
  const ret = adapter(config);
@@ -66,7 +67,37 @@ if (global.axios == null)
66
67
  axiosOptions.http2 = true;
67
68
  axiosOptions.adapter = http2AdapterEnhancer(axios.defaults.adapter);
68
69
  }
70
+ } else {
71
+ if (isNode)
72
+ {
73
+ let https;
74
+ try {
75
+ https = require("https");
76
+ } catch(e) {
77
+ console.log(e);
78
+ }
79
+ function httpsAdapterEnhancer(adapter) {
80
+ return async (config) => {
81
+ if (process.env.HTTPS != null ? process.env.HTTPS.trim() == 'true' : false && config.url.startsWith("https")) {
82
+ let req;
83
+ config.transport = {
84
+ request: function request(options, handleResponse) {
85
+ options.ca = global.ca;
86
+ req = https.request(options, handleResponse);
87
+ return req;
88
+ },
89
+ };
90
+ const ret = adapter(config);
91
+ return ret;
92
+ } else {
93
+ return adapter(config);
94
+ }
95
+ };
96
+ }
97
+ axiosOptions.adapter = httpsAdapterEnhancer(axios.defaults.adapter);
98
+ }
69
99
  }
100
+
70
101
  const { cassPromisify } = require("../promises/helpers");
71
102
 
72
103
  /**
@@ -170,6 +170,22 @@ module.exports = class CTDLASNCSVImport {
170
170
  }
171
171
  f["ceasn:educationLevelType"] = val;
172
172
  }
173
+ if (f["ceasn:publicationStatusType"] != null) {
174
+ let val = f["ceasn:publicationStatusType"];
175
+ if (!EcArray.isArray(val)) {
176
+ val = [val];
177
+ }
178
+ for (let i = val.length-1; i >=0; i--) {
179
+ if (!val[i].startsWith('http')) {
180
+ if (val[i] === "Deprecated" || val[i] === "Published" || val[i] === "Draft" ) {
181
+ val[i] = "http://credreg.net/ctdlasn/vocabs/publicationStatus/" + val[i];
182
+ } else {
183
+ val.splice(i, 1);
184
+ }
185
+ }
186
+ }
187
+ f["ceasn:publicationStatusType"] = val;
188
+ }
173
189
  frameworks[f.shortId()] = f;
174
190
  frameworkRows[f.shortId()] = e;
175
191
  f["ceasn:hasChild"] = null;
@@ -331,6 +347,22 @@ module.exports = class CTDLASNCSVImport {
331
347
  }
332
348
  f["ceasn:educationLevelType"] = val;
333
349
  }
350
+ if (f["ceasn:publicationStatusType"] != null) {
351
+ let val = f["ceasn:publicationStatusType"];
352
+ if (!EcArray.isArray(val)) {
353
+ val = [val];
354
+ }
355
+ for (let i = val.length-1; i >=0; i--) {
356
+ if (!val[i].startsWith('http')) {
357
+ if (val[i] === "Deprecated" || val[i] === "Published" || val[i] === "Draft" ) {
358
+ val[i] = "http://credreg.net/ctdlasn/vocabs/publicationStatus/" + val[i];
359
+ } else {
360
+ val.splice(i, 1);
361
+ }
362
+ }
363
+ }
364
+ f["ceasn:publicationStatusType"] = val;
365
+ }
334
366
  if (e["ceasn:isChildOf"] != null) {
335
367
  CTDLASNCSVImport.createEachRelation(
336
368
  e,
@@ -639,6 +671,22 @@ module.exports = class CTDLASNCSVImport {
639
671
  }
640
672
  f["ceasn:educationLevelType"] = val;
641
673
  }
674
+ if (f["ceasn:publicationStatusType"] != null) {
675
+ let val = f["ceasn:publicationStatusType"];
676
+ if (!EcArray.isArray(val)) {
677
+ val = [val];
678
+ }
679
+ for (let i = val.length-1; i >=0; i--) {
680
+ if (!val[i].startsWith('http')) {
681
+ if (val[i] === "Deprecated" || val[i] === "Published" || val[i] === "Draft" ) {
682
+ val[i] = "http://credreg.net/ctdlasn/vocabs/publicationStatus/" + val[i];
683
+ } else {
684
+ val.splice(i, 1);
685
+ }
686
+ }
687
+ }
688
+ f["ceasn:publicationStatusType"] = val;
689
+ }
642
690
  if (e["ceasn:broadAlignment"] != null) {
643
691
  CTDLASNCSVImport.createRelations(
644
692
  e,
@@ -825,6 +873,20 @@ module.exports = class CTDLASNCSVImport {
825
873
  var thisVal = thisKey[i].trim();
826
874
  thisKey[i] = thisVal;
827
875
  }
876
+ if (typeof thisKey[i] == "string" &&
877
+ thisKey[i].startsWith("ce-") &&
878
+ key != "ceterms:ctid"
879
+ ) {
880
+ var id = CTDLASNCSVImport.getIdFromCtid(
881
+ thisKey[i],
882
+ endpoint,
883
+ repo,
884
+ context,
885
+ type,
886
+ key
887
+ );
888
+ thisKey[i] = id;
889
+ }
828
890
  }
829
891
  } else if (
830
892
  thisKey.startsWith("ce-") &&
@@ -61,12 +61,15 @@ module.exports = class EcAssertion extends Assertion {
61
61
  async setSubject(pk) {
62
62
  var owners = [];
63
63
  var readers = null;
64
- if (this.reader == null) readers = [];
65
- else readers = JSON.parse(JSON.stringify(this.reader));
64
+ if (this.reader == null)
65
+ readers = [];
66
+ else
67
+ readers = JSON.parse(JSON.stringify(this.reader));
66
68
  if (this.subject != null) {
67
- if (this.subject.owner != null) owners.concat(this.subject.owner);
69
+ if (this.subject.owner != null)
70
+ owners = owners.concat(this.subject.owner);
68
71
  if (this.subject.reader != null)
69
- readers.concat(this.subject.reader);
72
+ readers = readers.concat(this.subject.reader);
70
73
  }
71
74
  if (this.owner != null) owners = owners.concat(this.owner);
72
75
  readers.push(pk.toPem());
@@ -82,12 +85,15 @@ module.exports = class EcAssertion extends Assertion {
82
85
  var me = this;
83
86
  var owners = [];
84
87
  var readers = null;
85
- if (this.reader == null) readers = [];
86
- else readers = JSON.parse(JSON.stringify(this.reader));
88
+ if (this.reader == null)
89
+ readers = [];
90
+ else
91
+ readers = JSON.parse(JSON.stringify(this.reader));
87
92
  if (this.subject != null) {
88
- if (this.subject.owner != null) owners.concat(this.subject.owner);
93
+ if (this.subject.owner != null)
94
+ owners = owners.concat(this.subject.owner);
89
95
  if (this.subject.reader != null)
90
- readers.concat(this.subject.reader);
96
+ readers = readers.concat(this.subject.reader);
91
97
  }
92
98
  if (this.owner != null) owners = owners.concat(this.owner);
93
99
  readers.push(pk.toPem());
@@ -351,26 +351,57 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
351
351
  var cs = arg0;
352
352
  me.pad = cs.pad;
353
353
  me.token = cs.token;
354
+ var shouldCommit = false;
354
355
  if (cs.credentials != null)
355
356
  for (var i = 0; i < cs.credentials.length; i++) {
356
357
  var c = cs.credentials[i];
357
- var identity = await EcIdentity.fromCredential(
358
+ let identity = null;
359
+ identity = await EcIdentity.fromCredential(
358
360
  c,
359
361
  me.secretWithSalt,
360
362
  me.server
361
363
  );
364
+ if (identity.ppk == null)
365
+ {
366
+ //Try alternate method of getting credential.
367
+ let newSecretWithSalt = forge.util.encode64(forge.pkcs5.pbkdf2('',this.secretSalt,this.secretIterations,32));
368
+ identity = await EcIdentity.fromCredential(
369
+ c,
370
+ newSecretWithSalt,
371
+ me.server
372
+ );
373
+ shouldCommit = true;
374
+ }
375
+ if (identity.ppk == null)
376
+ throw new Error("Could not retreive encrypted ppks from credential packet.")
362
377
  eim.addIdentity(identity);
363
378
  }
364
379
  if (cs.contacts != null)
365
380
  for (var i = 0; i < cs.contacts.length; i++) {
366
381
  var c = cs.contacts[i];
367
- var identity = await EcContact.fromEncryptedContact(
382
+ let identity = null;
383
+ identity = await EcContact.fromEncryptedContact(
368
384
  c,
369
385
  me.secretWithSalt,
370
386
  me.server
371
387
  );
388
+ if (identity.ppk == null)
389
+ {
390
+ //Try alternate method of getting contact.
391
+ let newSecretWithSalt = forge.util.encode64(forge.pkcs5.pbkdf2('',this.secretSalt,this.secretIterations,32));
392
+ identity = await EcContact.fromEncryptedContact(
393
+ c,
394
+ newSecretWithSalt,
395
+ me.server
396
+ );
397
+ shouldCommit = true;
398
+ }
399
+ if (identity.ppk == null)
400
+ throw new Error("Could not retreive encrypted pks from credential packet.")
372
401
  eim.addContact(identity);
373
402
  }
403
+ if (shouldCommit)
404
+ await me.commit(null,null,eim);
374
405
  return eim;
375
406
  },
376
407
  function (arg0) {
@@ -503,8 +534,7 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
503
534
  */
504
535
  splicePasswords(passwords) {
505
536
  var passwordSplice = "";
506
- // eslint-disable-next-line for-direction
507
- for (var charIndex = 0; charIndex > 0; charIndex++) {
537
+ for (var charIndex = 0; true; charIndex++) {
508
538
  var foundAny = false;
509
539
  for (
510
540
  var passwordIndex = 0;
@@ -0,0 +1,21 @@
1
+ let chai = require("chai");
2
+ const EcAes = require("../../../../../com/eduworks/ec/crypto/EcAes");
3
+ const EcPpk = require("../../../../../com/eduworks/ec/crypto/EcPpk");
4
+ const EcIdentity = require("../EcIdentity");
5
+ const EcIdentityManager = require("../EcIdentityManager");
6
+ const EcRemoteIdentityManager = require("./EcRemoteIdentityManager");
7
+
8
+ var should = chai.should();
9
+ var expect = chai.expect;
10
+ var assert = chai.assert;
11
+
12
+ describe("EcRemoteIdentityManager", () => {
13
+ it('splicePasswords', async () => {
14
+ let rim= new EcRemoteIdentityManager();
15
+ assert.equal(rim.splicePasswords(["abc","123"]),"a1b2c3");
16
+ assert.equal(rim.splicePasswords(["abcde","123"]),"a1b2c3de");
17
+ assert.equal(rim.splicePasswords(["abc","12345"]),"a1b2c345");
18
+ assert.equal(rim.splicePasswords(["","123"]),"123");
19
+ assert.equal(rim.splicePasswords(["abc",""]),"abc");
20
+ });
21
+ });
@@ -119,9 +119,10 @@ module.exports = class Assertion extends schema.CreativeWork {
119
119
  var readers = this.reader;
120
120
  if (readers == null) readers = [];
121
121
  if (this.subject != null) {
122
- if (this.subject.owner != null) owners.concat(this.subject.owner);
122
+ if (this.subject.owner != null)
123
+ owners = owners.concat(this.subject.owner);
123
124
  if (this.subject.reader != null)
124
- readers.concat(this.subject.reader);
125
+ readers = readers.concat(this.subject.reader);
125
126
  }
126
127
  if (this.owner != null) owners = owners.concat(this.owner);
127
128
  readers.push(pk.toPem());