cassproject 1.5.19 → 1.5.22
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 +7 -0
- package/index.js +12 -14
- package/package.json +15 -16
- package/src/com/eduworks/ec/array/EcArray.js +6 -6
- package/src/com/eduworks/ec/array/EcArray.test.js +3 -6
- package/src/com/eduworks/ec/array/EcAsyncHelper.js +9 -10
- package/src/com/eduworks/ec/array/EcObject.test.js +3 -3
- package/src/com/eduworks/ec/crypto/EcAes.test.js +3 -3
- package/src/com/eduworks/ec/crypto/EcAesCtr.js +6 -6
- package/src/com/eduworks/ec/crypto/EcAesCtr.test.js +19 -19
- package/src/com/eduworks/ec/crypto/EcAesCtrAsync.js +11 -12
- package/src/com/eduworks/ec/crypto/EcAesCtrAsync.test.js +39 -39
- package/src/com/eduworks/ec/crypto/EcAesCtrAsyncWorker.js +5 -5
- package/src/com/eduworks/ec/crypto/EcAesCtrAsyncWorker.test.js +29 -29
- package/src/com/eduworks/ec/crypto/EcCrypto.js +11 -14
- package/src/com/eduworks/ec/crypto/EcCrypto.test.js +20 -7
- package/src/com/eduworks/ec/crypto/EcPk.js +5 -6
- package/src/com/eduworks/ec/crypto/EcPpk.js +12 -13
- package/src/com/eduworks/ec/crypto/EcPpk.test.js +8 -8
- package/src/com/eduworks/ec/crypto/EcPpkFacade.js +3 -3
- package/src/com/eduworks/ec/crypto/EcRsaOaep.js +6 -6
- package/src/com/eduworks/ec/crypto/EcRsaOaep.test.js +47 -47
- package/src/com/eduworks/ec/crypto/EcRsaOaepAsync.js +20 -18
- package/src/com/eduworks/ec/crypto/EcRsaOaepAsync.test.js +50 -50
- package/src/com/eduworks/ec/crypto/EcRsaOaepAsyncWorker.js +15 -15
- package/src/com/eduworks/ec/crypto/EcRsaOaepAsyncWorker.test.js +50 -50
- package/src/com/eduworks/ec/graph/EcDirectedGraph.js +43 -43
- package/src/com/eduworks/ec/graph/EcFrameworkGraph.js +9 -9
- package/src/com/eduworks/ec/graph/EcFrameworkGraph.test.js +111 -114
- package/src/com/eduworks/ec/graph/Triple.js +1 -1
- package/src/com/eduworks/ec/remote/EcRemote.js +14 -9
- package/src/com/eduworks/ec/task/EcAsyncTask.js +12 -12
- package/src/com/eduworks/ec/task/EcAsyncTaskManager.js +13 -13
- package/src/com/eduworks/ec/task/EcAsyncTaskWorker.js +3 -3
- package/src/com/eduworks/ec/task/Task.js +4 -4
- package/src/com/eduworks/schema/cfd/competency/CfdAlignment.js +2 -2
- package/src/com/eduworks/schema/cfd/competency/CfdAssessment.js +8 -8
- package/src/com/eduworks/schema/cfd/competency/CfdFramework.js +9 -9
- package/src/com/eduworks/schema/cfd/competency/CfdReference.js +3 -3
- package/src/com/eduworks/schema/ebac/EbacContact.js +2 -2
- package/src/com/eduworks/schema/ebac/EbacContactGrant.js +2 -2
- package/src/com/eduworks/schema/ebac/EbacCredential.js +2 -2
- package/src/com/eduworks/schema/ebac/EbacCredentialCommit.js +2 -2
- package/src/com/eduworks/schema/ebac/EbacCredentialRequest.js +2 -2
- package/src/com/eduworks/schema/ebac/EbacCredentials.js +2 -2
- package/src/com/eduworks/schema/ebac/EbacEncryptedSecret.js +5 -5
- package/src/com/eduworks/schema/ebac/EbacEncryptedValue.js +6 -6
- package/src/com/eduworks/schema/ebac/EbacSignature.js +1 -1
- package/src/com/eduworks/schema/pebl/eXtension/ExtContent.js +5 -5
- package/src/com/eduworks/schema/pebl/eXtension/ExtInstitution.js +7 -7
- package/src/com/eduworks/schema/pebl/eXtension/ExtPerson.js +5 -5
- package/src/com/eduworks/schema/pebl/eXtension/ExtResource.js +3 -3
- package/src/org/cass/competency/EcAlignment.js +12 -12
- package/src/org/cass/competency/EcCompetency.js +13 -13
- package/src/org/cass/competency/EcDirectory.js +4 -4
- package/src/org/cass/competency/EcFramework.js +20 -20
- package/src/org/cass/competency/EcLevel.js +4 -4
- package/src/org/cass/competency/EcRollupRule.js +2 -2
- package/src/org/cass/exporter/CSVExport.js +37 -37
- package/src/org/cass/importer/ASNImport.js +24 -24
- package/src/org/cass/importer/CSVImport.js +59 -59
- package/src/org/cass/importer/CTDLASNCSVConceptImport.js +66 -66
- package/src/org/cass/importer/CTDLASNCSVImport.js +62 -62
- package/src/org/cass/importer/FrameworkImport.js +13 -13
- package/src/org/cass/importer/MedbiqImport.js +11 -11
- package/src/org/cass/importer/TabStructuredImport.js +14 -14
- package/src/org/cass/profile/EcAssertion.js +68 -68
- package/src/org/cassproject/ebac/identity/EcContact.js +2 -2
- package/src/org/cassproject/ebac/identity/EcContactGrant.js +2 -2
- package/src/org/cassproject/ebac/identity/EcIdentity.js +3 -3
- package/src/org/cassproject/ebac/identity/EcIdentityManager.js +53 -53
- package/src/org/cassproject/ebac/identity/EcIdentityManager.test.js +3 -3
- package/src/org/cassproject/ebac/identity/EcRekeyRequest.js +3 -3
- package/src/org/cassproject/ebac/identity/remote/EcRemoteIdentityManager.js +31 -31
- package/src/org/cassproject/ebac/identity/remote/EcRemoteIdentityManager.test.js +3 -3
- package/src/org/cassproject/ebac/identity/remote/OAuth2FileBasedRemoteIdentityManager.js +57 -57
- package/src/org/cassproject/ebac/repository/EcEncryptedValue.js +23 -23
- package/src/org/cassproject/ebac/repository/EcRepository.js +130 -76
- package/src/org/cassproject/ebac/repository/EcRepository.test.js +12 -5
- package/src/org/cassproject/general/repository/EcFile.js +2 -2
- package/src/org/cassproject/general/repository/GeneralFile.js +3 -3
- package/src/org/cassproject/schema/cass/competency/Competency.js +2 -2
- package/src/org/cassproject/schema/cass/competency/Directory.js +1 -1
- package/src/org/cassproject/schema/cass/competency/Framework.js +2 -2
- package/src/org/cassproject/schema/cass/competency/Level.js +2 -2
- package/src/org/cassproject/schema/cass/competency/Relation.js +2 -2
- package/src/org/cassproject/schema/cass/competency/RollupRule.js +1 -1
- package/src/org/cassproject/schema/cass/profile/Assertion.js +15 -15
- package/src/org/cassproject/schema/cass/profile/AssertionEnvelope.js +8 -8
- package/src/org/cassproject/schema/general/EcRemoteLinkedData.js +55 -55
- package/src/org/json/ld/EcLinkedData.js +37 -37
- package/src/org/schema/EcOrganization.js +30 -30
- package/src/org/schema/EcQuestion.js +13 -13
- package/src/org/w3/skos/Concept.js +1 -1
- package/src/org/w3/skos/ConceptScheme.js +1 -1
- package/src/org/w3/skos/EcConcept.js +3 -3
- package/src/org/w3/skos/EcConceptScheme.js +3 -3
- package/test.js +329 -329
package/README.md
CHANGED
|
@@ -49,6 +49,13 @@ Development unit tests presume you have a CaSS Repository running on `localhost:
|
|
|
49
49
|
|
|
50
50
|
# Changelog
|
|
51
51
|
|
|
52
|
+
## 1.5.22
|
|
53
|
+
* Code cleanup
|
|
54
|
+
* Better certificate authority support by setting global.ca
|
|
55
|
+
|
|
56
|
+
## 1.5.20
|
|
57
|
+
* Added history fetch (fetches a list of results)
|
|
58
|
+
|
|
52
59
|
## 1.5.19
|
|
53
60
|
* No longer use the selectedServerProxy URL to communicate in any context.
|
|
54
61
|
|
package/index.js
CHANGED
|
@@ -6,12 +6,12 @@ if (typeof window !== "undefined" && window) {
|
|
|
6
6
|
require("./src/org/cassproject/general/AuditLogger.js");
|
|
7
7
|
|
|
8
8
|
global.generateUUID = function () {
|
|
9
|
-
|
|
9
|
+
let d = new Date().getTime();
|
|
10
10
|
if (typeof window !== "undefined" && window && window.performance && typeof window.performance.now === "function") {
|
|
11
11
|
d += performance.now(); // use high-precision timer if available
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
14
|
+
let r = (d + Math.random() * 16) % 16 | 0;
|
|
15
15
|
d = Math.floor(d / 16);
|
|
16
16
|
return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);
|
|
17
17
|
});
|
|
@@ -67,8 +67,6 @@ try {
|
|
|
67
67
|
|
|
68
68
|
if (global.forge === undefined)
|
|
69
69
|
global.forge = require("node-forge");
|
|
70
|
-
else
|
|
71
|
-
var forge = global.forge;
|
|
72
70
|
|
|
73
71
|
let JavalikeEquals = function (value) {
|
|
74
72
|
if (value == null)
|
|
@@ -88,7 +86,7 @@ if (!String.prototype.equals) {
|
|
|
88
86
|
}
|
|
89
87
|
if (!String.prototype.startsWith) {
|
|
90
88
|
String.prototype.startsWith = function (start, from) {
|
|
91
|
-
|
|
89
|
+
let f = from != null ? from : 0;
|
|
92
90
|
return this.substring(f, f + start.length) == start;
|
|
93
91
|
};
|
|
94
92
|
}
|
|
@@ -166,8 +164,8 @@ if (!String.prototype.regionMatches) {
|
|
|
166
164
|
}
|
|
167
165
|
if (toffset < 0 || ooffset < 0 || other == null || toffset + len > this.length || ooffset + len > other.length)
|
|
168
166
|
return false;
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
let s1 = this.substring(toffset, toffset + len);
|
|
168
|
+
let s2 = other.substring(ooffset, ooffset + len);
|
|
171
169
|
return ignoreCase ? s1.equalsIgnoreCase(s2) : s1 === s2;
|
|
172
170
|
};
|
|
173
171
|
}
|
|
@@ -189,12 +187,12 @@ String.valueOf = function (value) {
|
|
|
189
187
|
};
|
|
190
188
|
|
|
191
189
|
/* Number */
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
190
|
+
let Byte = Number;
|
|
191
|
+
let Double = Number;
|
|
192
|
+
let Float = Number;
|
|
193
|
+
let Integer = Number;
|
|
194
|
+
let Long = Number;
|
|
195
|
+
let Short = Number;
|
|
198
196
|
|
|
199
197
|
/* type conversion - approximative as Javascript only has integers and doubles */
|
|
200
198
|
if (!Number.prototype.intValue) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cassproject",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.22",
|
|
4
4
|
"description": "Competency and Skills Service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"multitest": "concurrently --kill-others --kill-others-on-fail \"npm run test15\" \"npm run test14\" \"npm run test13\" \"npm run test12\"",
|
|
10
10
|
"testCassTest": "npm run testkill && docker run -d --name cass-test -p80:80 -e CASS_LOOPBACK cass-test && wait-on http://localhost/api/ping && npm run testNode18 && npm run testNode18Fips && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testCypressEdge && npm run testCypress && npm run testkill",
|
|
11
11
|
"testDevHttps": "npm run testkill && docker run -d --name cass-test -p443:80 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:dev && wait-on https://localhost/api/ping && npm run testNode18HttpsFips && npm run testNode18Https && npm run testNode16Https && npm run testNode15Https && npm run testNode14Https && npm run testNode13Https && npm run testNode12Https && npm run testCypressEdgeHttps && npm run testCypressHttps",
|
|
12
|
-
"test15Https": "npm run testkill && docker run -d --name cass-test -p443:443 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:1.5.
|
|
13
|
-
"test15Https11": "npm run testkill && docker run -d --name cass-test -p443:443 -e CASS_LOOPBACK -e HTTPS=true -e HTTP2=false cassproject/cass:1.5.
|
|
14
|
-
"test15": "export CASS_LOOPBACK=http://localhost/api/|| set CASS_LOOPBACK=http://localhost/api/&& npm run testkill15 && docker run -d -e CASS_LOOPBACK --name cass-test15 -p80:80 cassproject/cass:1.5.
|
|
12
|
+
"test15Https": "npm run testkill && docker run -d --name cass-test -p443:443 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:1.5.21 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode18HttpsFips\" \"npm run testNode18Https\" \"npm run testNode16Https\" && npm run testkill",
|
|
13
|
+
"test15Https11": "npm run testkill && docker run -d --name cass-test -p443:443 -e CASS_LOOPBACK -e HTTPS=true -e HTTP2=false cassproject/cass:1.5.21 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode18HttpsFips\" \"npm run testNode18Https\" \"npm run testNode16Https\" && npm run testkill",
|
|
14
|
+
"test15": "export CASS_LOOPBACK=http://localhost/api/|| set CASS_LOOPBACK=http://localhost/api/&& npm run testkill15 && docker run -d -e CASS_LOOPBACK --name cass-test15 -p80:80 cassproject/cass:1.5.21 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode18\" \"npm run testNode18Fips\" \"npm run testNode16\" && npm run testkill15",
|
|
15
15
|
"test14": "npm run testkill14 && docker run -d -e CASS_LOOPBACK --name cass-test14 -p80:80 cassproject/cass:1.4.4 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode16\" && npm run testkill14",
|
|
16
16
|
"test13": "npm run testkill13 && docker run -d -e CASS_LOOPBACK --name cass-test13 -p80:80 cassproject/cass:1.3.18 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode16\" && npm run testkill13",
|
|
17
17
|
"test12": "npm run testkill12 && docker run -d -e CASS_LOOPBACK --name cass-test12 -p80:80 cassproject/cass:1.2.44 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode16\" && npm run testkill12",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"mocha:dev": "export CASS_LOOPBACK=https://dev.cassproject.org/api/|| set CASS_LOOPBACK=https://dev.cassproject.org/api/&& export HTTP2=false|| set HTTP2=false&& mocha --timeout 300000 -b src/**/*.test.js",
|
|
47
47
|
"mocha:demo": "export CASS_LOOPBACK=https://demo.cassproject.org/api/|| set CASS_LOOPBACK=https://demo.cassproject.org/api/&& export HTTP2=false|| set HTTP2=false&& mocha --timeout 300000 -b src/**/*.test.js",
|
|
48
48
|
"mochaGraph": "mocha --timeout 15000 -b src/com/eduworks/ec/graph/**/*.test.js",
|
|
49
|
-
"automocha": "nodemon --exec \"npm run mocha:
|
|
49
|
+
"automocha": "nodemon --exec \"npm run mocha:https\"",
|
|
50
50
|
"automochaGraph": "nodemon --exec \"npm run mochaGraph\"",
|
|
51
51
|
"automocha:clientSideCertificates": "nodemon --exec \"npm run mocha:clientSideCertificates\"",
|
|
52
52
|
"lint": "eslint src -c .eslintrc.js --ext .js --fix",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
}
|
|
91
91
|
],
|
|
92
92
|
"dependencies": {
|
|
93
|
-
"axios": "
|
|
93
|
+
"axios": "1.1.3",
|
|
94
94
|
"base64-arraybuffer": "^1.0.2",
|
|
95
95
|
"forge": "^2.3.0",
|
|
96
96
|
"form-data": "^4.0.0",
|
|
@@ -125,25 +125,24 @@
|
|
|
125
125
|
},
|
|
126
126
|
"homepage": "https://github.com/cassproject/cass-npm#readme",
|
|
127
127
|
"devDependencies": {
|
|
128
|
-
"@babel/core": "^7.20.
|
|
128
|
+
"@babel/core": "^7.20.12",
|
|
129
129
|
"@babel/preset-env": "^7.20.2",
|
|
130
130
|
"@cypress/browserify-preprocessor": "^3.0.2",
|
|
131
|
-
"@cypress/vite-dev-server": "^
|
|
132
|
-
"@cypress/webpack-preprocessor": "^5.
|
|
131
|
+
"@cypress/vite-dev-server": "^5.0.2",
|
|
132
|
+
"@cypress/webpack-preprocessor": "^5.16.1",
|
|
133
133
|
"babel-eslint": "^10.1.0",
|
|
134
|
-
"babel-loader": "^9.1.0",
|
|
135
134
|
"babel-plugin-transform-remove-strict-mode": "^0.0.2",
|
|
136
135
|
"chai": "^4.3.7",
|
|
137
|
-
"concurrently": "^7.
|
|
136
|
+
"concurrently": "^7.6.0",
|
|
138
137
|
"convert-hrtime": "^5.0.0",
|
|
139
|
-
"cypress": "^
|
|
140
|
-
"eslint": "^8.
|
|
141
|
-
"mocha": "^10.
|
|
138
|
+
"cypress": "^12.3.0",
|
|
139
|
+
"eslint": "^8.31.0",
|
|
140
|
+
"mocha": "^10.2.0",
|
|
142
141
|
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
143
142
|
"nodemon": "^2.0.20",
|
|
144
143
|
"nyc": "^15.1.0",
|
|
145
|
-
"wait-on": "^
|
|
144
|
+
"wait-on": "^7.0.1",
|
|
146
145
|
"webpack": "^5.75.0",
|
|
147
|
-
"webpack-cli": "^
|
|
146
|
+
"webpack-cli": "^5.0.1"
|
|
148
147
|
}
|
|
149
148
|
}
|
|
@@ -29,8 +29,8 @@ module.exports = class EcArray {
|
|
|
29
29
|
* @memberOf EcArray
|
|
30
30
|
*/
|
|
31
31
|
static removeDuplicates = function (a) {
|
|
32
|
-
for (
|
|
33
|
-
for (
|
|
32
|
+
for (let i = 0; i < a.length; i++)
|
|
33
|
+
for (let j = i; j < a.length; j++) {
|
|
34
34
|
if (j == i) continue;
|
|
35
35
|
if (a[i] == a[j]) a.splice(j, 1);
|
|
36
36
|
}
|
|
@@ -70,7 +70,7 @@ module.exports = class EcArray {
|
|
|
70
70
|
*/
|
|
71
71
|
static has = function (a, o) {
|
|
72
72
|
if (EcObject.isObject(o))
|
|
73
|
-
for (
|
|
73
|
+
for (let i = 0; i < a.length; i++) {
|
|
74
74
|
if (a[i] === o) return true;
|
|
75
75
|
try {
|
|
76
76
|
if (a[i].equals(o)) return true;
|
|
@@ -79,7 +79,7 @@ module.exports = class EcArray {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
else
|
|
82
|
-
for (
|
|
82
|
+
for (let i = 0; i < a.length; i++) {
|
|
83
83
|
if (a[i] === o) {
|
|
84
84
|
return true;
|
|
85
85
|
}
|
|
@@ -98,7 +98,7 @@ module.exports = class EcArray {
|
|
|
98
98
|
*/
|
|
99
99
|
static indexOf = function (a, o) {
|
|
100
100
|
if (EcObject.isObject(o))
|
|
101
|
-
for (
|
|
101
|
+
for (let i = 0; i < a.length; i++) {
|
|
102
102
|
if (a[i] === o) return i;
|
|
103
103
|
try {
|
|
104
104
|
if (a[i].equals(o)) return i;
|
|
@@ -107,7 +107,7 @@ module.exports = class EcArray {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
else
|
|
110
|
-
for (
|
|
110
|
+
for (let i = 0; i < a.length; i++) {
|
|
111
111
|
if (a[i] === o) {
|
|
112
112
|
return i;
|
|
113
113
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
let EcArray = require("./EcArray.js");
|
|
2
2
|
let chai = require("chai");
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
let should = chai.should();
|
|
5
|
+
let expect = chai.expect;
|
|
6
|
+
let assert = chai.assert;
|
|
7
7
|
|
|
8
8
|
describe("EcArray", () => {
|
|
9
9
|
describe("isArray", () => {
|
|
@@ -19,9 +19,6 @@ describe("EcArray", () => {
|
|
|
19
19
|
});
|
|
20
20
|
it('Duplicates are removed', () => {
|
|
21
21
|
let ary = [1, 1, 2, 3, 4];
|
|
22
|
-
console.log((eval("var __temp = null"), (typeof __temp === "undefined")) ?
|
|
23
|
-
"strict":
|
|
24
|
-
"non-strict");
|
|
25
22
|
EcArray.removeDuplicates(ary);
|
|
26
23
|
expect(ary.length).to.equal(4);
|
|
27
24
|
});
|
|
@@ -33,11 +33,12 @@ module.exports = class EcAsyncHelper {
|
|
|
33
33
|
* @memberOf EcAsyncHelper
|
|
34
34
|
*/
|
|
35
35
|
each(array, each, after) {
|
|
36
|
-
var me = this;
|
|
37
36
|
this.counter = array.length;
|
|
38
37
|
if (array.length == 0) after(array);
|
|
39
|
-
for (
|
|
40
|
-
if (this.counter > 0)
|
|
38
|
+
for (let i = 0; i < array.length; i++) {
|
|
39
|
+
if (this.counter > 0) {
|
|
40
|
+
this.execute(array, each, after, this, i);
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
@@ -50,11 +51,12 @@ module.exports = class EcAsyncHelper {
|
|
|
50
51
|
* @memberOf EcAsyncHelper
|
|
51
52
|
*/
|
|
52
53
|
eachSet(array, each, after) {
|
|
53
|
-
var me = this;
|
|
54
54
|
this.counter = array.length;
|
|
55
55
|
if (array.length == 0) after(array);
|
|
56
|
-
for (
|
|
57
|
-
if (this.counter > 0)
|
|
56
|
+
for (let i = 0; i < array.length; i++) {
|
|
57
|
+
if (this.counter > 0) {
|
|
58
|
+
this.executeSet(array, each, after, this, i);
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
execute(array, each, after, me, i) {
|
|
@@ -71,10 +73,7 @@ module.exports = class EcAsyncHelper {
|
|
|
71
73
|
array[i] = result;
|
|
72
74
|
me.counter--;
|
|
73
75
|
if (me.counter == 0) {
|
|
74
|
-
|
|
75
|
-
for (var j = 0; j < array.length; j++)
|
|
76
|
-
if (array[j] != null) finalArray.push(array[j]);
|
|
77
|
-
after(finalArray);
|
|
76
|
+
after([...array].filter(n=>n));
|
|
78
77
|
}
|
|
79
78
|
});
|
|
80
79
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
let EcObject = require("./EcObject.js");
|
|
2
2
|
let chai = require("chai");
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
let should = chai.should();
|
|
5
|
+
let expect = chai.expect;
|
|
6
|
+
let assert = chai.assert;
|
|
7
7
|
|
|
8
8
|
describe("EcObject", () => {
|
|
9
9
|
describe("isObject", () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
let EcAes = require("./EcAes.js");
|
|
2
2
|
let chai = require("chai");
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
let should = chai.should();
|
|
5
|
+
let expect = chai.expect;
|
|
6
|
+
let assert = chai.assert;
|
|
7
7
|
|
|
8
8
|
describe("EcAes", () => {
|
|
9
9
|
it('newSecret != null', () => {
|
|
@@ -34,14 +34,14 @@ module.exports = class EcAesCtr {
|
|
|
34
34
|
forge.util.decode64(iv).length == 16
|
|
35
35
|
)
|
|
36
36
|
return aesEncrypt(plaintext, iv, secret);
|
|
37
|
-
|
|
37
|
+
let c = forge.cipher.createCipher(
|
|
38
38
|
"AES-CTR",
|
|
39
39
|
forge.util.decode64(secret)
|
|
40
40
|
);
|
|
41
41
|
c.start({iv: forge.util.decode64(iv)});
|
|
42
42
|
c.update(forge.util.createBuffer(forge.util.encodeUtf8(plaintext)));
|
|
43
43
|
c.finish();
|
|
44
|
-
|
|
44
|
+
let encrypted = c.output;
|
|
45
45
|
return forge.util.encode64(encrypted.bytes());
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -64,7 +64,7 @@ module.exports = class EcAesCtr {
|
|
|
64
64
|
);
|
|
65
65
|
EcCrypto.deprecationNotice = true;
|
|
66
66
|
if (EcCrypto.caching) {
|
|
67
|
-
|
|
67
|
+
let cacheGet = EcCrypto.decryptionCache[secret + iv + ciphertext];
|
|
68
68
|
if (cacheGet != null) return cacheGet;
|
|
69
69
|
}
|
|
70
70
|
if (
|
|
@@ -72,19 +72,19 @@ module.exports = class EcAesCtr {
|
|
|
72
72
|
forge.util.decode64(secret).length == 16 &&
|
|
73
73
|
forge.util.decode64(iv).length == 16
|
|
74
74
|
) {
|
|
75
|
-
|
|
75
|
+
let result = aesDecrypt(ciphertext, iv, secret);
|
|
76
76
|
if (EcCrypto.caching)
|
|
77
77
|
EcCrypto.decryptionCache[secret + iv + ciphertext] = result;
|
|
78
78
|
return result;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
let c = forge.cipher.createDecipher(
|
|
81
81
|
"AES-CTR",
|
|
82
82
|
forge.util.decode64(secret)
|
|
83
83
|
);
|
|
84
84
|
c.start({iv: forge.util.decode64(iv)});
|
|
85
85
|
c.update(forge.util.createBuffer(forge.util.decode64(ciphertext)));
|
|
86
86
|
c.finish();
|
|
87
|
-
|
|
87
|
+
let decrypted = c.output;
|
|
88
88
|
if (EcCrypto.caching)
|
|
89
89
|
EcCrypto.decryptionCache[
|
|
90
90
|
secret + iv + ciphertext
|
|
@@ -12,39 +12,39 @@ let hrtime = function() {
|
|
|
12
12
|
return process.hrtime();
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
let should = chai.should();
|
|
16
|
+
let expect = chai.expect;
|
|
17
|
+
let assert = chai.assert;
|
|
18
18
|
|
|
19
19
|
describe("EcAesCtr", () => {
|
|
20
20
|
it('encryption then decryption', () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
let randomString = EcAes.newIv(1024);
|
|
22
|
+
let secret = EcAes.newSecret(16);
|
|
23
|
+
let iv = EcAes.newIv(16);
|
|
24
|
+
let encrypted = EcAesCtr.encrypt(randomString, secret, iv);
|
|
25
|
+
let decrypted = EcAesCtr.decrypt(encrypted, secret, iv);
|
|
26
26
|
assert.isTrue(randomString == decrypted);
|
|
27
27
|
});
|
|
28
28
|
it('encryption then decryption (utf-8)', () => {
|
|
29
|
-
|
|
29
|
+
let randomString =
|
|
30
30
|
"abc\u16a0\u16c7\u16bb\u16eb\u16d2\u16e6\u16a6\u16eb\u16a0\u16b1\u16a9\u16a0\u16a2\u16b1\u16eb\u16a0\u16c1\u16b1\u16aa\u16eb\u16b7\u16d6\u16bb\u16b9\u16e6\u16da\u16b3\u16a2\u16d7";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
let secret = EcAes.newSecret(16);
|
|
32
|
+
let iv = EcAes.newIv(16);
|
|
33
|
+
let encrypted = EcAesCtr.encrypt(randomString, secret, iv);
|
|
34
|
+
let decrypted = EcAesCtr.decrypt(encrypted, secret, iv);
|
|
35
35
|
assert.isTrue(randomString == decrypted);
|
|
36
36
|
});
|
|
37
37
|
it('large encryption then decryption w/caching', () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
let randomString = EcAes.newIv(4096*16);
|
|
39
|
+
let secret = EcAes.newSecret(16);
|
|
40
|
+
let iv = EcAes.newIv(16);
|
|
41
|
+
let hrTime = hrtime();
|
|
42
|
+
let encrypted = EcAesCtr.encrypt(randomString, secret, iv);
|
|
43
43
|
let elapsed = (hrtime()[0]*1000000 + hrtime()[1]/1000 - hrTime[0] * 1000000 - hrTime[1] / 1000)/1000;
|
|
44
44
|
console.log(randomString.length/1024+"KB encryption speed: " + elapsed+"ms");
|
|
45
45
|
hrTime = hrtime();
|
|
46
46
|
EcCrypto.caching = true;
|
|
47
|
-
|
|
47
|
+
let decrypted = EcAesCtr.decrypt(encrypted, secret, iv);
|
|
48
48
|
elapsed = (hrtime()[0]*1000000 + hrtime()[1]/1000 - hrTime[0] * 1000000 - hrTime[1] / 1000)/1000;
|
|
49
49
|
console.log("decryption wout/caching speed: " + elapsed+"ms");
|
|
50
50
|
hrTime = hrtime();
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
let base64 = require("base64-arraybuffer");
|
|
2
2
|
let forge = require("node-forge");
|
|
3
3
|
require("../../../../org/cassproject/general/AuditLogger.js");
|
|
4
|
+
let crypto = null;
|
|
4
5
|
if (typeof crypto == 'undefined')
|
|
5
6
|
{
|
|
6
7
|
if (typeof window !== 'undefined' && window != null && window !== undefined)
|
|
7
8
|
if (window.crypto != null)
|
|
8
|
-
|
|
9
|
+
crypto = window.crypto;
|
|
9
10
|
try {
|
|
10
11
|
let requireResult = require('crypto').webcrypto;
|
|
11
12
|
if (requireResult != null)
|
|
12
|
-
|
|
13
|
+
crypto = requireResult;
|
|
13
14
|
} catch (err) {
|
|
14
15
|
global.auditLogger.report(global.auditLogger.LogCategory.SYSTEM, global.auditLogger.Severity.INFO, "EcAesCtrAsync", "Webcrypto not available. Tests will fail. Please upgrade, if possible, to Node 16. Non-test mode will fallback to slower cryptograpy methods.: " + err);
|
|
15
16
|
}
|
|
@@ -31,7 +32,6 @@ module.exports = class EcAesCtrAsync {
|
|
|
31
32
|
if (realCrypto.getFips() == 0)
|
|
32
33
|
try {
|
|
33
34
|
realCrypto.setFips(true);
|
|
34
|
-
//console.log("FIPS compliant crypto provider has been enabled.");
|
|
35
35
|
} catch (e) {
|
|
36
36
|
global.auditLogger.report(global.auditLogger.LogCategory.SYSTEM, global.auditLogger.Severity.INFO, "EcAesCtrAsyncFips", "ERR_CRYPTO_FIPS_UNAVAILABLE", e);
|
|
37
37
|
}
|
|
@@ -42,7 +42,6 @@ module.exports = class EcAesCtrAsync {
|
|
|
42
42
|
if (realCrypto.getFips() == 1)
|
|
43
43
|
try {
|
|
44
44
|
realCrypto.setFips(false);
|
|
45
|
-
//console.log("FIPS compliant crypto provider has been disabled.");
|
|
46
45
|
} catch (e) {
|
|
47
46
|
global.auditLogger.report(global.auditLogger.LogCategory.SYSTEM, global.auditLogger.Severity.INFO, "EcAesCtrAsyncFips", "ERR_CRYPTO_FIPS_UNAVAILABLE", e);
|
|
48
47
|
}
|
|
@@ -78,13 +77,13 @@ module.exports = class EcAesCtrAsync {
|
|
|
78
77
|
);
|
|
79
78
|
}
|
|
80
79
|
this.fipsOn();
|
|
81
|
-
|
|
80
|
+
let keyUsages = [];
|
|
82
81
|
keyUsages.push("encrypt", "decrypt");
|
|
83
|
-
|
|
82
|
+
let algorithm = {};
|
|
84
83
|
algorithm.name = "AES-CTR";
|
|
85
84
|
algorithm.counter = base64.decode(iv);
|
|
86
85
|
algorithm.length = 128;
|
|
87
|
-
|
|
86
|
+
let data;
|
|
88
87
|
data = EcCrypto.str2ab(plaintext);
|
|
89
88
|
return cassPromisify(
|
|
90
89
|
crypto.subtle
|
|
@@ -123,7 +122,7 @@ module.exports = class EcAesCtrAsync {
|
|
|
123
122
|
*/
|
|
124
123
|
static decrypt(ciphertext, secret, iv, success, failure) {
|
|
125
124
|
if (EcCrypto.caching) {
|
|
126
|
-
|
|
125
|
+
let cacheGet = EcCrypto.decryptionCache[secret + iv + ciphertext];
|
|
127
126
|
if (cacheGet != null) {
|
|
128
127
|
return cassReturnAsPromise(cacheGet, success, failure);
|
|
129
128
|
}
|
|
@@ -143,12 +142,12 @@ module.exports = class EcAesCtrAsync {
|
|
|
143
142
|
);
|
|
144
143
|
}
|
|
145
144
|
this.fipsOn();
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
let keyUsages = ["encrypt", "decrypt"];
|
|
146
|
+
let algorithm = {};
|
|
148
147
|
algorithm.name = "AES-CTR";
|
|
149
148
|
algorithm.counter = base64.decode(iv);
|
|
150
149
|
algorithm.length = 128;
|
|
151
|
-
|
|
150
|
+
let data;
|
|
152
151
|
data = base64.decode(ciphertext);
|
|
153
152
|
return cassPromisify(
|
|
154
153
|
crypto.subtle
|
|
@@ -15,41 +15,41 @@ let hrtime = function() {
|
|
|
15
15
|
return process.hrtime();
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
let should = chai.should();
|
|
19
|
+
let expect = chai.expect;
|
|
20
|
+
let assert = chai.assert;
|
|
21
21
|
|
|
22
22
|
after(()=>EcRsaOaepAsyncWorker.teardown());
|
|
23
23
|
|
|
24
24
|
describe("EcAesCtrAsync", () => {
|
|
25
25
|
it('await encryption then await decryption', async () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
let randomString = EcAes.newIv(1024);
|
|
27
|
+
let secret = EcAes.newSecret(16);
|
|
28
|
+
let iv = EcAes.newIv(16);
|
|
29
|
+
let encrypted = await EcAesCtrAsync.encrypt(randomString, secret, iv);
|
|
30
|
+
let decrypted = await EcAesCtrAsync.decrypt(encrypted, secret, iv);
|
|
31
31
|
assert.isTrue(randomString == decrypted);
|
|
32
32
|
});
|
|
33
33
|
it('encryption then decryption (utf-8)', async () => {
|
|
34
|
-
|
|
34
|
+
let randomString =
|
|
35
35
|
"abc\u16a0\u16c7\u16bb\u16eb\u16d2\u16e6\u16a6\u16eb\u16a0\u16b1\u16a9\u16a0\u16a2\u16b1\u16eb\u16a0\u16c1\u16b1\u16aa\u16eb\u16b7\u16d6\u16bb\u16b9\u16e6\u16da\u16b3\u16a2\u16d7";
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
let secret = EcAes.newSecret(16);
|
|
37
|
+
let iv = EcAes.newIv(16);
|
|
38
|
+
let encrypted = await EcAesCtrAsync.encrypt(randomString, secret, iv);
|
|
39
|
+
let decrypted = await EcAesCtrAsync.decrypt(encrypted, secret, iv);
|
|
40
40
|
assert.isTrue(randomString == decrypted);
|
|
41
41
|
});
|
|
42
42
|
it('large encryption then decryption w/caching', async () => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
let randomString = EcAes.newIv(4096*4);
|
|
44
|
+
let secret = EcAes.newSecret(16);
|
|
45
|
+
let iv = EcAes.newIv(16);
|
|
46
|
+
let hrTime = typeof process === "undefined" ? [Math.round(performance.now()/1000), performance.now() * 1000] : hrtime();
|
|
47
|
+
let encrypted = await EcAesCtrAsync.encrypt(randomString, secret, iv);
|
|
48
48
|
let elapsed = (hrtime()[0]*1000000 + hrtime()[1]/1000 - hrTime[0] * 1000000 - hrTime[1] / 1000)/1000;
|
|
49
49
|
console.log(randomString.length/1024+"KB encryption speed: " + elapsed+"ms");
|
|
50
50
|
hrTime = hrtime();
|
|
51
51
|
EcCrypto.caching = true;
|
|
52
|
-
|
|
52
|
+
let decrypted = await EcAesCtrAsync.decrypt(encrypted, secret, iv);
|
|
53
53
|
elapsed = (hrtime()[0]*1000000 + hrtime()[1]/1000 - hrTime[0] * 1000000 - hrTime[1] / 1000)/1000;
|
|
54
54
|
console.log("decryption wout/caching speed: " + elapsed+"ms");
|
|
55
55
|
hrTime = hrtime();
|
|
@@ -81,35 +81,35 @@ describe("EcAesCtrAsync", () => {
|
|
|
81
81
|
}
|
|
82
82
|
}).timeout(10000);
|
|
83
83
|
it('EcAesCtrAsync encryption then EcAesCtr decryption', async () => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
let randomString = EcAes.newIv(1024);
|
|
85
|
+
let secret = EcAes.newSecret(16);
|
|
86
|
+
let iv = EcAes.newIv(16);
|
|
87
|
+
let encrypted = await EcAesCtrAsync.encrypt(randomString, secret, iv);
|
|
88
|
+
let decrypted = EcAesCtr.decrypt(encrypted, secret, iv);
|
|
89
89
|
assert.isTrue(randomString == decrypted);
|
|
90
90
|
});
|
|
91
91
|
it('EcAesCtr encryption then EcAesCtrAsync decryption', async () => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
let randomString = EcAes.newIv(1024);
|
|
93
|
+
let secret = EcAes.newSecret(16);
|
|
94
|
+
let iv = EcAes.newIv(16);
|
|
95
|
+
let encrypted = EcAesCtr.encrypt(randomString, secret, iv);
|
|
96
|
+
let decrypted = await EcAesCtrAsync.decrypt(encrypted, secret, iv);
|
|
97
97
|
assert.isTrue(randomString == decrypted);
|
|
98
98
|
});
|
|
99
99
|
it('EcAesCtrAsync encryption then EcAesCtrAsyncWorker decryption', async () => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
let randomString = EcAes.newIv(1024);
|
|
101
|
+
let secret = EcAes.newSecret(16);
|
|
102
|
+
let iv = EcAes.newIv(16);
|
|
103
|
+
let encrypted = await EcAesCtrAsync.encrypt(randomString, secret, iv);
|
|
104
|
+
let decrypted = await EcAesCtrAsyncWorker.decrypt(encrypted, secret, iv);
|
|
105
105
|
assert.isTrue(randomString == decrypted);
|
|
106
106
|
});
|
|
107
107
|
it('EcAesCtrAsyncWorker encryption then EcAesCtrAsync decryption', async () => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
let randomString = EcAes.newIv(1024);
|
|
109
|
+
let secret = EcAes.newSecret(16);
|
|
110
|
+
let iv = EcAes.newIv(16);
|
|
111
|
+
let encrypted = await EcAesCtrAsyncWorker.encrypt(randomString, secret, iv);
|
|
112
|
+
let decrypted = await EcAesCtrAsync.decrypt(encrypted, secret, iv);
|
|
113
113
|
assert.isTrue(randomString == decrypted);
|
|
114
114
|
});
|
|
115
115
|
});
|
|
@@ -37,9 +37,9 @@ module.exports = class EcAesCtrAsyncWorker {
|
|
|
37
37
|
failure
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
let worker = EcRsaOaepAsyncWorker.rotator++;
|
|
41
41
|
EcRsaOaepAsyncWorker.rotator = EcRsaOaepAsyncWorker.rotator % 8;
|
|
42
|
-
|
|
42
|
+
let o = {};
|
|
43
43
|
o["secret"] = secret;
|
|
44
44
|
o["iv"] = iv;
|
|
45
45
|
o["text"] = forge.util.encodeUtf8(plaintext);
|
|
@@ -62,7 +62,7 @@ module.exports = class EcAesCtrAsyncWorker {
|
|
|
62
62
|
*/
|
|
63
63
|
static decrypt(ciphertext, secret, iv, success, failure) {
|
|
64
64
|
if (EcCrypto.caching) {
|
|
65
|
-
|
|
65
|
+
let cacheGet = null;
|
|
66
66
|
cacheGet = EcCrypto.decryptionCache[secret + iv + ciphertext];
|
|
67
67
|
if (cacheGet != null) {
|
|
68
68
|
return cassReturnAsPromise(cacheGet, success, failure);
|
|
@@ -76,9 +76,9 @@ module.exports = class EcAesCtrAsyncWorker {
|
|
|
76
76
|
failure
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
let worker = EcRsaOaepAsyncWorker.rotator++;
|
|
80
80
|
EcRsaOaepAsyncWorker.rotator = EcRsaOaepAsyncWorker.rotator % 8;
|
|
81
|
-
|
|
81
|
+
let o = {};
|
|
82
82
|
o["secret"] = secret;
|
|
83
83
|
o["iv"] = iv;
|
|
84
84
|
o["text"] = ciphertext;
|