@twin.org/immutable-proof-service 0.0.1-next.11 → 0.0.1-next.12
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
CHANGED
|
@@ -177,13 +177,6 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
177
177
|
request: {
|
|
178
178
|
pathParams: {
|
|
179
179
|
id: "ais:1234567890"
|
|
180
|
-
},
|
|
181
|
-
body: {
|
|
182
|
-
proofObject: {
|
|
183
|
-
"@context": "http://schema.org",
|
|
184
|
-
type: "Person",
|
|
185
|
-
name: "John Smith"
|
|
186
|
-
}
|
|
187
180
|
}
|
|
188
181
|
}
|
|
189
182
|
}
|
|
@@ -279,10 +272,9 @@ async function immutableProofVerify(httpRequestContext, componentName, request)
|
|
|
279
272
|
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
280
273
|
core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
281
274
|
core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
282
|
-
core.Guards.object(ROUTES_SOURCE, "request.body.proofObject", request.body.proofObject);
|
|
283
275
|
const mimeType = request.headers?.[web.HeaderTypes.Accept] === web.MimeTypes.JsonLd ? "jsonld" : "json";
|
|
284
276
|
const component = core.ComponentFactory.get(componentName);
|
|
285
|
-
const result = await component.verify(request.pathParams.id
|
|
277
|
+
const result = await component.verify(request.pathParams.id);
|
|
286
278
|
return {
|
|
287
279
|
headers: {
|
|
288
280
|
[web.HeaderTypes.ContentType]: mimeType === "json" ? web.MimeTypes.Json : web.MimeTypes.JsonLd
|
|
@@ -434,7 +426,7 @@ class ImmutableProofService {
|
|
|
434
426
|
});
|
|
435
427
|
}
|
|
436
428
|
try {
|
|
437
|
-
const { immutableProof } = await this.internalGet(id);
|
|
429
|
+
const { immutableProof } = await this.internalGet(id, false);
|
|
438
430
|
const compacted = await dataJsonLd.JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
|
|
439
431
|
return compacted;
|
|
440
432
|
}
|
|
@@ -445,11 +437,10 @@ class ImmutableProofService {
|
|
|
445
437
|
/**
|
|
446
438
|
* Verify an authentication proof.
|
|
447
439
|
* @param id The id of the proof to verify.
|
|
448
|
-
* @param proofObject The object to verify as JSON-LD.
|
|
449
440
|
* @returns The result of the verification and any failures.
|
|
450
441
|
* @throws NotFoundError if the proof is not found.
|
|
451
442
|
*/
|
|
452
|
-
async verify(id
|
|
443
|
+
async verify(id) {
|
|
453
444
|
core.Guards.stringValue(this.CLASS_NAME, "id", id);
|
|
454
445
|
const urnParsed = core.Urn.fromValidString(id);
|
|
455
446
|
if (urnParsed.namespaceIdentifier() !== ImmutableProofService.NAMESPACE) {
|
|
@@ -459,7 +450,7 @@ class ImmutableProofService {
|
|
|
459
450
|
});
|
|
460
451
|
}
|
|
461
452
|
try {
|
|
462
|
-
const { verified, failure } = await this.internalGet(id,
|
|
453
|
+
const { verified, failure } = await this.internalGet(id, true);
|
|
463
454
|
return {
|
|
464
455
|
"@context": immutableProofModels.ImmutableProofTypes.ContextRoot,
|
|
465
456
|
type: immutableProofModels.ImmutableProofTypes.ImmutableProofVerification,
|
|
@@ -565,12 +556,12 @@ class ImmutableProofService {
|
|
|
565
556
|
/**
|
|
566
557
|
* Verify an authentication proof.
|
|
567
558
|
* @param id The id of the proof to verify.
|
|
568
|
-
* @param
|
|
559
|
+
* @param verify Validate the proof.
|
|
569
560
|
* @returns The result of the verification and any failures.
|
|
570
561
|
* @throws NotFoundError if the proof is not found.
|
|
571
562
|
* @internal
|
|
572
563
|
*/
|
|
573
|
-
async internalGet(id,
|
|
564
|
+
async internalGet(id, verify) {
|
|
574
565
|
const urnParsed = core.Urn.fromValidString(id);
|
|
575
566
|
const proofId = urnParsed.namespaceSpecific(0);
|
|
576
567
|
const proofEntity = await this._proofStorage.get(proofId);
|
|
@@ -590,7 +581,7 @@ class ImmutableProofService {
|
|
|
590
581
|
if (core.Is.array(proofModel["@context"])) {
|
|
591
582
|
proofModel["@context"].push(immutableStorageModels.ImmutableStorageTypes.ContextRoot);
|
|
592
583
|
}
|
|
593
|
-
if (core.Is.object(proofModel.proof)
|
|
584
|
+
if (verify && core.Is.object(proofModel.proof)) {
|
|
594
585
|
if (proofModel.proof.cryptosuite !== standardsW3cDid.DidCryptoSuites.EdDSAJcs2022) {
|
|
595
586
|
failure = immutableProofModels.ImmutableProofFailure.CryptoSuiteMismatch;
|
|
596
587
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -175,13 +175,6 @@ function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
|
175
175
|
request: {
|
|
176
176
|
pathParams: {
|
|
177
177
|
id: "ais:1234567890"
|
|
178
|
-
},
|
|
179
|
-
body: {
|
|
180
|
-
proofObject: {
|
|
181
|
-
"@context": "http://schema.org",
|
|
182
|
-
type: "Person",
|
|
183
|
-
name: "John Smith"
|
|
184
|
-
}
|
|
185
178
|
}
|
|
186
179
|
}
|
|
187
180
|
}
|
|
@@ -277,10 +270,9 @@ async function immutableProofVerify(httpRequestContext, componentName, request)
|
|
|
277
270
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
278
271
|
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
279
272
|
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
280
|
-
Guards.object(ROUTES_SOURCE, "request.body.proofObject", request.body.proofObject);
|
|
281
273
|
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
282
274
|
const component = ComponentFactory.get(componentName);
|
|
283
|
-
const result = await component.verify(request.pathParams.id
|
|
275
|
+
const result = await component.verify(request.pathParams.id);
|
|
284
276
|
return {
|
|
285
277
|
headers: {
|
|
286
278
|
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
@@ -432,7 +424,7 @@ class ImmutableProofService {
|
|
|
432
424
|
});
|
|
433
425
|
}
|
|
434
426
|
try {
|
|
435
|
-
const { immutableProof } = await this.internalGet(id);
|
|
427
|
+
const { immutableProof } = await this.internalGet(id, false);
|
|
436
428
|
const compacted = await JsonLdProcessor.compact(immutableProof, immutableProof["@context"]);
|
|
437
429
|
return compacted;
|
|
438
430
|
}
|
|
@@ -443,11 +435,10 @@ class ImmutableProofService {
|
|
|
443
435
|
/**
|
|
444
436
|
* Verify an authentication proof.
|
|
445
437
|
* @param id The id of the proof to verify.
|
|
446
|
-
* @param proofObject The object to verify as JSON-LD.
|
|
447
438
|
* @returns The result of the verification and any failures.
|
|
448
439
|
* @throws NotFoundError if the proof is not found.
|
|
449
440
|
*/
|
|
450
|
-
async verify(id
|
|
441
|
+
async verify(id) {
|
|
451
442
|
Guards.stringValue(this.CLASS_NAME, "id", id);
|
|
452
443
|
const urnParsed = Urn.fromValidString(id);
|
|
453
444
|
if (urnParsed.namespaceIdentifier() !== ImmutableProofService.NAMESPACE) {
|
|
@@ -457,7 +448,7 @@ class ImmutableProofService {
|
|
|
457
448
|
});
|
|
458
449
|
}
|
|
459
450
|
try {
|
|
460
|
-
const { verified, failure } = await this.internalGet(id,
|
|
451
|
+
const { verified, failure } = await this.internalGet(id, true);
|
|
461
452
|
return {
|
|
462
453
|
"@context": ImmutableProofTypes.ContextRoot,
|
|
463
454
|
type: ImmutableProofTypes.ImmutableProofVerification,
|
|
@@ -563,12 +554,12 @@ class ImmutableProofService {
|
|
|
563
554
|
/**
|
|
564
555
|
* Verify an authentication proof.
|
|
565
556
|
* @param id The id of the proof to verify.
|
|
566
|
-
* @param
|
|
557
|
+
* @param verify Validate the proof.
|
|
567
558
|
* @returns The result of the verification and any failures.
|
|
568
559
|
* @throws NotFoundError if the proof is not found.
|
|
569
560
|
* @internal
|
|
570
561
|
*/
|
|
571
|
-
async internalGet(id,
|
|
562
|
+
async internalGet(id, verify) {
|
|
572
563
|
const urnParsed = Urn.fromValidString(id);
|
|
573
564
|
const proofId = urnParsed.namespaceSpecific(0);
|
|
574
565
|
const proofEntity = await this._proofStorage.get(proofId);
|
|
@@ -588,7 +579,7 @@ class ImmutableProofService {
|
|
|
588
579
|
if (Is.array(proofModel["@context"])) {
|
|
589
580
|
proofModel["@context"].push(ImmutableStorageTypes.ContextRoot);
|
|
590
581
|
}
|
|
591
|
-
if (Is.object(proofModel.proof)
|
|
582
|
+
if (verify && Is.object(proofModel.proof)) {
|
|
592
583
|
if (proofModel.proof.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {
|
|
593
584
|
failure = ImmutableProofFailure.CryptoSuiteMismatch;
|
|
594
585
|
}
|
|
@@ -49,11 +49,10 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
|
|
|
49
49
|
/**
|
|
50
50
|
* Verify an authentication proof.
|
|
51
51
|
* @param id The id of the proof to verify.
|
|
52
|
-
* @param proofObject The object to verify as JSON-LD.
|
|
53
52
|
* @returns The result of the verification and any failures.
|
|
54
53
|
* @throws NotFoundError if the proof is not found.
|
|
55
54
|
*/
|
|
56
|
-
verify(id: string
|
|
55
|
+
verify(id: string): Promise<IImmutableProofVerification>;
|
|
57
56
|
/**
|
|
58
57
|
* Remove the immutable storage for the proof.
|
|
59
58
|
* @param id The id of the proof to remove the storage from.
|
package/docs/changelog.md
CHANGED
package/docs/open-api/spec.json
CHANGED
|
@@ -360,28 +360,6 @@
|
|
|
360
360
|
"jwtBearerAuthScheme": []
|
|
361
361
|
}
|
|
362
362
|
],
|
|
363
|
-
"requestBody": {
|
|
364
|
-
"description": "Verify a proof.",
|
|
365
|
-
"required": true,
|
|
366
|
-
"content": {
|
|
367
|
-
"application/json": {
|
|
368
|
-
"schema": {
|
|
369
|
-
"$ref": "#/components/schemas/ImmutableProofVerifyRequest"
|
|
370
|
-
},
|
|
371
|
-
"examples": {
|
|
372
|
-
"immutableProofVerifyRequestExample": {
|
|
373
|
-
"value": {
|
|
374
|
-
"proofObject": {
|
|
375
|
-
"@context": "http://schema.org",
|
|
376
|
-
"type": "Person",
|
|
377
|
-
"name": "John Smith"
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
363
|
"responses": {
|
|
386
364
|
"200": {
|
|
387
365
|
"description": "Response to verifying an immutable proof.",
|
|
@@ -669,19 +647,6 @@
|
|
|
669
647
|
"additionalProperties": false,
|
|
670
648
|
"description": "The parameters from the body."
|
|
671
649
|
},
|
|
672
|
-
"ImmutableProofVerifyRequest": {
|
|
673
|
-
"type": "object",
|
|
674
|
-
"properties": {
|
|
675
|
-
"proofObject": {
|
|
676
|
-
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodeObject"
|
|
677
|
-
}
|
|
678
|
-
},
|
|
679
|
-
"required": [
|
|
680
|
-
"proofObject"
|
|
681
|
-
],
|
|
682
|
-
"additionalProperties": false,
|
|
683
|
-
"description": "The parameters from the body."
|
|
684
|
-
},
|
|
685
650
|
"NotFoundResponse": {
|
|
686
651
|
"type": "object",
|
|
687
652
|
"additionalProperties": false,
|
|
@@ -132,7 +132,7 @@ NotFoundError if the proof is not found.
|
|
|
132
132
|
|
|
133
133
|
### verify()
|
|
134
134
|
|
|
135
|
-
> **verify**(`id
|
|
135
|
+
> **verify**(`id`): `Promise`\<`IImmutableProofVerification`\>
|
|
136
136
|
|
|
137
137
|
Verify an authentication proof.
|
|
138
138
|
|
|
@@ -142,10 +142,6 @@ Verify an authentication proof.
|
|
|
142
142
|
|
|
143
143
|
The id of the proof to verify.
|
|
144
144
|
|
|
145
|
-
• **proofObject**: `IJsonLdNodeObject`
|
|
146
|
-
|
|
147
|
-
The object to verify as JSON-LD.
|
|
148
|
-
|
|
149
145
|
#### Returns
|
|
150
146
|
|
|
151
147
|
`Promise`\<`IImmutableProofVerification`\>
|
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.12",
|
|
4
4
|
"description": "Immutable proof contract implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@twin.org/entity": "next",
|
|
24
24
|
"@twin.org/entity-storage-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.
|
|
26
|
+
"@twin.org/immutable-proof-models": "0.0.1-next.12",
|
|
27
|
+
"@twin.org/immutable-proof-task": "0.0.1-next.12",
|
|
28
28
|
"@twin.org/immutable-storage-models": "next",
|
|
29
29
|
"@twin.org/nameof": "next",
|
|
30
30
|
"@twin.org/standards-w3c-did": "next",
|