@twin.org/immutable-proof-service 0.0.1-next.5 → 0.0.1-next.7
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
CHANGED
|
@@ -335,10 +335,10 @@ class ImmutableProofService {
|
|
|
335
335
|
*/
|
|
336
336
|
_assertionMethodId;
|
|
337
337
|
/**
|
|
338
|
-
* The proof
|
|
338
|
+
* The proof hash key id to use for the proofs.
|
|
339
339
|
* @internal
|
|
340
340
|
*/
|
|
341
|
-
|
|
341
|
+
_proofHashKeyId;
|
|
342
342
|
/**
|
|
343
343
|
* Are we currently processing proofs.
|
|
344
344
|
* @internal
|
|
@@ -359,8 +359,8 @@ class ImmutableProofService {
|
|
|
359
359
|
this._immutableStorage = immutableStorageModels.ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
|
|
360
360
|
this._identityConnector = identityModels.IdentityConnectorFactory.get(options?.identityConnectorType ?? "identity");
|
|
361
361
|
this._config = options?.config ?? {};
|
|
362
|
-
this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof";
|
|
363
|
-
this.
|
|
362
|
+
this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof-assertion";
|
|
363
|
+
this._proofHashKeyId = this._config.proofHashKeyId ?? "immutable-proof-hash";
|
|
364
364
|
this._processing = false;
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
@@ -557,7 +557,6 @@ class ImmutableProofService {
|
|
|
557
557
|
// As we are adding the proof to the data we update its context
|
|
558
558
|
immutableProof["@context"] = [
|
|
559
559
|
immutableProofModels.ImmutableProofTypes.ContextRoot,
|
|
560
|
-
immutableStorageModels.ImmutableStorageTypes.ContextRoot,
|
|
561
560
|
standardsW3cDid.DidContexts.ContextVCDataIntegrity
|
|
562
561
|
];
|
|
563
562
|
immutableProof.proof = await this._identityConnector.createProof(proofEntity.nodeIdentity, `${proofEntity.nodeIdentity}#${this._assertionMethodId}`, hashData);
|
|
@@ -603,6 +602,10 @@ class ImmutableProofService {
|
|
|
603
602
|
if (core.Is.uint8Array(immutableResult.data)) {
|
|
604
603
|
proofModel = core.ObjectHelper.fromBytes(immutableResult.data);
|
|
605
604
|
proofModel.immutableReceipt = immutableResult.receipt;
|
|
605
|
+
// As we are adding the receipt to the data we update its context
|
|
606
|
+
if (core.Is.array(proofModel["@context"])) {
|
|
607
|
+
proofModel["@context"].push(immutableStorageModels.ImmutableStorageTypes.ContextRoot);
|
|
608
|
+
}
|
|
606
609
|
if (core.Is.object(proofModel.proof) && core.Is.object(proofObject)) {
|
|
607
610
|
if (proofModel.proof.cryptosuite !== standardsW3cDid.DidCryptoSuites.EdDSAJcs2022) {
|
|
608
611
|
failure = immutableProofModels.ImmutableProofFailure.CryptoSuiteMismatch;
|
|
@@ -639,17 +642,17 @@ class ImmutableProofService {
|
|
|
639
642
|
* @internal
|
|
640
643
|
*/
|
|
641
644
|
async generateHashData(nodeIdentity, immutableProof) {
|
|
642
|
-
// We hash the data for the proof
|
|
645
|
+
// We hash the data for the proof without the the proof or immutable receipt for the proof
|
|
643
646
|
// without these objects we can simplify the context
|
|
644
647
|
const object = core.ObjectHelper.omit(immutableProof, ["proof", "immutableReceipt"]);
|
|
645
648
|
object["@context"] = immutableProofModels.ImmutableProofTypes.ContextRoot;
|
|
646
649
|
const canonicalDocument = core.JsonHelper.canonicalize(object);
|
|
647
|
-
const
|
|
648
|
-
const
|
|
650
|
+
const proofKey = await this._vaultConnector.getKey(`${nodeIdentity}/${this._proofHashKeyId}`);
|
|
651
|
+
const proofHash = crypto.Sha256.sum256(proofKey.privateKey);
|
|
649
652
|
const transformedDocumentHash = crypto.Sha256.sum256(core.Converter.utf8ToBytes(canonicalDocument));
|
|
650
|
-
const hashData = new Uint8Array(
|
|
651
|
-
hashData.set(
|
|
652
|
-
hashData.set(transformedDocumentHash,
|
|
653
|
+
const hashData = new Uint8Array(proofHash.length + transformedDocumentHash.length);
|
|
654
|
+
hashData.set(proofHash);
|
|
655
|
+
hashData.set(transformedDocumentHash, proofHash.length);
|
|
653
656
|
return hashData;
|
|
654
657
|
}
|
|
655
658
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -333,10 +333,10 @@ class ImmutableProofService {
|
|
|
333
333
|
*/
|
|
334
334
|
_assertionMethodId;
|
|
335
335
|
/**
|
|
336
|
-
* The proof
|
|
336
|
+
* The proof hash key id to use for the proofs.
|
|
337
337
|
* @internal
|
|
338
338
|
*/
|
|
339
|
-
|
|
339
|
+
_proofHashKeyId;
|
|
340
340
|
/**
|
|
341
341
|
* Are we currently processing proofs.
|
|
342
342
|
* @internal
|
|
@@ -357,8 +357,8 @@ class ImmutableProofService {
|
|
|
357
357
|
this._immutableStorage = ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
|
|
358
358
|
this._identityConnector = IdentityConnectorFactory.get(options?.identityConnectorType ?? "identity");
|
|
359
359
|
this._config = options?.config ?? {};
|
|
360
|
-
this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof";
|
|
361
|
-
this.
|
|
360
|
+
this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof-assertion";
|
|
361
|
+
this._proofHashKeyId = this._config.proofHashKeyId ?? "immutable-proof-hash";
|
|
362
362
|
this._processing = false;
|
|
363
363
|
}
|
|
364
364
|
/**
|
|
@@ -555,7 +555,6 @@ class ImmutableProofService {
|
|
|
555
555
|
// As we are adding the proof to the data we update its context
|
|
556
556
|
immutableProof["@context"] = [
|
|
557
557
|
ImmutableProofTypes.ContextRoot,
|
|
558
|
-
ImmutableStorageTypes.ContextRoot,
|
|
559
558
|
DidContexts.ContextVCDataIntegrity
|
|
560
559
|
];
|
|
561
560
|
immutableProof.proof = await this._identityConnector.createProof(proofEntity.nodeIdentity, `${proofEntity.nodeIdentity}#${this._assertionMethodId}`, hashData);
|
|
@@ -601,6 +600,10 @@ class ImmutableProofService {
|
|
|
601
600
|
if (Is.uint8Array(immutableResult.data)) {
|
|
602
601
|
proofModel = ObjectHelper.fromBytes(immutableResult.data);
|
|
603
602
|
proofModel.immutableReceipt = immutableResult.receipt;
|
|
603
|
+
// As we are adding the receipt to the data we update its context
|
|
604
|
+
if (Is.array(proofModel["@context"])) {
|
|
605
|
+
proofModel["@context"].push(ImmutableStorageTypes.ContextRoot);
|
|
606
|
+
}
|
|
604
607
|
if (Is.object(proofModel.proof) && Is.object(proofObject)) {
|
|
605
608
|
if (proofModel.proof.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {
|
|
606
609
|
failure = ImmutableProofFailure.CryptoSuiteMismatch;
|
|
@@ -637,17 +640,17 @@ class ImmutableProofService {
|
|
|
637
640
|
* @internal
|
|
638
641
|
*/
|
|
639
642
|
async generateHashData(nodeIdentity, immutableProof) {
|
|
640
|
-
// We hash the data for the proof
|
|
643
|
+
// We hash the data for the proof without the the proof or immutable receipt for the proof
|
|
641
644
|
// without these objects we can simplify the context
|
|
642
645
|
const object = ObjectHelper.omit(immutableProof, ["proof", "immutableReceipt"]);
|
|
643
646
|
object["@context"] = ImmutableProofTypes.ContextRoot;
|
|
644
647
|
const canonicalDocument = JsonHelper.canonicalize(object);
|
|
645
|
-
const
|
|
646
|
-
const
|
|
648
|
+
const proofKey = await this._vaultConnector.getKey(`${nodeIdentity}/${this._proofHashKeyId}`);
|
|
649
|
+
const proofHash = Sha256.sum256(proofKey.privateKey);
|
|
647
650
|
const transformedDocumentHash = Sha256.sum256(Converter.utf8ToBytes(canonicalDocument));
|
|
648
|
-
const hashData = new Uint8Array(
|
|
649
|
-
hashData.set(
|
|
650
|
-
hashData.set(transformedDocumentHash,
|
|
651
|
+
const hashData = new Uint8Array(proofHash.length + transformedDocumentHash.length);
|
|
652
|
+
hashData.set(proofHash);
|
|
653
|
+
hashData.set(transformedDocumentHash, proofHash.length);
|
|
651
654
|
return hashData;
|
|
652
655
|
}
|
|
653
656
|
}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
export interface IImmutableProofServiceConfig {
|
|
5
5
|
/**
|
|
6
6
|
* The assertion method id to use for the stream.
|
|
7
|
-
* @default immutable-proof
|
|
7
|
+
* @default immutable-proof-assertion
|
|
8
8
|
*/
|
|
9
9
|
assertionMethodId?: string;
|
|
10
10
|
/**
|
|
11
|
-
* The key to use in the proof
|
|
12
|
-
* @default immutable-proof
|
|
11
|
+
* The key to use in the proof hash.
|
|
12
|
+
* @default immutable-proof-hash
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
proofHashKeyId?: string;
|
|
15
15
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -13,19 +13,19 @@ The assertion method id to use for the stream.
|
|
|
13
13
|
#### Default
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
immutable-proof
|
|
16
|
+
immutable-proof-assertion
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
***
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### proofHashKeyId?
|
|
22
22
|
|
|
23
|
-
> `optional` **
|
|
23
|
+
> `optional` **proofHashKeyId**: `string`
|
|
24
24
|
|
|
25
|
-
The key to use in the proof
|
|
25
|
+
The key to use in the proof hash.
|
|
26
26
|
|
|
27
27
|
#### Default
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
immutable-proof
|
|
30
|
+
immutable-proof-hash
|
|
31
31
|
```
|
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.7",
|
|
4
4
|
"description": "Immutable proof contract implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@twin.org/entity": "next",
|
|
23
23
|
"@twin.org/entity-storage-models": "next",
|
|
24
24
|
"@twin.org/identity-models": "next",
|
|
25
|
-
"@twin.org/immutable-proof-models": "0.0.1-next.
|
|
25
|
+
"@twin.org/immutable-proof-models": "0.0.1-next.7",
|
|
26
26
|
"@twin.org/immutable-storage-models": "next",
|
|
27
27
|
"@twin.org/nameof": "next",
|
|
28
28
|
"@twin.org/standards-w3c-did": "next",
|