cassproject 5.0.20 → 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.
- package/package.json +49 -52
- package/src/com/eduworks/ec/array/EcArray.js +1 -1
- package/src/com/eduworks/ec/array/EcAsyncHelper.js +1 -1
- package/src/com/eduworks/ec/array/EcObject.js +1 -1
- package/src/com/eduworks/ec/crypto/EcAes.js +1 -1
- package/src/com/eduworks/ec/crypto/EcAesCtrAsync.js +20 -22
- package/src/com/eduworks/ec/crypto/EcCrypto.js +8 -4
- package/src/com/eduworks/ec/crypto/EcPk.js +7 -7
- package/src/com/eduworks/ec/crypto/EcPpk.js +7 -7
- package/src/com/eduworks/ec/crypto/EcRsaOaepAsync.js +20 -19
- package/src/com/eduworks/ec/crypto/EcRsaOaepAsyncWorker.js +7 -6
- package/src/com/eduworks/ec/crypto/forgeAsync.js +1 -9
- package/src/com/eduworks/ec/crypto/forgeAsyncNode.js +8 -8
- package/src/com/eduworks/ec/graph/EcDirectedGraph.js +1 -2
- package/src/com/eduworks/ec/graph/EcFrameworkGraph.js +18 -24
- package/src/com/eduworks/ec/promises/helpers.js +1 -3
- package/src/com/eduworks/ec/remote/EcRemote.js +9 -9
- package/src/com/eduworks/ec/task/EcAsyncTask.js +5 -20
- package/src/com/eduworks/ec/task/EcAsyncTaskManager.js +3 -4
- package/src/com/eduworks/ec/task/EcAsyncTaskWorker.js +9 -11
- package/src/com/eduworks/schema/cfd/competency/CfdFramework.js +36 -37
- package/src/com/eduworks/schema/ebac/EbacContact.js +3 -9
- package/src/com/eduworks/schema/ebac/EbacContactGrant.js +3 -9
- package/src/com/eduworks/schema/ebac/EbacCredential.js +3 -9
- package/src/com/eduworks/schema/ebac/EbacCredentialCommit.js +3 -9
- package/src/com/eduworks/schema/ebac/EbacCredentialRequest.js +3 -9
- package/src/com/eduworks/schema/ebac/EbacCredentials.js +3 -9
- package/src/com/eduworks/schema/ebac/EbacEncryptedSecret.js +3 -9
- package/src/com/eduworks/schema/ebac/EbacEncryptedValue.js +5 -12
- package/src/com/eduworks/schema/ebac/EbacSignature.js +1 -6
- package/src/index/env.js +6 -3
- package/src/index/polyfills.js +13 -27
- package/src/org/angles/schema/angles/VideoStory.js +1 -1
- package/src/org/cass/competency/EcCompetency.js +1 -2
- package/src/org/cass/competency/EcDirectory.js +1 -2
- package/src/org/cass/competency/EcFramework.js +9 -12
- package/src/org/cass/exporter/CSVExport.js +12 -13
- package/src/org/cass/importer/ASNImport.js +3 -6
- package/src/org/cass/importer/CSVImport.js +9 -17
- package/src/org/cass/importer/CTDLASNCSVConceptImport.js +25 -121
- package/src/org/cass/importer/CTDLASNCSVImport.js +88 -133
- package/src/org/cass/importer/FrameworkImport.js +16 -30
- package/src/org/cass/importer/MedbiqImport.js +3 -4
- package/src/org/cass/importer/TabStructuredImport.js +6 -6
- package/src/org/cass/profile/EcAssertion.js +40 -51
- package/src/org/cassproject/ebac/identity/EcContactGrant.js +2 -2
- package/src/org/cassproject/ebac/identity/EcIdentityManager.js +56 -62
- package/src/org/cassproject/ebac/identity/EcRekeyRequest.js +3 -2
- package/src/org/cassproject/ebac/identity/remote/EcRemoteIdentityManager.js +51 -62
- package/src/org/cassproject/ebac/identity/remote/OAuth2FileBasedRemoteIdentityManager.js +56 -70
- package/src/org/cassproject/ebac/identity/remote/RemoteIdentityManagerInterface.js +3 -3
- package/src/org/cassproject/ebac/repository/EcEncryptedValue.js +51 -44
- package/src/org/cassproject/ebac/repository/EcRepository.js +228 -301
- package/src/org/cassproject/general/repository/GeneralFile.js +8 -9
- package/src/org/cassproject/schema/cass/competency/Competency.js +10 -11
- package/src/org/cassproject/schema/cass/competency/Framework.js +10 -11
- package/src/org/cassproject/schema/cass/competency/Level.js +10 -11
- package/src/org/cassproject/schema/cass/competency/Relation.js +10 -11
- package/src/org/cassproject/schema/cass/competency/RollupRule.js +7 -7
- package/src/org/cassproject/schema/cass/profile/Assertion.js +20 -27
- package/src/org/cassproject/schema/cass/profile/AssertionEnvelope.js +3 -5
- package/src/org/cassproject/schema/general/EcRemoteLinkedData.js +41 -44
- package/src/org/json/ld/EcLinkedData.js +10 -12
- package/src/org/schema/EcOrganization.js +10 -10
- package/src/org/schema/EcQuestion.js +8 -8
- package/src/org/w3/skos/Concept.js +6 -6
- package/src/org/w3/skos/ConceptScheme.js +6 -6
- package/src/org/w3/skos/EcConcept.js +1 -2
- package/src/org/w3/skos/EcConceptScheme.js +1 -2
- package/src/test/0.start.test.js +1 -1
- package/src/test/0.testLibraries.test.js +172 -0
- package/src/test/1.ASNImport.test.js +122 -0
- package/src/test/1.CSVExport.test.js +57 -0
- package/src/test/1.CSVImport.test.js +185 -0
- package/src/test/1.CTDLASNCSVConceptImport.test.js +348 -0
- package/src/test/1.CTDLASNCSVImport.import.test.js +497 -0
- package/src/test/1.Ebac.schema.test.js +107 -0
- package/src/test/1.EcAssertion.decrypt.test.js +98 -0
- package/src/test/1.EcAssertion.pinned.test.js +160 -0
- package/src/test/1.EcCrypto.formats.test.js +293 -0
- package/src/test/1.EcCrypto.generateUUID.test.js +47 -0
- package/src/test/1.EcEncryptedValue.helpers.test.js +236 -0
- package/src/test/1.EcHelpers.misc.test.js +259 -0
- package/src/test/1.EcIdentityManager.keys.test.js +439 -0
- package/src/test/1.EcOrganization.rekey.test.js +68 -0
- package/src/test/1.EcRemote.responses.test.js +155 -0
- package/src/test/1.EcRemoteIdentityManager.flows.test.js +326 -0
- package/src/test/1.EcRemoteLinkedData.pinned.test.js +473 -0
- package/src/test/1.EcRepository.l0.test.js +14 -5
- package/src/test/1.EcRepository.l1.test.js +16 -7
- package/src/test/1.EcRepository.l2.test.js +20 -11
- package/src/test/1.EcRepository.unit.test.js +961 -0
- package/src/test/1.EcRsaOaep.test.js +2 -12
- package/src/test/1.EcRsaOaepAsync.test.js +2 -12
- package/src/test/1.EcRsaOaepAsyncWorker.test.js +2 -12
- package/src/test/1.EcRsaOaepAsyncWorker.workers.test.js +147 -0
- package/src/test/1.FrameworkImport.test.js +170 -0
- package/src/test/1.MedbiqImport.test.js +92 -0
- package/src/test/1.OAuth2FileBasedRemoteIdentityManager.test.js +399 -0
- package/src/test/1.TabStructuredImport.test.js +61 -0
- package/src/test/1.polyfills.test.js +89 -0
- package/src/test/1.schema.competency.pinned.test.js +384 -0
- package/src/test/3.EcFrameworkGraph.test.js +3 -2
- package/src/test/4.schema.test.js +33 -28
- package/src/test/4.skyId.test.js +4 -2
- package/src/test/cypressValue.js +9 -0
- package/src/test/2.EcCompetency.test.js +0 -17
|
@@ -115,64 +115,63 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
|
|
|
115
115
|
* @method configureFromServer
|
|
116
116
|
*/
|
|
117
117
|
async configureFromServer(success, failure) {
|
|
118
|
-
let me = this;
|
|
119
118
|
return cassPromisify(
|
|
120
119
|
EcRemote.getExpectingObject(
|
|
121
120
|
this.server,
|
|
122
121
|
"sky/id/salts",
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (
|
|
122
|
+
(p1) => {
|
|
123
|
+
this.usernameSalt = p1["usernameSalt"];
|
|
124
|
+
if (this.usernameSalt.length < 16) {
|
|
126
125
|
throw new Error("Insufficient length on Username Salt");
|
|
127
126
|
}
|
|
128
|
-
|
|
127
|
+
this.usernameIterations = Math.trunc(
|
|
129
128
|
p1["usernameIterations"]
|
|
130
129
|
);
|
|
131
|
-
if (
|
|
130
|
+
if (this.usernameIterations < 1000) {
|
|
132
131
|
throw new Error(
|
|
133
132
|
"Insufficient iterations on Username Hash"
|
|
134
133
|
);
|
|
135
134
|
}
|
|
136
|
-
|
|
137
|
-
if (
|
|
135
|
+
this.usernameWidth = Math.trunc(p1["usernameLength"]);
|
|
136
|
+
if (this.usernameWidth != 64) {
|
|
138
137
|
throw new Error(
|
|
139
138
|
"Username Hash required to be length 64."
|
|
140
139
|
);
|
|
141
140
|
}
|
|
142
|
-
|
|
143
|
-
if (
|
|
141
|
+
this.passwordSalt = p1["passwordSalt"];
|
|
142
|
+
if (this.passwordSalt.length < 16) {
|
|
144
143
|
throw new Error("Insufficient length on Password Salt");
|
|
145
144
|
}
|
|
146
|
-
|
|
145
|
+
this.passwordIterations = Math.trunc(
|
|
147
146
|
p1["passwordIterations"]
|
|
148
147
|
);
|
|
149
|
-
if (
|
|
148
|
+
if (this.passwordIterations < 1000) {
|
|
150
149
|
throw new Error(
|
|
151
150
|
"Insufficient iterations on Password Hash"
|
|
152
151
|
);
|
|
153
152
|
}
|
|
154
|
-
|
|
155
|
-
if (
|
|
153
|
+
this.passwordWidth = Math.trunc(p1["passwordLength"]);
|
|
154
|
+
if (this.passwordWidth != 64) {
|
|
156
155
|
throw new Error(
|
|
157
156
|
"Password Hash required to be length 64."
|
|
158
157
|
);
|
|
159
158
|
}
|
|
160
|
-
|
|
161
|
-
if (
|
|
159
|
+
this.secretSalt = p1["secretSalt"];
|
|
160
|
+
if (this.secretSalt.length < 16) {
|
|
162
161
|
throw new Error("Insufficient length on Secret Salt");
|
|
163
162
|
}
|
|
164
|
-
|
|
165
|
-
if (
|
|
163
|
+
this.secretIterations = Math.trunc(p1["secretIterations"]);
|
|
164
|
+
if (this.secretIterations < 1000) {
|
|
166
165
|
throw new Error(
|
|
167
166
|
"Insufficient iterations on Secret Hash"
|
|
168
167
|
);
|
|
169
168
|
}
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
this.signatureSheetHashAlgorithm = p1["signatureSheetHashAlgorithm"];
|
|
170
|
+
this.configured = true;
|
|
172
171
|
return p1;
|
|
173
172
|
},
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
(p1) => {
|
|
174
|
+
this.configured = false;
|
|
176
175
|
throw new Error(p1);
|
|
177
176
|
}
|
|
178
177
|
),
|
|
@@ -344,7 +343,6 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
|
|
|
344
343
|
r.password = this.passwordWithSalt;
|
|
345
344
|
let fd = new FormData();
|
|
346
345
|
fd.append("credentialRequest", r.toJson());
|
|
347
|
-
let me = this;
|
|
348
346
|
return cassPromisify(
|
|
349
347
|
EcRemote.postExpectingObject(
|
|
350
348
|
this.server,
|
|
@@ -353,32 +351,31 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
|
|
|
353
351
|
async (arg0) => {
|
|
354
352
|
let eim = new EcIdentityManager();
|
|
355
353
|
let cs = arg0;
|
|
356
|
-
|
|
357
|
-
|
|
354
|
+
this.pad = cs.pad;
|
|
355
|
+
this.token = cs.token;
|
|
358
356
|
let shouldCommit = false;
|
|
359
357
|
if (cs.credentials != null)
|
|
360
|
-
for (
|
|
361
|
-
let c = cs.credentials[i];
|
|
358
|
+
for (const c of cs.credentials) {
|
|
362
359
|
let identity = null;
|
|
363
360
|
try{
|
|
364
361
|
identity = await EcIdentity.fromCredential(
|
|
365
362
|
c,
|
|
366
|
-
|
|
367
|
-
|
|
363
|
+
this.secretWithSalt,
|
|
364
|
+
this.server
|
|
368
365
|
);
|
|
369
|
-
}
|
|
366
|
+
}
|
|
370
367
|
catch(ex)
|
|
371
368
|
{
|
|
372
369
|
global.auditLogger.report(global.auditLogger.LogCategory.SYSTEM, global.auditLogger.Severity.ERROR, "EcRemoIdenManaFetch", ex);
|
|
373
370
|
}
|
|
374
|
-
if (identity
|
|
375
|
-
{
|
|
371
|
+
if (identity?.ppk == null)
|
|
372
|
+
{
|
|
376
373
|
//Try alternate method of getting credential.
|
|
377
|
-
let newSecretWithSalt = forge.util.encode64(forge.pkcs5.pbkdf2('',this.secretSalt,this.secretIterations,32));
|
|
374
|
+
let newSecretWithSalt = forge.util.encode64(forge.pkcs5.pbkdf2('',this.secretSalt,this.secretIterations,32));
|
|
378
375
|
identity = await EcIdentity.fromCredential(
|
|
379
376
|
c,
|
|
380
377
|
newSecretWithSalt,
|
|
381
|
-
|
|
378
|
+
this.server
|
|
382
379
|
);
|
|
383
380
|
shouldCommit = true;
|
|
384
381
|
}
|
|
@@ -388,37 +385,36 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
|
|
|
388
385
|
eim.addIdentity(identity);
|
|
389
386
|
}
|
|
390
387
|
if (cs.contacts != null)
|
|
391
|
-
for (
|
|
392
|
-
let c = cs.contacts[i];
|
|
388
|
+
for (const c of cs.contacts) {
|
|
393
389
|
let identity = null;
|
|
394
390
|
try{
|
|
395
|
-
identity =
|
|
391
|
+
identity = EcContact.fromEncryptedContact(
|
|
396
392
|
c,
|
|
397
|
-
|
|
398
|
-
|
|
393
|
+
this.secretWithSalt,
|
|
394
|
+
this.server
|
|
399
395
|
);
|
|
400
|
-
}
|
|
396
|
+
}
|
|
401
397
|
catch(ex)
|
|
402
398
|
{
|
|
403
399
|
global.auditLogger.report(global.auditLogger.LogCategory.SYSTEM, global.auditLogger.Severity.ERROR, "EcRemoIdenManaFetch", ex);
|
|
404
400
|
}
|
|
405
|
-
if (identity
|
|
406
|
-
{
|
|
401
|
+
if (identity?.pk == null)
|
|
402
|
+
{
|
|
407
403
|
//Try alternate method of getting contact.
|
|
408
|
-
let newSecretWithSalt = forge.util.encode64(forge.pkcs5.pbkdf2('',this.secretSalt,this.secretIterations,32));
|
|
409
|
-
identity =
|
|
404
|
+
let newSecretWithSalt = forge.util.encode64(forge.pkcs5.pbkdf2('',this.secretSalt,this.secretIterations,32));
|
|
405
|
+
identity = EcContact.fromEncryptedContact(
|
|
410
406
|
c,
|
|
411
407
|
newSecretWithSalt,
|
|
412
|
-
|
|
408
|
+
this.server
|
|
413
409
|
);
|
|
414
410
|
shouldCommit = true;
|
|
415
|
-
}
|
|
411
|
+
}
|
|
416
412
|
if (identity.pk == null)
|
|
417
|
-
throw new Error("Could not retreive encrypted pks from credential packet.")
|
|
413
|
+
throw new Error("Could not retreive encrypted pks from credential packet.")
|
|
418
414
|
eim.addContact(identity);
|
|
419
415
|
}
|
|
420
|
-
|
|
421
|
-
|
|
416
|
+
if (shouldCommit)
|
|
417
|
+
await this.commit(null,null,eim);
|
|
422
418
|
return eim;
|
|
423
419
|
},
|
|
424
420
|
function (arg0) {
|
|
@@ -490,14 +486,12 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
|
|
|
490
486
|
}
|
|
491
487
|
let credentials = [];
|
|
492
488
|
let contacts = [];
|
|
493
|
-
for (
|
|
494
|
-
let id = eim.ids[i];
|
|
489
|
+
for (const id of eim.ids) {
|
|
495
490
|
if (id.source != null && id.source != this.server) continue;
|
|
496
491
|
id.source = this.server;
|
|
497
492
|
credentials.push(await id.toCredential(this.secretWithSalt));
|
|
498
493
|
}
|
|
499
|
-
for (
|
|
500
|
-
let id = eim.contacts[i];
|
|
494
|
+
for (const id of eim.contacts) {
|
|
501
495
|
if (id.source != null && id.source != this.server) continue;
|
|
502
496
|
id.source = this.server;
|
|
503
497
|
contacts.push(await id.toEncryptedContact(this.secretWithSalt));
|
|
@@ -511,7 +505,6 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
|
|
|
511
505
|
commit.credentials.contacts = contacts;
|
|
512
506
|
let fd = new FormData();
|
|
513
507
|
fd.append("credentialCommit", commit.toJson());
|
|
514
|
-
let me = this;
|
|
515
508
|
return cassPromisify(
|
|
516
509
|
eim.signatureSheet(
|
|
517
510
|
60000,
|
|
@@ -519,7 +512,7 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
|
|
|
519
512
|
async (p1) => {
|
|
520
513
|
fd.append("signatureSheet", p1);
|
|
521
514
|
return await EcRemote.postExpectingString(
|
|
522
|
-
|
|
515
|
+
this.server,
|
|
523
516
|
service,
|
|
524
517
|
fd,
|
|
525
518
|
function (arg0) {
|
|
@@ -553,13 +546,9 @@ module.exports = class EcRemoteIdentityManager extends RemoteIdentityManagerInte
|
|
|
553
546
|
let passwordSplice = "";
|
|
554
547
|
for (let charIndex = 0; true; charIndex++) {
|
|
555
548
|
let foundAny = false;
|
|
556
|
-
for (
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
passwordIndex++
|
|
560
|
-
) {
|
|
561
|
-
if (charIndex >= passwords[passwordIndex].length) continue;
|
|
562
|
-
passwordSplice += passwords[passwordIndex].charAt(charIndex);
|
|
549
|
+
for (const password of passwords) {
|
|
550
|
+
if (charIndex >= password.length) continue;
|
|
551
|
+
passwordSplice += password.charAt(charIndex);
|
|
563
552
|
foundAny = true;
|
|
564
553
|
}
|
|
565
554
|
if (!foundAny) break;
|
|
@@ -14,22 +14,21 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
14
14
|
*/
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
|
-
let me = this;
|
|
18
17
|
EcRemote.getExpectingObject(
|
|
19
18
|
"",
|
|
20
19
|
"hello.json",
|
|
21
|
-
|
|
20
|
+
(o) => {
|
|
22
21
|
try {
|
|
23
|
-
|
|
22
|
+
this.configuration = structuredClone(o);
|
|
24
23
|
hello.init(o);
|
|
25
|
-
|
|
24
|
+
this.oauthEnabled = true;
|
|
26
25
|
initialized();
|
|
27
|
-
} catch (ex) {
|
|
28
|
-
|
|
26
|
+
} catch (ex) { // NOSONAR - hello.js missing, a bad configuration or no initialized() hook: run without OAuth.
|
|
27
|
+
this.oauthEnabled = false;
|
|
29
28
|
}
|
|
30
29
|
},
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
(s) => {
|
|
31
|
+
this.oauthEnabled = false;
|
|
33
32
|
}
|
|
34
33
|
);
|
|
35
34
|
}
|
|
@@ -94,36 +93,34 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
94
93
|
let o = {};
|
|
95
94
|
o["scope"] = this.configuration[this.server + "Scope"];
|
|
96
95
|
o["display"] = "page";
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
me.network = me.oauthLoginResponse["network"];
|
|
96
|
+
hello.on("auth.login", (o) => {
|
|
97
|
+
this.oauthLoginResponse = o;
|
|
98
|
+
this.network = this.oauthLoginResponse["network"];
|
|
101
99
|
hello
|
|
102
|
-
.api(
|
|
103
|
-
.then(
|
|
100
|
+
.api(this.network + "/me/folders", "get", {})
|
|
101
|
+
.then((folderResponse) => {
|
|
104
102
|
let folders = folderResponse["data"];
|
|
105
103
|
let foundIdentities = false;
|
|
106
104
|
let foundContacts = false;
|
|
107
|
-
for (
|
|
108
|
-
let d = folders[i];
|
|
105
|
+
for (const d of folders) {
|
|
109
106
|
let name = d["name"];
|
|
110
107
|
let id = d["id"];
|
|
111
108
|
if (name == "CASS Identities") {
|
|
112
109
|
foundIdentities = true;
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
this.hookIdentityManagerIdentities(id);
|
|
111
|
+
this.readIdentityFiles(id, success, failure);
|
|
115
112
|
}
|
|
116
113
|
if (name == "CASS Contacts") {
|
|
117
114
|
foundContacts = true;
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
this.hookIdentityManagerContacts(id);
|
|
116
|
+
this.readContactFiles(id, success, failure);
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
119
|
if (!foundIdentities) {
|
|
123
|
-
|
|
120
|
+
this.createIdentityFolder(success);
|
|
124
121
|
}
|
|
125
122
|
if (!foundContacts) {
|
|
126
|
-
|
|
123
|
+
this.createContactFolder();
|
|
127
124
|
}
|
|
128
125
|
})
|
|
129
126
|
.fail(failure);
|
|
@@ -131,31 +128,28 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
131
128
|
hello.login(this.server, o).fail(failure);
|
|
132
129
|
}
|
|
133
130
|
createContactFolder() {
|
|
134
|
-
let me = this;
|
|
135
131
|
let o = {};
|
|
136
132
|
o["name"] = "CASS Contacts";
|
|
137
|
-
hello.api(
|
|
138
|
-
|
|
133
|
+
hello.api(this.network + "/me/folders", "post", o).then((r) => {
|
|
134
|
+
this.hookIdentityManagerContacts(r["id"]);
|
|
139
135
|
});
|
|
140
136
|
}
|
|
141
137
|
createIdentityFolder(success) {
|
|
142
|
-
let me = this;
|
|
143
138
|
let o = {};
|
|
144
139
|
o["name"] = "CASS Identities";
|
|
145
|
-
hello.api(
|
|
146
|
-
|
|
140
|
+
hello.api(this.network + "/me/folders", "post", o).then((r) => {
|
|
141
|
+
this.hookIdentityManagerIdentities(r["id"]);
|
|
147
142
|
success(r);
|
|
148
143
|
});
|
|
149
144
|
}
|
|
150
145
|
writeIdentityFiles(folderId, success, eim) {
|
|
151
146
|
if (eim === undefined || eim == null)
|
|
152
147
|
eim = EcIdentityManager.default;
|
|
153
|
-
let me = this;
|
|
154
148
|
let helper = new EcAsyncHelper();
|
|
155
149
|
helper.each(
|
|
156
150
|
eim.ids,
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
(identity, callback0) => {
|
|
152
|
+
this.writeIdentityFile(folderId, identity, callback0);
|
|
159
153
|
},
|
|
160
154
|
function(strings) {
|
|
161
155
|
success(strings);
|
|
@@ -189,8 +183,8 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
189
183
|
writeContactFiles(folderId, eim) {
|
|
190
184
|
if (eim === undefined || eim == null)
|
|
191
185
|
eim = EcIdentityManager.default;
|
|
192
|
-
for (
|
|
193
|
-
this.writeContactFile(folderId,
|
|
186
|
+
for (const contact of eim.contacts) {
|
|
187
|
+
this.writeContactFile(folderId, contact);
|
|
194
188
|
}
|
|
195
189
|
}
|
|
196
190
|
writeContactFile(folderId, contact) {
|
|
@@ -217,27 +211,26 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
217
211
|
});
|
|
218
212
|
}
|
|
219
213
|
readIdentityFiles(folderId, success, failure, eim) {
|
|
220
|
-
let me = this;
|
|
221
214
|
let o = {};
|
|
222
215
|
o["parent"] = folderId;
|
|
223
216
|
if (eim === undefined || eim == null)
|
|
224
217
|
eim = EcIdentityManager.default;
|
|
225
218
|
hello
|
|
226
219
|
.api(this.network + "/me/files", "get", o)
|
|
227
|
-
.then(
|
|
220
|
+
.then((folderResponse) => {
|
|
228
221
|
let files = folderResponse["data"];
|
|
229
222
|
let h = new EcAsyncHelper();
|
|
230
223
|
h.each(
|
|
231
224
|
files,
|
|
232
|
-
|
|
233
|
-
let name = d["name"].replace(
|
|
225
|
+
(d, callback0) => {
|
|
226
|
+
let name = d["name"].replace(String.raw`\.pem`, "");
|
|
234
227
|
let id = d["id"];
|
|
235
228
|
let directLink = d["downloadUrl"];
|
|
236
229
|
EcRemote.getExpectingString(
|
|
237
230
|
"",
|
|
238
231
|
directLink +
|
|
239
232
|
"&access_token=" +
|
|
240
|
-
hello.getAuthResponse(
|
|
233
|
+
hello.getAuthResponse(this.network)[
|
|
241
234
|
"access_token"
|
|
242
235
|
],
|
|
243
236
|
function(s) {
|
|
@@ -259,27 +252,26 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
259
252
|
});
|
|
260
253
|
}
|
|
261
254
|
readContactFiles(folderId, success, failure, eim) {
|
|
262
|
-
let me = this;
|
|
263
255
|
let o = {};
|
|
264
256
|
o["parent"] = folderId;
|
|
265
257
|
if (eim === undefined || eim == null)
|
|
266
258
|
eim = EcIdentityManager.default;
|
|
267
259
|
hello
|
|
268
260
|
.api(this.network + "/me/files", "get", o)
|
|
269
|
-
.then(
|
|
261
|
+
.then((folderResponse) => {
|
|
270
262
|
let files = folderResponse["data"];
|
|
271
263
|
let h = new EcAsyncHelper();
|
|
272
264
|
h.each(
|
|
273
265
|
files,
|
|
274
|
-
|
|
275
|
-
let name = d["name"].replace(
|
|
266
|
+
(d, callback0) => {
|
|
267
|
+
let name = d["name"].replace(String.raw`\.pem`, "");
|
|
276
268
|
let id = d["id"];
|
|
277
269
|
let directLink = d["downloadUrl"];
|
|
278
270
|
EcRemote.getExpectingString(
|
|
279
271
|
"",
|
|
280
272
|
directLink +
|
|
281
273
|
"&access_token=" +
|
|
282
|
-
hello.getAuthResponse(
|
|
274
|
+
hello.getAuthResponse(this.network)[
|
|
283
275
|
"access_token"
|
|
284
276
|
],
|
|
285
277
|
function(s) {
|
|
@@ -303,17 +295,15 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
303
295
|
hookIdentityManagerIdentities(folderId, eim) {
|
|
304
296
|
if (eim === undefined || eim == null)
|
|
305
297
|
eim = EcIdentityManager.default;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
me.writeIdentityFile(folderId, identity, null);
|
|
298
|
+
eim.onIdentityChanged = (identity) => {
|
|
299
|
+
this.writeIdentityFile(folderId, identity, null);
|
|
309
300
|
};
|
|
310
301
|
}
|
|
311
302
|
hookIdentityManagerContacts(folderId, eim) {
|
|
312
303
|
if (eim === undefined || eim == null)
|
|
313
304
|
eim = EcIdentityManager.default;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
me.writeContactFile(folderId, contact);
|
|
305
|
+
eim.onContactChanged = (contact) => {
|
|
306
|
+
this.writeContactFile(folderId, contact);
|
|
317
307
|
};
|
|
318
308
|
}
|
|
319
309
|
/**
|
|
@@ -325,23 +315,21 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
325
315
|
* @method commit
|
|
326
316
|
*/
|
|
327
317
|
commit(success, failure) {
|
|
328
|
-
let me = this;
|
|
329
318
|
let apio = {};
|
|
330
319
|
apio["network"] = this.network;
|
|
331
320
|
if (hello.getAuthResponse(this.server))
|
|
332
321
|
hello
|
|
333
|
-
.api(
|
|
334
|
-
.then(
|
|
322
|
+
.api(this.network + "/me/folders", "get", apio)
|
|
323
|
+
.then((folderResponse) => {
|
|
335
324
|
let folders = folderResponse["data"];
|
|
336
|
-
for (
|
|
337
|
-
let d = folders[i];
|
|
325
|
+
for (const d of folders) {
|
|
338
326
|
let name = d["name"];
|
|
339
327
|
let id = d["id"];
|
|
340
328
|
if (name == "CASS Identities") {
|
|
341
|
-
|
|
329
|
+
this.writeIdentityFiles(id, success);
|
|
342
330
|
}
|
|
343
331
|
if (name == "CASS Contacts") {
|
|
344
|
-
|
|
332
|
+
this.writeContactFiles(id);
|
|
345
333
|
}
|
|
346
334
|
}
|
|
347
335
|
})
|
|
@@ -351,36 +339,34 @@ module.exports = class OAuth2FileBasedRemoteIdentityManager extends
|
|
|
351
339
|
create(success, failure) {
|
|
352
340
|
let o = {};
|
|
353
341
|
o["scope"] = this.configuration[this.server + "Scope"];
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
me.network = me.oauthLoginResponse["network"];
|
|
342
|
+
hello.on("auth.login", (o) => {
|
|
343
|
+
this.oauthLoginResponse = o;
|
|
344
|
+
this.network = this.oauthLoginResponse["network"];
|
|
358
345
|
hello
|
|
359
|
-
.api(
|
|
360
|
-
.then(
|
|
346
|
+
.api(this.network + "/me/folders", "get", {})
|
|
347
|
+
.then((folderResponse) => {
|
|
361
348
|
let folders = folderResponse["data"];
|
|
362
349
|
let foundIdentities = false;
|
|
363
350
|
let foundContacts = false;
|
|
364
|
-
for (
|
|
365
|
-
let d = folders[i];
|
|
351
|
+
for (const d of folders) {
|
|
366
352
|
let name = d["name"];
|
|
367
353
|
let id = d["id"];
|
|
368
354
|
if (name == "CASS Identities") {
|
|
369
355
|
foundIdentities = true;
|
|
370
|
-
|
|
371
|
-
|
|
356
|
+
this.hookIdentityManagerIdentities(id);
|
|
357
|
+
this.readIdentityFiles(id, success, failure);
|
|
372
358
|
}
|
|
373
359
|
if (name == "CASS Contacts") {
|
|
374
360
|
foundContacts = true;
|
|
375
|
-
|
|
376
|
-
|
|
361
|
+
this.hookIdentityManagerContacts(id);
|
|
362
|
+
this.readContactFiles(id, success, failure);
|
|
377
363
|
}
|
|
378
364
|
}
|
|
379
365
|
if (!foundIdentities) {
|
|
380
|
-
|
|
366
|
+
this.createIdentityFolder(success);
|
|
381
367
|
}
|
|
382
368
|
if (!foundContacts) {
|
|
383
|
-
|
|
369
|
+
this.createContactFolder();
|
|
384
370
|
}
|
|
385
371
|
})
|
|
386
372
|
.fail(failure);
|
|
@@ -9,13 +9,13 @@ module.exports = class RemoteIdentityManagerInterface {
|
|
|
9
9
|
secretSalt,
|
|
10
10
|
secretIterations
|
|
11
11
|
) {}
|
|
12
|
-
configureFromServer(success, failure) {/*Do nothing.*/}
|
|
12
|
+
async configureFromServer(success, failure) {/*Do nothing.*/}
|
|
13
13
|
isGlobal() {/*Do nothing.*/ }
|
|
14
14
|
clear() {/*Do nothing.*/ }
|
|
15
15
|
setDefaultIdentityManagementServer(server) {/*Do nothing.*/ }
|
|
16
16
|
startLogin(username, password) {/*Do nothing.*/ }
|
|
17
17
|
changePassword(username, oldPassword, newPassword) {/*Do nothing.*/ }
|
|
18
18
|
fetch(success, failure) {/*Do nothing.*/ }
|
|
19
|
-
commit(success, failure) {/*Do nothing.*/ }
|
|
20
|
-
create(success, failure) {/*Do nothing.*/ }
|
|
19
|
+
async commit(success, failure) {/*Do nothing.*/ }
|
|
20
|
+
async create(success, failure) {/*Do nothing.*/ }
|
|
21
21
|
};
|