@twin.org/immutable-proof-service 0.0.1-next.27 → 0.0.1-next.29
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 +19 -18
- package/dist/esm/index.mjs +19 -18
- package/dist/types/entities/immutableProof.d.ts +2 -2
- package/dist/types/immutableProofService.d.ts +2 -2
- package/dist/types/models/IImmutableProofServiceConstructorOptions.d.ts +3 -3
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/ImmutableProof.md +3 -3
- package/docs/reference/classes/ImmutableProofService.md +4 -4
- package/docs/reference/interfaces/IImmutableProofServiceConstructorOptions.md +4 -4
- package/locales/en.json +1 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -10,7 +10,7 @@ var crypto = require('@twin.org/crypto');
|
|
|
10
10
|
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
|
-
var
|
|
13
|
+
var verifiableStorageModels = require('@twin.org/verifiable-storage-models');
|
|
14
14
|
|
|
15
15
|
// Copyright 2024 IOTA Stiftung.
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -43,9 +43,9 @@ exports.ImmutableProof = class ImmutableProof {
|
|
|
43
43
|
*/
|
|
44
44
|
proofObjectHash;
|
|
45
45
|
/**
|
|
46
|
-
* The
|
|
46
|
+
* The verifiable storage id.
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
verifiableStorageId;
|
|
49
49
|
};
|
|
50
50
|
__decorate([
|
|
51
51
|
entity.property({ type: "string", isPrimary: true }),
|
|
@@ -74,7 +74,7 @@ __decorate([
|
|
|
74
74
|
__decorate([
|
|
75
75
|
entity.property({ type: "string", optional: true }),
|
|
76
76
|
__metadata("design:type", String)
|
|
77
|
-
], exports.ImmutableProof.prototype, "
|
|
77
|
+
], exports.ImmutableProof.prototype, "verifiableStorageId", void 0);
|
|
78
78
|
exports.ImmutableProof = __decorate([
|
|
79
79
|
entity.entity()
|
|
80
80
|
], exports.ImmutableProof);
|
|
@@ -387,10 +387,10 @@ class ImmutableProofService {
|
|
|
387
387
|
*/
|
|
388
388
|
_proofStorage;
|
|
389
389
|
/**
|
|
390
|
-
* The
|
|
390
|
+
* The verifiable storage for the credentials.
|
|
391
391
|
* @internal
|
|
392
392
|
*/
|
|
393
|
-
|
|
393
|
+
_verifiableStorage;
|
|
394
394
|
/**
|
|
395
395
|
* The background task connector.
|
|
396
396
|
* @internal
|
|
@@ -417,7 +417,7 @@ class ImmutableProofService {
|
|
|
417
417
|
*/
|
|
418
418
|
constructor(options) {
|
|
419
419
|
this._proofStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.immutableProofEntityStorageType ?? core.StringHelper.kebabCase("ImmutableProof"));
|
|
420
|
-
this.
|
|
420
|
+
this._verifiableStorage = verifiableStorageModels.VerifiableStorageConnectorFactory.get(options?.verifiableStorageType ?? "verifiable-storage");
|
|
421
421
|
this._identityConnectorType = options?.identityConnectorType ?? "identity";
|
|
422
422
|
this._identityConnector = identityModels.IdentityConnectorFactory.get(this._identityConnectorType);
|
|
423
423
|
this._backgroundTaskConnector = backgroundTaskModels.BackgroundTaskConnectorFactory.get(options?.backgroundTaskConnectorType ?? "background-task");
|
|
@@ -528,13 +528,13 @@ class ImmutableProofService {
|
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
530
|
/**
|
|
531
|
-
* Remove the
|
|
531
|
+
* Remove the verifiable storage for the proof.
|
|
532
532
|
* @param id The id of the proof to remove the storage from.
|
|
533
533
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
534
534
|
* @returns Nothing.
|
|
535
535
|
* @throws NotFoundError if the proof is not found.
|
|
536
536
|
*/
|
|
537
|
-
async
|
|
537
|
+
async removeVerifiable(id, nodeIdentity) {
|
|
538
538
|
core.Guards.stringValue(this.CLASS_NAME, "id", id);
|
|
539
539
|
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
540
540
|
const urnParsed = core.Urn.fromValidString(id);
|
|
@@ -550,14 +550,14 @@ class ImmutableProofService {
|
|
|
550
550
|
if (core.Is.empty(streamEntity)) {
|
|
551
551
|
throw new core.NotFoundError(this.CLASS_NAME, "proofNotFound", id);
|
|
552
552
|
}
|
|
553
|
-
if (core.Is.stringValue(streamEntity.
|
|
554
|
-
await this.
|
|
555
|
-
delete streamEntity.
|
|
553
|
+
if (core.Is.stringValue(streamEntity.verifiableStorageId)) {
|
|
554
|
+
await this._verifiableStorage.remove(nodeIdentity, streamEntity.verifiableStorageId);
|
|
555
|
+
delete streamEntity.verifiableStorageId;
|
|
556
556
|
await this._proofStorage.set(streamEntity);
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
catch (error) {
|
|
560
|
-
throw new core.GeneralError(this.CLASS_NAME, "
|
|
560
|
+
throw new core.GeneralError(this.CLASS_NAME, "removeVerifiableFailed", undefined, error);
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
/**
|
|
@@ -583,7 +583,8 @@ class ImmutableProofService {
|
|
|
583
583
|
nodeIdentity: proofEntity.nodeIdentity,
|
|
584
584
|
userIdentity: proofEntity.userIdentity,
|
|
585
585
|
proofObjectId: proofEntity.proofObjectId,
|
|
586
|
-
proofObjectHash: proofEntity.proofObjectHash
|
|
586
|
+
proofObjectHash: proofEntity.proofObjectHash,
|
|
587
|
+
verifiableStorageId: proofEntity.verifiableStorageId
|
|
587
588
|
};
|
|
588
589
|
return jsonLd;
|
|
589
590
|
}
|
|
@@ -605,8 +606,8 @@ class ImmutableProofService {
|
|
|
605
606
|
proofEntity.dateCreated = immutableProof.proof.created;
|
|
606
607
|
}
|
|
607
608
|
const compacted = await dataJsonLd.JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
|
|
608
|
-
const
|
|
609
|
-
proofEntity.
|
|
609
|
+
const verifiableCreateResult = await this._verifiableStorage.create(proofEntity.nodeIdentity, core.ObjectHelper.toBytes(compacted));
|
|
610
|
+
proofEntity.verifiableStorageId = verifiableCreateResult.id;
|
|
610
611
|
await this._proofStorage.set(proofEntity);
|
|
611
612
|
await this._eventBusComponent?.publish(immutableProofModels.ImmutableProofTopics.ProofCreated, { id: new core.Urn(ImmutableProofService.NAMESPACE, task.payload.proofId).toString() });
|
|
612
613
|
}
|
|
@@ -630,9 +631,9 @@ class ImmutableProofService {
|
|
|
630
631
|
let proofJsonLd = this.proofEntityToJsonLd(proofEntity);
|
|
631
632
|
let verified = false;
|
|
632
633
|
let failure = immutableProofModels.ImmutableProofFailure.NotIssued;
|
|
633
|
-
if (core.Is.stringValue(proofEntity.
|
|
634
|
+
if (core.Is.stringValue(proofEntity.verifiableStorageId)) {
|
|
634
635
|
failure = immutableProofModels.ImmutableProofFailure.ProofMissing;
|
|
635
|
-
const immutableResult = await this.
|
|
636
|
+
const immutableResult = await this._verifiableStorage.get(proofEntity.verifiableStorageId);
|
|
636
637
|
if (core.Is.uint8Array(immutableResult.data)) {
|
|
637
638
|
proofJsonLd = core.ObjectHelper.fromBytes(immutableResult.data);
|
|
638
639
|
const unsecureDocument = core.ObjectHelper.clone(proofJsonLd);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -8,7 +8,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
|
-
import {
|
|
11
|
+
import { VerifiableStorageConnectorFactory } from '@twin.org/verifiable-storage-models';
|
|
12
12
|
|
|
13
13
|
// Copyright 2024 IOTA Stiftung.
|
|
14
14
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -41,9 +41,9 @@ let ImmutableProof = class ImmutableProof {
|
|
|
41
41
|
*/
|
|
42
42
|
proofObjectHash;
|
|
43
43
|
/**
|
|
44
|
-
* The
|
|
44
|
+
* The verifiable storage id.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
verifiableStorageId;
|
|
47
47
|
};
|
|
48
48
|
__decorate([
|
|
49
49
|
property({ type: "string", isPrimary: true }),
|
|
@@ -72,7 +72,7 @@ __decorate([
|
|
|
72
72
|
__decorate([
|
|
73
73
|
property({ type: "string", optional: true }),
|
|
74
74
|
__metadata("design:type", String)
|
|
75
|
-
], ImmutableProof.prototype, "
|
|
75
|
+
], ImmutableProof.prototype, "verifiableStorageId", void 0);
|
|
76
76
|
ImmutableProof = __decorate([
|
|
77
77
|
entity()
|
|
78
78
|
], ImmutableProof);
|
|
@@ -385,10 +385,10 @@ class ImmutableProofService {
|
|
|
385
385
|
*/
|
|
386
386
|
_proofStorage;
|
|
387
387
|
/**
|
|
388
|
-
* The
|
|
388
|
+
* The verifiable storage for the credentials.
|
|
389
389
|
* @internal
|
|
390
390
|
*/
|
|
391
|
-
|
|
391
|
+
_verifiableStorage;
|
|
392
392
|
/**
|
|
393
393
|
* The background task connector.
|
|
394
394
|
* @internal
|
|
@@ -415,7 +415,7 @@ class ImmutableProofService {
|
|
|
415
415
|
*/
|
|
416
416
|
constructor(options) {
|
|
417
417
|
this._proofStorage = EntityStorageConnectorFactory.get(options?.immutableProofEntityStorageType ?? StringHelper.kebabCase("ImmutableProof"));
|
|
418
|
-
this.
|
|
418
|
+
this._verifiableStorage = VerifiableStorageConnectorFactory.get(options?.verifiableStorageType ?? "verifiable-storage");
|
|
419
419
|
this._identityConnectorType = options?.identityConnectorType ?? "identity";
|
|
420
420
|
this._identityConnector = IdentityConnectorFactory.get(this._identityConnectorType);
|
|
421
421
|
this._backgroundTaskConnector = BackgroundTaskConnectorFactory.get(options?.backgroundTaskConnectorType ?? "background-task");
|
|
@@ -526,13 +526,13 @@ class ImmutableProofService {
|
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
528
|
/**
|
|
529
|
-
* Remove the
|
|
529
|
+
* Remove the verifiable storage for the proof.
|
|
530
530
|
* @param id The id of the proof to remove the storage from.
|
|
531
531
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
532
532
|
* @returns Nothing.
|
|
533
533
|
* @throws NotFoundError if the proof is not found.
|
|
534
534
|
*/
|
|
535
|
-
async
|
|
535
|
+
async removeVerifiable(id, nodeIdentity) {
|
|
536
536
|
Guards.stringValue(this.CLASS_NAME, "id", id);
|
|
537
537
|
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
538
538
|
const urnParsed = Urn.fromValidString(id);
|
|
@@ -548,14 +548,14 @@ class ImmutableProofService {
|
|
|
548
548
|
if (Is.empty(streamEntity)) {
|
|
549
549
|
throw new NotFoundError(this.CLASS_NAME, "proofNotFound", id);
|
|
550
550
|
}
|
|
551
|
-
if (Is.stringValue(streamEntity.
|
|
552
|
-
await this.
|
|
553
|
-
delete streamEntity.
|
|
551
|
+
if (Is.stringValue(streamEntity.verifiableStorageId)) {
|
|
552
|
+
await this._verifiableStorage.remove(nodeIdentity, streamEntity.verifiableStorageId);
|
|
553
|
+
delete streamEntity.verifiableStorageId;
|
|
554
554
|
await this._proofStorage.set(streamEntity);
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
557
|
catch (error) {
|
|
558
|
-
throw new GeneralError(this.CLASS_NAME, "
|
|
558
|
+
throw new GeneralError(this.CLASS_NAME, "removeVerifiableFailed", undefined, error);
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
/**
|
|
@@ -581,7 +581,8 @@ class ImmutableProofService {
|
|
|
581
581
|
nodeIdentity: proofEntity.nodeIdentity,
|
|
582
582
|
userIdentity: proofEntity.userIdentity,
|
|
583
583
|
proofObjectId: proofEntity.proofObjectId,
|
|
584
|
-
proofObjectHash: proofEntity.proofObjectHash
|
|
584
|
+
proofObjectHash: proofEntity.proofObjectHash,
|
|
585
|
+
verifiableStorageId: proofEntity.verifiableStorageId
|
|
585
586
|
};
|
|
586
587
|
return jsonLd;
|
|
587
588
|
}
|
|
@@ -603,8 +604,8 @@ class ImmutableProofService {
|
|
|
603
604
|
proofEntity.dateCreated = immutableProof.proof.created;
|
|
604
605
|
}
|
|
605
606
|
const compacted = await JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
|
|
606
|
-
const
|
|
607
|
-
proofEntity.
|
|
607
|
+
const verifiableCreateResult = await this._verifiableStorage.create(proofEntity.nodeIdentity, ObjectHelper.toBytes(compacted));
|
|
608
|
+
proofEntity.verifiableStorageId = verifiableCreateResult.id;
|
|
608
609
|
await this._proofStorage.set(proofEntity);
|
|
609
610
|
await this._eventBusComponent?.publish(ImmutableProofTopics.ProofCreated, { id: new Urn(ImmutableProofService.NAMESPACE, task.payload.proofId).toString() });
|
|
610
611
|
}
|
|
@@ -628,9 +629,9 @@ class ImmutableProofService {
|
|
|
628
629
|
let proofJsonLd = this.proofEntityToJsonLd(proofEntity);
|
|
629
630
|
let verified = false;
|
|
630
631
|
let failure = ImmutableProofFailure.NotIssued;
|
|
631
|
-
if (Is.stringValue(proofEntity.
|
|
632
|
+
if (Is.stringValue(proofEntity.verifiableStorageId)) {
|
|
632
633
|
failure = ImmutableProofFailure.ProofMissing;
|
|
633
|
-
const immutableResult = await this.
|
|
634
|
+
const immutableResult = await this._verifiableStorage.get(proofEntity.verifiableStorageId);
|
|
634
635
|
if (Is.uint8Array(immutableResult.data)) {
|
|
635
636
|
proofJsonLd = ObjectHelper.fromBytes(immutableResult.data);
|
|
636
637
|
const unsecureDocument = ObjectHelper.clone(proofJsonLd);
|
|
@@ -41,11 +41,11 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
|
|
|
41
41
|
*/
|
|
42
42
|
verify(id: string): Promise<IImmutableProofVerification>;
|
|
43
43
|
/**
|
|
44
|
-
* Remove the
|
|
44
|
+
* Remove the verifiable storage for the proof.
|
|
45
45
|
* @param id The id of the proof to remove the storage from.
|
|
46
46
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
47
47
|
* @returns Nothing.
|
|
48
48
|
* @throws NotFoundError if the proof is not found.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
removeVerifiable(id: string, nodeIdentity?: string): Promise<void>;
|
|
51
51
|
}
|
|
@@ -9,10 +9,10 @@ export interface IImmutableProofServiceConstructorOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
immutableProofEntityStorageType?: string;
|
|
11
11
|
/**
|
|
12
|
-
* The
|
|
13
|
-
* @default
|
|
12
|
+
* The verifiable storage.
|
|
13
|
+
* @default verifiable-storage
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
verifiableStorageType?: string;
|
|
16
16
|
/**
|
|
17
17
|
* The identity connector type.
|
|
18
18
|
* @default identity
|
package/docs/changelog.md
CHANGED
|
@@ -62,8 +62,8 @@ The associated hash for the item.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
-
###
|
|
65
|
+
### verifiableStorageId?
|
|
66
66
|
|
|
67
|
-
> `optional` **
|
|
67
|
+
> `optional` **verifiableStorageId**: `string`
|
|
68
68
|
|
|
69
|
-
The
|
|
69
|
+
The verifiable storage id.
|
|
@@ -146,11 +146,11 @@ NotFoundError if the proof is not found.
|
|
|
146
146
|
|
|
147
147
|
***
|
|
148
148
|
|
|
149
|
-
###
|
|
149
|
+
### removeVerifiable()
|
|
150
150
|
|
|
151
|
-
> **
|
|
151
|
+
> **removeVerifiable**(`id`, `nodeIdentity`?): `Promise`\<`void`\>
|
|
152
152
|
|
|
153
|
-
Remove the
|
|
153
|
+
Remove the verifiable storage for the proof.
|
|
154
154
|
|
|
155
155
|
#### Parameters
|
|
156
156
|
|
|
@@ -178,4 +178,4 @@ NotFoundError if the proof is not found.
|
|
|
178
178
|
|
|
179
179
|
#### Implementation of
|
|
180
180
|
|
|
181
|
-
`IImmutableProofComponent.
|
|
181
|
+
`IImmutableProofComponent.removeVerifiable`
|
|
@@ -18,16 +18,16 @@ immutable-proof
|
|
|
18
18
|
|
|
19
19
|
***
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### verifiableStorageType?
|
|
22
22
|
|
|
23
|
-
> `optional` **
|
|
23
|
+
> `optional` **verifiableStorageType**: `string`
|
|
24
24
|
|
|
25
|
-
The
|
|
25
|
+
The verifiable storage.
|
|
26
26
|
|
|
27
27
|
#### Default
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
|
|
30
|
+
verifiable-storage
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
***
|
package/locales/en.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"createFailed": "Creating the proof failed",
|
|
6
6
|
"getFailed": "Getting the proof failed",
|
|
7
7
|
"verifyFailed": "Verifying the proof failed",
|
|
8
|
-
"
|
|
8
|
+
"removeVerifiableFailed": "Removing verifiable entry from the Immutable Proof failed",
|
|
9
9
|
"proofNotFound": "The proof with the Id \"{notFoundId}\" was not found"
|
|
10
10
|
}
|
|
11
11
|
}
|
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.29",
|
|
4
4
|
"description": "Immutable proof contract implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,12 +23,12 @@
|
|
|
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.
|
|
28
|
-
"@twin.org/immutable-storage-models": "next",
|
|
26
|
+
"@twin.org/immutable-proof-models": "0.0.1-next.29",
|
|
27
|
+
"@twin.org/immutable-proof-task": "0.0.1-next.29",
|
|
29
28
|
"@twin.org/nameof": "next",
|
|
30
29
|
"@twin.org/standards-w3c-did": "next",
|
|
31
30
|
"@twin.org/vault-models": "next",
|
|
31
|
+
"@twin.org/verifiable-storage-models": "next",
|
|
32
32
|
"@twin.org/web": "next",
|
|
33
33
|
"jsonschema": "1.5.0"
|
|
34
34
|
},
|