@twin.org/immutable-proof-service 0.0.1-next.1 → 0.0.1-next.3

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.
@@ -197,6 +197,8 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
197
197
  id: "immutableProofVerifyResponseExample",
198
198
  response: {
199
199
  body: {
200
+ "@context": immutableProofModels.ImmutableProofTypes.ContextRoot,
201
+ type: immutableProofModels.ImmutableProofTypes.ImmutableProofVerification,
200
202
  verified: true
201
203
  }
202
204
  }
@@ -210,6 +212,8 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
210
212
  id: "immutableProofVerifyResponseFailExample",
211
213
  response: {
212
214
  body: {
215
+ "@context": immutableProofModels.ImmutableProofTypes.ContextRoot,
216
+ type: immutableProofModels.ImmutableProofTypes.ImmutableProofVerification,
213
217
  verified: false,
214
218
  failure: immutableProofModels.ImmutableProofFailure.ProofTypeMismatch
215
219
  }
@@ -276,9 +280,13 @@ async function immutableProofVerify(httpRequestContext, componentName, request)
276
280
  core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
277
281
  core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
278
282
  core.Guards.object(ROUTES_SOURCE, "request.body.proofObject", request.body.proofObject);
283
+ const mimeType = request.headers?.[web.HeaderTypes.Accept] === web.MimeTypes.JsonLd ? "jsonld" : "json";
279
284
  const component = core.ComponentFactory.get(componentName);
280
285
  const result = await component.verify(request.pathParams.id, request.body.proofObject);
281
286
  return {
287
+ headers: {
288
+ [web.HeaderTypes.ContentType]: mimeType === "json" ? web.MimeTypes.Json : web.MimeTypes.JsonLd
289
+ },
282
290
  body: result
283
291
  };
284
292
  }
@@ -343,13 +351,13 @@ class ImmutableProofService {
343
351
  * @param options.config The configuration for the connector.
344
352
  * @param options.vaultConnectorType The vault connector type, defaults to "vault".
345
353
  * @param options.immutableProofEntityStorageType The entity storage for proofs, defaults to "immutable-proof".
346
- * @param options.immutableStorageType The immutable storage, defaults to "immutable-proof".
354
+ * @param options.immutableStorageType The immutable storage, defaults to "immutable-storage".
347
355
  * @param options.identityConnectorType The identity connector type, defaults to "identity".
348
356
  */
349
357
  constructor(options) {
350
358
  this._vaultConnector = vaultModels.VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
351
359
  this._proofStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.immutableProofEntityStorageType ?? core.StringHelper.kebabCase("ImmutableProof"));
352
- this._immutableStorage = immutableStorageModels.ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-proof");
360
+ this._immutableStorage = immutableStorageModels.ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
353
361
  this._identityConnector = identityModels.IdentityConnectorFactory.get(options?.identityConnectorType ?? "identity");
354
362
  this._config = options?.config ?? {};
355
363
  this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof";
@@ -435,6 +443,8 @@ class ImmutableProofService {
435
443
  try {
436
444
  const { verified, failure } = await this.internalGet(id, proofObject);
437
445
  return {
446
+ "@context": immutableProofModels.ImmutableProofTypes.ContextRoot,
447
+ type: immutableProofModels.ImmutableProofTypes.ImmutableProofVerification,
438
448
  verified,
439
449
  failure
440
450
  };
@@ -195,6 +195,8 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
195
195
  id: "immutableProofVerifyResponseExample",
196
196
  response: {
197
197
  body: {
198
+ "@context": ImmutableProofTypes.ContextRoot,
199
+ type: ImmutableProofTypes.ImmutableProofVerification,
198
200
  verified: true
199
201
  }
200
202
  }
@@ -208,6 +210,8 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
208
210
  id: "immutableProofVerifyResponseFailExample",
209
211
  response: {
210
212
  body: {
213
+ "@context": ImmutableProofTypes.ContextRoot,
214
+ type: ImmutableProofTypes.ImmutableProofVerification,
211
215
  verified: false,
212
216
  failure: ImmutableProofFailure.ProofTypeMismatch
213
217
  }
@@ -274,9 +278,13 @@ async function immutableProofVerify(httpRequestContext, componentName, request)
274
278
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
275
279
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
276
280
  Guards.object(ROUTES_SOURCE, "request.body.proofObject", request.body.proofObject);
281
+ const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
277
282
  const component = ComponentFactory.get(componentName);
278
283
  const result = await component.verify(request.pathParams.id, request.body.proofObject);
279
284
  return {
285
+ headers: {
286
+ [HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
287
+ },
280
288
  body: result
281
289
  };
282
290
  }
@@ -341,13 +349,13 @@ class ImmutableProofService {
341
349
  * @param options.config The configuration for the connector.
342
350
  * @param options.vaultConnectorType The vault connector type, defaults to "vault".
343
351
  * @param options.immutableProofEntityStorageType The entity storage for proofs, defaults to "immutable-proof".
344
- * @param options.immutableStorageType The immutable storage, defaults to "immutable-proof".
352
+ * @param options.immutableStorageType The immutable storage, defaults to "immutable-storage".
345
353
  * @param options.identityConnectorType The identity connector type, defaults to "identity".
346
354
  */
347
355
  constructor(options) {
348
356
  this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
349
357
  this._proofStorage = EntityStorageConnectorFactory.get(options?.immutableProofEntityStorageType ?? StringHelper.kebabCase("ImmutableProof"));
350
- this._immutableStorage = ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-proof");
358
+ this._immutableStorage = ImmutableStorageConnectorFactory.get(options?.immutableStorageType ?? "immutable-storage");
351
359
  this._identityConnector = IdentityConnectorFactory.get(options?.identityConnectorType ?? "identity");
352
360
  this._config = options?.config ?? {};
353
361
  this._assertionMethodId = this._config.assertionMethodId ?? "immutable-proof";
@@ -433,6 +441,8 @@ class ImmutableProofService {
433
441
  try {
434
442
  const { verified, failure } = await this.internalGet(id, proofObject);
435
443
  return {
444
+ "@context": ImmutableProofTypes.ContextRoot,
445
+ type: ImmutableProofTypes.ImmutableProofVerification,
436
446
  verified,
437
447
  failure
438
448
  };
@@ -1,5 +1,5 @@
1
1
  import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
- import { ImmutableProofFailure, type IImmutableProof, type IImmutableProofComponent } from "@twin.org/immutable-proof-models";
2
+ import { type IImmutableProofVerification, type IImmutableProof, type IImmutableProofComponent } from "@twin.org/immutable-proof-models";
3
3
  import type { IImmutableProofServiceConfig } from "./models/IImmutableProofServiceConfig";
4
4
  /**
5
5
  * Class for performing immutable proof operations.
@@ -19,7 +19,7 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
19
19
  * @param options.config The configuration for the connector.
20
20
  * @param options.vaultConnectorType The vault connector type, defaults to "vault".
21
21
  * @param options.immutableProofEntityStorageType The entity storage for proofs, defaults to "immutable-proof".
22
- * @param options.immutableStorageType The immutable storage, defaults to "immutable-proof".
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
  */
25
25
  constructor(options?: {
@@ -51,10 +51,7 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
51
51
  * @returns The result of the verification and any failures.
52
52
  * @throws NotFoundError if the proof is not found.
53
53
  */
54
- verify(id: string, proofObject: IJsonLdNodeObject): Promise<{
55
- verified: boolean;
56
- failure?: ImmutableProofFailure;
57
- }>;
54
+ verify(id: string, proofObject: IJsonLdNodeObject): Promise<IImmutableProofVerification>;
58
55
  /**
59
56
  * Remove the immutable storage for the proof.
60
57
  * @param id The id of the proof to remove the storage from.
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/immutable-proof-service - Changelog
2
2
 
3
- ## v0.0.1-next.1
3
+ ## v0.0.1-next.3
4
4
 
5
5
  - Initial Release
@@ -189,7 +189,7 @@
189
189
  "content": {
190
190
  "application/json": {
191
191
  "schema": {
192
- "$ref": "#/components/schemas/ImmutableProof"
192
+ "$ref": "https://schema.twindev.org/immutable-proof/ImmutableProof"
193
193
  },
194
194
  "examples": {
195
195
  "immutableProofGetResponseExample": {
@@ -214,7 +214,7 @@
214
214
  },
215
215
  "application/ld+json": {
216
216
  "schema": {
217
- "$ref": "#/components/schemas/ImmutableProof"
217
+ "$ref": "https://schema.twindev.org/immutable-proof/ImmutableProof"
218
218
  },
219
219
  "examples": {
220
220
  "immutableProofJsonLdGetResponseExample": {
@@ -344,6 +344,15 @@
344
344
  },
345
345
  "style": "simple",
346
346
  "example": "ais:1234567890"
347
+ },
348
+ {
349
+ "name": "accept",
350
+ "in": "header",
351
+ "required": true,
352
+ "schema": {
353
+ "type": "string"
354
+ },
355
+ "style": "simple"
347
356
  }
348
357
  ],
349
358
  "security": [
@@ -379,16 +388,20 @@
379
388
  "content": {
380
389
  "application/json": {
381
390
  "schema": {
382
- "$ref": "#/components/schemas/ImmutableProofVerifyResponse"
391
+ "$ref": "https://schema.twindev.org/immutable-proof/ImmutableProofVerification"
383
392
  },
384
393
  "examples": {
385
394
  "immutableProofVerifyResponseExample": {
386
395
  "value": {
396
+ "@context": "https://schema.twindev.org/immutable-proof/",
397
+ "type": "ImmutableProofVerification",
387
398
  "verified": true
388
399
  }
389
400
  },
390
401
  "immutableProofVerifyResponseFailExample": {
391
402
  "value": {
403
+ "@context": "https://schema.twindev.org/immutable-proof/",
404
+ "type": "ImmutableProofVerification",
392
405
  "verified": false,
393
406
  "failure": "proofTypeMismatch"
394
407
  }
@@ -643,66 +656,6 @@
643
656
  "additionalProperties": false,
644
657
  "description": "Model to describe serialized error."
645
658
  },
646
- "ImmutableProof": {
647
- "type": "object",
648
- "properties": {
649
- "@context": {
650
- "anyOf": [
651
- {
652
- "type": "string",
653
- "const": "https://schema.twindev.org/immutable-proof/"
654
- },
655
- {
656
- "type": "array",
657
- "minItems": 1,
658
- "items": [
659
- {
660
- "type": "string",
661
- "const": "https://schema.twindev.org/immutable-proof/"
662
- }
663
- ],
664
- "additionalItems": {
665
- "type": "string"
666
- }
667
- }
668
- ],
669
- "description": "JSON-LD Context."
670
- },
671
- "type": {
672
- "type": "string",
673
- "const": "ImmutableProof",
674
- "description": "JSON-LD Type."
675
- },
676
- "id": {
677
- "type": "string",
678
- "description": "The id of the proof."
679
- },
680
- "userIdentity": {
681
- "type": "string",
682
- "description": "The id of the user who created the proof."
683
- },
684
- "proofObjectId": {
685
- "type": "string",
686
- "description": "The id of the object associated with the proof."
687
- },
688
- "proofObjectHash": {
689
- "type": "string",
690
- "description": "The hash of the object associated with the proof."
691
- },
692
- "proof": {
693
- "$ref": "#/components/schemas/DidProof"
694
- }
695
- },
696
- "required": [
697
- "@context",
698
- "type",
699
- "id",
700
- "userIdentity",
701
- "proofObjectHash"
702
- ],
703
- "additionalProperties": false,
704
- "description": "Interface describing an immutable proof state."
705
- },
706
659
  "ImmutableProofCreateRequest": {
707
660
  "type": "object",
708
661
  "properties": {
@@ -716,36 +669,6 @@
716
669
  "additionalProperties": false,
717
670
  "description": "The parameters from the body."
718
671
  },
719
- "ImmutableProofFailure": {
720
- "anyOf": [
721
- {
722
- "type": "string",
723
- "const": "notIssued",
724
- "description": "Proof not yes issued."
725
- },
726
- {
727
- "type": "string",
728
- "const": "proofMissing",
729
- "description": "Proof missing."
730
- },
731
- {
732
- "type": "string",
733
- "const": "cryptoSuiteMismatch",
734
- "description": "Crypto suite mismatch."
735
- },
736
- {
737
- "type": "string",
738
- "const": "proofTypeMismatch",
739
- "description": "Proof type."
740
- },
741
- {
742
- "type": "string",
743
- "const": "signatureMismatch",
744
- "description": "Signature mismatch."
745
- }
746
- ],
747
- "description": "The failure reason of the proof."
748
- },
749
672
  "ImmutableProofVerifyRequest": {
750
673
  "type": "object",
751
674
  "properties": {
@@ -759,23 +682,6 @@
759
682
  "additionalProperties": false,
760
683
  "description": "The parameters from the body."
761
684
  },
762
- "ImmutableProofVerifyResponse": {
763
- "type": "object",
764
- "properties": {
765
- "verified": {
766
- "type": "boolean",
767
- "description": "Was the proof verified."
768
- },
769
- "failure": {
770
- "$ref": "#/components/schemas/ImmutableProofFailure"
771
- }
772
- },
773
- "required": [
774
- "verified"
775
- ],
776
- "additionalProperties": false,
777
- "description": "The response body."
778
- },
779
685
  "NotFoundResponse": {
780
686
  "type": "object",
781
687
  "additionalProperties": false,
@@ -30,7 +30,7 @@ The entity storage for proofs, defaults to "immutable-proof".
30
30
 
31
31
  • **options.immutableStorageType?**: `string`
32
32
 
33
- The immutable storage, defaults to "immutable-proof".
33
+ The immutable storage, defaults to "immutable-storage".
34
34
 
35
35
  • **options.config?**: [`IImmutableProofServiceConfig`](../interfaces/IImmutableProofServiceConfig.md)
36
36
 
@@ -128,7 +128,7 @@ NotFoundError if the proof is not found.
128
128
 
129
129
  ### verify()
130
130
 
131
- > **verify**(`id`, `proofObject`): `Promise`\<`object`\>
131
+ > **verify**(`id`, `proofObject`): `Promise`\<`IImmutableProofVerification`\>
132
132
 
133
133
  Verify an authentication proof.
134
134
 
@@ -144,18 +144,10 @@ The object to verify as JSON-LD.
144
144
 
145
145
  #### Returns
146
146
 
147
- `Promise`\<`object`\>
147
+ `Promise`\<`IImmutableProofVerification`\>
148
148
 
149
149
  The result of the verification and any failures.
150
150
 
151
- ##### verified
152
-
153
- > **verified**: `boolean`
154
-
155
- ##### failure?
156
-
157
- > `optional` **failure**: `ImmutableProofFailure`
158
-
159
151
  #### Throws
160
152
 
161
153
  NotFoundError if the proof is not found.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/immutable-proof-service",
3
- "version": "0.0.1-next.1",
3
+ "version": "0.0.1-next.3",
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.1",
25
+ "@twin.org/immutable-proof-models": "0.0.1-next.3",
26
26
  "@twin.org/immutable-storage-models": "next",
27
27
  "@twin.org/nameof": "next",
28
28
  "@twin.org/standards-w3c-did": "next",