@twin.org/identity-connector-entity-storage 0.0.1-next.16 → 0.0.1-next.17
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/dist/cjs/index.cjs +24 -14
- package/dist/esm/index.mjs +24 -14
- package/docs/changelog.md +1 -1
- package/locales/en.json +2 -2
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -215,7 +215,7 @@ class EntityStorageIdentityConnector {
|
|
|
215
215
|
}
|
|
216
216
|
return m.method.id === methodId;
|
|
217
217
|
});
|
|
218
|
-
if (existingMethodIndex
|
|
218
|
+
if (existingMethodIndex !== -1) {
|
|
219
219
|
const methodArray = didDocument[methods[existingMethodIndex].arrayKey];
|
|
220
220
|
if (core.Is.array(methodArray)) {
|
|
221
221
|
methodArray.splice(existingMethodIndex, 1);
|
|
@@ -268,7 +268,7 @@ class EntityStorageIdentityConnector {
|
|
|
268
268
|
}
|
|
269
269
|
return m.method.id === verificationMethodId;
|
|
270
270
|
});
|
|
271
|
-
if (existingMethodIndex
|
|
271
|
+
if (existingMethodIndex !== -1) {
|
|
272
272
|
const methodArray = didDocument[methods[existingMethodIndex].arrayKey];
|
|
273
273
|
if (core.Is.array(methodArray)) {
|
|
274
274
|
methodArray.splice(existingMethodIndex, 1);
|
|
@@ -312,7 +312,7 @@ class EntityStorageIdentityConnector {
|
|
|
312
312
|
const fullServiceId = serviceId.includes("#") ? serviceId : `${documentId}#${serviceId}`;
|
|
313
313
|
if (core.Is.array(didDocument.service)) {
|
|
314
314
|
const existingServiceIndex = didDocument.service.findIndex(s => s.id === fullServiceId);
|
|
315
|
-
if (existingServiceIndex
|
|
315
|
+
if (existingServiceIndex !== -1) {
|
|
316
316
|
didDocument.service?.splice(existingServiceIndex, 1);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
@@ -353,7 +353,7 @@ class EntityStorageIdentityConnector {
|
|
|
353
353
|
const didDocument = didIdentityDocument.document;
|
|
354
354
|
if (core.Is.array(didDocument.service)) {
|
|
355
355
|
const existingServiceIndex = didDocument.service.findIndex(s => s.id === serviceId);
|
|
356
|
-
if (existingServiceIndex
|
|
356
|
+
if (existingServiceIndex !== -1) {
|
|
357
357
|
didDocument.service?.splice(existingServiceIndex, 1);
|
|
358
358
|
if (didDocument.service?.length === 0) {
|
|
359
359
|
delete didDocument.service;
|
|
@@ -405,11 +405,13 @@ class EntityStorageIdentityConnector {
|
|
|
405
405
|
return m.method.id === verificationMethodId;
|
|
406
406
|
});
|
|
407
407
|
if (!methodAndArray) {
|
|
408
|
-
throw new core.GeneralError(this.CLASS_NAME, "methodMissing");
|
|
408
|
+
throw new core.GeneralError(this.CLASS_NAME, "methodMissing", { method: verificationMethodId });
|
|
409
409
|
}
|
|
410
410
|
const verificationDidMethod = methodAndArray.method;
|
|
411
411
|
if (!core.Is.stringValue(verificationDidMethod.publicKeyJwk?.x)) {
|
|
412
|
-
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing"
|
|
412
|
+
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
|
|
413
|
+
method: verificationMethodId
|
|
414
|
+
});
|
|
413
415
|
}
|
|
414
416
|
const revocationService = issuerDidDocument.service?.find(s => s.id.endsWith("#revocation"));
|
|
415
417
|
const credentialClone = core.ObjectHelper.clone(credential);
|
|
@@ -510,11 +512,11 @@ class EntityStorageIdentityConnector {
|
|
|
510
512
|
return m.method.id === jwtHeader.kid;
|
|
511
513
|
});
|
|
512
514
|
if (!methodAndArray) {
|
|
513
|
-
throw new core.GeneralError(this.CLASS_NAME, "methodMissing");
|
|
515
|
+
throw new core.GeneralError(this.CLASS_NAME, "methodMissing", { method: jwtHeader.kid });
|
|
514
516
|
}
|
|
515
517
|
const didMethod = methodAndArray.method;
|
|
516
518
|
if (!core.Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
517
|
-
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing");
|
|
519
|
+
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", { method: jwtHeader.kid });
|
|
518
520
|
}
|
|
519
521
|
const verified = web.Jwt.verifySignature(jwtHeader, jwtPayload, jwtSignature, core.Converter.base64UrlToBytes(didMethod.publicKeyJwk.x));
|
|
520
522
|
if (!verified) {
|
|
@@ -673,11 +675,13 @@ class EntityStorageIdentityConnector {
|
|
|
673
675
|
return m.method.id === presentationMethodId;
|
|
674
676
|
});
|
|
675
677
|
if (!methodAndArray) {
|
|
676
|
-
throw new core.GeneralError(this.CLASS_NAME, "methodMissing");
|
|
678
|
+
throw new core.GeneralError(this.CLASS_NAME, "methodMissing", { method: presentationMethodId });
|
|
677
679
|
}
|
|
678
680
|
const didMethod = methodAndArray.method;
|
|
679
681
|
if (!core.Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
680
|
-
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing"
|
|
682
|
+
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
|
|
683
|
+
method: presentationMethodId
|
|
684
|
+
});
|
|
681
685
|
}
|
|
682
686
|
const finalTypes = [standardsW3cDid.DidTypes.VerifiablePresentation];
|
|
683
687
|
if (core.Is.array(types)) {
|
|
@@ -824,11 +828,13 @@ class EntityStorageIdentityConnector {
|
|
|
824
828
|
return m.method.id === verificationMethodId;
|
|
825
829
|
});
|
|
826
830
|
if (!methodAndArray) {
|
|
827
|
-
throw new core.GeneralError(this.CLASS_NAME, "methodMissing");
|
|
831
|
+
throw new core.GeneralError(this.CLASS_NAME, "methodMissing", { method: verificationMethodId });
|
|
828
832
|
}
|
|
829
833
|
const didMethod = methodAndArray.method;
|
|
830
834
|
if (!core.Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
831
|
-
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing"
|
|
835
|
+
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
|
|
836
|
+
method: verificationMethodId
|
|
837
|
+
});
|
|
832
838
|
}
|
|
833
839
|
const signature = await this._vaultConnector.sign(this.buildVaultKey(didDocument.id, idParts.hash ?? ""), bytes);
|
|
834
840
|
return {
|
|
@@ -883,11 +889,15 @@ class EntityStorageIdentityConnector {
|
|
|
883
889
|
return m.method.id === proof.verificationMethod;
|
|
884
890
|
});
|
|
885
891
|
if (!methodAndArray) {
|
|
886
|
-
throw new core.GeneralError(this.CLASS_NAME, "methodMissing"
|
|
892
|
+
throw new core.GeneralError(this.CLASS_NAME, "methodMissing", {
|
|
893
|
+
method: proof.verificationMethod
|
|
894
|
+
});
|
|
887
895
|
}
|
|
888
896
|
const didMethod = methodAndArray.method;
|
|
889
897
|
if (!core.Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
890
|
-
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing"
|
|
898
|
+
throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
|
|
899
|
+
method: proof.verificationMethodId
|
|
900
|
+
});
|
|
891
901
|
}
|
|
892
902
|
return this._vaultConnector.verify(this.buildVaultKey(didIdentityDocument.id, idParts.hash), bytes, core.Converter.base58ToBytes(proof.proofValue));
|
|
893
903
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -213,7 +213,7 @@ class EntityStorageIdentityConnector {
|
|
|
213
213
|
}
|
|
214
214
|
return m.method.id === methodId;
|
|
215
215
|
});
|
|
216
|
-
if (existingMethodIndex
|
|
216
|
+
if (existingMethodIndex !== -1) {
|
|
217
217
|
const methodArray = didDocument[methods[existingMethodIndex].arrayKey];
|
|
218
218
|
if (Is.array(methodArray)) {
|
|
219
219
|
methodArray.splice(existingMethodIndex, 1);
|
|
@@ -266,7 +266,7 @@ class EntityStorageIdentityConnector {
|
|
|
266
266
|
}
|
|
267
267
|
return m.method.id === verificationMethodId;
|
|
268
268
|
});
|
|
269
|
-
if (existingMethodIndex
|
|
269
|
+
if (existingMethodIndex !== -1) {
|
|
270
270
|
const methodArray = didDocument[methods[existingMethodIndex].arrayKey];
|
|
271
271
|
if (Is.array(methodArray)) {
|
|
272
272
|
methodArray.splice(existingMethodIndex, 1);
|
|
@@ -310,7 +310,7 @@ class EntityStorageIdentityConnector {
|
|
|
310
310
|
const fullServiceId = serviceId.includes("#") ? serviceId : `${documentId}#${serviceId}`;
|
|
311
311
|
if (Is.array(didDocument.service)) {
|
|
312
312
|
const existingServiceIndex = didDocument.service.findIndex(s => s.id === fullServiceId);
|
|
313
|
-
if (existingServiceIndex
|
|
313
|
+
if (existingServiceIndex !== -1) {
|
|
314
314
|
didDocument.service?.splice(existingServiceIndex, 1);
|
|
315
315
|
}
|
|
316
316
|
}
|
|
@@ -351,7 +351,7 @@ class EntityStorageIdentityConnector {
|
|
|
351
351
|
const didDocument = didIdentityDocument.document;
|
|
352
352
|
if (Is.array(didDocument.service)) {
|
|
353
353
|
const existingServiceIndex = didDocument.service.findIndex(s => s.id === serviceId);
|
|
354
|
-
if (existingServiceIndex
|
|
354
|
+
if (existingServiceIndex !== -1) {
|
|
355
355
|
didDocument.service?.splice(existingServiceIndex, 1);
|
|
356
356
|
if (didDocument.service?.length === 0) {
|
|
357
357
|
delete didDocument.service;
|
|
@@ -403,11 +403,13 @@ class EntityStorageIdentityConnector {
|
|
|
403
403
|
return m.method.id === verificationMethodId;
|
|
404
404
|
});
|
|
405
405
|
if (!methodAndArray) {
|
|
406
|
-
throw new GeneralError(this.CLASS_NAME, "methodMissing");
|
|
406
|
+
throw new GeneralError(this.CLASS_NAME, "methodMissing", { method: verificationMethodId });
|
|
407
407
|
}
|
|
408
408
|
const verificationDidMethod = methodAndArray.method;
|
|
409
409
|
if (!Is.stringValue(verificationDidMethod.publicKeyJwk?.x)) {
|
|
410
|
-
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing"
|
|
410
|
+
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
|
|
411
|
+
method: verificationMethodId
|
|
412
|
+
});
|
|
411
413
|
}
|
|
412
414
|
const revocationService = issuerDidDocument.service?.find(s => s.id.endsWith("#revocation"));
|
|
413
415
|
const credentialClone = ObjectHelper.clone(credential);
|
|
@@ -508,11 +510,11 @@ class EntityStorageIdentityConnector {
|
|
|
508
510
|
return m.method.id === jwtHeader.kid;
|
|
509
511
|
});
|
|
510
512
|
if (!methodAndArray) {
|
|
511
|
-
throw new GeneralError(this.CLASS_NAME, "methodMissing");
|
|
513
|
+
throw new GeneralError(this.CLASS_NAME, "methodMissing", { method: jwtHeader.kid });
|
|
512
514
|
}
|
|
513
515
|
const didMethod = methodAndArray.method;
|
|
514
516
|
if (!Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
515
|
-
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing");
|
|
517
|
+
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", { method: jwtHeader.kid });
|
|
516
518
|
}
|
|
517
519
|
const verified = Jwt.verifySignature(jwtHeader, jwtPayload, jwtSignature, Converter.base64UrlToBytes(didMethod.publicKeyJwk.x));
|
|
518
520
|
if (!verified) {
|
|
@@ -671,11 +673,13 @@ class EntityStorageIdentityConnector {
|
|
|
671
673
|
return m.method.id === presentationMethodId;
|
|
672
674
|
});
|
|
673
675
|
if (!methodAndArray) {
|
|
674
|
-
throw new GeneralError(this.CLASS_NAME, "methodMissing");
|
|
676
|
+
throw new GeneralError(this.CLASS_NAME, "methodMissing", { method: presentationMethodId });
|
|
675
677
|
}
|
|
676
678
|
const didMethod = methodAndArray.method;
|
|
677
679
|
if (!Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
678
|
-
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing"
|
|
680
|
+
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
|
|
681
|
+
method: presentationMethodId
|
|
682
|
+
});
|
|
679
683
|
}
|
|
680
684
|
const finalTypes = [DidTypes.VerifiablePresentation];
|
|
681
685
|
if (Is.array(types)) {
|
|
@@ -822,11 +826,13 @@ class EntityStorageIdentityConnector {
|
|
|
822
826
|
return m.method.id === verificationMethodId;
|
|
823
827
|
});
|
|
824
828
|
if (!methodAndArray) {
|
|
825
|
-
throw new GeneralError(this.CLASS_NAME, "methodMissing");
|
|
829
|
+
throw new GeneralError(this.CLASS_NAME, "methodMissing", { method: verificationMethodId });
|
|
826
830
|
}
|
|
827
831
|
const didMethod = methodAndArray.method;
|
|
828
832
|
if (!Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
829
|
-
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing"
|
|
833
|
+
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
|
|
834
|
+
method: verificationMethodId
|
|
835
|
+
});
|
|
830
836
|
}
|
|
831
837
|
const signature = await this._vaultConnector.sign(this.buildVaultKey(didDocument.id, idParts.hash ?? ""), bytes);
|
|
832
838
|
return {
|
|
@@ -881,11 +887,15 @@ class EntityStorageIdentityConnector {
|
|
|
881
887
|
return m.method.id === proof.verificationMethod;
|
|
882
888
|
});
|
|
883
889
|
if (!methodAndArray) {
|
|
884
|
-
throw new GeneralError(this.CLASS_NAME, "methodMissing"
|
|
890
|
+
throw new GeneralError(this.CLASS_NAME, "methodMissing", {
|
|
891
|
+
method: proof.verificationMethod
|
|
892
|
+
});
|
|
885
893
|
}
|
|
886
894
|
const didMethod = methodAndArray.method;
|
|
887
895
|
if (!Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
888
|
-
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing"
|
|
896
|
+
throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
|
|
897
|
+
method: proof.verificationMethodId
|
|
898
|
+
});
|
|
889
899
|
}
|
|
890
900
|
return this._vaultConnector.verify(this.buildVaultKey(didIdentityDocument.id, idParts.hash), bytes, Converter.base58ToBytes(proof.proofValue));
|
|
891
901
|
}
|
package/docs/changelog.md
CHANGED
package/locales/en.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"verificationMethodNotFound": "The verification method could not be found",
|
|
15
15
|
"verificationPrivateKeyNotFound": "The private key for the verification method could not be found in the vault",
|
|
16
16
|
"serviceNotFound": "The service could not be found",
|
|
17
|
-
"publicKeyJwkMissing": "The verification method contains no publicKeyJwk",
|
|
17
|
+
"publicKeyJwkMissing": "The verification method contains no publicKeyJwk in method \"{method}\"",
|
|
18
18
|
"jwkSignatureFailed": "The signature on the JWK failed verification",
|
|
19
19
|
"createVerifiableCredentialFailed": "Creating the verifiable credential failed",
|
|
20
20
|
"checkingVerifiableCredentialFailed": "Checking the verifiable credential failed",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"expectingJwtCredential": "Expecting JWT credential in the presentation",
|
|
24
24
|
"keyIndexOutOfRange": "The supplied keyIndex is not in the range of the key list",
|
|
25
25
|
"createProofFailed": "Creating the signature for the data failed",
|
|
26
|
-
"methodMissing": "The verification method specified does not exist",
|
|
26
|
+
"methodMissing": "The verification method specified does not exist \"{method}\"",
|
|
27
27
|
"verifyProofFailed": "Verifying the signature for the data failed",
|
|
28
28
|
"revokeVerifiableCredentialsFailed": "Revoking verifiable credentials failed",
|
|
29
29
|
"unrevokeVerifiableCredentialsFailed": "Unrevoking verifiable credentials failed",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-connector-entity-storage",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.17",
|
|
4
4
|
"description": "Identity connector implementation using entity storage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@twin.org/data-core": "next",
|
|
20
20
|
"@twin.org/data-json-ld": "next",
|
|
21
21
|
"@twin.org/entity": "next",
|
|
22
|
-
"@twin.org/identity-models": "0.0.1-next.
|
|
22
|
+
"@twin.org/identity-models": "0.0.1-next.17",
|
|
23
23
|
"@twin.org/nameof": "next",
|
|
24
24
|
"@twin.org/standards-w3c-did": "next",
|
|
25
25
|
"@twin.org/vault-models": "next",
|