cassproject 1.5.3 → 1.5.6

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
@@ -38,6 +38,7 @@ Development unit tests presume you have a CaSS Repository running on `localhost:
38
38
  * Review dependencies, autocomplete version numbers
39
39
  * Increment version number in package.json and yuidoc.json
40
40
  * Update documentation, `npm run docs`
41
+ * Delete yuidocs from package.json, delete package-lock.json
41
42
  * `npm install`
42
43
  * `npm test` - Must not fail any tests.
43
44
  * Commit changes to GitHub.
package/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ if (typeof window !== "undefined" && window) {
2
+ window.global = window;
3
+ window.module = {};
4
+ }
1
5
  global.generateUUID = function () {
2
6
  var d = new Date().getTime();
3
7
  if (typeof window !== "undefined" && window && window.performance && typeof window.performance.now === "function") {
@@ -51,8 +55,8 @@ global.cassReturnNullAsPromise = function (success, failure) {
51
55
  return p;
52
56
  };
53
57
 
54
- global.crypto = null;
55
58
  try {
59
+ global.crypto = null;
56
60
  global.crypto = require('crypto').webcrypto;
57
61
  } catch (err) {
58
62
  console.log("Webcrypto not available. Tests will fail. Please upgrade, if possible, to Node 16. Non-test mode will fallback to slower cryptograpy methods.: " + err);
@@ -63,8 +67,7 @@ if (global.forge === undefined)
63
67
  else
64
68
  var forge = global.forge;
65
69
 
66
-
67
- JavalikeEquals = function (value) {
70
+ let JavalikeEquals = function (value) {
68
71
  if (value == null)
69
72
  return false;
70
73
  if (value.valueOf)
@@ -72,7 +75,7 @@ JavalikeEquals = function (value) {
72
75
  return this === value;
73
76
  };
74
77
 
75
- JavalikeGetClass = function () {
78
+ let JavalikeGetClass = function () {
76
79
  return this.constructor;
77
80
  };
78
81
 
package/package.json CHANGED
@@ -1,39 +1,55 @@
1
1
  {
2
2
  "name": "cassproject",
3
- "version": "1.5.3",
3
+ "version": "1.5.6",
4
4
  "description": "Competency and Skills Service",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "npm run test15 && npm run test14 && npm run test13 && npm run test12",
8
8
  "testCassTest": "npm run testkill && docker run -d --name cass-test -p80:80 cass-test && wait-on http://localhost/api/ping && npm run testCypressEdge && npm run testCypress && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testkill",
9
- "test15": "npm run testkill && docker run -d --name cass-test -p80:80 cassproject/cass:1.5.1 && wait-on http://localhost/api/ping && npm run testCypressEdge && npm run testCypress && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testkill",
9
+ "testDevHttps": "npm run testkill && docker run -d --name cass-test -p443:80 -e HTTPS=true cassproject/cass:dev && wait-on https://localhost/api/ping && npm run testCypressEdgeHttps && npm run testCypressHttps && npm run testNode16Https && npm run testNode15Https && npm run testNode14Https && npm run testNode13Https && npm run testNode12Https",
10
+ "test15Https": "npm run testkill && docker run -d --name cass-test -p443:80 -e HTTPS=true cassproject/cass:1.5.4 && wait-on https://localhost/api/ping && npm run testCypressEdgeHttps && npm run testCypressHttps && npm run testNode16Https && npm run testkill",
11
+ "test15": "npm run testkill && docker run -d --name cass-test -p80:80 cassproject/cass:1.5.5 && wait-on http://localhost/api/ping && npm run testCypressEdge && npm run testCypress && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testkill",
10
12
  "test14": "npm run testkill && docker run -d --name cass-test -p80:80 cassproject/cass:1.4.4 && wait-on http://localhost/api/ping && npm run testCypressEdge && npm run testCypress && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testkill",
11
13
  "test13": "npm run testkill && docker run -d --name cass-test -p80:80 cassproject/cass:1.3.18 && wait-on http://localhost/api/ping && npm run testCypressEdge && npm run testCypress && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testkill",
12
14
  "test12": "npm run testkill && docker run -d --name cass-test -p80:80 cassproject/cass:1.2.44 && wait-on http://localhost/api/ping && npm run testCypressEdge && npm run testCypress && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testkill",
13
15
  "testkill": "docker kill cass-test | exit 0 && docker rm cass-test | exit 0",
14
16
  "testNode16": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node16 -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
17
+ "testNode16Https": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node16https -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
15
18
  "testNode15": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node15 -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
19
+ "testNode15Https": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node15https -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
16
20
  "testNode14": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node14 -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
21
+ "testNode14Https": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node14https -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
17
22
  "testNode13": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node13 -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
23
+ "testNode13Https": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node13https -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
18
24
  "testNode12": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node12 -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
25
+ "testNode12Https": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/node12https -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
19
26
  "testCypress": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/cypress -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
20
27
  "testCypressEdge": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/cypressEdge -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
28
+ "testCypressHttps": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/cypressHttps -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
29
+ "testCypressEdgeHttps": "docker kill npm-cass & docker rm -f npm-cass & docker build --progress plain -f docker/cypressEdgeHttps -t npm-cass . & docker run --network=\"host\" --name npm-cass npm-cass",
21
30
  "autotest": "nodemon test.js",
22
31
  "autoindex": "nodemon index.js",
23
32
  "mocha": "mocha -b src/**/*.test.js",
33
+ "mocha:clientSideCertificates": "set CASS_LOOPBACK=https://localhost/api/&& mocha -b src/**/*.test.js",
24
34
  "mochaGraph": "mocha -b src/com/eduworks/ec/graph/**/*.test.js",
25
35
  "automocha": "nodemon --exec \"npm run mocha\"",
26
36
  "automochaGraph": "nodemon --exec \"npm run mochaGraph\"",
27
- "automocha:clientSideCertificates": "set CASS_LOOPBACK=https://localhost/api/&& nodemon --exec \"npm run mocha\"",
37
+ "automocha:clientSideCertificates": "nodemon --exec \"npm run mocha:clientSideCertificates\"",
28
38
  "lint": "eslint src -c .eslintrc.js --ext .js --fix",
29
39
  "docs": "npm install yuidocjs yuidoc-ember-cli-theme && yuidoc -c yuidoc.json -o docs -e .js src && npm remove yuidocjs yuidoc-ember-cli-theme",
30
40
  "doclint": "npm install yuidocjs yuidoc-ember-cli-theme && yuidoc --lint -c yuidoc.json -o docs -e .js src",
31
41
  "browserify:cypress:open": "cypress open --config-file cypressBrowserify.json",
42
+ "browserify:cypress:open:https": "cypress open -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.json",
32
43
  "webpack:cypress:open": "cypress open --config-file cypressWebpack.json",
44
+ "webpack:cypress:open:https": "cypress open -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.json",
33
45
  "browserify:cypress": "cypress run --config-file cypressBrowserify.json --headless --browser chrome",
46
+ "browserify:cypressHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.json --headless --browser chrome",
34
47
  "browserify:cypressEdge": "cypress run --config-file cypressBrowserify.json --headless --browser edge",
48
+ "browserify:cypressEdgeHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.json --headless --browser edge",
35
49
  "webpack:cypress": "cypress run --config-file cypressWebpack.json --headless --browser chrome",
36
- "webpack:cypressEdge": "cypress run --config-file cypressWebpack.json --headless --browser edge"
50
+ "webpack:cypressHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.json --headless --browser chrome",
51
+ "webpack:cypressEdge": "cypress run --config-file cypressWebpack.json --headless --browser edge",
52
+ "webpack:cypressEdgeHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.json --headless --browser edge"
37
53
  },
38
54
  "contributors": [
39
55
  {
@@ -54,13 +70,14 @@
54
70
  }
55
71
  ],
56
72
  "dependencies": {
57
- "axios": "^0.26.0",
73
+ "axios": "^0.26.1",
58
74
  "base64-arraybuffer": "^1.0.2",
59
75
  "forge": "^2.3.0",
60
76
  "form-data": "^4.0.0",
77
+ "http2-wrapper": "^2.1.10",
61
78
  "jsonld": "^5.2.0",
62
- "node-forge": "^1.2.1",
63
- "papaparse": "^5.3.1",
79
+ "node-forge": "^1.3.1",
80
+ "papaparse": "^5.3.2",
64
81
  "pem-jwk": "^2.0.0",
65
82
  "promise-worker": "^2.0.1",
66
83
  "rdf-canonize": "^3.0.0",
@@ -88,22 +105,22 @@
88
105
  },
89
106
  "homepage": "https://github.com/cassproject/cass-npm#readme",
90
107
  "devDependencies": {
91
- "@babel/core": "^7.17.0",
108
+ "@babel/core": "^7.17.9",
92
109
  "@babel/preset-env": "^7.16.11",
93
110
  "@cypress/browserify-preprocessor": "^3.0.2",
94
- "@cypress/webpack-preprocessor": "^5.11.0",
111
+ "@cypress/webpack-preprocessor": "^5.11.1",
95
112
  "babel-eslint": "^10.1.0",
96
- "babel-loader": "^8.2.3",
113
+ "babel-loader": "^8.2.4",
97
114
  "babel-plugin-transform-remove-strict-mode": "^0.0.2",
98
115
  "chai": "^4.3.6",
99
116
  "convert-hrtime": "^5.0.0",
100
- "cypress": "^9.4.1",
101
- "eslint": "^8.8.0",
102
- "mocha": "^9.2.0",
117
+ "cypress": "^9.5.3",
118
+ "eslint": "^8.12.0",
119
+ "mocha": "^9.2.2",
103
120
  "node-polyfill-webpack-plugin": "^1.1.4",
104
121
  "nodemon": "^2.0.15",
105
- "wait-on": "^6.0.0",
106
- "webpack": "^5.68.0",
122
+ "wait-on": "^6.0.1",
123
+ "webpack": "^5.71.0",
107
124
  "webpack-cli": "^4.9.2"
108
125
  }
109
126
  }
@@ -127,6 +127,9 @@ describe("EcFrameworkGraph", () => {
127
127
  it('init', async () => {
128
128
  let newId1;
129
129
  EcIdentityManager.default.clearIdentities();
130
+ if ((typeof Cypress !== 'undefined') && Cypress != null && Cypress.env != null)
131
+ process.env.CASS_LOOPBACK = Cypress.env('CASS_LOOPBACK');
132
+ console.log(process.env.CASS_LOOPBACK);
130
133
  await repo.init(process.env.CASS_LOOPBACK || "http://localhost/api/", null, null, console.log);
131
134
  newId1 = null;
132
135
  if (EcIdentityManager.default.ids.length > 0)
@@ -1,5 +1,46 @@
1
- if (global.axios == null)
1
+ global.axiosOptions = {};
2
+ var isNode = false;
3
+ if (typeof process === 'object') {
4
+ if (typeof process.versions === 'object') {
5
+ if (typeof process.versions.node !== 'undefined') {
6
+ isNode = true;
7
+ }
8
+ }
9
+ }if (global.axios == null)
10
+ {
2
11
  global.axios = require("axios");
12
+ if (isNode)
13
+ {
14
+ let http2;
15
+ try {
16
+ http2 = require("http2-wrapper");
17
+ } catch(e) {
18
+ console.log(e);
19
+ }
20
+ function http2AdapterEnhancer(adapter) {
21
+ return async (config) => {
22
+ if (config.http2 && config.url.startsWith("https")) {
23
+ let req;
24
+ config.transport = {
25
+ request: function request(options, handleResponse) {
26
+ req = http2.request(options, handleResponse);
27
+ return req;
28
+ },
29
+ };
30
+ const ret = adapter(config);
31
+ // Remove the axios action `socket.setKeepAlive` because the HTTP/2 sockets should not be directly manipulated
32
+ const listeners = req.listeners("socket");
33
+ if (listeners.length) req.removeListener("socket", listeners[0]);
34
+ return ret;
35
+ } else {
36
+ return adapter(config);
37
+ }
38
+ };
39
+ }
40
+ axiosOptions.http2 = true;
41
+ axiosOptions.adapter = http2AdapterEnhancer(axios.defaults.adapter);
42
+ }
43
+ }
3
44
  const { cassPromisify } = require("../promises/helpers");
4
45
 
5
46
  /**
@@ -121,10 +162,13 @@ module.exports = class EcRemote {
121
162
  postHeaders = {
122
163
  'content-type': 'multipart/form-data'
123
164
  }
165
+ if (fd.getLengthSync != null)
166
+ postHeaders["content-length"] = fd.getLengthSync();
124
167
  if (headers !== undefined && headers != null)
125
168
  for (let header in headers) postHeaders[header] = headers[header];
126
169
  let p = axios
127
170
  .post(url, fd, {
171
+ ...axiosOptions,
128
172
  headers: postHeaders,
129
173
  maxContentLength: Infinity,
130
174
  maxBodyLength: Infinity
@@ -178,7 +222,7 @@ module.exports = class EcRemote {
178
222
  var url = EcRemote.urlAppend(server, service);
179
223
  url = EcRemote.upgradeHttpToHttps(url);
180
224
  let p = axios
181
- .get(url)
225
+ .get(url,axiosOptions)
182
226
  .then((response) => {
183
227
  return response.data;
184
228
  })
@@ -221,6 +265,7 @@ module.exports = class EcRemote {
221
265
  url = EcRemote.upgradeHttpToHttps(url);
222
266
  let p = axios
223
267
  .delete(url, {
268
+ ...axiosOptions,
224
269
  headers: { signatureSheet: signatureSheet }
225
270
  })
226
271
  .then((response) => {
@@ -31,6 +31,7 @@ module.exports = class EcRepository {
31
31
  static cache = {};
32
32
  static fetching = {};
33
33
  static repos = [];
34
+ static defaultPlugins = [];
34
35
  adminKeys = null;
35
36
  selectedServer = null;
36
37
  selectedServerProxy = null;
@@ -52,6 +53,9 @@ module.exports = class EcRepository {
52
53
  identity.ppk = new EcPpkFacade(EcPk.fromPem(p1.ssoPublicKey));
53
54
  EcIdentityManager.default.addIdentity(identity);
54
55
  }
56
+ if (p1["plugins"]) {
57
+ EcRepository.defaultPlugins = JSON.parse(p1["plugins"]);
58
+ }
55
59
  if (p1["ping"] == "pong") {
56
60
  if (loginObjectCallback != null)
57
61
  loginObjectCallback(p1);
@@ -55,6 +55,11 @@ if (fs.readFileSync != null) {
55
55
  https.globalAgent.options.key = fs.readFileSync('client.key');
56
56
  https.globalAgent.options.cert = fs.readFileSync('client.crt');
57
57
  https.globalAgent.options.ca = fs.readFileSync('ca.crt');
58
+ // global.axiosOptions.key = fs.readFileSync('client.key');
59
+ // global.axiosOptions.cert = fs.readFileSync('client.crt');
60
+ // global.axiosOptions.ca = fs.readFileSync('ca.crt');
61
+ //When http2 supports client side self-signed certificates, don't use this.
62
+ process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
58
63
  }
59
64
 
60
65
  let changeNameAndSaveAndCheck = async (rld) => {
@@ -86,6 +91,9 @@ describe("EcRepository", () => {
86
91
  let rld = null;
87
92
  it('create', async () => {
88
93
  EcIdentityManager.default.clearIdentities();
94
+ if ((typeof Cypress !== 'undefined') && Cypress != null && Cypress.env != null)
95
+ process.env.CASS_LOOPBACK = Cypress.env('CASS_LOOPBACK');
96
+ console.log(process.env.CASS_LOOPBACK);
89
97
  await repo.init(process.env.CASS_LOOPBACK || "http://localhost/api/", null, null, console.log);
90
98
  if (EcIdentityManager.default.ids.length > 0)
91
99
  newId1 = EcIdentityManager.default.ids[0];