@twin.org/immutable-proof-service 0.0.1-next.27 → 0.0.1-next.28

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.
@@ -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 immutableStorageModels = require('@twin.org/immutable-storage-models');
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 immutable storage id.
46
+ * The verifiable storage id.
47
47
  */
48
- immutableStorageId;
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, "immutableStorageId", void 0);
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 immutable storage for the credentials.
390
+ * The verifiable storage for the credentials.
391
391
  * @internal
392
392
  */
393
- _immutableStorage;
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._immutableStorage = immutableStorageModels.ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
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 immutable storage for the proof.
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 removeImmutable(id, nodeIdentity) {
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.immutableStorageId)) {
554
- await this._immutableStorage.remove(nodeIdentity, streamEntity.immutableStorageId);
555
- delete streamEntity.immutableStorageId;
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, "removeImmutableFailed", undefined, error);
560
+ throw new core.GeneralError(this.CLASS_NAME, "removeVerifiableFailed", undefined, error);
561
561
  }
562
562
  }
563
563
  /**
@@ -605,8 +605,8 @@ class ImmutableProofService {
605
605
  proofEntity.dateCreated = immutableProof.proof.created;
606
606
  }
607
607
  const compacted = await dataJsonLd.JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
608
- const immutableStoreResult = await this._immutableStorage.store(proofEntity.nodeIdentity, core.ObjectHelper.toBytes(compacted));
609
- proofEntity.immutableStorageId = immutableStoreResult.id;
608
+ const verifiableCreateResult = await this._verifiableStorage.create(proofEntity.nodeIdentity, core.ObjectHelper.toBytes(compacted));
609
+ proofEntity.verifiableStorageId = verifiableCreateResult.id;
610
610
  await this._proofStorage.set(proofEntity);
611
611
  await this._eventBusComponent?.publish(immutableProofModels.ImmutableProofTopics.ProofCreated, { id: new core.Urn(ImmutableProofService.NAMESPACE, task.payload.proofId).toString() });
612
612
  }
@@ -630,9 +630,9 @@ class ImmutableProofService {
630
630
  let proofJsonLd = this.proofEntityToJsonLd(proofEntity);
631
631
  let verified = false;
632
632
  let failure = immutableProofModels.ImmutableProofFailure.NotIssued;
633
- if (core.Is.stringValue(proofEntity.immutableStorageId)) {
633
+ if (core.Is.stringValue(proofEntity.verifiableStorageId)) {
634
634
  failure = immutableProofModels.ImmutableProofFailure.ProofMissing;
635
- const immutableResult = await this._immutableStorage.get(proofEntity.immutableStorageId);
635
+ const immutableResult = await this._verifiableStorage.get(proofEntity.verifiableStorageId);
636
636
  if (core.Is.uint8Array(immutableResult.data)) {
637
637
  proofJsonLd = core.ObjectHelper.fromBytes(immutableResult.data);
638
638
  const unsecureDocument = core.ObjectHelper.clone(proofJsonLd);
@@ -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 { ImmutableStorageConnectorFactory } from '@twin.org/immutable-storage-models';
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 immutable storage id.
44
+ * The verifiable storage id.
45
45
  */
46
- immutableStorageId;
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, "immutableStorageId", void 0);
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 immutable storage for the credentials.
388
+ * The verifiable storage for the credentials.
389
389
  * @internal
390
390
  */
391
- _immutableStorage;
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._immutableStorage = ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
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 immutable storage for the proof.
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 removeImmutable(id, nodeIdentity) {
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.immutableStorageId)) {
552
- await this._immutableStorage.remove(nodeIdentity, streamEntity.immutableStorageId);
553
- delete streamEntity.immutableStorageId;
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, "removeImmutableFailed", undefined, error);
558
+ throw new GeneralError(this.CLASS_NAME, "removeVerifiableFailed", undefined, error);
559
559
  }
560
560
  }
561
561
  /**
@@ -603,8 +603,8 @@ class ImmutableProofService {
603
603
  proofEntity.dateCreated = immutableProof.proof.created;
604
604
  }
605
605
  const compacted = await JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
606
- const immutableStoreResult = await this._immutableStorage.store(proofEntity.nodeIdentity, ObjectHelper.toBytes(compacted));
607
- proofEntity.immutableStorageId = immutableStoreResult.id;
606
+ const verifiableCreateResult = await this._verifiableStorage.create(proofEntity.nodeIdentity, ObjectHelper.toBytes(compacted));
607
+ proofEntity.verifiableStorageId = verifiableCreateResult.id;
608
608
  await this._proofStorage.set(proofEntity);
609
609
  await this._eventBusComponent?.publish(ImmutableProofTopics.ProofCreated, { id: new Urn(ImmutableProofService.NAMESPACE, task.payload.proofId).toString() });
610
610
  }
@@ -628,9 +628,9 @@ class ImmutableProofService {
628
628
  let proofJsonLd = this.proofEntityToJsonLd(proofEntity);
629
629
  let verified = false;
630
630
  let failure = ImmutableProofFailure.NotIssued;
631
- if (Is.stringValue(proofEntity.immutableStorageId)) {
631
+ if (Is.stringValue(proofEntity.verifiableStorageId)) {
632
632
  failure = ImmutableProofFailure.ProofMissing;
633
- const immutableResult = await this._immutableStorage.get(proofEntity.immutableStorageId);
633
+ const immutableResult = await this._verifiableStorage.get(proofEntity.verifiableStorageId);
634
634
  if (Is.uint8Array(immutableResult.data)) {
635
635
  proofJsonLd = ObjectHelper.fromBytes(immutableResult.data);
636
636
  const unsecureDocument = ObjectHelper.clone(proofJsonLd);
@@ -27,7 +27,7 @@ export declare class ImmutableProof {
27
27
  */
28
28
  proofObjectHash: string;
29
29
  /**
30
- * The immutable storage id.
30
+ * The verifiable storage id.
31
31
  */
32
- immutableStorageId?: string;
32
+ verifiableStorageId?: string;
33
33
  }
@@ -41,11 +41,11 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
41
41
  */
42
42
  verify(id: string): Promise<IImmutableProofVerification>;
43
43
  /**
44
- * Remove the immutable storage for the proof.
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
- removeImmutable(id: string, nodeIdentity?: string): Promise<void>;
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 immutable storage.
13
- * @default immutable-storage
12
+ * The verifiable storage.
13
+ * @default verifiable-storage
14
14
  */
15
- immutableStorageType?: string;
15
+ verifiableStorageType?: string;
16
16
  /**
17
17
  * The identity connector type.
18
18
  * @default identity
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/immutable-proof-service - Changelog
2
2
 
3
- ## v0.0.1-next.27
3
+ ## v0.0.1-next.28
4
4
 
5
5
  - Initial Release
@@ -62,8 +62,8 @@ The associated hash for the item.
62
62
 
63
63
  ***
64
64
 
65
- ### immutableStorageId?
65
+ ### verifiableStorageId?
66
66
 
67
- > `optional` **immutableStorageId**: `string`
67
+ > `optional` **verifiableStorageId**: `string`
68
68
 
69
- The immutable storage id.
69
+ The verifiable storage id.
@@ -146,11 +146,11 @@ NotFoundError if the proof is not found.
146
146
 
147
147
  ***
148
148
 
149
- ### removeImmutable()
149
+ ### removeVerifiable()
150
150
 
151
- > **removeImmutable**(`id`, `nodeIdentity`?): `Promise`\<`void`\>
151
+ > **removeVerifiable**(`id`, `nodeIdentity`?): `Promise`\<`void`\>
152
152
 
153
- Remove the immutable storage for the proof.
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.removeImmutable`
181
+ `IImmutableProofComponent.removeVerifiable`
@@ -18,16 +18,16 @@ immutable-proof
18
18
 
19
19
  ***
20
20
 
21
- ### immutableStorageType?
21
+ ### verifiableStorageType?
22
22
 
23
- > `optional` **immutableStorageType**: `string`
23
+ > `optional` **verifiableStorageType**: `string`
24
24
 
25
- The immutable storage.
25
+ The verifiable storage.
26
26
 
27
27
  #### Default
28
28
 
29
29
  ```ts
30
- immutable-storage
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
- "removeImmutableFailed": "Removing immutable entry from the Immutable Proof failed",
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.27",
3
+ "version": "0.0.1-next.28",
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",
27
- "@twin.org/immutable-proof-task": "0.0.1-next.27",
28
- "@twin.org/immutable-storage-models": "next",
26
+ "@twin.org/immutable-proof-models": "0.0.1-next.28",
27
+ "@twin.org/immutable-proof-task": "0.0.1-next.28",
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
  },