@twin.org/immutable-proof-service 0.0.1-next.2 → 0.0.1-next.21

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.
@@ -1,16 +1,83 @@
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';
3
- import { DidContexts, DidTypes, DidCryptoSuites } from '@twin.org/standards-w3c-did';
1
+ import { property, SortDirection, entity, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
2
+ import { Guards, ComponentFactory, StringHelper, Is, Validation, Converter, RandomHelper, ObjectHelper, Urn, GeneralError, NotFoundError, JsonHelper } from '@twin.org/core';
3
+ import { ImmutableProofTypes, ImmutableProofFailure, ImmutableProofTopics } from '@twin.org/immutable-proof-models';
4
+ import { DidCryptoSuites, DidTypes, DidContexts } from '@twin.org/standards-w3c-did';
4
5
  import { HttpStatusCode, HeaderTypes, MimeTypes } from '@twin.org/web';
6
+ import { BackgroundTaskConnectorFactory, TaskStatus } from '@twin.org/background-task-models';
5
7
  import { Blake2b, Sha256 } from '@twin.org/crypto';
6
8
  import { JsonLdHelper, JsonLdProcessor } from '@twin.org/data-json-ld';
7
- import { SchemaOrgDataTypes, SchemaOrgTypes } from '@twin.org/data-schema-org';
8
- import { ComparisonOperator, SortDirection, property, entity, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
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 { ImmutableStorageConnectorFactory, ImmutableStorageTypes } from '@twin.org/immutable-storage-models';
12
12
  import { VaultConnectorFactory } from '@twin.org/vault-models';
13
13
 
14
+ // Copyright 2024 IOTA Stiftung.
15
+ // SPDX-License-Identifier: Apache-2.0.
16
+ /**
17
+ * Class describing the immutable proof.
18
+ */
19
+ let ImmutableProof = class ImmutableProof {
20
+ /**
21
+ * The id of the proof.
22
+ */
23
+ id;
24
+ /**
25
+ * The identity of the node which controls the proof.
26
+ */
27
+ nodeIdentity;
28
+ /**
29
+ * The identity of the user which created the proof.
30
+ */
31
+ userIdentity;
32
+ /**
33
+ * The date/time of when the proof was created.
34
+ */
35
+ dateCreated;
36
+ /**
37
+ * The associated id for the item.
38
+ */
39
+ proofObjectId;
40
+ /**
41
+ * The associated hash for the item.
42
+ */
43
+ proofObjectHash;
44
+ /**
45
+ * The immutable storage id.
46
+ */
47
+ immutableStorageId;
48
+ };
49
+ __decorate([
50
+ property({ type: "string", isPrimary: true }),
51
+ __metadata("design:type", String)
52
+ ], ImmutableProof.prototype, "id", void 0);
53
+ __decorate([
54
+ property({ type: "string" }),
55
+ __metadata("design:type", String)
56
+ ], ImmutableProof.prototype, "nodeIdentity", void 0);
57
+ __decorate([
58
+ property({ type: "string" }),
59
+ __metadata("design:type", String)
60
+ ], ImmutableProof.prototype, "userIdentity", void 0);
61
+ __decorate([
62
+ property({ type: "string", format: "date-time", sortDirection: SortDirection.Descending }),
63
+ __metadata("design:type", String)
64
+ ], ImmutableProof.prototype, "dateCreated", void 0);
65
+ __decorate([
66
+ property({ type: "string" }),
67
+ __metadata("design:type", String)
68
+ ], ImmutableProof.prototype, "proofObjectId", void 0);
69
+ __decorate([
70
+ property({ type: "string" }),
71
+ __metadata("design:type", String)
72
+ ], ImmutableProof.prototype, "proofObjectHash", void 0);
73
+ __decorate([
74
+ property({ type: "string" }),
75
+ __metadata("design:type", String)
76
+ ], ImmutableProof.prototype, "immutableStorageId", void 0);
77
+ ImmutableProof = __decorate([
78
+ entity()
79
+ ], ImmutableProof);
80
+
14
81
  /**
15
82
  * The source used when communicating about these routes.
16
83
  */
@@ -46,7 +113,7 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
46
113
  request: {
47
114
  body: {
48
115
  proofObject: {
49
- "@context": "http://schema.org",
116
+ "@context": "https://schema.org",
50
117
  type: "Person",
51
118
  name: "John Smith"
52
119
  }
@@ -106,7 +173,10 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
106
173
  id: "immutableProofGetResponseExample",
107
174
  response: {
108
175
  body: {
109
- "@context": ImmutableProofTypes.ContextRoot,
176
+ "@context": [
177
+ ImmutableProofTypes.ContextRoot,
178
+ ImmutableProofTypes.ContextRootCommon
179
+ ],
110
180
  type: ImmutableProofTypes.ImmutableProof,
111
181
  id: "ais:1234567890",
112
182
  userIdentity: "user-1",
@@ -136,7 +206,10 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
136
206
  [HeaderTypes.ContentType]: MimeTypes.JsonLd
137
207
  },
138
208
  body: {
139
- "@context": ImmutableProofTypes.ContextRoot,
209
+ "@context": [
210
+ ImmutableProofTypes.ContextRoot,
211
+ ImmutableProofTypes.ContextRootCommon
212
+ ],
140
213
  type: ImmutableProofTypes.ImmutableProof,
141
214
  id: "ais:1234567890",
142
215
  userIdentity: "user-1",
@@ -164,8 +237,8 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
164
237
  operationId: "immutableProofVerify",
165
238
  summary: "Verify a proof",
166
239
  tag: tagsImmutableProof[0].name,
167
- method: "POST",
168
- path: `${baseRouteName}/:id`,
240
+ method: "GET",
241
+ path: `${baseRouteName}/:id/verify`,
169
242
  handler: async (httpRequestContext, request) => immutableProofVerify(httpRequestContext, componentName, request),
170
243
  requestType: {
171
244
  type: "IImmutableProofVerifyRequest",
@@ -175,13 +248,6 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
175
248
  request: {
176
249
  pathParams: {
177
250
  id: "ais:1234567890"
178
- },
179
- body: {
180
- proofObject: {
181
- "@context": "http://schema.org",
182
- type: "Person",
183
- name: "John Smith"
184
- }
185
251
  }
186
252
  }
187
253
  }
@@ -277,10 +343,9 @@ async function immutableProofVerify(httpRequestContext, componentName, request)
277
343
  Guards.object(ROUTES_SOURCE, "request", request);
278
344
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
279
345
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
280
- Guards.object(ROUTES_SOURCE, "request.body.proofObject", request.body.proofObject);
281
346
  const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
282
347
  const component = ComponentFactory.get(componentName);
283
- const result = await component.verify(request.pathParams.id, request.body.proofObject);
348
+ const result = await component.verify(request.pathParams.id);
284
349
  return {
285
350
  headers: {
286
351
  [HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
@@ -329,39 +394,50 @@ class ImmutableProofService {
329
394
  */
330
395
  _immutableStorage;
331
396
  /**
332
- * The assertion method id to use for the proofs.
397
+ * The background task connector.
398
+ * @internal
399
+ */
400
+ _backgroundTaskConnector;
401
+ /**
402
+ * The event bus component.
403
+ * @internal
404
+ */
405
+ _eventBusComponent;
406
+ /**
407
+ * The verification method id to use for the proofs.
333
408
  * @internal
334
409
  */
335
- _assertionMethodId;
410
+ _verificationMethodId;
336
411
  /**
337
- * The proof config key id to use for the proofs.
412
+ * The proof hash key id to use for the proofs.
338
413
  * @internal
339
414
  */
340
- _proofConfigKeyId;
415
+ _proofHashKeyId;
341
416
  /**
342
- * Are we currently processing proofs.
417
+ * The identity connector type.
343
418
  * @internal
344
419
  */
345
- _processing;
420
+ _identityConnectorType;
346
421
  /**
347
422
  * Create a new instance of ImmutableProofService.
348
423
  * @param options The dependencies for the immutable proof connector.
349
- * @param options.config The configuration for the connector.
350
- * @param options.vaultConnectorType The vault connector type, defaults to "vault".
351
- * @param options.immutableProofEntityStorageType The entity storage for proofs, defaults to "immutable-proof".
352
- * @param options.immutableStorageType The immutable storage, defaults to "immutable-proof".
353
- * @param options.identityConnectorType The identity connector type, defaults to "identity".
354
424
  */
355
425
  constructor(options) {
356
426
  this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
357
427
  this._proofStorage = EntityStorageConnectorFactory.get(options?.immutableProofEntityStorageType ?? StringHelper.kebabCase("ImmutableProof"));
358
- this._immutableStorage = ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-proof");
359
- this._identityConnector = IdentityConnectorFactory.get(options?.identityConnectorType ?? "identity");
428
+ this._immutableStorage = ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
429
+ this._identityConnectorType = options?.identityConnectorType ?? "identity";
430
+ this._identityConnector = IdentityConnectorFactory.get(this._identityConnectorType);
431
+ this._backgroundTaskConnector = BackgroundTaskConnectorFactory.get(options?.backgroundTaskConnectorType ?? "background-task");
432
+ if (Is.stringValue(options?.eventBusComponentType)) {
433
+ this._eventBusComponent = ComponentFactory.get(options.eventBusComponentType);
434
+ }
360
435
  this._config = options?.config ?? {};
361
- this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof";
362
- this._proofConfigKeyId = this._config.proofConfigKeyId ?? "immutable-proof";
363
- SchemaOrgDataTypes.registerRedirects();
364
- this._processing = false;
436
+ this._verificationMethodId = this._config.verificationMethodId ?? "immutable-proof-assertion";
437
+ this._proofHashKeyId = this._config.proofHashKeyId ?? "immutable-proof-hash";
438
+ this._backgroundTaskConnector.registerHandler("immutable-proof", "@twin.org/immutable-proof-task", "processProofTask", async (task) => {
439
+ await this.finaliseTask(task);
440
+ });
365
441
  }
366
442
  /**
367
443
  * Create a new authentication proof.
@@ -391,7 +467,16 @@ class ImmutableProofService {
391
467
  proofObjectHash: Converter.bytesToBase64(hash)
392
468
  };
393
469
  await this._proofStorage.set(proofEntity);
394
- this.startProcessingProofs();
470
+ const immutableProof = this.proofEntityToJsonLd(proofEntity);
471
+ const hashData = await this.generateHashData(proofEntity.nodeIdentity, immutableProof);
472
+ const proofTaskPayload = {
473
+ proofId: id,
474
+ nodeIdentity,
475
+ identityConnectorType: this._identityConnectorType,
476
+ assertionMethodId: this._verificationMethodId,
477
+ hashData: Converter.bytesToHex(hashData)
478
+ };
479
+ await this._backgroundTaskConnector.create("immutable-proof", proofTaskPayload);
395
480
  return new Urn(ImmutableProofService.NAMESPACE, id).toString();
396
481
  }
397
482
  catch (error) {
@@ -414,7 +499,7 @@ class ImmutableProofService {
414
499
  });
415
500
  }
416
501
  try {
417
- const { immutableProof } = await this.internalGet(id);
502
+ const { immutableProof } = await this.internalGet(id, false);
418
503
  const compacted = await JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
419
504
  return compacted;
420
505
  }
@@ -425,11 +510,10 @@ class ImmutableProofService {
425
510
  /**
426
511
  * Verify an authentication proof.
427
512
  * @param id The id of the proof to verify.
428
- * @param proofObject The object to verify as JSON-LD.
429
513
  * @returns The result of the verification and any failures.
430
514
  * @throws NotFoundError if the proof is not found.
431
515
  */
432
- async verify(id, proofObject) {
516
+ async verify(id) {
433
517
  Guards.stringValue(this.CLASS_NAME, "id", id);
434
518
  const urnParsed = Urn.fromValidString(id);
435
519
  if (urnParsed.namespaceIdentifier() !== ImmutableProofService.NAMESPACE) {
@@ -439,7 +523,7 @@ class ImmutableProofService {
439
523
  });
440
524
  }
441
525
  try {
442
- const { verified, failure } = await this.internalGet(id, proofObject);
526
+ const { verified, failure } = await this.internalGet(id, true);
443
527
  return {
444
528
  "@context": ImmutableProofTypes.ContextRoot,
445
529
  type: ImmutableProofTypes.ImmutableProofVerification,
@@ -505,13 +589,9 @@ class ImmutableProofService {
505
589
  * @returns The model.
506
590
  * @internal
507
591
  */
508
- proofEntityToModel(proofEntity) {
592
+ proofEntityToJsonLd(proofEntity) {
509
593
  const model = {
510
- "@context": [
511
- ImmutableProofTypes.ContextRoot,
512
- SchemaOrgTypes.ContextRoot,
513
- DidContexts.ContextVCDataIntegrity
514
- ],
594
+ "@context": [ImmutableProofTypes.ContextRoot, ImmutableProofTypes.ContextRootCommon],
515
595
  type: ImmutableProofTypes.ImmutableProof,
516
596
  id: proofEntity.id,
517
597
  userIdentity: proofEntity.userIdentity,
@@ -521,74 +601,62 @@ class ImmutableProofService {
521
601
  return model;
522
602
  }
523
603
  /**
524
- * Start processing proofs.
525
- * @returns Nothing.
604
+ * Process a proof.
605
+ * @param proofEntity The proof entity to process.
526
606
  * @internal
527
607
  */
528
- startProcessingProofs() {
529
- if (!this._processing) {
530
- setTimeout(async () => {
531
- await this.processProofs();
532
- }, 0);
533
- }
534
- }
535
- /**
536
- * Process the proofs.
537
- * @internal
538
- */
539
- async processProofs() {
540
- // Get the oldest pending proof, plus one more, we can then determine whether to
541
- // trigger another process after this one
542
- const pendingProofs = await this._proofStorage.query({
543
- property: "immutableStorageId",
544
- comparison: ComparisonOperator.Equals,
545
- value: undefined
546
- }, [
547
- {
548
- property: "dateCreated",
549
- sortDirection: SortDirection.Ascending
608
+ async finaliseTask(task) {
609
+ if (task.status === TaskStatus.Success && Is.object(task.payload) && Is.object(task.result)) {
610
+ const proofEntity = await this._proofStorage.get(task.payload.proofId);
611
+ if (Is.object(proofEntity)) {
612
+ const immutableProof = this.proofEntityToJsonLd(proofEntity);
613
+ // As we are adding the proof to the data we update its context
614
+ immutableProof["@context"] = [
615
+ ImmutableProofTypes.ContextRoot,
616
+ ImmutableProofTypes.ContextRootCommon,
617
+ DidContexts.ContextVCDataIntegrity
618
+ ];
619
+ immutableProof.proof = task.result.proof;
620
+ if (Is.stringValue(immutableProof.proof.created)) {
621
+ proofEntity.dateCreated = immutableProof.proof.created;
622
+ }
623
+ const compacted = await JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
624
+ const immutableStoreResult = await this._immutableStorage.store(proofEntity.nodeIdentity, ObjectHelper.toBytes(compacted));
625
+ proofEntity.immutableStorageId = immutableStoreResult.id;
626
+ await this._proofStorage.set(proofEntity);
627
+ await this._eventBusComponent?.publish(ImmutableProofTopics.ProofCreated, { id: new Urn(ImmutableProofService.NAMESPACE, task.payload.proofId).toString() });
550
628
  }
551
- ], undefined, undefined, 2);
552
- if (pendingProofs.entities.length > 0) {
553
- const proofEntity = pendingProofs.entities[0];
554
- const immutableProof = this.proofEntityToModel(proofEntity);
555
- const hashData = await this.generateHashData(proofEntity.nodeIdentity, immutableProof);
556
- immutableProof.proof = await this._identityConnector.createProof(proofEntity.nodeIdentity, `${proofEntity.nodeIdentity}#${this._assertionMethodId}`, hashData);
557
- proofEntity.dateCreated = immutableProof.proof.created ?? new Date(Date.now()).toISOString();
558
- const compacted = await JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
559
- proofEntity.immutableStorageId = await this._immutableStorage.store(proofEntity.nodeIdentity, ObjectHelper.toBytes(compacted));
560
- await this._proofStorage.set(proofEntity);
561
- }
562
- // If there are still remaining proofs, start the timer again
563
- this._processing = false;
564
- if (pendingProofs.entities.length > 1) {
565
- this.startProcessingProofs();
566
629
  }
567
630
  }
568
631
  /**
569
632
  * Verify an authentication proof.
570
633
  * @param id The id of the proof to verify.
571
- * @param proofObject The object to verify as JSON-LD.
634
+ * @param verify Validate the proof.
572
635
  * @returns The result of the verification and any failures.
573
636
  * @throws NotFoundError if the proof is not found.
574
637
  * @internal
575
638
  */
576
- async internalGet(id, proofObject) {
639
+ async internalGet(id, verify) {
577
640
  const urnParsed = Urn.fromValidString(id);
578
641
  const proofId = urnParsed.namespaceSpecific(0);
579
642
  const proofEntity = await this._proofStorage.get(proofId);
580
643
  if (Is.empty(proofEntity)) {
581
644
  throw new NotFoundError(this.CLASS_NAME, "proofNotFound", id);
582
645
  }
583
- let proofModel = await this.proofEntityToModel(proofEntity);
646
+ let proofModel = await this.proofEntityToJsonLd(proofEntity);
584
647
  let verified = false;
585
648
  let failure = ImmutableProofFailure.NotIssued;
586
649
  if (Is.stringValue(proofEntity.immutableStorageId)) {
587
650
  failure = ImmutableProofFailure.ProofMissing;
588
- const immutableData = await this._immutableStorage.get(proofEntity.immutableStorageId);
589
- if (Is.uint8Array(immutableData)) {
590
- proofModel = ObjectHelper.fromBytes(immutableData);
591
- if (Is.object(proofModel.proof) && Is.object(proofObject)) {
651
+ const immutableResult = await this._immutableStorage.get(proofEntity.immutableStorageId);
652
+ if (Is.uint8Array(immutableResult.data)) {
653
+ proofModel = ObjectHelper.fromBytes(immutableResult.data);
654
+ proofModel.immutableReceipt = immutableResult.receipt;
655
+ // As we are adding the receipt to the data we update its context
656
+ if (Is.array(proofModel["@context"])) {
657
+ proofModel["@context"].push(ImmutableStorageTypes.ContextRoot);
658
+ }
659
+ if (verify && Is.object(proofModel.proof)) {
592
660
  if (proofModel.proof.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {
593
661
  failure = ImmutableProofFailure.CryptoSuiteMismatch;
594
662
  }
@@ -624,84 +692,21 @@ class ImmutableProofService {
624
692
  * @internal
625
693
  */
626
694
  async generateHashData(nodeIdentity, immutableProof) {
627
- const canonicalDocument = JsonHelper.canonicalize(ObjectHelper.omit(immutableProof, ["proof"]));
628
- const proofConfigKey = await this._vaultConnector.getKey(`${nodeIdentity}/${this._proofConfigKeyId}`);
629
- const proofConfigHash = Sha256.sum256(proofConfigKey.privateKey);
695
+ // We hash the data for the proof without the the proof or immutable receipt for the proof
696
+ // without these objects we can simplify the context
697
+ const object = ObjectHelper.omit(immutableProof, ["proof", "immutableReceipt"]);
698
+ object["@context"] = [ImmutableProofTypes.ContextRoot, ImmutableProofTypes.ContextRootCommon];
699
+ const canonicalDocument = JsonHelper.canonicalize(object);
700
+ const proofKey = await this._vaultConnector.getKey(`${nodeIdentity}/${this._proofHashKeyId}`);
701
+ const proofHash = Sha256.sum256(proofKey.privateKey);
630
702
  const transformedDocumentHash = Sha256.sum256(Converter.utf8ToBytes(canonicalDocument));
631
- const hashData = new Uint8Array(proofConfigHash.length + transformedDocumentHash.length);
632
- hashData.set(proofConfigHash);
633
- hashData.set(transformedDocumentHash, proofConfigHash.length);
703
+ const hashData = new Uint8Array(proofHash.length + transformedDocumentHash.length);
704
+ hashData.set(proofHash);
705
+ hashData.set(transformedDocumentHash, proofHash.length);
634
706
  return hashData;
635
707
  }
636
708
  }
637
709
 
638
- // Copyright 2024 IOTA Stiftung.
639
- // SPDX-License-Identifier: Apache-2.0.
640
- /**
641
- * Class describing the immutable proof.
642
- */
643
- let ImmutableProof = class ImmutableProof {
644
- /**
645
- * The id of the proof.
646
- */
647
- id;
648
- /**
649
- * The identity of the node which controls the proof.
650
- */
651
- nodeIdentity;
652
- /**
653
- * The identity of the user which created the proof.
654
- */
655
- userIdentity;
656
- /**
657
- * The date/time of when the proof was created.
658
- */
659
- dateCreated;
660
- /**
661
- * The associated id for the item.
662
- */
663
- proofObjectId;
664
- /**
665
- * The associated hash for the item.
666
- */
667
- proofObjectHash;
668
- /**
669
- * The immutable storage id.
670
- */
671
- immutableStorageId;
672
- };
673
- __decorate([
674
- property({ type: "string", isPrimary: true }),
675
- __metadata("design:type", String)
676
- ], ImmutableProof.prototype, "id", void 0);
677
- __decorate([
678
- property({ type: "string" }),
679
- __metadata("design:type", String)
680
- ], ImmutableProof.prototype, "nodeIdentity", void 0);
681
- __decorate([
682
- property({ type: "string" }),
683
- __metadata("design:type", String)
684
- ], ImmutableProof.prototype, "userIdentity", void 0);
685
- __decorate([
686
- property({ type: "string", format: "date-time", sortDirection: SortDirection.Descending }),
687
- __metadata("design:type", String)
688
- ], ImmutableProof.prototype, "dateCreated", void 0);
689
- __decorate([
690
- property({ type: "string" }),
691
- __metadata("design:type", String)
692
- ], ImmutableProof.prototype, "proofObjectId", void 0);
693
- __decorate([
694
- property({ type: "string" }),
695
- __metadata("design:type", String)
696
- ], ImmutableProof.prototype, "proofObjectHash", void 0);
697
- __decorate([
698
- property({ type: "string" }),
699
- __metadata("design:type", String)
700
- ], ImmutableProof.prototype, "immutableStorageId", void 0);
701
- ImmutableProof = __decorate([
702
- entity()
703
- ], ImmutableProof);
704
-
705
710
  const restEntryPoints = [
706
711
  {
707
712
  name: "immutable-proof",
@@ -1,6 +1,6 @@
1
1
  import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
- import { type IImmutableProofVerification, type IImmutableProof, type IImmutableProofComponent } from "@twin.org/immutable-proof-models";
3
- import type { IImmutableProofServiceConfig } from "./models/IImmutableProofServiceConfig";
2
+ import { type IImmutableProof, type IImmutableProofComponent, type IImmutableProofVerification } from "@twin.org/immutable-proof-models";
3
+ import type { IImmutableProofServiceConstructorOptions } from "./models/IImmutableProofServiceConstructorOptions";
4
4
  /**
5
5
  * Class for performing immutable proof operations.
6
6
  */
@@ -16,19 +16,8 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
16
16
  /**
17
17
  * Create a new instance of ImmutableProofService.
18
18
  * @param options The dependencies for the immutable proof connector.
19
- * @param options.config The configuration for the connector.
20
- * @param options.vaultConnectorType The vault connector type, defaults to "vault".
21
- * @param options.immutableProofEntityStorageType The entity storage for proofs, defaults to "immutable-proof".
22
- * @param options.immutableStorageType The immutable storage, defaults to "immutable-proof".
23
- * @param options.identityConnectorType The identity connector type, defaults to "identity".
24
19
  */
25
- constructor(options?: {
26
- vaultConnectorType?: string;
27
- immutableProofEntityStorageType?: string;
28
- immutableStorageType?: string;
29
- config?: IImmutableProofServiceConfig;
30
- identityConnectorType?: string;
31
- });
20
+ constructor(options?: IImmutableProofServiceConstructorOptions);
32
21
  /**
33
22
  * Create a new authentication proof.
34
23
  * @param proofObject The object for the proof as JSON-LD.
@@ -47,11 +36,10 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
47
36
  /**
48
37
  * Verify an authentication proof.
49
38
  * @param id The id of the proof to verify.
50
- * @param proofObject The object to verify as JSON-LD.
51
39
  * @returns The result of the verification and any failures.
52
40
  * @throws NotFoundError if the proof is not found.
53
41
  */
54
- verify(id: string, proofObject: IJsonLdNodeObject): Promise<IImmutableProofVerification>;
42
+ verify(id: string): Promise<IImmutableProofVerification>;
55
43
  /**
56
44
  * Remove the immutable storage for the proof.
57
45
  * @param id The id of the proof to remove the storage from.
@@ -1,6 +1,7 @@
1
+ export * from "./entities/immutableProof";
1
2
  export * from "./immutableProofRoutes";
2
3
  export * from "./immutableProofService";
3
- export * from "./entities/immutableProof";
4
4
  export * from "./models/IImmutableProofServiceConfig";
5
+ export * from "./models/IImmutableProofServiceConstructorOptions";
5
6
  export * from "./restEntryPoints";
6
7
  export * from "./schema";
@@ -3,13 +3,13 @@
3
3
  */
4
4
  export interface IImmutableProofServiceConfig {
5
5
  /**
6
- * The assertion method id to use for the stream.
7
- * @default immutable-proof
6
+ * The verification method id to use for the proof.
7
+ * @default immutable-proof-assertion
8
8
  */
9
- assertionMethodId?: string;
9
+ verificationMethodId?: string;
10
10
  /**
11
- * The key to use in the proof config.
12
- * @default immutable-proof
11
+ * The key to use in the proof hash.
12
+ * @default immutable-proof-hash
13
13
  */
14
- proofConfigKeyId?: string;
14
+ proofHashKeyId?: string;
15
15
  }
@@ -0,0 +1,39 @@
1
+ import type { IImmutableProofServiceConfig } from "./IImmutableProofServiceConfig";
2
+ /**
3
+ * Options for the immutable proof service constructor.
4
+ */
5
+ export interface IImmutableProofServiceConstructorOptions {
6
+ /**
7
+ * The vault connector type.
8
+ * @default vault
9
+ */
10
+ vaultConnectorType?: string;
11
+ /**
12
+ * The entity storage for proofs.
13
+ * @default immutable-proof
14
+ */
15
+ immutableProofEntityStorageType?: string;
16
+ /**
17
+ * The immutable storage.
18
+ * @default immutable-storage
19
+ */
20
+ immutableStorageType?: string;
21
+ /**
22
+ * The identity connector type.
23
+ * @default identity
24
+ */
25
+ identityConnectorType?: string;
26
+ /**
27
+ * The background task connector type.
28
+ * @default background-task
29
+ */
30
+ backgroundTaskConnectorType?: string;
31
+ /**
32
+ * The event bus component type, defaults to no event bus.
33
+ */
34
+ eventBusComponentType?: string;
35
+ /**
36
+ * The configuration for the connector.
37
+ */
38
+ config?: IImmutableProofServiceConfig;
39
+ }
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/immutable-proof-service - Changelog
2
2
 
3
- ## v0.0.1-next.2
3
+ ## v0.0.1-next.21
4
4
 
5
5
  - Initial Release