@twin.org/immutable-proof-service 0.0.2-next.2 → 0.0.3-next.1
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/es/entities/immutableProof.js +53 -0
- package/dist/es/entities/immutableProof.js.map +1 -0
- package/dist/es/immutableProofRoutes.js +278 -0
- package/dist/es/immutableProofRoutes.js.map +1 -0
- package/dist/es/immutableProofService.js +335 -0
- package/dist/es/immutableProofService.js.map +1 -0
- package/dist/es/index.js +10 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IImmutableProofServiceConfig.js +4 -0
- package/dist/es/models/IImmutableProofServiceConfig.js.map +1 -0
- package/dist/es/models/IImmutableProofServiceConstructorOptions.js +2 -0
- package/dist/es/models/IImmutableProofServiceConstructorOptions.js.map +1 -0
- package/dist/es/restEntryPoints.js +10 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/es/schema.js +11 -0
- package/dist/es/schema.js.map +1 -0
- package/dist/types/entities/immutableProof.d.ts +0 -8
- package/dist/types/immutableProofService.d.ts +15 -7
- package/dist/types/index.d.ts +7 -7
- package/dist/types/models/IImmutableProofServiceConstructorOptions.d.ts +1 -1
- package/docs/changelog.md +42 -0
- package/docs/open-api/spec.json +22 -32
- package/docs/reference/classes/ImmutableProof.md +0 -16
- package/docs/reference/classes/ImmutableProofService.md +44 -22
- package/package.json +24 -10
- package/dist/cjs/index.cjs +0 -701
- package/dist/esm/index.mjs +0 -692
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { entity, property, SortDirection } from "@twin.org/entity";
|
|
4
|
+
/**
|
|
5
|
+
* Class describing the immutable proof.
|
|
6
|
+
*/
|
|
7
|
+
let ImmutableProof = class ImmutableProof {
|
|
8
|
+
/**
|
|
9
|
+
* The id of the proof.
|
|
10
|
+
*/
|
|
11
|
+
id;
|
|
12
|
+
/**
|
|
13
|
+
* The date/time of when the proof was created.
|
|
14
|
+
*/
|
|
15
|
+
dateCreated;
|
|
16
|
+
/**
|
|
17
|
+
* The associated id for the item.
|
|
18
|
+
*/
|
|
19
|
+
proofObjectId;
|
|
20
|
+
/**
|
|
21
|
+
* The associated hash for the item.
|
|
22
|
+
*/
|
|
23
|
+
proofObjectHash;
|
|
24
|
+
/**
|
|
25
|
+
* The verifiable storage id.
|
|
26
|
+
*/
|
|
27
|
+
verifiableStorageId;
|
|
28
|
+
};
|
|
29
|
+
__decorate([
|
|
30
|
+
property({ type: "string", isPrimary: true }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], ImmutableProof.prototype, "id", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
property({ type: "string", format: "date-time", sortDirection: SortDirection.Descending }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], ImmutableProof.prototype, "dateCreated", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
property({ type: "string", optional: true }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], ImmutableProof.prototype, "proofObjectId", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
property({ type: "string" }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], ImmutableProof.prototype, "proofObjectHash", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
property({ type: "string", optional: true }),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], ImmutableProof.prototype, "verifiableStorageId", void 0);
|
|
49
|
+
ImmutableProof = __decorate([
|
|
50
|
+
entity()
|
|
51
|
+
], ImmutableProof);
|
|
52
|
+
export { ImmutableProof };
|
|
53
|
+
//# sourceMappingURL=immutableProof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"immutableProof.js","sourceRoot":"","sources":["../../../src/entities/immutableProof.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAC1B;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,WAAW,CAAU;IAE5B;;OAEG;IAEI,aAAa,CAAU;IAE9B;;OAEG;IAEI,eAAe,CAAU;IAEhC;;OAEG;IAEI,mBAAmB,CAAU;CACpC,CAAA;AAzBO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;0CAC3B;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC;;mDAC/D;AAMrB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACf;AAMvB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;uDACG;AAMzB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2DACT;AA7BxB,cAAc;IAD1B,MAAM,EAAE;GACI,cAAc,CA8B1B","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property, SortDirection } from \"@twin.org/entity\";\n\n/**\n * Class describing the immutable proof.\n */\n@entity()\nexport class ImmutableProof {\n\t/**\n\t * The id of the proof.\n\t */\n\t@property({ type: \"string\", isPrimary: true })\n\tpublic id!: string;\n\n\t/**\n\t * The date/time of when the proof was created.\n\t */\n\t@property({ type: \"string\", format: \"date-time\", sortDirection: SortDirection.Descending })\n\tpublic dateCreated!: string;\n\n\t/**\n\t * The associated id for the item.\n\t */\n\t@property({ type: \"string\", optional: true })\n\tpublic proofObjectId?: string;\n\n\t/**\n\t * The associated hash for the item.\n\t */\n\t@property({ type: \"string\" })\n\tpublic proofObjectHash!: string;\n\n\t/**\n\t * The verifiable storage id.\n\t */\n\t@property({ type: \"string\", optional: true })\n\tpublic verifiableStorageId?: string;\n}\n"]}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { ComponentFactory, Guards } from "@twin.org/core";
|
|
2
|
+
import { ImmutableProofContexts, ImmutableProofFailure, ImmutableProofTypes } from "@twin.org/immutable-proof-models";
|
|
3
|
+
import { DidContexts, DidCryptoSuites, ProofTypes } from "@twin.org/standards-w3c-did";
|
|
4
|
+
import { HeaderTypes, HttpStatusCode, MimeTypes } from "@twin.org/web";
|
|
5
|
+
/**
|
|
6
|
+
* The source used when communicating about these routes.
|
|
7
|
+
*/
|
|
8
|
+
const ROUTES_SOURCE = "immutableProofRoutes";
|
|
9
|
+
/**
|
|
10
|
+
* The tag to associate with the routes.
|
|
11
|
+
*/
|
|
12
|
+
export const tagsImmutableProof = [
|
|
13
|
+
{
|
|
14
|
+
name: "Immutable Proof",
|
|
15
|
+
description: "Endpoints which are modelled to access an immutable proof contract."
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* The REST routes for immutable proof.
|
|
20
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
21
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
22
|
+
* @returns The generated routes.
|
|
23
|
+
*/
|
|
24
|
+
export function generateRestRoutesImmutableProof(baseRouteName, componentName) {
|
|
25
|
+
const createRoute = {
|
|
26
|
+
operationId: "immutableProofCreate",
|
|
27
|
+
summary: "Create a proof",
|
|
28
|
+
tag: tagsImmutableProof[0].name,
|
|
29
|
+
method: "POST",
|
|
30
|
+
path: `${baseRouteName}/`,
|
|
31
|
+
handler: async (httpRequestContext, request) => immutableProofCreate(httpRequestContext, componentName, request),
|
|
32
|
+
requestType: {
|
|
33
|
+
type: "IImmutableProofCreateRequest",
|
|
34
|
+
examples: [
|
|
35
|
+
{
|
|
36
|
+
id: "immutableProofCreateRequestExample",
|
|
37
|
+
request: {
|
|
38
|
+
body: {
|
|
39
|
+
document: {
|
|
40
|
+
"@context": "https://schema.org",
|
|
41
|
+
type: "Person",
|
|
42
|
+
name: "John Smith"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
responseType: [
|
|
50
|
+
{
|
|
51
|
+
type: "ICreatedResponse",
|
|
52
|
+
examples: [
|
|
53
|
+
{
|
|
54
|
+
id: "immutableProofCreateResponseExample",
|
|
55
|
+
response: {
|
|
56
|
+
statusCode: HttpStatusCode.created,
|
|
57
|
+
headers: {
|
|
58
|
+
[HeaderTypes.Location]: "test:1234567890"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: "INotFoundResponse"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
const getRoute = {
|
|
70
|
+
operationId: "immutableProofGet",
|
|
71
|
+
summary: "Get a proof",
|
|
72
|
+
tag: tagsImmutableProof[0].name,
|
|
73
|
+
method: "GET",
|
|
74
|
+
path: `${baseRouteName}/:id`,
|
|
75
|
+
handler: async (httpRequestContext, request) => immutableProofGet(httpRequestContext, componentName, request),
|
|
76
|
+
requestType: {
|
|
77
|
+
type: "IImmutableProofGetRequest",
|
|
78
|
+
examples: [
|
|
79
|
+
{
|
|
80
|
+
id: "immutableProofGetRequestExample",
|
|
81
|
+
request: {
|
|
82
|
+
headers: {
|
|
83
|
+
[HeaderTypes.Accept]: MimeTypes.Json
|
|
84
|
+
},
|
|
85
|
+
pathParams: {
|
|
86
|
+
id: "ais:1234567890"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
responseType: [
|
|
93
|
+
{
|
|
94
|
+
type: "IImmutableProofGetResponse",
|
|
95
|
+
examples: [
|
|
96
|
+
{
|
|
97
|
+
id: "immutableProofGetResponseExample",
|
|
98
|
+
response: {
|
|
99
|
+
body: {
|
|
100
|
+
"@context": [
|
|
101
|
+
ImmutableProofContexts.ContextRoot,
|
|
102
|
+
ImmutableProofContexts.ContextRootCommon
|
|
103
|
+
],
|
|
104
|
+
type: ImmutableProofTypes.ImmutableProof,
|
|
105
|
+
id: "ais:1234567890",
|
|
106
|
+
proofObjectId: "test:1234567890",
|
|
107
|
+
proofObjectHash: "EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=",
|
|
108
|
+
proof: {
|
|
109
|
+
"@context": DidContexts.ContextDataIntegrity,
|
|
110
|
+
type: ProofTypes.DataIntegrityProof,
|
|
111
|
+
cryptosuite: DidCryptoSuites.EdDSAJcs2022,
|
|
112
|
+
created: "2024-08-22T11:56:56.272Z",
|
|
113
|
+
proofPurpose: "assertionMethod",
|
|
114
|
+
proofValue: "7DdiPPYtxLjCD3wA1po2rv..."
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "IImmutableProofGetResponse",
|
|
123
|
+
mimeType: MimeTypes.JsonLd,
|
|
124
|
+
examples: [
|
|
125
|
+
{
|
|
126
|
+
id: "immutableProofJsonLdGetResponseExample",
|
|
127
|
+
response: {
|
|
128
|
+
headers: {
|
|
129
|
+
[HeaderTypes.ContentType]: MimeTypes.JsonLd
|
|
130
|
+
},
|
|
131
|
+
body: {
|
|
132
|
+
"@context": [
|
|
133
|
+
ImmutableProofContexts.ContextRoot,
|
|
134
|
+
ImmutableProofContexts.ContextRootCommon
|
|
135
|
+
],
|
|
136
|
+
type: ImmutableProofTypes.ImmutableProof,
|
|
137
|
+
id: "ais:1234567890",
|
|
138
|
+
proofObjectId: "test:1234567890",
|
|
139
|
+
proofObjectHash: "EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=",
|
|
140
|
+
proof: {
|
|
141
|
+
"@context": DidContexts.ContextDataIntegrity,
|
|
142
|
+
type: ProofTypes.DataIntegrityProof,
|
|
143
|
+
cryptosuite: DidCryptoSuites.EdDSAJcs2022,
|
|
144
|
+
created: "2024-08-22T11:56:56.272Z",
|
|
145
|
+
proofPurpose: "assertionMethod",
|
|
146
|
+
proofValue: "7DdiPPYtxLjCD3wA1po2rv..."
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
type: "INotFoundResponse"
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
};
|
|
158
|
+
const verifyRoute = {
|
|
159
|
+
operationId: "immutableProofVerify",
|
|
160
|
+
summary: "Verify a proof",
|
|
161
|
+
tag: tagsImmutableProof[0].name,
|
|
162
|
+
method: "GET",
|
|
163
|
+
path: `${baseRouteName}/:id/verify`,
|
|
164
|
+
handler: async (httpRequestContext, request) => immutableProofVerify(httpRequestContext, componentName, request),
|
|
165
|
+
requestType: {
|
|
166
|
+
type: "IImmutableProofVerifyRequest",
|
|
167
|
+
examples: [
|
|
168
|
+
{
|
|
169
|
+
id: "immutableProofVerifyRequestExample",
|
|
170
|
+
request: {
|
|
171
|
+
pathParams: {
|
|
172
|
+
id: "ais:1234567890"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
responseType: [
|
|
179
|
+
{
|
|
180
|
+
type: "IImmutableProofVerifyResponse",
|
|
181
|
+
examples: [
|
|
182
|
+
{
|
|
183
|
+
id: "immutableProofVerifyResponseExample",
|
|
184
|
+
response: {
|
|
185
|
+
body: {
|
|
186
|
+
"@context": ImmutableProofContexts.ContextRoot,
|
|
187
|
+
type: ImmutableProofTypes.ImmutableProofVerification,
|
|
188
|
+
verified: true
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
type: "IImmutableProofVerifyResponse",
|
|
196
|
+
examples: [
|
|
197
|
+
{
|
|
198
|
+
id: "immutableProofVerifyResponseFailExample",
|
|
199
|
+
response: {
|
|
200
|
+
body: {
|
|
201
|
+
"@context": ImmutableProofContexts.ContextRoot,
|
|
202
|
+
type: ImmutableProofTypes.ImmutableProofVerification,
|
|
203
|
+
verified: false,
|
|
204
|
+
failure: ImmutableProofFailure.ProofTypeMismatch
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
type: "INotFoundResponse"
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
};
|
|
215
|
+
return [createRoute, getRoute, verifyRoute];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Create a proof.
|
|
219
|
+
* @param httpRequestContext The request context for the API.
|
|
220
|
+
* @param componentName The name of the component to use in the routes.
|
|
221
|
+
* @param request The request.
|
|
222
|
+
* @returns The response object with additional http response properties.
|
|
223
|
+
*/
|
|
224
|
+
export async function immutableProofCreate(httpRequestContext, componentName, request) {
|
|
225
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
226
|
+
Guards.object(ROUTES_SOURCE, "request.body.document", request.body.document);
|
|
227
|
+
const component = ComponentFactory.get(componentName);
|
|
228
|
+
const result = await component.create(request.body.document);
|
|
229
|
+
return {
|
|
230
|
+
statusCode: HttpStatusCode.created,
|
|
231
|
+
headers: {
|
|
232
|
+
[HeaderTypes.Location]: result
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get the proof.
|
|
238
|
+
* @param httpRequestContext The request context for the API.
|
|
239
|
+
* @param componentName The name of the component to use in the routes.
|
|
240
|
+
* @param request The request.
|
|
241
|
+
* @returns The response object with additional http response properties.
|
|
242
|
+
*/
|
|
243
|
+
export async function immutableProofGet(httpRequestContext, componentName, request) {
|
|
244
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
245
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
246
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
247
|
+
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
248
|
+
const component = ComponentFactory.get(componentName);
|
|
249
|
+
const result = await component.get(request.pathParams.id);
|
|
250
|
+
return {
|
|
251
|
+
headers: {
|
|
252
|
+
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
253
|
+
},
|
|
254
|
+
body: result
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Verify the proof.
|
|
259
|
+
* @param httpRequestContext The request context for the API.
|
|
260
|
+
* @param componentName The name of the component to use in the routes.
|
|
261
|
+
* @param request The request.
|
|
262
|
+
* @returns The response object with additional http response properties.
|
|
263
|
+
*/
|
|
264
|
+
export async function immutableProofVerify(httpRequestContext, componentName, request) {
|
|
265
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
266
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
267
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
268
|
+
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
269
|
+
const component = ComponentFactory.get(componentName);
|
|
270
|
+
const result = await component.verify(request.pathParams.id);
|
|
271
|
+
return {
|
|
272
|
+
headers: {
|
|
273
|
+
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
274
|
+
},
|
|
275
|
+
body: result
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=immutableProofRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"immutableProofRoutes.js","sourceRoot":"","sources":["../../src/immutableProofRoutes.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAON,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEvE;;GAEG;AACH,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAW;IACzC;QACC,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,qEAAqE;KAClF;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC/C,aAAqB,EACrB,aAAqB;IAErB,MAAM,WAAW,GAA+D;QAC/E,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE,gBAAgB;QACzB,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,IAAI;QAC/B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,GAAG;QACzB,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,oBAAoB,CAAC,kBAAkB,EAAE,aAAa,EAAE,OAAO,CAAC;QACjE,WAAW,EAAE;YACZ,IAAI,gCAAwC;YAC5C,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,oCAAoC;oBACxC,OAAO,EAAE;wBACR,IAAI,EAAE;4BACL,QAAQ,EAAE;gCACT,UAAU,EAAE,oBAAoB;gCAChC,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,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U,oBAAoB,CACzC,kBAAuC,EACvC,aAAqB,EACrB,OAAqC;IAErC,MAAM,CAAC,MAAM,CAA+B,aAAa,aAAmB,OAAO,CAAC,CAAC;IACrF,MAAM,CAAC,MAAM,CACZ,aAAa,wBAEb,OAAO,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,CAAC,WAAW,CAAC,aAAa,2BAAiC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAExF,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAEhG,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA2B,aAAa,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAE7D,OAAO;QACN,OAAO,EAAE;YACR,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM;SAClF;QACD,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tICreatedResponse,\n\tIHttpRequestContext,\n\tINotFoundResponse,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport {\n\ttype IImmutableProofComponent,\n\ttype IImmutableProofCreateRequest,\n\ttype IImmutableProofGetRequest,\n\ttype IImmutableProofGetResponse,\n\ttype IImmutableProofVerifyRequest,\n\ttype IImmutableProofVerifyResponse,\n\tImmutableProofContexts,\n\tImmutableProofFailure,\n\tImmutableProofTypes\n} from \"@twin.org/immutable-proof-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts, DidCryptoSuites, ProofTypes } from \"@twin.org/standards-w3c-did\";\nimport { HeaderTypes, HttpStatusCode, MimeTypes } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"immutableProofRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsImmutableProof: ITag[] = [\n\t{\n\t\tname: \"Immutable Proof\",\n\t\tdescription: \"Endpoints which are modelled to access an immutable proof contract.\"\n\t}\n];\n\n/**\n * The REST routes for immutable proof.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesImmutableProof(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst createRoute: IRestRoute<IImmutableProofCreateRequest, ICreatedResponse> = {\n\t\toperationId: \"immutableProofCreate\",\n\t\tsummary: \"Create a proof\",\n\t\ttag: tagsImmutableProof[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\timmutableProofCreate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IImmutableProofCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"immutableProofCreateRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tdocument: {\n\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\ttype: \"Person\",\n\t\t\t\t\t\t\t\tname: \"John Smith\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"immutableProofCreateResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.created,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Location]: \"test:1234567890\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getRoute: IRestRoute<IImmutableProofGetRequest, IImmutableProofGetResponse> = {\n\t\toperationId: \"immutableProofGet\",\n\t\tsummary: \"Get a proof\",\n\t\ttag: tagsImmutableProof[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\timmutableProofGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IImmutableProofGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"immutableProofGetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.Json\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"ais:1234567890\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IImmutableProofGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"immutableProofGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tImmutableProofContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\tImmutableProofContexts.ContextRootCommon\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: ImmutableProofTypes.ImmutableProof,\n\t\t\t\t\t\t\t\tid: \"ais:1234567890\",\n\t\t\t\t\t\t\t\tproofObjectId: \"test:1234567890\",\n\t\t\t\t\t\t\t\tproofObjectHash: \"EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=\",\n\t\t\t\t\t\t\t\tproof: {\n\t\t\t\t\t\t\t\t\t\"@context\": DidContexts.ContextDataIntegrity,\n\t\t\t\t\t\t\t\t\ttype: ProofTypes.DataIntegrityProof,\n\t\t\t\t\t\t\t\t\tcryptosuite: DidCryptoSuites.EdDSAJcs2022,\n\t\t\t\t\t\t\t\t\tcreated: \"2024-08-22T11:56:56.272Z\",\n\t\t\t\t\t\t\t\t\tproofPurpose: \"assertionMethod\",\n\t\t\t\t\t\t\t\t\tproofValue: \"7DdiPPYtxLjCD3wA1po2rv...\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IImmutableProofGetResponse>(),\n\t\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"immutableProofJsonLdGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.ContentType]: MimeTypes.JsonLd\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tImmutableProofContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\tImmutableProofContexts.ContextRootCommon\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: ImmutableProofTypes.ImmutableProof,\n\t\t\t\t\t\t\t\tid: \"ais:1234567890\",\n\t\t\t\t\t\t\t\tproofObjectId: \"test:1234567890\",\n\t\t\t\t\t\t\t\tproofObjectHash: \"EAOKyDN0mYQbBh91eMdVeroxQx1H4GfnRbmt6n/2L/Y=\",\n\t\t\t\t\t\t\t\tproof: {\n\t\t\t\t\t\t\t\t\t\"@context\": DidContexts.ContextDataIntegrity,\n\t\t\t\t\t\t\t\t\ttype: ProofTypes.DataIntegrityProof,\n\t\t\t\t\t\t\t\t\tcryptosuite: DidCryptoSuites.EdDSAJcs2022,\n\t\t\t\t\t\t\t\t\tcreated: \"2024-08-22T11:56:56.272Z\",\n\t\t\t\t\t\t\t\t\tproofPurpose: \"assertionMethod\",\n\t\t\t\t\t\t\t\t\tproofValue: \"7DdiPPYtxLjCD3wA1po2rv...\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst verifyRoute: IRestRoute<IImmutableProofVerifyRequest, IImmutableProofVerifyResponse> = {\n\t\toperationId: \"immutableProofVerify\",\n\t\tsummary: \"Verify a proof\",\n\t\ttag: tagsImmutableProof[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id/verify`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\timmutableProofVerify(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IImmutableProofVerifyRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"immutableProofVerifyRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"ais:1234567890\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IImmutableProofVerifyResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"immutableProofVerifyResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": ImmutableProofContexts.ContextRoot,\n\t\t\t\t\t\t\t\ttype: ImmutableProofTypes.ImmutableProofVerification,\n\t\t\t\t\t\t\t\tverified: true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IImmutableProofVerifyResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"immutableProofVerifyResponseFailExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": ImmutableProofContexts.ContextRoot,\n\t\t\t\t\t\t\t\ttype: ImmutableProofTypes.ImmutableProofVerification,\n\t\t\t\t\t\t\t\tverified: false,\n\t\t\t\t\t\t\t\tfailure: ImmutableProofFailure.ProofTypeMismatch\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [createRoute, getRoute, verifyRoute];\n}\n\n/**\n * Create a proof.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function immutableProofCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IImmutableProofCreateRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<IImmutableProofCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body.document), request.body.document);\n\n\tconst component = ComponentFactory.get<IImmutableProofComponent>(componentName);\n\tconst result = await component.create(request.body.document);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\t[HeaderTypes.Location]: result\n\t\t}\n\t};\n}\n\n/**\n * Get the proof.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function immutableProofGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IImmutableProofGetRequest\n): Promise<IImmutableProofGetResponse> {\n\tGuards.object<IImmutableProofGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IImmutableProofGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? \"jsonld\" : \"json\";\n\n\tconst component = ComponentFactory.get<IImmutableProofComponent>(componentName);\n\tconst result = await component.get(request.pathParams.id);\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: mimeType === \"json\" ? MimeTypes.Json : MimeTypes.JsonLd\n\t\t},\n\t\tbody: result\n\t};\n}\n\n/**\n * Verify the proof.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function immutableProofVerify(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IImmutableProofVerifyRequest\n): Promise<IImmutableProofVerifyResponse> {\n\tGuards.object<IImmutableProofVerifyRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IImmutableProofVerifyRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? \"jsonld\" : \"json\";\n\n\tconst component = ComponentFactory.get<IImmutableProofComponent>(componentName);\n\tconst result = await component.verify(request.pathParams.id);\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: mimeType === \"json\" ? MimeTypes.Json : MimeTypes.JsonLd\n\t\t},\n\t\tbody: result\n\t};\n}\n"]}
|