@twin.org/rights-management-service 0.0.2-next.9 → 0.0.3-next.2
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/dataAccessPointRoutes.js +379 -0
- package/dist/es/dataAccessPointRoutes.js.map +1 -0
- package/dist/es/index.js +8 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/policyAdministrationPointRoutes.js +319 -0
- package/dist/es/policyAdministrationPointRoutes.js.map +1 -0
- package/dist/es/policyNegotiationAdminPointRoutes.js +221 -0
- package/dist/es/policyNegotiationAdminPointRoutes.js.map +1 -0
- package/dist/es/policyNegotiationPointRoutes.js +729 -0
- package/dist/es/policyNegotiationPointRoutes.js.map +1 -0
- package/dist/es/restEntryPoints.js +34 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/types/dataAccessPointRoutes.d.ts +53 -0
- package/dist/types/index.d.ts +5 -4
- package/dist/types/policyNegotiationPointRoutes.d.ts +40 -8
- package/docs/changelog.md +189 -0
- package/docs/open-api/spec.json +1920 -608
- package/docs/reference/functions/{pnpNegotiate.md → dapCreate.md} +5 -5
- package/docs/reference/functions/{pnpNegotiationState.md → dapGet.md} +5 -5
- package/docs/reference/functions/dapQuery.md +31 -0
- package/docs/reference/functions/{pnpNegotiationCancel.md → dapRemove.md} +4 -4
- package/docs/reference/functions/dapUpdate.md +31 -0
- package/docs/reference/functions/generateRestRoutesDataAccessPoint.md +25 -0
- package/docs/reference/functions/pnpGetNegotiation.md +31 -0
- package/docs/reference/functions/pnpNegotiationAgreement.md +31 -0
- package/docs/reference/functions/pnpNegotiationAgreementVerification.md +31 -0
- package/docs/reference/functions/pnpNegotiationOffer.md +31 -0
- package/docs/reference/functions/pnpNegotiationProviderEvents.md +31 -0
- package/docs/reference/functions/pnpNegotiationRequest.md +31 -0
- package/docs/reference/functions/pnpNegotiationTermination.md +31 -0
- package/docs/reference/index.md +14 -3
- package/docs/reference/variables/dapTags.md +5 -0
- package/package.json +30 -10
- package/dist/cjs/index.cjs +0 -814
- package/dist/esm/index.mjs +0 -794
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { ContextIdKeys } from "@twin.org/context";
|
|
2
|
+
import { ComponentFactory, Guards } from "@twin.org/core";
|
|
3
|
+
import { RightsManagementContexts, RightsManagementTypes } from "@twin.org/rights-management-models";
|
|
4
|
+
import { HeaderTypes, HttpStatusCode, MimeTypes } from "@twin.org/web";
|
|
5
|
+
/**
|
|
6
|
+
* The source used when communicating about these routes.
|
|
7
|
+
*/
|
|
8
|
+
const ROUTES_SOURCE = "dataAccessPointRoutes";
|
|
9
|
+
/**
|
|
10
|
+
* The tag to associate with the routes.
|
|
11
|
+
*/
|
|
12
|
+
export const dapTags = [
|
|
13
|
+
{
|
|
14
|
+
name: "Data Access Point",
|
|
15
|
+
description: "Endpoints for providing access to the Rights Management Data Access Point"
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* The REST routes for the Data Access Point.
|
|
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 generateRestRoutesDataAccessPoint(baseRouteName, componentName) {
|
|
25
|
+
const dapCreateRoute = {
|
|
26
|
+
operationId: "dapCreate",
|
|
27
|
+
summary: "Create a new item",
|
|
28
|
+
tag: dapTags[0].name,
|
|
29
|
+
method: "POST",
|
|
30
|
+
path: `${baseRouteName}/data/:assetType`,
|
|
31
|
+
handler: async (httpRequestContext, request) => dapCreate(httpRequestContext, componentName, request),
|
|
32
|
+
requestType: {
|
|
33
|
+
type: "IDapCreateRequest",
|
|
34
|
+
examples: [
|
|
35
|
+
{
|
|
36
|
+
id: "dapCreateRequestExample",
|
|
37
|
+
request: {
|
|
38
|
+
headers: {
|
|
39
|
+
[HeaderTypes.Accept]: MimeTypes.JsonLd,
|
|
40
|
+
[HeaderTypes.Authorization]: "z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC"
|
|
41
|
+
},
|
|
42
|
+
pathParams: {
|
|
43
|
+
assetType: "contacts"
|
|
44
|
+
},
|
|
45
|
+
body: {
|
|
46
|
+
"@context": RightsManagementContexts.ContextRoot,
|
|
47
|
+
type: RightsManagementTypes.DataAccessRequestWithObject,
|
|
48
|
+
assetType: "contacts",
|
|
49
|
+
object: {
|
|
50
|
+
"@context": "https://schema.org",
|
|
51
|
+
type: "Person",
|
|
52
|
+
name: "Jane Doe"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
responseType: [
|
|
60
|
+
{
|
|
61
|
+
type: "ICreatedResponse",
|
|
62
|
+
examples: [
|
|
63
|
+
{
|
|
64
|
+
id: "IDapCreateResponseExample",
|
|
65
|
+
response: {
|
|
66
|
+
statusCode: 201,
|
|
67
|
+
headers: {
|
|
68
|
+
location: "urn:contacts:abc123def456"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
skipAuth: true,
|
|
76
|
+
processorFeatures: ["verifiableCredential"],
|
|
77
|
+
processorData: {
|
|
78
|
+
verifiableCredential: { contextId: ContextIdKeys.Organization }
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const dapGetRoute = {
|
|
82
|
+
operationId: "dapGet",
|
|
83
|
+
summary: "Get an existing item",
|
|
84
|
+
tag: dapTags[0].name,
|
|
85
|
+
method: "GET",
|
|
86
|
+
path: `${baseRouteName}/data/:assetType/:id`,
|
|
87
|
+
handler: async (httpRequestContext, request) => dapGet(httpRequestContext, componentName, request),
|
|
88
|
+
requestType: {
|
|
89
|
+
type: "IDapGetRequest",
|
|
90
|
+
examples: [
|
|
91
|
+
{
|
|
92
|
+
id: "dapCreateRequestExample",
|
|
93
|
+
request: {
|
|
94
|
+
headers: {
|
|
95
|
+
[HeaderTypes.Accept]: MimeTypes.JsonLd,
|
|
96
|
+
[HeaderTypes.Authorization]: "z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC"
|
|
97
|
+
},
|
|
98
|
+
pathParams: {
|
|
99
|
+
assetType: "contacts",
|
|
100
|
+
id: "urn:contacts:abc123def456"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
responseType: [
|
|
107
|
+
{
|
|
108
|
+
type: "IDapGetResponse",
|
|
109
|
+
examples: [
|
|
110
|
+
{
|
|
111
|
+
id: "IDapGetResponseExample",
|
|
112
|
+
response: {
|
|
113
|
+
body: {
|
|
114
|
+
"@context": "https://schema.org",
|
|
115
|
+
type: "Person",
|
|
116
|
+
name: "Jane Doe"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
skipAuth: true,
|
|
124
|
+
processorFeatures: ["verifiableCredential"],
|
|
125
|
+
processorData: {
|
|
126
|
+
verifiableCredential: { contextId: ContextIdKeys.Organization }
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const dapUpdateRoute = {
|
|
130
|
+
operationId: "dapUpdate",
|
|
131
|
+
summary: "Update an existing item",
|
|
132
|
+
tag: dapTags[0].name,
|
|
133
|
+
method: "PUT",
|
|
134
|
+
path: `${baseRouteName}/data/:assetType/:id`,
|
|
135
|
+
handler: async (httpRequestContext, request) => dapUpdate(httpRequestContext, componentName, request),
|
|
136
|
+
requestType: {
|
|
137
|
+
type: "IDapUpdateRequest",
|
|
138
|
+
examples: [
|
|
139
|
+
{
|
|
140
|
+
id: "dapUpdateRequestExample",
|
|
141
|
+
request: {
|
|
142
|
+
headers: {
|
|
143
|
+
[HeaderTypes.Accept]: MimeTypes.JsonLd,
|
|
144
|
+
[HeaderTypes.Authorization]: "z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC"
|
|
145
|
+
},
|
|
146
|
+
pathParams: {
|
|
147
|
+
assetType: "contacts",
|
|
148
|
+
id: "urn:contacts:abc123def456"
|
|
149
|
+
},
|
|
150
|
+
body: {
|
|
151
|
+
"@context": RightsManagementContexts.ContextRoot,
|
|
152
|
+
type: RightsManagementTypes.DataAccessRequestWithObject,
|
|
153
|
+
assetType: "contacts",
|
|
154
|
+
object: {
|
|
155
|
+
"@context": "https://schema.org",
|
|
156
|
+
type: "Person",
|
|
157
|
+
name: "Jane Doe"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
responseType: [
|
|
165
|
+
{
|
|
166
|
+
type: "INoContentResponse"
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
skipAuth: true,
|
|
170
|
+
processorFeatures: ["verifiableCredential"],
|
|
171
|
+
processorData: {
|
|
172
|
+
verifiableCredential: { contextId: ContextIdKeys.Organization }
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const dapRemoveRoute = {
|
|
176
|
+
operationId: "dapRemove",
|
|
177
|
+
summary: "Remove an existing item",
|
|
178
|
+
tag: dapTags[0].name,
|
|
179
|
+
method: "DELETE",
|
|
180
|
+
path: `${baseRouteName}/data/:assetType/:id`,
|
|
181
|
+
handler: async (httpRequestContext, request) => dapRemove(httpRequestContext, componentName, request),
|
|
182
|
+
requestType: {
|
|
183
|
+
type: "IDapRemoveRequest",
|
|
184
|
+
examples: [
|
|
185
|
+
{
|
|
186
|
+
id: "dapRemoveRequestExample",
|
|
187
|
+
request: {
|
|
188
|
+
headers: {
|
|
189
|
+
[HeaderTypes.Accept]: MimeTypes.JsonLd,
|
|
190
|
+
[HeaderTypes.Authorization]: "z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC"
|
|
191
|
+
},
|
|
192
|
+
pathParams: {
|
|
193
|
+
assetType: "contacts",
|
|
194
|
+
id: "urn:contacts:abc123def456"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
responseType: [
|
|
201
|
+
{
|
|
202
|
+
type: "INoContentResponse"
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
skipAuth: true,
|
|
206
|
+
processorFeatures: ["verifiableCredential"],
|
|
207
|
+
processorData: {
|
|
208
|
+
verifiableCredential: { contextId: ContextIdKeys.Organization }
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const dapQueryRoute = {
|
|
212
|
+
operationId: "dapQuery",
|
|
213
|
+
summary: "Query items",
|
|
214
|
+
tag: dapTags[0].name,
|
|
215
|
+
method: "POST",
|
|
216
|
+
path: `${baseRouteName}/data/:assetType/query`,
|
|
217
|
+
handler: async (httpRequestContext, request) => dapQuery(httpRequestContext, componentName, request),
|
|
218
|
+
requestType: {
|
|
219
|
+
type: "IDapQueryRequest",
|
|
220
|
+
examples: [
|
|
221
|
+
{
|
|
222
|
+
id: "dapQueryRequestExample",
|
|
223
|
+
request: {
|
|
224
|
+
headers: {
|
|
225
|
+
[HeaderTypes.Accept]: MimeTypes.JsonLd,
|
|
226
|
+
[HeaderTypes.Authorization]: "z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC"
|
|
227
|
+
},
|
|
228
|
+
pathParams: {
|
|
229
|
+
assetType: "contacts"
|
|
230
|
+
},
|
|
231
|
+
body: {
|
|
232
|
+
"@context": RightsManagementContexts.ContextRoot,
|
|
233
|
+
type: RightsManagementTypes.DataAccessQuery,
|
|
234
|
+
assetType: "contacts"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
responseType: [
|
|
241
|
+
{
|
|
242
|
+
type: "IDapQueryResponse",
|
|
243
|
+
examples: [
|
|
244
|
+
{
|
|
245
|
+
id: "IDapQueryResponseExample",
|
|
246
|
+
response: {
|
|
247
|
+
body: {
|
|
248
|
+
"@context": RightsManagementContexts.ContextRoot,
|
|
249
|
+
type: RightsManagementTypes.DataAccessQueryResponse,
|
|
250
|
+
items: [
|
|
251
|
+
{
|
|
252
|
+
"@context": "https://schema.org",
|
|
253
|
+
type: "Person",
|
|
254
|
+
name: "Jane Doe"
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
skipAuth: true,
|
|
264
|
+
processorFeatures: ["verifiableCredential"],
|
|
265
|
+
processorData: {
|
|
266
|
+
verifiableCredential: { contextId: ContextIdKeys.Organization }
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
return [dapCreateRoute, dapGetRoute, dapUpdateRoute, dapRemoveRoute, dapQueryRoute];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* DAP: Create.
|
|
273
|
+
* @param httpRequestContext The request context for the API.
|
|
274
|
+
* @param componentName The name of the component to use in the routes.
|
|
275
|
+
* @param request The request.
|
|
276
|
+
* @returns The response object with additional http response properties.
|
|
277
|
+
*/
|
|
278
|
+
export async function dapCreate(httpRequestContext, componentName, request) {
|
|
279
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
280
|
+
Guards.object(ROUTES_SOURCE, "request.headers", request.headers);
|
|
281
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
282
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
283
|
+
const component = ComponentFactory.get(componentName);
|
|
284
|
+
const result = await component.create(request.pathParams.assetType, request.body.object, httpRequestContext.processorState
|
|
285
|
+
.verifiableCredentialSubject);
|
|
286
|
+
return {
|
|
287
|
+
statusCode: HttpStatusCode.created,
|
|
288
|
+
headers: {
|
|
289
|
+
[HeaderTypes.Location]: result
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* DAP: Get.
|
|
295
|
+
* @param httpRequestContext The request context for the API.
|
|
296
|
+
* @param componentName The name of the component to use in the routes.
|
|
297
|
+
* @param request The request.
|
|
298
|
+
* @returns The response object with additional http response properties.
|
|
299
|
+
*/
|
|
300
|
+
export async function dapGet(httpRequestContext, componentName, request) {
|
|
301
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
302
|
+
Guards.object(ROUTES_SOURCE, "request.headers", request.headers);
|
|
303
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
304
|
+
const mimeType = request.headers[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
305
|
+
const component = ComponentFactory.get(componentName);
|
|
306
|
+
const result = await component.get(request.pathParams.assetType, request.pathParams.id, httpRequestContext.processorState
|
|
307
|
+
.verifiableCredentialSubject);
|
|
308
|
+
return {
|
|
309
|
+
headers: {
|
|
310
|
+
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
311
|
+
},
|
|
312
|
+
body: result
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* DAP: Update.
|
|
317
|
+
* @param httpRequestContext The request context for the API.
|
|
318
|
+
* @param componentName The name of the component to use in the routes.
|
|
319
|
+
* @param request The request.
|
|
320
|
+
* @returns The response object with additional http response properties.
|
|
321
|
+
*/
|
|
322
|
+
export async function dapUpdate(httpRequestContext, componentName, request) {
|
|
323
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
324
|
+
Guards.object(ROUTES_SOURCE, "request.headers", request.headers);
|
|
325
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
326
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
327
|
+
const component = ComponentFactory.get(componentName);
|
|
328
|
+
await component.update(request.pathParams.assetType, request.body.object, httpRequestContext.processorState
|
|
329
|
+
.verifiableCredentialSubject);
|
|
330
|
+
return {
|
|
331
|
+
statusCode: HttpStatusCode.noContent
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* DAP: Remove.
|
|
336
|
+
* @param httpRequestContext The request context for the API.
|
|
337
|
+
* @param componentName The name of the component to use in the routes.
|
|
338
|
+
* @param request The request.
|
|
339
|
+
* @returns The response object with additional http response properties.
|
|
340
|
+
*/
|
|
341
|
+
export async function dapRemove(httpRequestContext, componentName, request) {
|
|
342
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
343
|
+
Guards.object(ROUTES_SOURCE, "request.headers", request.headers);
|
|
344
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
345
|
+
const component = ComponentFactory.get(componentName);
|
|
346
|
+
await component.remove(request.pathParams.assetType, request.pathParams.id, httpRequestContext.processorState
|
|
347
|
+
.verifiableCredentialSubject);
|
|
348
|
+
return {
|
|
349
|
+
statusCode: HttpStatusCode.noContent
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* DAP: Query.
|
|
354
|
+
* @param httpRequestContext The request context for the API.
|
|
355
|
+
* @param componentName The name of the component to use in the routes.
|
|
356
|
+
* @param request The request.
|
|
357
|
+
* @returns The response object with additional http response properties.
|
|
358
|
+
*/
|
|
359
|
+
export async function dapQuery(httpRequestContext, componentName, request) {
|
|
360
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
361
|
+
Guards.object(ROUTES_SOURCE, "request.headers", request.headers);
|
|
362
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
363
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
364
|
+
const mimeType = request.headers[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
365
|
+
const component = ComponentFactory.get(componentName);
|
|
366
|
+
const result = await component.query(request.pathParams.assetType, request.body.conditions, request.body.cursor, request.body.options, httpRequestContext.processorState
|
|
367
|
+
.verifiableCredentialSubject);
|
|
368
|
+
return {
|
|
369
|
+
headers: {
|
|
370
|
+
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
371
|
+
},
|
|
372
|
+
body: {
|
|
373
|
+
"@context": RightsManagementContexts.ContextRoot,
|
|
374
|
+
type: RightsManagementTypes.DataAccessQueryResponse,
|
|
375
|
+
...result
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
//# sourceMappingURL=dataAccessPointRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataAccessPointRoutes.js","sourceRoot":"","sources":["../../src/dataAccessPointRoutes.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EASrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEvE;;GAEG;AACH,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAW;IAC9B;QACC,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,2EAA2E;KACxF;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAChD,aAAqB,EACrB,aAAqB;IAErB,MAAM,cAAc,GAAoD;QACvE,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,mBAAmB;QAC5B,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;QACpB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,kBAAkB;QACxC,OAAO,EAAE,KA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,MAAM,CACZ,aAAa,qBAEb,OAAO,CAAC,OAAO,CACf,CAAC;IACF,MAAM,CAAC,MAAM,CACZ,aAAa,wBAEb,OAAO,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,CAAC,MAAM,CAA2B,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3F,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAE9F,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA4B,aAAa,CAAC,CAAC;IACjF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CACnC,OAAO,CAAC,UAAU,CAAC,SAAS,EAC5B,OAAO,CAAC,IAAI,CAAC,UAAU,EACvB,OAAO,CAAC,IAAI,CAAC,MAAM,EACnB,OAAO,CAAC,IAAI,CAAC,OAAO,EACpB,kBAAkB,CAAC,cAAc;SAC/B,2BAAmE,CACrE,CAAC;IAEF,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;YACL,UAAU,EAAE,wBAAwB,CAAC,WAAW;YAChD,IAAI,EAAE,qBAAqB,CAAC,uBAAuB;YACnD,GAAG,MAAM;SACT;KACD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tICreatedResponse,\n\tIHttpRequestContext,\n\tINoContentResponse,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ContextIdKeys } from \"@twin.org/context\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type { IIdentityAuthenticationActionRequest } from \"@twin.org/identity-authentication\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tRightsManagementContexts,\n\tRightsManagementTypes,\n\ttype IDapCreateRequest,\n\ttype IDapGetRequest,\n\ttype IDapGetResponse,\n\ttype IDapQueryRequest,\n\ttype IDapQueryResponse,\n\ttype IDapRemoveRequest,\n\ttype IDapUpdateRequest,\n\ttype IDataAccessPointComponent\n} from \"@twin.org/rights-management-models\";\nimport { HeaderTypes, HttpStatusCode, MimeTypes } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"dataAccessPointRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const dapTags: ITag[] = [\n\t{\n\t\tname: \"Data Access Point\",\n\t\tdescription: \"Endpoints for providing access to the Rights Management Data Access Point\"\n\t}\n];\n\n/**\n * The REST routes for the Data Access Point.\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 generateRestRoutesDataAccessPoint(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst dapCreateRoute: IRestRoute<IDapCreateRequest, ICreatedResponse> = {\n\t\toperationId: \"dapCreate\",\n\t\tsummary: \"Create a new item\",\n\t\ttag: dapTags[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/data/:assetType`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdapCreate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDapCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dapCreateRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd,\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tassetType: \"contacts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": RightsManagementContexts.ContextRoot,\n\t\t\t\t\t\t\ttype: RightsManagementTypes.DataAccessRequestWithObject,\n\t\t\t\t\t\t\tassetType: \"contacts\",\n\t\t\t\t\t\t\tobject: {\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: \"Jane Doe\"\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: \"IDapCreateResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: 201,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\tlocation: \"urn:contacts:abc123def456\"\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\tskipAuth: true,\n\t\tprocessorFeatures: [\"verifiableCredential\"],\n\t\tprocessorData: {\n\t\t\tverifiableCredential: { contextId: ContextIdKeys.Organization }\n\t\t}\n\t};\n\n\tconst dapGetRoute: IRestRoute<IDapGetRequest, IDapGetResponse> = {\n\t\toperationId: \"dapGet\",\n\t\tsummary: \"Get an existing item\",\n\t\ttag: dapTags[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/data/:assetType/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdapGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDapGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dapCreateRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd,\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tassetType: \"contacts\",\n\t\t\t\t\t\t\tid: \"urn:contacts:abc123def456\"\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<IDapGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"IDapGetResponseExample\",\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\": \"https://schema.org\",\n\t\t\t\t\t\t\t\ttype: \"Person\",\n\t\t\t\t\t\t\t\tname: \"Jane Doe\"\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\tskipAuth: true,\n\t\tprocessorFeatures: [\"verifiableCredential\"],\n\t\tprocessorData: {\n\t\t\tverifiableCredential: { contextId: ContextIdKeys.Organization }\n\t\t}\n\t};\n\n\tconst dapUpdateRoute: IRestRoute<IDapUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"dapUpdate\",\n\t\tsummary: \"Update an existing item\",\n\t\ttag: dapTags[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/data/:assetType/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdapUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDapUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dapUpdateRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd,\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tassetType: \"contacts\",\n\t\t\t\t\t\t\tid: \"urn:contacts:abc123def456\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": RightsManagementContexts.ContextRoot,\n\t\t\t\t\t\t\ttype: RightsManagementTypes.DataAccessRequestWithObject,\n\t\t\t\t\t\t\tassetType: \"contacts\",\n\t\t\t\t\t\t\tobject: {\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: \"Jane Doe\"\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<INoContentResponse>()\n\t\t\t}\n\t\t],\n\t\tskipAuth: true,\n\t\tprocessorFeatures: [\"verifiableCredential\"],\n\t\tprocessorData: {\n\t\t\tverifiableCredential: { contextId: ContextIdKeys.Organization }\n\t\t}\n\t};\n\n\tconst dapRemoveRoute: IRestRoute<IDapRemoveRequest, INoContentResponse> = {\n\t\toperationId: \"dapRemove\",\n\t\tsummary: \"Remove an existing item\",\n\t\ttag: dapTags[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/data/:assetType/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdapRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDapRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dapRemoveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd,\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tassetType: \"contacts\",\n\t\t\t\t\t\t\tid: \"urn:contacts:abc123def456\"\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<INoContentResponse>()\n\t\t\t}\n\t\t],\n\t\tskipAuth: true,\n\t\tprocessorFeatures: [\"verifiableCredential\"],\n\t\tprocessorData: {\n\t\t\tverifiableCredential: { contextId: ContextIdKeys.Organization }\n\t\t}\n\t};\n\n\tconst dapQueryRoute: IRestRoute<IDapQueryRequest, IDapQueryResponse> = {\n\t\toperationId: \"dapQuery\",\n\t\tsummary: \"Query items\",\n\t\ttag: dapTags[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/data/:assetType/query`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdapQuery(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDapQueryRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dapQueryRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd,\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"z3Vcuh2BP9ShC.z3Vcuh2BP9ShC.z3Vcuh2BP9ShC\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tassetType: \"contacts\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": RightsManagementContexts.ContextRoot,\n\t\t\t\t\t\t\ttype: RightsManagementTypes.DataAccessQuery,\n\t\t\t\t\t\t\tassetType: \"contacts\"\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<IDapQueryResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"IDapQueryResponseExample\",\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\": RightsManagementContexts.ContextRoot,\n\t\t\t\t\t\t\t\ttype: RightsManagementTypes.DataAccessQueryResponse,\n\t\t\t\t\t\t\t\titems: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\ttype: \"Person\",\n\t\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t\t}\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],\n\t\tskipAuth: true,\n\t\tprocessorFeatures: [\"verifiableCredential\"],\n\t\tprocessorData: {\n\t\t\tverifiableCredential: { contextId: ContextIdKeys.Organization }\n\t\t}\n\t};\n\n\treturn [dapCreateRoute, dapGetRoute, dapUpdateRoute, dapRemoveRoute, dapQueryRoute];\n}\n\n/**\n * DAP: Create.\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 dapCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDapCreateRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<IDapCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDapCreateRequest[\"headers\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.headers),\n\t\trequest.headers\n\t);\n\tGuards.object<IDapCreateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.object<IDapCreateRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IDataAccessPointComponent>(componentName);\n\tconst result = await component.create(\n\t\trequest.pathParams.assetType,\n\t\trequest.body.object,\n\t\thttpRequestContext.processorState\n\t\t\t.verifiableCredentialSubject as IIdentityAuthenticationActionRequest\n\t);\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 * DAP: Get.\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 dapGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDapGetRequest\n): Promise<IDapGetResponse> {\n\tGuards.object<IDapGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDapGetRequest[\"headers\"]>(ROUTES_SOURCE, nameof(request.headers), request.headers);\n\tGuards.object<IDapGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\n\tconst mimeType = request.headers[HeaderTypes.Accept] === MimeTypes.JsonLd ? \"jsonld\" : \"json\";\n\n\tconst component = ComponentFactory.get<IDataAccessPointComponent>(componentName);\n\tconst result = await component.get(\n\t\trequest.pathParams.assetType,\n\t\trequest.pathParams.id,\n\t\thttpRequestContext.processorState\n\t\t\t.verifiableCredentialSubject as IIdentityAuthenticationActionRequest\n\t);\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 * DAP: Update.\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 dapUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDapUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IDapUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDapGetRequest[\"headers\"]>(ROUTES_SOURCE, nameof(request.headers), request.headers);\n\tGuards.object<IDapUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.object<IDapUpdateRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IDataAccessPointComponent>(componentName);\n\tawait component.update(\n\t\trequest.pathParams.assetType,\n\t\trequest.body.object,\n\t\thttpRequestContext.processorState\n\t\t\t.verifiableCredentialSubject as IIdentityAuthenticationActionRequest\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * DAP: Remove.\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 dapRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDapRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IDapRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDapRemoveRequest[\"headers\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.headers),\n\t\trequest.headers\n\t);\n\tGuards.object<IDapRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\n\tconst component = ComponentFactory.get<IDataAccessPointComponent>(componentName);\n\tawait component.remove(\n\t\trequest.pathParams.assetType,\n\t\trequest.pathParams.id,\n\t\thttpRequestContext.processorState\n\t\t\t.verifiableCredentialSubject as IIdentityAuthenticationActionRequest\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * DAP: Query.\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 dapQuery(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDapQueryRequest\n): Promise<IDapQueryResponse> {\n\tGuards.object<IDapQueryRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDapQueryRequest[\"headers\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.headers),\n\t\trequest.headers\n\t);\n\tGuards.object<IDapQueryRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.object<IDapQueryRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst mimeType = request.headers[HeaderTypes.Accept] === MimeTypes.JsonLd ? \"jsonld\" : \"json\";\n\n\tconst component = ComponentFactory.get<IDataAccessPointComponent>(componentName);\n\tconst result = await component.query(\n\t\trequest.pathParams.assetType,\n\t\trequest.body.conditions,\n\t\trequest.body.cursor,\n\t\trequest.body.options,\n\t\thttpRequestContext.processorState\n\t\t\t.verifiableCredentialSubject as IIdentityAuthenticationActionRequest\n\t);\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: mimeType === \"json\" ? MimeTypes.Json : MimeTypes.JsonLd\n\t\t},\n\t\tbody: {\n\t\t\t\"@context\": RightsManagementContexts.ContextRoot,\n\t\t\ttype: RightsManagementTypes.DataAccessQueryResponse,\n\t\t\t...result\n\t\t}\n\t};\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./dataAccessPointRoutes.js";
|
|
4
|
+
export * from "./policyAdministrationPointRoutes.js";
|
|
5
|
+
export * from "./policyNegotiationAdminPointRoutes.js";
|
|
6
|
+
export * from "./policyNegotiationPointRoutes.js";
|
|
7
|
+
export * from "./restEntryPoints.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataAccessPointRoutes.js\";\nexport * from \"./policyAdministrationPointRoutes.js\";\nexport * from \"./policyNegotiationAdminPointRoutes.js\";\nexport * from \"./policyNegotiationPointRoutes.js\";\nexport * from \"./restEntryPoints.js\";\n"]}
|