@twin.org/immutable-proof-service 0.0.1-next.23 → 0.0.1-next.25
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 +14 -13
- package/dist/esm/index.mjs +15 -14
- package/docs/changelog.md +1 -1
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -305,7 +305,7 @@ async function immutableProofCreate(httpRequestContext, componentName, request)
|
|
|
305
305
|
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
306
306
|
core.Guards.object(ROUTES_SOURCE, "request.body.proofObject", request.body.proofObject);
|
|
307
307
|
const component = core.ComponentFactory.get(componentName);
|
|
308
|
-
const result = await component.create(request.body.proofObject);
|
|
308
|
+
const result = await component.create(request.body.proofObject, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
309
309
|
return {
|
|
310
310
|
statusCode: web.HttpStatusCode.created,
|
|
311
311
|
headers: {
|
|
@@ -644,29 +644,30 @@ class ImmutableProofService {
|
|
|
644
644
|
if (core.Is.empty(proofEntity)) {
|
|
645
645
|
throw new core.NotFoundError(this.CLASS_NAME, "proofNotFound", id);
|
|
646
646
|
}
|
|
647
|
-
let
|
|
647
|
+
let proofJsonLd = await this.proofEntityToJsonLd(proofEntity);
|
|
648
648
|
let verified = false;
|
|
649
649
|
let failure = immutableProofModels.ImmutableProofFailure.NotIssued;
|
|
650
650
|
if (core.Is.stringValue(proofEntity.immutableStorageId)) {
|
|
651
651
|
failure = immutableProofModels.ImmutableProofFailure.ProofMissing;
|
|
652
652
|
const immutableResult = await this._immutableStorage.get(proofEntity.immutableStorageId);
|
|
653
653
|
if (core.Is.uint8Array(immutableResult.data)) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
// As we are adding the receipt to the data we update
|
|
657
|
-
|
|
658
|
-
|
|
654
|
+
proofJsonLd = core.ObjectHelper.fromBytes(immutableResult.data);
|
|
655
|
+
proofJsonLd.immutableReceipt = immutableResult.receipt;
|
|
656
|
+
// As we are adding the receipt to the data we update the JSON-LD context
|
|
657
|
+
const receiptContext = immutableResult.receipt["@context"];
|
|
658
|
+
if (!core.Is.empty(receiptContext)) {
|
|
659
|
+
proofJsonLd["@context"] = dataJsonLd.JsonLdProcessor.combineContexts(proofJsonLd["@context"], receiptContext);
|
|
659
660
|
}
|
|
660
|
-
if (verify && core.Is.object(
|
|
661
|
-
if (
|
|
661
|
+
if (verify && core.Is.object(proofJsonLd.proof)) {
|
|
662
|
+
if (proofJsonLd.proof.cryptosuite !== standardsW3cDid.DidCryptoSuites.EdDSAJcs2022) {
|
|
662
663
|
failure = immutableProofModels.ImmutableProofFailure.CryptoSuiteMismatch;
|
|
663
664
|
}
|
|
664
|
-
else if (
|
|
665
|
+
else if (proofJsonLd.proof.type !== standardsW3cDid.DidTypes.DataIntegrityProof) {
|
|
665
666
|
failure = immutableProofModels.ImmutableProofFailure.ProofTypeMismatch;
|
|
666
667
|
}
|
|
667
668
|
else {
|
|
668
|
-
const hashData = await this.generateHashData(proofEntity.nodeIdentity,
|
|
669
|
-
const isVerified = await this._identityConnector.verifyProof(hashData,
|
|
669
|
+
const hashData = await this.generateHashData(proofEntity.nodeIdentity, proofJsonLd);
|
|
670
|
+
const isVerified = await this._identityConnector.verifyProof(hashData, proofJsonLd.proof);
|
|
670
671
|
if (isVerified) {
|
|
671
672
|
verified = true;
|
|
672
673
|
failure = undefined;
|
|
@@ -679,7 +680,7 @@ class ImmutableProofService {
|
|
|
679
680
|
}
|
|
680
681
|
}
|
|
681
682
|
return {
|
|
682
|
-
immutableProof:
|
|
683
|
+
immutableProof: proofJsonLd,
|
|
683
684
|
verified,
|
|
684
685
|
failure
|
|
685
686
|
};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { Blake2b, Sha256 } from '@twin.org/crypto';
|
|
|
8
8
|
import { JsonLdHelper, JsonLdProcessor } from '@twin.org/data-json-ld';
|
|
9
9
|
import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
|
|
10
10
|
import { IdentityConnectorFactory } from '@twin.org/identity-models';
|
|
11
|
-
import { ImmutableStorageConnectorFactory
|
|
11
|
+
import { ImmutableStorageConnectorFactory } from '@twin.org/immutable-storage-models';
|
|
12
12
|
import { VaultConnectorFactory } from '@twin.org/vault-models';
|
|
13
13
|
|
|
14
14
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -303,7 +303,7 @@ async function immutableProofCreate(httpRequestContext, componentName, request)
|
|
|
303
303
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
304
304
|
Guards.object(ROUTES_SOURCE, "request.body.proofObject", request.body.proofObject);
|
|
305
305
|
const component = ComponentFactory.get(componentName);
|
|
306
|
-
const result = await component.create(request.body.proofObject);
|
|
306
|
+
const result = await component.create(request.body.proofObject, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
307
307
|
return {
|
|
308
308
|
statusCode: HttpStatusCode.created,
|
|
309
309
|
headers: {
|
|
@@ -642,29 +642,30 @@ class ImmutableProofService {
|
|
|
642
642
|
if (Is.empty(proofEntity)) {
|
|
643
643
|
throw new NotFoundError(this.CLASS_NAME, "proofNotFound", id);
|
|
644
644
|
}
|
|
645
|
-
let
|
|
645
|
+
let proofJsonLd = await this.proofEntityToJsonLd(proofEntity);
|
|
646
646
|
let verified = false;
|
|
647
647
|
let failure = ImmutableProofFailure.NotIssued;
|
|
648
648
|
if (Is.stringValue(proofEntity.immutableStorageId)) {
|
|
649
649
|
failure = ImmutableProofFailure.ProofMissing;
|
|
650
650
|
const immutableResult = await this._immutableStorage.get(proofEntity.immutableStorageId);
|
|
651
651
|
if (Is.uint8Array(immutableResult.data)) {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
// As we are adding the receipt to the data we update
|
|
655
|
-
|
|
656
|
-
|
|
652
|
+
proofJsonLd = ObjectHelper.fromBytes(immutableResult.data);
|
|
653
|
+
proofJsonLd.immutableReceipt = immutableResult.receipt;
|
|
654
|
+
// As we are adding the receipt to the data we update the JSON-LD context
|
|
655
|
+
const receiptContext = immutableResult.receipt["@context"];
|
|
656
|
+
if (!Is.empty(receiptContext)) {
|
|
657
|
+
proofJsonLd["@context"] = JsonLdProcessor.combineContexts(proofJsonLd["@context"], receiptContext);
|
|
657
658
|
}
|
|
658
|
-
if (verify && Is.object(
|
|
659
|
-
if (
|
|
659
|
+
if (verify && Is.object(proofJsonLd.proof)) {
|
|
660
|
+
if (proofJsonLd.proof.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {
|
|
660
661
|
failure = ImmutableProofFailure.CryptoSuiteMismatch;
|
|
661
662
|
}
|
|
662
|
-
else if (
|
|
663
|
+
else if (proofJsonLd.proof.type !== DidTypes.DataIntegrityProof) {
|
|
663
664
|
failure = ImmutableProofFailure.ProofTypeMismatch;
|
|
664
665
|
}
|
|
665
666
|
else {
|
|
666
|
-
const hashData = await this.generateHashData(proofEntity.nodeIdentity,
|
|
667
|
-
const isVerified = await this._identityConnector.verifyProof(hashData,
|
|
667
|
+
const hashData = await this.generateHashData(proofEntity.nodeIdentity, proofJsonLd);
|
|
668
|
+
const isVerified = await this._identityConnector.verifyProof(hashData, proofJsonLd.proof);
|
|
668
669
|
if (isVerified) {
|
|
669
670
|
verified = true;
|
|
670
671
|
failure = undefined;
|
|
@@ -677,7 +678,7 @@ class ImmutableProofService {
|
|
|
677
678
|
}
|
|
678
679
|
}
|
|
679
680
|
return {
|
|
680
|
-
immutableProof:
|
|
681
|
+
immutableProof: proofJsonLd,
|
|
681
682
|
verified,
|
|
682
683
|
failure
|
|
683
684
|
};
|
package/docs/changelog.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/immutable-proof-service",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.25",
|
|
4
4
|
"description": "Immutable proof contract implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@twin.org/entity-storage-models": "next",
|
|
24
24
|
"@twin.org/event-bus-models": "next",
|
|
25
25
|
"@twin.org/identity-models": "next",
|
|
26
|
-
"@twin.org/immutable-proof-models": "0.0.1-next.
|
|
27
|
-
"@twin.org/immutable-proof-task": "0.0.1-next.
|
|
26
|
+
"@twin.org/immutable-proof-models": "0.0.1-next.25",
|
|
27
|
+
"@twin.org/immutable-proof-task": "0.0.1-next.25",
|
|
28
28
|
"@twin.org/immutable-storage-models": "next",
|
|
29
29
|
"@twin.org/nameof": "next",
|
|
30
30
|
"@twin.org/standards-w3c-did": "next",
|