@twin.org/immutable-proof-service 0.0.1-next.13 → 0.0.1-next.14

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.
@@ -327,6 +327,11 @@ class ImmutableProofService {
327
327
  * @internal
328
328
  */
329
329
  _backgroundTaskConnector;
330
+ /**
331
+ * The event bus component.
332
+ * @internal
333
+ */
334
+ _eventBusComponent;
330
335
  /**
331
336
  * The assertion method id to use for the proofs.
332
337
  * @internal
@@ -351,6 +356,7 @@ class ImmutableProofService {
351
356
  * @param options.immutableStorageType The immutable storage, defaults to "immutable-storage".
352
357
  * @param options.identityConnectorType The identity connector type, defaults to "identity".
353
358
  * @param options.backgroundTaskConnectorType The background task connector type, defaults to "background-task".
359
+ * @param options.eventBusComponentType The event bus component type, defaults to no event bus.
354
360
  */
355
361
  constructor(options) {
356
362
  this._vaultConnector = vaultModels.VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
@@ -359,6 +365,9 @@ class ImmutableProofService {
359
365
  this._identityConnectorType = options?.identityConnectorType ?? "identity";
360
366
  this._identityConnector = identityModels.IdentityConnectorFactory.get(this._identityConnectorType);
361
367
  this._backgroundTaskConnector = backgroundTaskModels.BackgroundTaskConnectorFactory.get(options?.backgroundTaskConnectorType ?? "background-task");
368
+ if (core.Is.stringValue(options?.eventBusComponentType)) {
369
+ this._eventBusComponent = core.ComponentFactory.get(options.eventBusComponentType);
370
+ }
362
371
  this._config = options?.config ?? {};
363
372
  this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof-assertion";
364
373
  this._proofHashKeyId = this._config.proofHashKeyId ?? "immutable-proof-hash";
@@ -550,6 +559,7 @@ class ImmutableProofService {
550
559
  const immutableStoreResult = await this._immutableStorage.store(proofEntity.nodeIdentity, core.ObjectHelper.toBytes(compacted));
551
560
  proofEntity.immutableStorageId = immutableStoreResult.id;
552
561
  await this._proofStorage.set(proofEntity);
562
+ await this._eventBusComponent?.publish(immutableProofModels.ImmutableProofTopics.ProofCreated, { id: new core.Urn(ImmutableProofService.NAMESPACE, task.payload.proofId).toString() });
553
563
  }
554
564
  }
555
565
  }
@@ -1,5 +1,5 @@
1
- import { Guards, ComponentFactory, StringHelper, Validation, Converter, RandomHelper, ObjectHelper, Urn, GeneralError, Is, NotFoundError, JsonHelper } from '@twin.org/core';
2
- import { ImmutableProofTypes, ImmutableProofFailure } from '@twin.org/immutable-proof-models';
1
+ import { Guards, ComponentFactory, StringHelper, Is, Validation, Converter, RandomHelper, ObjectHelper, Urn, GeneralError, NotFoundError, JsonHelper } from '@twin.org/core';
2
+ import { ImmutableProofTypes, ImmutableProofFailure, ImmutableProofTopics } from '@twin.org/immutable-proof-models';
3
3
  import { DidContexts, DidTypes, DidCryptoSuites } from '@twin.org/standards-w3c-did';
4
4
  import { HttpStatusCode, HeaderTypes, MimeTypes } from '@twin.org/web';
5
5
  import { BackgroundTaskConnectorFactory, TaskStatus } from '@twin.org/background-task-models';
@@ -325,6 +325,11 @@ class ImmutableProofService {
325
325
  * @internal
326
326
  */
327
327
  _backgroundTaskConnector;
328
+ /**
329
+ * The event bus component.
330
+ * @internal
331
+ */
332
+ _eventBusComponent;
328
333
  /**
329
334
  * The assertion method id to use for the proofs.
330
335
  * @internal
@@ -349,6 +354,7 @@ class ImmutableProofService {
349
354
  * @param options.immutableStorageType The immutable storage, defaults to "immutable-storage".
350
355
  * @param options.identityConnectorType The identity connector type, defaults to "identity".
351
356
  * @param options.backgroundTaskConnectorType The background task connector type, defaults to "background-task".
357
+ * @param options.eventBusComponentType The event bus component type, defaults to no event bus.
352
358
  */
353
359
  constructor(options) {
354
360
  this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
@@ -357,6 +363,9 @@ class ImmutableProofService {
357
363
  this._identityConnectorType = options?.identityConnectorType ?? "identity";
358
364
  this._identityConnector = IdentityConnectorFactory.get(this._identityConnectorType);
359
365
  this._backgroundTaskConnector = BackgroundTaskConnectorFactory.get(options?.backgroundTaskConnectorType ?? "background-task");
366
+ if (Is.stringValue(options?.eventBusComponentType)) {
367
+ this._eventBusComponent = ComponentFactory.get(options.eventBusComponentType);
368
+ }
360
369
  this._config = options?.config ?? {};
361
370
  this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof-assertion";
362
371
  this._proofHashKeyId = this._config.proofHashKeyId ?? "immutable-proof-hash";
@@ -548,6 +557,7 @@ class ImmutableProofService {
548
557
  const immutableStoreResult = await this._immutableStorage.store(proofEntity.nodeIdentity, ObjectHelper.toBytes(compacted));
549
558
  proofEntity.immutableStorageId = immutableStoreResult.id;
550
559
  await this._proofStorage.set(proofEntity);
560
+ await this._eventBusComponent?.publish(ImmutableProofTopics.ProofCreated, { id: new Urn(ImmutableProofService.NAMESPACE, task.payload.proofId).toString() });
551
561
  }
552
562
  }
553
563
  }
@@ -22,6 +22,7 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
22
22
  * @param options.immutableStorageType The immutable storage, defaults to "immutable-storage".
23
23
  * @param options.identityConnectorType The identity connector type, defaults to "identity".
24
24
  * @param options.backgroundTaskConnectorType The background task connector type, defaults to "background-task".
25
+ * @param options.eventBusComponentType The event bus component type, defaults to no event bus.
25
26
  */
26
27
  constructor(options?: {
27
28
  vaultConnectorType?: string;
@@ -29,6 +30,7 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
29
30
  immutableStorageType?: string;
30
31
  identityConnectorType?: string;
31
32
  backgroundTaskConnectorType?: string;
33
+ eventBusComponentType?: string;
32
34
  config?: IImmutableProofServiceConfig;
33
35
  });
34
36
  /**
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/immutable-proof-service - Changelog
2
2
 
3
- ## v0.0.1-next.13
3
+ ## v0.0.1-next.14
4
4
 
5
5
  - Initial Release
@@ -40,6 +40,10 @@ The identity connector type, defaults to "identity".
40
40
 
41
41
  The background task connector type, defaults to "background-task".
42
42
 
43
+ • **options.eventBusComponentType?**: `string`
44
+
45
+ The event bus component type, defaults to no event bus.
46
+
43
47
  • **options.config?**: [`IImmutableProofServiceConfig`](../interfaces/IImmutableProofServiceConfig.md)
44
48
 
45
49
  The configuration for the connector.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/immutable-proof-service",
3
- "version": "0.0.1-next.13",
3
+ "version": "0.0.1-next.14",
4
4
  "description": "Immutable proof contract implementation and REST endpoint definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,9 +22,10 @@
22
22
  "@twin.org/data-schema-org": "next",
23
23
  "@twin.org/entity": "next",
24
24
  "@twin.org/entity-storage-models": "next",
25
+ "@twin.org/event-bus-models": "next",
25
26
  "@twin.org/identity-models": "next",
26
- "@twin.org/immutable-proof-models": "0.0.1-next.13",
27
- "@twin.org/immutable-proof-task": "0.0.1-next.13",
27
+ "@twin.org/immutable-proof-models": "0.0.1-next.14",
28
+ "@twin.org/immutable-proof-task": "0.0.1-next.14",
28
29
  "@twin.org/immutable-storage-models": "next",
29
30
  "@twin.org/nameof": "next",
30
31
  "@twin.org/standards-w3c-did": "next",