@twin.org/immutable-proof-service 0.0.1-next.24 → 0.0.1-next.26
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 +40 -79
- package/dist/esm/index.mjs +42 -81
- package/dist/types/immutableProofService.d.ts +6 -6
- package/dist/types/models/IImmutableProofServiceConfig.d.ts +0 -5
- package/dist/types/models/IImmutableProofServiceConstructorOptions.d.ts +0 -5
- package/docs/changelog.md +1 -1
- package/docs/open-api/spec.json +27 -25
- package/docs/reference/classes/ImmutableProofService.md +7 -7
- package/docs/reference/interfaces/IImmutableProofServiceConfig.md +0 -14
- package/docs/reference/interfaces/IImmutableProofServiceConstructorOptions.md +0 -14
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -11,7 +11,6 @@ var dataJsonLd = require('@twin.org/data-json-ld');
|
|
|
11
11
|
var entityStorageModels = require('@twin.org/entity-storage-models');
|
|
12
12
|
var identityModels = require('@twin.org/identity-models');
|
|
13
13
|
var immutableStorageModels = require('@twin.org/immutable-storage-models');
|
|
14
|
-
var vaultModels = require('@twin.org/vault-models');
|
|
15
14
|
|
|
16
15
|
// Copyright 2024 IOTA Stiftung.
|
|
17
16
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -65,7 +64,7 @@ __decorate([
|
|
|
65
64
|
__metadata("design:type", String)
|
|
66
65
|
], exports.ImmutableProof.prototype, "dateCreated", void 0);
|
|
67
66
|
__decorate([
|
|
68
|
-
entity.property({ type: "string" }),
|
|
67
|
+
entity.property({ type: "string", optional: true }),
|
|
69
68
|
__metadata("design:type", String)
|
|
70
69
|
], exports.ImmutableProof.prototype, "proofObjectId", void 0);
|
|
71
70
|
__decorate([
|
|
@@ -73,7 +72,7 @@ __decorate([
|
|
|
73
72
|
__metadata("design:type", String)
|
|
74
73
|
], exports.ImmutableProof.prototype, "proofObjectHash", void 0);
|
|
75
74
|
__decorate([
|
|
76
|
-
entity.property({ type: "string" }),
|
|
75
|
+
entity.property({ type: "string", optional: true }),
|
|
77
76
|
__metadata("design:type", String)
|
|
78
77
|
], exports.ImmutableProof.prototype, "immutableStorageId", void 0);
|
|
79
78
|
exports.ImmutableProof = __decorate([
|
|
@@ -114,7 +113,7 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
114
113
|
id: "immutableProofCreateRequestExample",
|
|
115
114
|
request: {
|
|
116
115
|
body: {
|
|
117
|
-
|
|
116
|
+
document: {
|
|
118
117
|
"@context": "https://schema.org",
|
|
119
118
|
type: "Person",
|
|
120
119
|
name: "John Smith"
|
|
@@ -181,12 +180,13 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
181
180
|
],
|
|
182
181
|
type: immutableProofModels.ImmutableProofTypes.ImmutableProof,
|
|
183
182
|
id: "ais:1234567890",
|
|
183
|
+
nodeIdentity: "node-1",
|
|
184
184
|
userIdentity: "user-1",
|
|
185
185
|
proofObjectId: "test:1234567890",
|
|
186
186
|
proofObjectHash: "EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=",
|
|
187
187
|
proof: {
|
|
188
|
-
"@context": standardsW3cDid.DidContexts.
|
|
189
|
-
type: standardsW3cDid.
|
|
188
|
+
"@context": standardsW3cDid.DidContexts.ContextDataIntegrity,
|
|
189
|
+
type: standardsW3cDid.ProofTypes.DataIntegrityProof,
|
|
190
190
|
cryptosuite: standardsW3cDid.DidCryptoSuites.EdDSAJcs2022,
|
|
191
191
|
created: "2024-08-22T11:56:56.272Z",
|
|
192
192
|
proofPurpose: "assertionMethod",
|
|
@@ -214,12 +214,13 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
214
214
|
],
|
|
215
215
|
type: immutableProofModels.ImmutableProofTypes.ImmutableProof,
|
|
216
216
|
id: "ais:1234567890",
|
|
217
|
+
nodeIdentity: "node-1",
|
|
217
218
|
userIdentity: "user-1",
|
|
218
219
|
proofObjectId: "test:1234567890",
|
|
219
220
|
proofObjectHash: "EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=",
|
|
220
221
|
proof: {
|
|
221
|
-
"@context": standardsW3cDid.DidContexts.
|
|
222
|
-
type: standardsW3cDid.
|
|
222
|
+
"@context": standardsW3cDid.DidContexts.ContextDataIntegrity,
|
|
223
|
+
type: standardsW3cDid.ProofTypes.DataIntegrityProof,
|
|
223
224
|
cryptosuite: standardsW3cDid.DidCryptoSuites.EdDSAJcs2022,
|
|
224
225
|
created: "2024-08-22T11:56:56.272Z",
|
|
225
226
|
proofPurpose: "assertionMethod",
|
|
@@ -303,9 +304,9 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
303
304
|
*/
|
|
304
305
|
async function immutableProofCreate(httpRequestContext, componentName, request) {
|
|
305
306
|
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
306
|
-
core.Guards.object(ROUTES_SOURCE, "request.body.
|
|
307
|
+
core.Guards.object(ROUTES_SOURCE, "request.body.document", request.body.document);
|
|
307
308
|
const component = core.ComponentFactory.get(componentName);
|
|
308
|
-
const result = await component.create(request.body.
|
|
309
|
+
const result = await component.create(request.body.document, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
309
310
|
return {
|
|
310
311
|
statusCode: web.HttpStatusCode.created,
|
|
311
312
|
headers: {
|
|
@@ -375,11 +376,6 @@ class ImmutableProofService {
|
|
|
375
376
|
* @internal
|
|
376
377
|
*/
|
|
377
378
|
_config;
|
|
378
|
-
/**
|
|
379
|
-
* The vault connector.
|
|
380
|
-
* @internal
|
|
381
|
-
*/
|
|
382
|
-
_vaultConnector;
|
|
383
379
|
/**
|
|
384
380
|
* The identity connector.
|
|
385
381
|
* @internal
|
|
@@ -410,11 +406,6 @@ class ImmutableProofService {
|
|
|
410
406
|
* @internal
|
|
411
407
|
*/
|
|
412
408
|
_verificationMethodId;
|
|
413
|
-
/**
|
|
414
|
-
* The proof hash key id to use for the proofs.
|
|
415
|
-
* @internal
|
|
416
|
-
*/
|
|
417
|
-
_proofHashKeyId;
|
|
418
409
|
/**
|
|
419
410
|
* The identity connector type.
|
|
420
411
|
* @internal
|
|
@@ -425,7 +416,6 @@ class ImmutableProofService {
|
|
|
425
416
|
* @param options The dependencies for the immutable proof connector.
|
|
426
417
|
*/
|
|
427
418
|
constructor(options) {
|
|
428
|
-
this._vaultConnector = vaultModels.VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
|
|
429
419
|
this._proofStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.immutableProofEntityStorageType ?? core.StringHelper.kebabCase("ImmutableProof"));
|
|
430
420
|
this._immutableStorage = immutableStorageModels.ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
|
|
431
421
|
this._identityConnectorType = options?.identityConnectorType ?? "identity";
|
|
@@ -436,47 +426,48 @@ class ImmutableProofService {
|
|
|
436
426
|
}
|
|
437
427
|
this._config = options?.config ?? {};
|
|
438
428
|
this._verificationMethodId = this._config.verificationMethodId ?? "immutable-proof-assertion";
|
|
439
|
-
this._proofHashKeyId = this._config.proofHashKeyId ?? "immutable-proof-hash";
|
|
440
429
|
this._backgroundTaskConnector.registerHandler("immutable-proof", "@twin.org/immutable-proof-task", "processProofTask", async (task) => {
|
|
441
430
|
await this.finaliseTask(task);
|
|
442
431
|
});
|
|
443
432
|
}
|
|
444
433
|
/**
|
|
445
|
-
* Create a new
|
|
446
|
-
* @param
|
|
434
|
+
* Create a new proof.
|
|
435
|
+
* @param document The document to create the proof for.
|
|
447
436
|
* @param userIdentity The identity to create the immutable proof operation with.
|
|
448
437
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
449
|
-
* @returns The id of the new
|
|
438
|
+
* @returns The id of the new proof.
|
|
450
439
|
*/
|
|
451
|
-
async create(
|
|
452
|
-
core.Guards.object(this.CLASS_NAME, "
|
|
440
|
+
async create(document, userIdentity, nodeIdentity) {
|
|
441
|
+
core.Guards.object(this.CLASS_NAME, "document", document);
|
|
453
442
|
core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
454
443
|
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
455
444
|
try {
|
|
456
445
|
const validationFailures = [];
|
|
457
|
-
await dataJsonLd.JsonLdHelper.validate(
|
|
458
|
-
core.Validation.asValidationError(this.CLASS_NAME, "
|
|
446
|
+
await dataJsonLd.JsonLdHelper.validate(document, validationFailures);
|
|
447
|
+
core.Validation.asValidationError(this.CLASS_NAME, "document", validationFailures);
|
|
459
448
|
const id = core.Converter.bytesToHex(core.RandomHelper.generate(32), false);
|
|
460
449
|
const dateCreated = new Date(Date.now()).toISOString();
|
|
461
|
-
const proofObjectId = core.ObjectHelper.extractProperty(
|
|
462
|
-
|
|
450
|
+
const proofObjectId = core.ObjectHelper.extractProperty(document, ["@id", "id"], false);
|
|
451
|
+
// We don't want to store the whole document in the immutable proof, as this could be large
|
|
452
|
+
// and also reveal information that should not be stored in the proof so we hash the document
|
|
453
|
+
// and store the hash
|
|
454
|
+
const proofObjectHash = this.calculateDocumentHash(document);
|
|
463
455
|
const proofEntity = {
|
|
464
456
|
id,
|
|
465
457
|
nodeIdentity,
|
|
466
458
|
userIdentity,
|
|
467
459
|
dateCreated,
|
|
468
460
|
proofObjectId,
|
|
469
|
-
proofObjectHash
|
|
461
|
+
proofObjectHash
|
|
470
462
|
};
|
|
471
463
|
await this._proofStorage.set(proofEntity);
|
|
472
464
|
const immutableProof = this.proofEntityToJsonLd(proofEntity);
|
|
473
|
-
const hashData = await this.generateHashData(proofEntity.nodeIdentity, immutableProof);
|
|
474
465
|
const proofTaskPayload = {
|
|
475
466
|
proofId: id,
|
|
476
467
|
nodeIdentity,
|
|
477
468
|
identityConnectorType: this._identityConnectorType,
|
|
478
|
-
|
|
479
|
-
|
|
469
|
+
verificationMethodId: this._verificationMethodId,
|
|
470
|
+
document: immutableProof
|
|
480
471
|
};
|
|
481
472
|
await this._backgroundTaskConnector.create("immutable-proof", proofTaskPayload);
|
|
482
473
|
return new core.Urn(ImmutableProofService.NAMESPACE, id).toString();
|
|
@@ -486,7 +477,7 @@ class ImmutableProofService {
|
|
|
486
477
|
}
|
|
487
478
|
}
|
|
488
479
|
/**
|
|
489
|
-
* Get
|
|
480
|
+
* Get a proof.
|
|
490
481
|
* @param id The id of the proof to get.
|
|
491
482
|
* @returns The proof.
|
|
492
483
|
* @throws NotFoundError if the proof is not found.
|
|
@@ -509,7 +500,7 @@ class ImmutableProofService {
|
|
|
509
500
|
}
|
|
510
501
|
}
|
|
511
502
|
/**
|
|
512
|
-
* Verify
|
|
503
|
+
* Verify a proof.
|
|
513
504
|
* @param id The id of the proof to verify.
|
|
514
505
|
* @returns The result of the verification and any failures.
|
|
515
506
|
* @throws NotFoundError if the proof is not found.
|
|
@@ -575,14 +566,8 @@ class ImmutableProofService {
|
|
|
575
566
|
* @returns The hash.
|
|
576
567
|
* @internal
|
|
577
568
|
*/
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
b2b.update(core.Converter.utf8ToBytes(id));
|
|
581
|
-
b2b.update(core.Converter.utf8ToBytes(dateCreated));
|
|
582
|
-
b2b.update(core.Converter.utf8ToBytes(nodeIdentity));
|
|
583
|
-
b2b.update(core.Converter.utf8ToBytes(userIdentity));
|
|
584
|
-
b2b.update(core.ObjectHelper.toBytes(proofObject));
|
|
585
|
-
return b2b.digest();
|
|
569
|
+
calculateDocumentHash(nodeObject) {
|
|
570
|
+
return `sha256:${core.Converter.bytesToBase64(crypto.Sha256.sum256(core.ObjectHelper.toBytes(core.JsonHelper.canonicalize(nodeObject))))}`;
|
|
586
571
|
}
|
|
587
572
|
/**
|
|
588
573
|
* Map the stream entity to a model.
|
|
@@ -591,15 +576,16 @@ class ImmutableProofService {
|
|
|
591
576
|
* @internal
|
|
592
577
|
*/
|
|
593
578
|
proofEntityToJsonLd(proofEntity) {
|
|
594
|
-
const
|
|
579
|
+
const jsonLd = {
|
|
595
580
|
"@context": [immutableProofModels.ImmutableProofTypes.ContextRoot, immutableProofModels.ImmutableProofTypes.ContextRootCommon],
|
|
596
581
|
type: immutableProofModels.ImmutableProofTypes.ImmutableProof,
|
|
597
582
|
id: proofEntity.id,
|
|
583
|
+
nodeIdentity: proofEntity.nodeIdentity,
|
|
598
584
|
userIdentity: proofEntity.userIdentity,
|
|
599
585
|
proofObjectId: proofEntity.proofObjectId,
|
|
600
586
|
proofObjectHash: proofEntity.proofObjectHash
|
|
601
587
|
};
|
|
602
|
-
return
|
|
588
|
+
return jsonLd;
|
|
603
589
|
}
|
|
604
590
|
/**
|
|
605
591
|
* Process a proof.
|
|
@@ -612,12 +598,9 @@ class ImmutableProofService {
|
|
|
612
598
|
if (core.Is.object(proofEntity)) {
|
|
613
599
|
const immutableProof = this.proofEntityToJsonLd(proofEntity);
|
|
614
600
|
// As we are adding the proof to the data we update its context
|
|
615
|
-
immutableProof["@context"] = [
|
|
616
|
-
immutableProofModels.ImmutableProofTypes.ContextRoot,
|
|
617
|
-
immutableProofModels.ImmutableProofTypes.ContextRootCommon,
|
|
618
|
-
standardsW3cDid.DidContexts.ContextVCDataIntegrity
|
|
619
|
-
];
|
|
601
|
+
immutableProof["@context"] = dataJsonLd.JsonLdProcessor.combineContexts([immutableProofModels.ImmutableProofTypes.ContextRoot, immutableProofModels.ImmutableProofTypes.ContextRootCommon], task.result.proof["@context"]);
|
|
620
602
|
immutableProof.proof = task.result.proof;
|
|
603
|
+
core.ObjectHelper.propertyDelete(immutableProof.proof, "@context");
|
|
621
604
|
if (core.Is.stringValue(immutableProof.proof.created)) {
|
|
622
605
|
proofEntity.dateCreated = immutableProof.proof.created;
|
|
623
606
|
}
|
|
@@ -630,7 +613,7 @@ class ImmutableProofService {
|
|
|
630
613
|
}
|
|
631
614
|
}
|
|
632
615
|
/**
|
|
633
|
-
* Verify
|
|
616
|
+
* Verify a proof.
|
|
634
617
|
* @param id The id of the proof to verify.
|
|
635
618
|
* @param verify Validate the proof.
|
|
636
619
|
* @returns The result of the verification and any failures.
|
|
@@ -644,7 +627,7 @@ class ImmutableProofService {
|
|
|
644
627
|
if (core.Is.empty(proofEntity)) {
|
|
645
628
|
throw new core.NotFoundError(this.CLASS_NAME, "proofNotFound", id);
|
|
646
629
|
}
|
|
647
|
-
let proofJsonLd =
|
|
630
|
+
let proofJsonLd = this.proofEntityToJsonLd(proofEntity);
|
|
648
631
|
let verified = false;
|
|
649
632
|
let failure = immutableProofModels.ImmutableProofFailure.NotIssued;
|
|
650
633
|
if (core.Is.stringValue(proofEntity.immutableStorageId)) {
|
|
@@ -652,6 +635,7 @@ class ImmutableProofService {
|
|
|
652
635
|
const immutableResult = await this._immutableStorage.get(proofEntity.immutableStorageId);
|
|
653
636
|
if (core.Is.uint8Array(immutableResult.data)) {
|
|
654
637
|
proofJsonLd = core.ObjectHelper.fromBytes(immutableResult.data);
|
|
638
|
+
const unsecureDocument = core.ObjectHelper.clone(proofJsonLd);
|
|
655
639
|
proofJsonLd.immutableReceipt = immutableResult.receipt;
|
|
656
640
|
// As we are adding the receipt to the data we update the JSON-LD context
|
|
657
641
|
const receiptContext = immutableResult.receipt["@context"];
|
|
@@ -662,12 +646,11 @@ class ImmutableProofService {
|
|
|
662
646
|
if (proofJsonLd.proof.cryptosuite !== standardsW3cDid.DidCryptoSuites.EdDSAJcs2022) {
|
|
663
647
|
failure = immutableProofModels.ImmutableProofFailure.CryptoSuiteMismatch;
|
|
664
648
|
}
|
|
665
|
-
else if (proofJsonLd.proof.type !== standardsW3cDid.
|
|
649
|
+
else if (proofJsonLd.proof.type !== standardsW3cDid.ProofTypes.DataIntegrityProof) {
|
|
666
650
|
failure = immutableProofModels.ImmutableProofFailure.ProofTypeMismatch;
|
|
667
651
|
}
|
|
668
652
|
else {
|
|
669
|
-
const
|
|
670
|
-
const isVerified = await this._identityConnector.verifyProof(hashData, proofJsonLd.proof);
|
|
653
|
+
const isVerified = await this._identityConnector.verifyProof(unsecureDocument, proofJsonLd.proof);
|
|
671
654
|
if (isVerified) {
|
|
672
655
|
verified = true;
|
|
673
656
|
failure = undefined;
|
|
@@ -685,28 +668,6 @@ class ImmutableProofService {
|
|
|
685
668
|
failure
|
|
686
669
|
};
|
|
687
670
|
}
|
|
688
|
-
/**
|
|
689
|
-
* Generate the hash data for the proof.
|
|
690
|
-
* Conforms to https://www.w3.org/TR/vc-di-eddsa/#create-proof-eddsa-jcs-2022
|
|
691
|
-
* @param nodeIdentity The node identity to use for vault operations.
|
|
692
|
-
* @param immutableProof The immutable proof to generate the hash data for.
|
|
693
|
-
* @returns The hash data.
|
|
694
|
-
* @internal
|
|
695
|
-
*/
|
|
696
|
-
async generateHashData(nodeIdentity, immutableProof) {
|
|
697
|
-
// We hash the data for the proof without the the proof or immutable receipt for the proof
|
|
698
|
-
// without these objects we can simplify the context
|
|
699
|
-
const object = core.ObjectHelper.omit(immutableProof, ["proof", "immutableReceipt"]);
|
|
700
|
-
object["@context"] = [immutableProofModels.ImmutableProofTypes.ContextRoot, immutableProofModels.ImmutableProofTypes.ContextRootCommon];
|
|
701
|
-
const canonicalDocument = core.JsonHelper.canonicalize(object);
|
|
702
|
-
const proofKey = await this._vaultConnector.getKey(`${nodeIdentity}/${this._proofHashKeyId}`);
|
|
703
|
-
const proofHash = crypto.Sha256.sum256(proofKey.privateKey);
|
|
704
|
-
const transformedDocumentHash = crypto.Sha256.sum256(core.Converter.utf8ToBytes(canonicalDocument));
|
|
705
|
-
const hashData = new Uint8Array(proofHash.length + transformedDocumentHash.length);
|
|
706
|
-
hashData.set(proofHash);
|
|
707
|
-
hashData.set(transformedDocumentHash, proofHash.length);
|
|
708
|
-
return hashData;
|
|
709
|
-
}
|
|
710
671
|
}
|
|
711
672
|
|
|
712
673
|
const restEntryPoints = [
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { property, SortDirection, entity, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
|
|
2
2
|
import { Guards, ComponentFactory, StringHelper, Is, Validation, Converter, RandomHelper, ObjectHelper, Urn, GeneralError, NotFoundError, JsonHelper } from '@twin.org/core';
|
|
3
3
|
import { ImmutableProofTypes, ImmutableProofFailure, ImmutableProofTopics } from '@twin.org/immutable-proof-models';
|
|
4
|
-
import { DidCryptoSuites,
|
|
4
|
+
import { DidCryptoSuites, ProofTypes, DidContexts } from '@twin.org/standards-w3c-did';
|
|
5
5
|
import { HttpStatusCode, HeaderTypes, MimeTypes } from '@twin.org/web';
|
|
6
6
|
import { BackgroundTaskConnectorFactory, TaskStatus } from '@twin.org/background-task-models';
|
|
7
|
-
import {
|
|
7
|
+
import { 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
11
|
import { ImmutableStorageConnectorFactory } from '@twin.org/immutable-storage-models';
|
|
12
|
-
import { VaultConnectorFactory } from '@twin.org/vault-models';
|
|
13
12
|
|
|
14
13
|
// Copyright 2024 IOTA Stiftung.
|
|
15
14
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -63,7 +62,7 @@ __decorate([
|
|
|
63
62
|
__metadata("design:type", String)
|
|
64
63
|
], ImmutableProof.prototype, "dateCreated", void 0);
|
|
65
64
|
__decorate([
|
|
66
|
-
property({ type: "string" }),
|
|
65
|
+
property({ type: "string", optional: true }),
|
|
67
66
|
__metadata("design:type", String)
|
|
68
67
|
], ImmutableProof.prototype, "proofObjectId", void 0);
|
|
69
68
|
__decorate([
|
|
@@ -71,7 +70,7 @@ __decorate([
|
|
|
71
70
|
__metadata("design:type", String)
|
|
72
71
|
], ImmutableProof.prototype, "proofObjectHash", void 0);
|
|
73
72
|
__decorate([
|
|
74
|
-
property({ type: "string" }),
|
|
73
|
+
property({ type: "string", optional: true }),
|
|
75
74
|
__metadata("design:type", String)
|
|
76
75
|
], ImmutableProof.prototype, "immutableStorageId", void 0);
|
|
77
76
|
ImmutableProof = __decorate([
|
|
@@ -112,7 +111,7 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
112
111
|
id: "immutableProofCreateRequestExample",
|
|
113
112
|
request: {
|
|
114
113
|
body: {
|
|
115
|
-
|
|
114
|
+
document: {
|
|
116
115
|
"@context": "https://schema.org",
|
|
117
116
|
type: "Person",
|
|
118
117
|
name: "John Smith"
|
|
@@ -179,12 +178,13 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
179
178
|
],
|
|
180
179
|
type: ImmutableProofTypes.ImmutableProof,
|
|
181
180
|
id: "ais:1234567890",
|
|
181
|
+
nodeIdentity: "node-1",
|
|
182
182
|
userIdentity: "user-1",
|
|
183
183
|
proofObjectId: "test:1234567890",
|
|
184
184
|
proofObjectHash: "EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=",
|
|
185
185
|
proof: {
|
|
186
|
-
"@context": DidContexts.
|
|
187
|
-
type:
|
|
186
|
+
"@context": DidContexts.ContextDataIntegrity,
|
|
187
|
+
type: ProofTypes.DataIntegrityProof,
|
|
188
188
|
cryptosuite: DidCryptoSuites.EdDSAJcs2022,
|
|
189
189
|
created: "2024-08-22T11:56:56.272Z",
|
|
190
190
|
proofPurpose: "assertionMethod",
|
|
@@ -212,12 +212,13 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
212
212
|
],
|
|
213
213
|
type: ImmutableProofTypes.ImmutableProof,
|
|
214
214
|
id: "ais:1234567890",
|
|
215
|
+
nodeIdentity: "node-1",
|
|
215
216
|
userIdentity: "user-1",
|
|
216
217
|
proofObjectId: "test:1234567890",
|
|
217
218
|
proofObjectHash: "EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=",
|
|
218
219
|
proof: {
|
|
219
|
-
"@context": DidContexts.
|
|
220
|
-
type:
|
|
220
|
+
"@context": DidContexts.ContextDataIntegrity,
|
|
221
|
+
type: ProofTypes.DataIntegrityProof,
|
|
221
222
|
cryptosuite: DidCryptoSuites.EdDSAJcs2022,
|
|
222
223
|
created: "2024-08-22T11:56:56.272Z",
|
|
223
224
|
proofPurpose: "assertionMethod",
|
|
@@ -301,9 +302,9 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
301
302
|
*/
|
|
302
303
|
async function immutableProofCreate(httpRequestContext, componentName, request) {
|
|
303
304
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
304
|
-
Guards.object(ROUTES_SOURCE, "request.body.
|
|
305
|
+
Guards.object(ROUTES_SOURCE, "request.body.document", request.body.document);
|
|
305
306
|
const component = ComponentFactory.get(componentName);
|
|
306
|
-
const result = await component.create(request.body.
|
|
307
|
+
const result = await component.create(request.body.document, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
307
308
|
return {
|
|
308
309
|
statusCode: HttpStatusCode.created,
|
|
309
310
|
headers: {
|
|
@@ -373,11 +374,6 @@ class ImmutableProofService {
|
|
|
373
374
|
* @internal
|
|
374
375
|
*/
|
|
375
376
|
_config;
|
|
376
|
-
/**
|
|
377
|
-
* The vault connector.
|
|
378
|
-
* @internal
|
|
379
|
-
*/
|
|
380
|
-
_vaultConnector;
|
|
381
377
|
/**
|
|
382
378
|
* The identity connector.
|
|
383
379
|
* @internal
|
|
@@ -408,11 +404,6 @@ class ImmutableProofService {
|
|
|
408
404
|
* @internal
|
|
409
405
|
*/
|
|
410
406
|
_verificationMethodId;
|
|
411
|
-
/**
|
|
412
|
-
* The proof hash key id to use for the proofs.
|
|
413
|
-
* @internal
|
|
414
|
-
*/
|
|
415
|
-
_proofHashKeyId;
|
|
416
407
|
/**
|
|
417
408
|
* The identity connector type.
|
|
418
409
|
* @internal
|
|
@@ -423,7 +414,6 @@ class ImmutableProofService {
|
|
|
423
414
|
* @param options The dependencies for the immutable proof connector.
|
|
424
415
|
*/
|
|
425
416
|
constructor(options) {
|
|
426
|
-
this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
|
|
427
417
|
this._proofStorage = EntityStorageConnectorFactory.get(options?.immutableProofEntityStorageType ?? StringHelper.kebabCase("ImmutableProof"));
|
|
428
418
|
this._immutableStorage = ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
|
|
429
419
|
this._identityConnectorType = options?.identityConnectorType ?? "identity";
|
|
@@ -434,47 +424,48 @@ class ImmutableProofService {
|
|
|
434
424
|
}
|
|
435
425
|
this._config = options?.config ?? {};
|
|
436
426
|
this._verificationMethodId = this._config.verificationMethodId ?? "immutable-proof-assertion";
|
|
437
|
-
this._proofHashKeyId = this._config.proofHashKeyId ?? "immutable-proof-hash";
|
|
438
427
|
this._backgroundTaskConnector.registerHandler("immutable-proof", "@twin.org/immutable-proof-task", "processProofTask", async (task) => {
|
|
439
428
|
await this.finaliseTask(task);
|
|
440
429
|
});
|
|
441
430
|
}
|
|
442
431
|
/**
|
|
443
|
-
* Create a new
|
|
444
|
-
* @param
|
|
432
|
+
* Create a new proof.
|
|
433
|
+
* @param document The document to create the proof for.
|
|
445
434
|
* @param userIdentity The identity to create the immutable proof operation with.
|
|
446
435
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
447
|
-
* @returns The id of the new
|
|
436
|
+
* @returns The id of the new proof.
|
|
448
437
|
*/
|
|
449
|
-
async create(
|
|
450
|
-
Guards.object(this.CLASS_NAME, "
|
|
438
|
+
async create(document, userIdentity, nodeIdentity) {
|
|
439
|
+
Guards.object(this.CLASS_NAME, "document", document);
|
|
451
440
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
452
441
|
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
453
442
|
try {
|
|
454
443
|
const validationFailures = [];
|
|
455
|
-
await JsonLdHelper.validate(
|
|
456
|
-
Validation.asValidationError(this.CLASS_NAME, "
|
|
444
|
+
await JsonLdHelper.validate(document, validationFailures);
|
|
445
|
+
Validation.asValidationError(this.CLASS_NAME, "document", validationFailures);
|
|
457
446
|
const id = Converter.bytesToHex(RandomHelper.generate(32), false);
|
|
458
447
|
const dateCreated = new Date(Date.now()).toISOString();
|
|
459
|
-
const proofObjectId = ObjectHelper.extractProperty(
|
|
460
|
-
|
|
448
|
+
const proofObjectId = ObjectHelper.extractProperty(document, ["@id", "id"], false);
|
|
449
|
+
// We don't want to store the whole document in the immutable proof, as this could be large
|
|
450
|
+
// and also reveal information that should not be stored in the proof so we hash the document
|
|
451
|
+
// and store the hash
|
|
452
|
+
const proofObjectHash = this.calculateDocumentHash(document);
|
|
461
453
|
const proofEntity = {
|
|
462
454
|
id,
|
|
463
455
|
nodeIdentity,
|
|
464
456
|
userIdentity,
|
|
465
457
|
dateCreated,
|
|
466
458
|
proofObjectId,
|
|
467
|
-
proofObjectHash
|
|
459
|
+
proofObjectHash
|
|
468
460
|
};
|
|
469
461
|
await this._proofStorage.set(proofEntity);
|
|
470
462
|
const immutableProof = this.proofEntityToJsonLd(proofEntity);
|
|
471
|
-
const hashData = await this.generateHashData(proofEntity.nodeIdentity, immutableProof);
|
|
472
463
|
const proofTaskPayload = {
|
|
473
464
|
proofId: id,
|
|
474
465
|
nodeIdentity,
|
|
475
466
|
identityConnectorType: this._identityConnectorType,
|
|
476
|
-
|
|
477
|
-
|
|
467
|
+
verificationMethodId: this._verificationMethodId,
|
|
468
|
+
document: immutableProof
|
|
478
469
|
};
|
|
479
470
|
await this._backgroundTaskConnector.create("immutable-proof", proofTaskPayload);
|
|
480
471
|
return new Urn(ImmutableProofService.NAMESPACE, id).toString();
|
|
@@ -484,7 +475,7 @@ class ImmutableProofService {
|
|
|
484
475
|
}
|
|
485
476
|
}
|
|
486
477
|
/**
|
|
487
|
-
* Get
|
|
478
|
+
* Get a proof.
|
|
488
479
|
* @param id The id of the proof to get.
|
|
489
480
|
* @returns The proof.
|
|
490
481
|
* @throws NotFoundError if the proof is not found.
|
|
@@ -507,7 +498,7 @@ class ImmutableProofService {
|
|
|
507
498
|
}
|
|
508
499
|
}
|
|
509
500
|
/**
|
|
510
|
-
* Verify
|
|
501
|
+
* Verify a proof.
|
|
511
502
|
* @param id The id of the proof to verify.
|
|
512
503
|
* @returns The result of the verification and any failures.
|
|
513
504
|
* @throws NotFoundError if the proof is not found.
|
|
@@ -573,14 +564,8 @@ class ImmutableProofService {
|
|
|
573
564
|
* @returns The hash.
|
|
574
565
|
* @internal
|
|
575
566
|
*/
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
b2b.update(Converter.utf8ToBytes(id));
|
|
579
|
-
b2b.update(Converter.utf8ToBytes(dateCreated));
|
|
580
|
-
b2b.update(Converter.utf8ToBytes(nodeIdentity));
|
|
581
|
-
b2b.update(Converter.utf8ToBytes(userIdentity));
|
|
582
|
-
b2b.update(ObjectHelper.toBytes(proofObject));
|
|
583
|
-
return b2b.digest();
|
|
567
|
+
calculateDocumentHash(nodeObject) {
|
|
568
|
+
return `sha256:${Converter.bytesToBase64(Sha256.sum256(ObjectHelper.toBytes(JsonHelper.canonicalize(nodeObject))))}`;
|
|
584
569
|
}
|
|
585
570
|
/**
|
|
586
571
|
* Map the stream entity to a model.
|
|
@@ -589,15 +574,16 @@ class ImmutableProofService {
|
|
|
589
574
|
* @internal
|
|
590
575
|
*/
|
|
591
576
|
proofEntityToJsonLd(proofEntity) {
|
|
592
|
-
const
|
|
577
|
+
const jsonLd = {
|
|
593
578
|
"@context": [ImmutableProofTypes.ContextRoot, ImmutableProofTypes.ContextRootCommon],
|
|
594
579
|
type: ImmutableProofTypes.ImmutableProof,
|
|
595
580
|
id: proofEntity.id,
|
|
581
|
+
nodeIdentity: proofEntity.nodeIdentity,
|
|
596
582
|
userIdentity: proofEntity.userIdentity,
|
|
597
583
|
proofObjectId: proofEntity.proofObjectId,
|
|
598
584
|
proofObjectHash: proofEntity.proofObjectHash
|
|
599
585
|
};
|
|
600
|
-
return
|
|
586
|
+
return jsonLd;
|
|
601
587
|
}
|
|
602
588
|
/**
|
|
603
589
|
* Process a proof.
|
|
@@ -610,12 +596,9 @@ class ImmutableProofService {
|
|
|
610
596
|
if (Is.object(proofEntity)) {
|
|
611
597
|
const immutableProof = this.proofEntityToJsonLd(proofEntity);
|
|
612
598
|
// As we are adding the proof to the data we update its context
|
|
613
|
-
immutableProof["@context"] = [
|
|
614
|
-
ImmutableProofTypes.ContextRoot,
|
|
615
|
-
ImmutableProofTypes.ContextRootCommon,
|
|
616
|
-
DidContexts.ContextVCDataIntegrity
|
|
617
|
-
];
|
|
599
|
+
immutableProof["@context"] = JsonLdProcessor.combineContexts([ImmutableProofTypes.ContextRoot, ImmutableProofTypes.ContextRootCommon], task.result.proof["@context"]);
|
|
618
600
|
immutableProof.proof = task.result.proof;
|
|
601
|
+
ObjectHelper.propertyDelete(immutableProof.proof, "@context");
|
|
619
602
|
if (Is.stringValue(immutableProof.proof.created)) {
|
|
620
603
|
proofEntity.dateCreated = immutableProof.proof.created;
|
|
621
604
|
}
|
|
@@ -628,7 +611,7 @@ class ImmutableProofService {
|
|
|
628
611
|
}
|
|
629
612
|
}
|
|
630
613
|
/**
|
|
631
|
-
* Verify
|
|
614
|
+
* Verify a proof.
|
|
632
615
|
* @param id The id of the proof to verify.
|
|
633
616
|
* @param verify Validate the proof.
|
|
634
617
|
* @returns The result of the verification and any failures.
|
|
@@ -642,7 +625,7 @@ class ImmutableProofService {
|
|
|
642
625
|
if (Is.empty(proofEntity)) {
|
|
643
626
|
throw new NotFoundError(this.CLASS_NAME, "proofNotFound", id);
|
|
644
627
|
}
|
|
645
|
-
let proofJsonLd =
|
|
628
|
+
let proofJsonLd = this.proofEntityToJsonLd(proofEntity);
|
|
646
629
|
let verified = false;
|
|
647
630
|
let failure = ImmutableProofFailure.NotIssued;
|
|
648
631
|
if (Is.stringValue(proofEntity.immutableStorageId)) {
|
|
@@ -650,6 +633,7 @@ class ImmutableProofService {
|
|
|
650
633
|
const immutableResult = await this._immutableStorage.get(proofEntity.immutableStorageId);
|
|
651
634
|
if (Is.uint8Array(immutableResult.data)) {
|
|
652
635
|
proofJsonLd = ObjectHelper.fromBytes(immutableResult.data);
|
|
636
|
+
const unsecureDocument = ObjectHelper.clone(proofJsonLd);
|
|
653
637
|
proofJsonLd.immutableReceipt = immutableResult.receipt;
|
|
654
638
|
// As we are adding the receipt to the data we update the JSON-LD context
|
|
655
639
|
const receiptContext = immutableResult.receipt["@context"];
|
|
@@ -660,12 +644,11 @@ class ImmutableProofService {
|
|
|
660
644
|
if (proofJsonLd.proof.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {
|
|
661
645
|
failure = ImmutableProofFailure.CryptoSuiteMismatch;
|
|
662
646
|
}
|
|
663
|
-
else if (proofJsonLd.proof.type !==
|
|
647
|
+
else if (proofJsonLd.proof.type !== ProofTypes.DataIntegrityProof) {
|
|
664
648
|
failure = ImmutableProofFailure.ProofTypeMismatch;
|
|
665
649
|
}
|
|
666
650
|
else {
|
|
667
|
-
const
|
|
668
|
-
const isVerified = await this._identityConnector.verifyProof(hashData, proofJsonLd.proof);
|
|
651
|
+
const isVerified = await this._identityConnector.verifyProof(unsecureDocument, proofJsonLd.proof);
|
|
669
652
|
if (isVerified) {
|
|
670
653
|
verified = true;
|
|
671
654
|
failure = undefined;
|
|
@@ -683,28 +666,6 @@ class ImmutableProofService {
|
|
|
683
666
|
failure
|
|
684
667
|
};
|
|
685
668
|
}
|
|
686
|
-
/**
|
|
687
|
-
* Generate the hash data for the proof.
|
|
688
|
-
* Conforms to https://www.w3.org/TR/vc-di-eddsa/#create-proof-eddsa-jcs-2022
|
|
689
|
-
* @param nodeIdentity The node identity to use for vault operations.
|
|
690
|
-
* @param immutableProof The immutable proof to generate the hash data for.
|
|
691
|
-
* @returns The hash data.
|
|
692
|
-
* @internal
|
|
693
|
-
*/
|
|
694
|
-
async generateHashData(nodeIdentity, immutableProof) {
|
|
695
|
-
// We hash the data for the proof without the the proof or immutable receipt for the proof
|
|
696
|
-
// without these objects we can simplify the context
|
|
697
|
-
const object = ObjectHelper.omit(immutableProof, ["proof", "immutableReceipt"]);
|
|
698
|
-
object["@context"] = [ImmutableProofTypes.ContextRoot, ImmutableProofTypes.ContextRootCommon];
|
|
699
|
-
const canonicalDocument = JsonHelper.canonicalize(object);
|
|
700
|
-
const proofKey = await this._vaultConnector.getKey(`${nodeIdentity}/${this._proofHashKeyId}`);
|
|
701
|
-
const proofHash = Sha256.sum256(proofKey.privateKey);
|
|
702
|
-
const transformedDocumentHash = Sha256.sum256(Converter.utf8ToBytes(canonicalDocument));
|
|
703
|
-
const hashData = new Uint8Array(proofHash.length + transformedDocumentHash.length);
|
|
704
|
-
hashData.set(proofHash);
|
|
705
|
-
hashData.set(transformedDocumentHash, proofHash.length);
|
|
706
|
-
return hashData;
|
|
707
|
-
}
|
|
708
669
|
}
|
|
709
670
|
|
|
710
671
|
const restEntryPoints = [
|
|
@@ -19,22 +19,22 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
|
|
|
19
19
|
*/
|
|
20
20
|
constructor(options?: IImmutableProofServiceConstructorOptions);
|
|
21
21
|
/**
|
|
22
|
-
* Create a new
|
|
23
|
-
* @param
|
|
22
|
+
* Create a new proof.
|
|
23
|
+
* @param document The document to create the proof for.
|
|
24
24
|
* @param userIdentity The identity to create the immutable proof operation with.
|
|
25
25
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
26
|
-
* @returns The id of the new
|
|
26
|
+
* @returns The id of the new proof.
|
|
27
27
|
*/
|
|
28
|
-
create(
|
|
28
|
+
create(document: IJsonLdNodeObject, userIdentity?: string, nodeIdentity?: string): Promise<string>;
|
|
29
29
|
/**
|
|
30
|
-
* Get
|
|
30
|
+
* Get a proof.
|
|
31
31
|
* @param id The id of the proof to get.
|
|
32
32
|
* @returns The proof.
|
|
33
33
|
* @throws NotFoundError if the proof is not found.
|
|
34
34
|
*/
|
|
35
35
|
get(id: string): Promise<IImmutableProof>;
|
|
36
36
|
/**
|
|
37
|
-
* Verify
|
|
37
|
+
* Verify a proof.
|
|
38
38
|
* @param id The id of the proof to verify.
|
|
39
39
|
* @returns The result of the verification and any failures.
|
|
40
40
|
* @throws NotFoundError if the proof is not found.
|
|
@@ -3,11 +3,6 @@ import type { IImmutableProofServiceConfig } from "./IImmutableProofServiceConfi
|
|
|
3
3
|
* Options for the immutable proof service constructor.
|
|
4
4
|
*/
|
|
5
5
|
export interface IImmutableProofServiceConstructorOptions {
|
|
6
|
-
/**
|
|
7
|
-
* The vault connector type.
|
|
8
|
-
* @default vault
|
|
9
|
-
*/
|
|
10
|
-
vaultConnectorType?: string;
|
|
11
6
|
/**
|
|
12
7
|
* The entity storage for proofs.
|
|
13
8
|
* @default immutable-proof
|
package/docs/changelog.md
CHANGED
package/docs/open-api/spec.json
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"examples": {
|
|
45
45
|
"immutableProofCreateRequestExample": {
|
|
46
46
|
"value": {
|
|
47
|
-
"
|
|
47
|
+
"document": {
|
|
48
48
|
"@context": "https://schema.org",
|
|
49
49
|
"type": "Person",
|
|
50
50
|
"name": "John Smith"
|
|
@@ -200,11 +200,12 @@
|
|
|
200
200
|
],
|
|
201
201
|
"type": "ImmutableProof",
|
|
202
202
|
"id": "ais:1234567890",
|
|
203
|
+
"nodeIdentity": "node-1",
|
|
203
204
|
"userIdentity": "user-1",
|
|
204
205
|
"proofObjectId": "test:1234567890",
|
|
205
206
|
"proofObjectHash": "EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=",
|
|
206
207
|
"proof": {
|
|
207
|
-
"@context": "https://
|
|
208
|
+
"@context": "https://www.w3.org/ns/credentials/v2",
|
|
208
209
|
"type": "DataIntegrityProof",
|
|
209
210
|
"cryptosuite": "eddsa-jcs-2022",
|
|
210
211
|
"created": "2024-08-22T11:56:56.272Z",
|
|
@@ -228,11 +229,12 @@
|
|
|
228
229
|
],
|
|
229
230
|
"type": "ImmutableProof",
|
|
230
231
|
"id": "ais:1234567890",
|
|
232
|
+
"nodeIdentity": "node-1",
|
|
231
233
|
"userIdentity": "user-1",
|
|
232
234
|
"proofObjectId": "test:1234567890",
|
|
233
235
|
"proofObjectHash": "EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=",
|
|
234
236
|
"proof": {
|
|
235
|
-
"@context": "https://
|
|
237
|
+
"@context": "https://www.w3.org/ns/credentials/v2",
|
|
236
238
|
"type": "DataIntegrityProof",
|
|
237
239
|
"cryptosuite": "eddsa-jcs-2022",
|
|
238
240
|
"created": "2024-08-22T11:56:56.272Z",
|
|
@@ -480,29 +482,14 @@
|
|
|
480
482
|
},
|
|
481
483
|
"components": {
|
|
482
484
|
"schemas": {
|
|
483
|
-
"
|
|
484
|
-
"anyOf": [
|
|
485
|
-
{
|
|
486
|
-
"type": "string",
|
|
487
|
-
"const": "eddsa-jcs-2022",
|
|
488
|
-
"description": "The type for EdDSA crypto suite for JSON Canonicalization Scheme [RFC8785]. https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022"
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
"type": "string",
|
|
492
|
-
"const": "eddsa-rdfc-2022",
|
|
493
|
-
"description": "The type for EdDSA crypto suite for RDF Dataset Canonicalization. https://www.w3.org/TR/vc-di-eddsa/#eddsa-rdfc-2022"
|
|
494
|
-
}
|
|
495
|
-
],
|
|
496
|
-
"description": "The types for DID Proof crypto suites."
|
|
497
|
-
},
|
|
498
|
-
"DidProof": {
|
|
485
|
+
"DataIntegrityProof": {
|
|
499
486
|
"type": "object",
|
|
500
487
|
"properties": {
|
|
501
488
|
"@context": {
|
|
502
489
|
"anyOf": [
|
|
503
490
|
{
|
|
504
491
|
"type": "string",
|
|
505
|
-
"const": "https://
|
|
492
|
+
"const": "https://www.w3.org/ns/credentials/v2"
|
|
506
493
|
},
|
|
507
494
|
{
|
|
508
495
|
"type": "array",
|
|
@@ -510,7 +497,7 @@
|
|
|
510
497
|
"items": [
|
|
511
498
|
{
|
|
512
499
|
"type": "string",
|
|
513
|
-
"const": "https://
|
|
500
|
+
"const": "https://www.w3.org/ns/credentials/v2"
|
|
514
501
|
}
|
|
515
502
|
],
|
|
516
503
|
"additionalItems": {
|
|
@@ -522,6 +509,7 @@
|
|
|
522
509
|
},
|
|
523
510
|
"type": {
|
|
524
511
|
"type": "string",
|
|
512
|
+
"const": "DataIntegrityProof",
|
|
525
513
|
"description": "JSON-LD Type."
|
|
526
514
|
},
|
|
527
515
|
"cryptosuite": {
|
|
@@ -599,12 +587,26 @@
|
|
|
599
587
|
"required": [
|
|
600
588
|
"type",
|
|
601
589
|
"cryptosuite",
|
|
602
|
-
"proofPurpose"
|
|
603
|
-
"proofValue"
|
|
590
|
+
"proofPurpose"
|
|
604
591
|
],
|
|
605
592
|
"additionalProperties": false,
|
|
606
593
|
"description": "Interface describing a did proof. https://www.w3.org/TR/vc-data-integrity/"
|
|
607
594
|
},
|
|
595
|
+
"DidCryptoSuites": {
|
|
596
|
+
"anyOf": [
|
|
597
|
+
{
|
|
598
|
+
"type": "string",
|
|
599
|
+
"const": "eddsa-jcs-2022",
|
|
600
|
+
"description": "The type for EdDSA crypto suite for JSON Canonicalization Scheme [RFC8785]. https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022"
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
"type": "string",
|
|
604
|
+
"const": "eddsa-rdfc-2022",
|
|
605
|
+
"description": "The type for EdDSA crypto suite for RDF Dataset Canonicalization. https://www.w3.org/TR/vc-di-eddsa/#eddsa-rdfc-2022"
|
|
606
|
+
}
|
|
607
|
+
],
|
|
608
|
+
"description": "The types for DID Proof crypto suites."
|
|
609
|
+
},
|
|
608
610
|
"Error": {
|
|
609
611
|
"type": "object",
|
|
610
612
|
"properties": {
|
|
@@ -643,12 +645,12 @@
|
|
|
643
645
|
"ImmutableProofCreateRequest": {
|
|
644
646
|
"type": "object",
|
|
645
647
|
"properties": {
|
|
646
|
-
"
|
|
648
|
+
"document": {
|
|
647
649
|
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodeObject"
|
|
648
650
|
}
|
|
649
651
|
},
|
|
650
652
|
"required": [
|
|
651
|
-
"
|
|
653
|
+
"document"
|
|
652
654
|
],
|
|
653
655
|
"additionalProperties": false,
|
|
654
656
|
"description": "The parameters from the body."
|
|
@@ -50,17 +50,17 @@ Runtime name for the class.
|
|
|
50
50
|
|
|
51
51
|
### create()
|
|
52
52
|
|
|
53
|
-
> **create**(`
|
|
53
|
+
> **create**(`document`, `userIdentity`?, `nodeIdentity`?): `Promise`\<`string`\>
|
|
54
54
|
|
|
55
|
-
Create a new
|
|
55
|
+
Create a new proof.
|
|
56
56
|
|
|
57
57
|
#### Parameters
|
|
58
58
|
|
|
59
|
-
#####
|
|
59
|
+
##### document
|
|
60
60
|
|
|
61
61
|
`IJsonLdNodeObject`
|
|
62
62
|
|
|
63
|
-
The
|
|
63
|
+
The document to create the proof for.
|
|
64
64
|
|
|
65
65
|
##### userIdentity?
|
|
66
66
|
|
|
@@ -78,7 +78,7 @@ The node identity to use for vault operations.
|
|
|
78
78
|
|
|
79
79
|
`Promise`\<`string`\>
|
|
80
80
|
|
|
81
|
-
The id of the new
|
|
81
|
+
The id of the new proof.
|
|
82
82
|
|
|
83
83
|
#### Implementation of
|
|
84
84
|
|
|
@@ -90,7 +90,7 @@ The id of the new authentication proof.
|
|
|
90
90
|
|
|
91
91
|
> **get**(`id`): `Promise`\<`IImmutableProof`\>
|
|
92
92
|
|
|
93
|
-
Get
|
|
93
|
+
Get a proof.
|
|
94
94
|
|
|
95
95
|
#### Parameters
|
|
96
96
|
|
|
@@ -120,7 +120,7 @@ NotFoundError if the proof is not found.
|
|
|
120
120
|
|
|
121
121
|
> **verify**(`id`): `Promise`\<`IImmutableProofVerification`\>
|
|
122
122
|
|
|
123
|
-
Verify
|
|
123
|
+
Verify a proof.
|
|
124
124
|
|
|
125
125
|
#### Parameters
|
|
126
126
|
|
|
@@ -15,17 +15,3 @@ The verification method id to use for the proof.
|
|
|
15
15
|
```ts
|
|
16
16
|
immutable-proof-assertion
|
|
17
17
|
```
|
|
18
|
-
|
|
19
|
-
***
|
|
20
|
-
|
|
21
|
-
### proofHashKeyId?
|
|
22
|
-
|
|
23
|
-
> `optional` **proofHashKeyId**: `string`
|
|
24
|
-
|
|
25
|
-
The key to use in the proof hash.
|
|
26
|
-
|
|
27
|
-
#### Default
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
immutable-proof-hash
|
|
31
|
-
```
|
|
@@ -4,20 +4,6 @@ Options for the immutable proof service constructor.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### vaultConnectorType?
|
|
8
|
-
|
|
9
|
-
> `optional` **vaultConnectorType**: `string`
|
|
10
|
-
|
|
11
|
-
The vault connector type.
|
|
12
|
-
|
|
13
|
-
#### Default
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
vault
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
***
|
|
20
|
-
|
|
21
7
|
### immutableProofEntityStorageType?
|
|
22
8
|
|
|
23
9
|
> `optional` **immutableProofEntityStorageType**: `string`
|
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.26",
|
|
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.26",
|
|
27
|
+
"@twin.org/immutable-proof-task": "0.0.1-next.26",
|
|
28
28
|
"@twin.org/immutable-storage-models": "next",
|
|
29
29
|
"@twin.org/nameof": "next",
|
|
30
30
|
"@twin.org/standards-w3c-did": "next",
|