@twin.org/immutable-proof-service 0.0.1-next.6 → 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
|
/**
|
|
@@ -642,17 +642,17 @@ class ImmutableProofService {
|
|
|
642
642
|
* @internal
|
|
643
643
|
*/
|
|
644
644
|
async generateHashData(nodeIdentity, immutableProof) {
|
|
645
|
-
// 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
|
|
646
646
|
// without these objects we can simplify the context
|
|
647
647
|
const object = core.ObjectHelper.omit(immutableProof, ["proof", "immutableReceipt"]);
|
|
648
648
|
object["@context"] = immutableProofModels.ImmutableProofTypes.ContextRoot;
|
|
649
649
|
const canonicalDocument = core.JsonHelper.canonicalize(object);
|
|
650
|
-
const
|
|
651
|
-
const
|
|
650
|
+
const proofKey = await this._vaultConnector.getKey(`${nodeIdentity}/${this._proofHashKeyId}`);
|
|
651
|
+
const proofHash = crypto.Sha256.sum256(proofKey.privateKey);
|
|
652
652
|
const transformedDocumentHash = crypto.Sha256.sum256(core.Converter.utf8ToBytes(canonicalDocument));
|
|
653
|
-
const hashData = new Uint8Array(
|
|
654
|
-
hashData.set(
|
|
655
|
-
hashData.set(transformedDocumentHash,
|
|
653
|
+
const hashData = new Uint8Array(proofHash.length + transformedDocumentHash.length);
|
|
654
|
+
hashData.set(proofHash);
|
|
655
|
+
hashData.set(transformedDocumentHash, proofHash.length);
|
|
656
656
|
return hashData;
|
|
657
657
|
}
|
|
658
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
|
/**
|
|
@@ -640,17 +640,17 @@ class ImmutableProofService {
|
|
|
640
640
|
* @internal
|
|
641
641
|
*/
|
|
642
642
|
async generateHashData(nodeIdentity, immutableProof) {
|
|
643
|
-
// 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
|
|
644
644
|
// without these objects we can simplify the context
|
|
645
645
|
const object = ObjectHelper.omit(immutableProof, ["proof", "immutableReceipt"]);
|
|
646
646
|
object["@context"] = ImmutableProofTypes.ContextRoot;
|
|
647
647
|
const canonicalDocument = JsonHelper.canonicalize(object);
|
|
648
|
-
const
|
|
649
|
-
const
|
|
648
|
+
const proofKey = await this._vaultConnector.getKey(`${nodeIdentity}/${this._proofHashKeyId}`);
|
|
649
|
+
const proofHash = Sha256.sum256(proofKey.privateKey);
|
|
650
650
|
const transformedDocumentHash = Sha256.sum256(Converter.utf8ToBytes(canonicalDocument));
|
|
651
|
-
const hashData = new Uint8Array(
|
|
652
|
-
hashData.set(
|
|
653
|
-
hashData.set(transformedDocumentHash,
|
|
651
|
+
const hashData = new Uint8Array(proofHash.length + transformedDocumentHash.length);
|
|
652
|
+
hashData.set(proofHash);
|
|
653
|
+
hashData.set(transformedDocumentHash, proofHash.length);
|
|
654
654
|
return hashData;
|
|
655
655
|
}
|
|
656
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",
|