@sphereon/ssi-sdk.oidf-metatdata-server 0.33.1-next.2 → 0.33.1-next.68
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/index.cjs +522 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{ssi-sdk.oidf-metatdata-server.d.ts → index.d.cts} +107 -125
- package/dist/index.d.ts +103 -6
- package/dist/index.js +491 -28
- package/dist/index.js.map +1 -1
- package/package.json +25 -14
- package/plugin.schema.json +15 -23
- package/dist/index.d.ts.map +0 -1
- package/dist/oidf-metadata-server.d.ts +0 -24
- package/dist/oidf-metadata-server.d.ts.map +0 -1
- package/dist/oidf-metadata-server.js +0 -126
- package/dist/oidf-metadata-server.js.map +0 -1
- package/dist/oidf-metadata-store.d.ts +0 -23
- package/dist/oidf-metadata-store.d.ts.map +0 -1
- package/dist/oidf-metadata-store.js +0 -137
- package/dist/oidf-metadata-store.js.map +0 -1
- package/dist/tsdoc-metadata.json +0 -11
- package/dist/types/metadata-server.d.ts +0 -12
- package/dist/types/metadata-server.d.ts.map +0 -1
- package/dist/types/metadata-server.js +0 -8
- package/dist/types/metadata-server.js.map +0 -1
- package/dist/types/metadata-store.d.ts +0 -48
- package/dist/types/metadata-store.d.ts.map +0 -1
- package/dist/types/metadata-store.js +0 -3
- package/dist/types/metadata-store.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
|
|
34
|
+
// plugin.schema.json
|
|
35
|
+
var require_plugin_schema = __commonJS({
|
|
36
|
+
"plugin.schema.json"(exports, module2) {
|
|
37
|
+
module2.exports = {
|
|
38
|
+
IOIDFMetadataStore: {
|
|
39
|
+
components: {
|
|
40
|
+
schemas: {
|
|
41
|
+
IFederationMetadataClearArgs: {
|
|
42
|
+
type: "object",
|
|
43
|
+
properties: {
|
|
44
|
+
storeId: {
|
|
45
|
+
type: "string"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
additionalProperties: false
|
|
49
|
+
},
|
|
50
|
+
IFederationMetadataGetArgs: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
storeId: {
|
|
54
|
+
type: "string"
|
|
55
|
+
},
|
|
56
|
+
namespace: {
|
|
57
|
+
type: "string"
|
|
58
|
+
},
|
|
59
|
+
correlationId: {
|
|
60
|
+
type: "string"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
required: ["correlationId"],
|
|
64
|
+
additionalProperties: false
|
|
65
|
+
},
|
|
66
|
+
OptionalOpenidFederationMetadata: {
|
|
67
|
+
anyOf: [
|
|
68
|
+
{
|
|
69
|
+
$ref: "#/components/schemas/OpenidFederationMetadata"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
not: {}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
OpenidFederationMetadata: {
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {
|
|
79
|
+
baseUrl: {
|
|
80
|
+
type: "string"
|
|
81
|
+
},
|
|
82
|
+
jwt: {
|
|
83
|
+
type: "string"
|
|
84
|
+
},
|
|
85
|
+
enabled: {
|
|
86
|
+
type: "boolean"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
required: ["baseUrl", "jwt"],
|
|
90
|
+
additionalProperties: false
|
|
91
|
+
},
|
|
92
|
+
FederationMetadataExistsArgs: {
|
|
93
|
+
$ref: "#/components/schemas/IFederationMetadataGetArgs"
|
|
94
|
+
},
|
|
95
|
+
IMetadataImportArgs: {
|
|
96
|
+
type: "object",
|
|
97
|
+
properties: {
|
|
98
|
+
metadataType: {
|
|
99
|
+
$ref: "#/components/schemas/MetadataType"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
required: ["metadataType"],
|
|
103
|
+
additionalProperties: false
|
|
104
|
+
},
|
|
105
|
+
MetadataType: {
|
|
106
|
+
type: "string",
|
|
107
|
+
enum: ["issuer", "authorizationServer", "openidFederation"]
|
|
108
|
+
},
|
|
109
|
+
IFederationMetadataListArgs: {
|
|
110
|
+
type: "object",
|
|
111
|
+
properties: {
|
|
112
|
+
storeId: {
|
|
113
|
+
type: "string"
|
|
114
|
+
},
|
|
115
|
+
namespace: {
|
|
116
|
+
type: "string"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
additionalProperties: false
|
|
120
|
+
},
|
|
121
|
+
IFederationMetadataPersistArgs: {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {
|
|
124
|
+
metadataType: {
|
|
125
|
+
$ref: "#/components/schemas/MetadataType"
|
|
126
|
+
},
|
|
127
|
+
correlationId: {
|
|
128
|
+
type: "string"
|
|
129
|
+
},
|
|
130
|
+
metadata: {
|
|
131
|
+
$ref: "#/components/schemas/OpenidFederationMetadata"
|
|
132
|
+
},
|
|
133
|
+
overwriteExisting: {
|
|
134
|
+
type: "boolean"
|
|
135
|
+
},
|
|
136
|
+
validation: {
|
|
137
|
+
type: "boolean"
|
|
138
|
+
},
|
|
139
|
+
ttl: {
|
|
140
|
+
type: "number"
|
|
141
|
+
},
|
|
142
|
+
storeId: {
|
|
143
|
+
type: "string"
|
|
144
|
+
},
|
|
145
|
+
namespace: {
|
|
146
|
+
type: "string"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
required: ["correlationId", "metadata", "metadataType"],
|
|
150
|
+
additionalProperties: false
|
|
151
|
+
},
|
|
152
|
+
OptionalOpenidFederationValueData: {
|
|
153
|
+
anyOf: [
|
|
154
|
+
{
|
|
155
|
+
$ref: "#/components/schemas/IValueData<OpenidFederationMetadata>"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
not: {}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
"IValueData<OpenidFederationMetadata>": {
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {
|
|
165
|
+
value: {
|
|
166
|
+
$ref: "#/components/schemas/OpenidFederationMetadata"
|
|
167
|
+
},
|
|
168
|
+
expires: {
|
|
169
|
+
type: "number"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
additionalProperties: false,
|
|
173
|
+
description: "This is how the store will actually store the value. It contains an optional `expires` property, which indicates when the value would expire"
|
|
174
|
+
},
|
|
175
|
+
FederationMetadataRemoveArgs: {
|
|
176
|
+
$ref: "#/components/schemas/IFederationMetadataGetArgs"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
methods: {
|
|
180
|
+
oidfStoreClearAllMetadata: {
|
|
181
|
+
description: "",
|
|
182
|
+
arguments: {
|
|
183
|
+
$ref: "#/components/schemas/IFederationMetadataClearArgs"
|
|
184
|
+
},
|
|
185
|
+
returnType: {
|
|
186
|
+
type: "boolean"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
oidfStoreGetMetadata: {
|
|
190
|
+
description: "",
|
|
191
|
+
arguments: {
|
|
192
|
+
$ref: "#/components/schemas/IFederationMetadataGetArgs"
|
|
193
|
+
},
|
|
194
|
+
returnType: {
|
|
195
|
+
$ref: "#/components/schemas/OptionalOpenidFederationMetadata"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
oidfStoreHasMetadata: {
|
|
199
|
+
description: "",
|
|
200
|
+
arguments: {
|
|
201
|
+
$ref: "#/components/schemas/FederationMetadataExistsArgs"
|
|
202
|
+
},
|
|
203
|
+
returnType: {
|
|
204
|
+
type: "boolean"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
oidfStoreImportMetadatas: {
|
|
208
|
+
description: "",
|
|
209
|
+
arguments: {
|
|
210
|
+
type: "array",
|
|
211
|
+
items: {
|
|
212
|
+
$ref: "#/components/schemas/IMetadataImportArgs"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
returnType: {
|
|
216
|
+
type: "boolean"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
oidfStoreListMetadata: {
|
|
220
|
+
description: "",
|
|
221
|
+
arguments: {
|
|
222
|
+
$ref: "#/components/schemas/IFederationMetadataListArgs"
|
|
223
|
+
},
|
|
224
|
+
returnType: {
|
|
225
|
+
type: "array",
|
|
226
|
+
items: {
|
|
227
|
+
$ref: "#/components/schemas/OpenidFederationMetadata"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
oidfStorePersistMetadata: {
|
|
232
|
+
description: "",
|
|
233
|
+
arguments: {
|
|
234
|
+
$ref: "#/components/schemas/IFederationMetadataPersistArgs"
|
|
235
|
+
},
|
|
236
|
+
returnType: {
|
|
237
|
+
$ref: "#/components/schemas/OptionalOpenidFederationValueData"
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
oidfStoreRemoveMetadata: {
|
|
241
|
+
description: "",
|
|
242
|
+
arguments: {
|
|
243
|
+
$ref: "#/components/schemas/FederationMetadataRemoveArgs"
|
|
244
|
+
},
|
|
245
|
+
returnType: {
|
|
246
|
+
type: "boolean"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// src/index.ts
|
|
257
|
+
var index_exports = {};
|
|
258
|
+
__export(index_exports, {
|
|
259
|
+
OIDFMetadataServer: () => OIDFMetadataServer,
|
|
260
|
+
OIDFMetadataStore: () => OIDFMetadataStore,
|
|
261
|
+
logger: () => logger,
|
|
262
|
+
schema: () => schema
|
|
263
|
+
});
|
|
264
|
+
module.exports = __toCommonJS(index_exports);
|
|
265
|
+
var import_ssi_types = require("@sphereon/ssi-types");
|
|
266
|
+
|
|
267
|
+
// src/oidf-metadata-store.ts
|
|
268
|
+
var import_ssi_sdk = require("@sphereon/ssi-sdk.kv-store-temp");
|
|
269
|
+
var OIDFMetadataStore = class {
|
|
270
|
+
static {
|
|
271
|
+
__name(this, "OIDFMetadataStore");
|
|
272
|
+
}
|
|
273
|
+
defaultStoreId;
|
|
274
|
+
defaultNamespace;
|
|
275
|
+
_openidFederationMetadataStores;
|
|
276
|
+
schema = schema.IOIDFMetadataStore;
|
|
277
|
+
methods = {
|
|
278
|
+
oidfStoreGetMetadata: this.oidfStoreGetMetadata.bind(this),
|
|
279
|
+
oidfStoreListMetadata: this.oidfStoreListMetadata.bind(this),
|
|
280
|
+
oidfStoreHasMetadata: this.oidfStoreHasMetadata.bind(this),
|
|
281
|
+
oidfStorePersistMetadata: this.oidfStorePersistMetadata.bind(this),
|
|
282
|
+
oidfStoreImportMetadatas: this.oidfStoreImportMetadatas.bind(this),
|
|
283
|
+
oidfStoreRemoveMetadata: this.oidfStoreRemoveMetadata.bind(this),
|
|
284
|
+
oidfStoreClearAllMetadata: this.oidfStoreClearAllMetadata.bind(this)
|
|
285
|
+
};
|
|
286
|
+
constructor(options) {
|
|
287
|
+
this.defaultStoreId = options?.defaultStoreId ?? "_default";
|
|
288
|
+
this.defaultNamespace = options?.defaultNamespace ?? "oidFederation";
|
|
289
|
+
if (options?.openidFederationMetadataStores && options.openidFederationMetadataStores instanceof Map) {
|
|
290
|
+
this._openidFederationMetadataStores = options.openidFederationMetadataStores;
|
|
291
|
+
} else if (options?.openidFederationMetadataStores) {
|
|
292
|
+
this._openidFederationMetadataStores = (/* @__PURE__ */ new Map()).set(this.defaultStoreId, options.openidFederationMetadataStores);
|
|
293
|
+
} else {
|
|
294
|
+
this._openidFederationMetadataStores = (/* @__PURE__ */ new Map()).set(this.defaultStoreId, new import_ssi_sdk.KeyValueStore({
|
|
295
|
+
namespace: this.defaultNamespace,
|
|
296
|
+
store: /* @__PURE__ */ new Map()
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
store(args) {
|
|
301
|
+
const storeId = this.storeIdStr({
|
|
302
|
+
storeId: args.storeId
|
|
303
|
+
});
|
|
304
|
+
const store = args.stores.get(storeId);
|
|
305
|
+
if (!store) {
|
|
306
|
+
throw Error(`Could not get federation metadata store: ${storeId}`);
|
|
307
|
+
}
|
|
308
|
+
return store;
|
|
309
|
+
}
|
|
310
|
+
async oidfStoreGetMetadata({ correlationId, storeId, namespace }) {
|
|
311
|
+
return this.store({
|
|
312
|
+
stores: this._openidFederationMetadataStores,
|
|
313
|
+
storeId
|
|
314
|
+
}).get(this.prefix({
|
|
315
|
+
namespace,
|
|
316
|
+
correlationId
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
async oidfStoreListMetadata({ storeId, namespace }) {
|
|
320
|
+
const result = await this.store({
|
|
321
|
+
stores: this._openidFederationMetadataStores,
|
|
322
|
+
storeId
|
|
323
|
+
}).getMany([
|
|
324
|
+
`${this.namespaceStr({
|
|
325
|
+
namespace
|
|
326
|
+
})}`
|
|
327
|
+
]);
|
|
328
|
+
return result.filter((value) => !!value);
|
|
329
|
+
}
|
|
330
|
+
async oidfStoreHasMetadata({ correlationId, storeId, namespace }) {
|
|
331
|
+
return this.store({
|
|
332
|
+
stores: this._openidFederationMetadataStores,
|
|
333
|
+
storeId
|
|
334
|
+
}).has(this.prefix({
|
|
335
|
+
namespace,
|
|
336
|
+
correlationId
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
async oidfStorePersistMetadata(args) {
|
|
340
|
+
const namespace = this.namespaceStr(args);
|
|
341
|
+
const storeId = this.storeIdStr(args);
|
|
342
|
+
const { metadataType, correlationId, metadata, ttl } = args;
|
|
343
|
+
if (metadataType !== "openidFederation") {
|
|
344
|
+
return void 0;
|
|
345
|
+
}
|
|
346
|
+
const existingOpenIdFederation = await this.store({
|
|
347
|
+
stores: this._openidFederationMetadataStores,
|
|
348
|
+
storeId
|
|
349
|
+
}).getAsValueData(this.prefix({
|
|
350
|
+
namespace,
|
|
351
|
+
correlationId
|
|
352
|
+
}));
|
|
353
|
+
if (!existingOpenIdFederation.value || existingOpenIdFederation.value && args.overwriteExisting !== false) {
|
|
354
|
+
return await this.store({
|
|
355
|
+
stores: this._openidFederationMetadataStores,
|
|
356
|
+
storeId
|
|
357
|
+
}).set(this.prefix({
|
|
358
|
+
namespace,
|
|
359
|
+
correlationId
|
|
360
|
+
}), metadata, ttl);
|
|
361
|
+
}
|
|
362
|
+
return existingOpenIdFederation;
|
|
363
|
+
}
|
|
364
|
+
async oidfStoreImportMetadatas(items) {
|
|
365
|
+
await Promise.all(items.map((args) => {
|
|
366
|
+
const fedArgs = args;
|
|
367
|
+
return this.oidfStorePersistMetadata(fedArgs);
|
|
368
|
+
}));
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
async oidfStoreRemoveMetadata(args) {
|
|
372
|
+
const namespace = this.namespaceStr(args);
|
|
373
|
+
const storeId = this.storeIdStr(args);
|
|
374
|
+
return this.store({
|
|
375
|
+
stores: this._openidFederationMetadataStores,
|
|
376
|
+
storeId
|
|
377
|
+
}).delete(this.prefix({
|
|
378
|
+
namespace,
|
|
379
|
+
correlationId: args.correlationId
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
async oidfStoreClearAllMetadata({ storeId }) {
|
|
383
|
+
return await this.store({
|
|
384
|
+
stores: this._openidFederationMetadataStores,
|
|
385
|
+
storeId
|
|
386
|
+
}).clear().then(() => true);
|
|
387
|
+
}
|
|
388
|
+
storeIdStr({ storeId }) {
|
|
389
|
+
return storeId ?? this.defaultStoreId;
|
|
390
|
+
}
|
|
391
|
+
namespaceStr({ namespace }) {
|
|
392
|
+
return namespace ?? this.defaultNamespace;
|
|
393
|
+
}
|
|
394
|
+
prefix({ namespace, correlationId }) {
|
|
395
|
+
return `${this.namespaceStr({
|
|
396
|
+
namespace
|
|
397
|
+
})}:${correlationId}`;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// src/types/metadata-server.ts
|
|
402
|
+
var FederationEndpoints = /* @__PURE__ */ function(FederationEndpoints2) {
|
|
403
|
+
FederationEndpoints2["WELL_KNOWN_OPENID_FEDERATION"] = "/.well-known/openid-federation";
|
|
404
|
+
return FederationEndpoints2;
|
|
405
|
+
}({});
|
|
406
|
+
|
|
407
|
+
// src/oidf-metadata-server.ts
|
|
408
|
+
var import_express = __toESM(require("express"), 1);
|
|
409
|
+
var OIDFMetadataServer = class _OIDFMetadataServer {
|
|
410
|
+
static {
|
|
411
|
+
__name(this, "OIDFMetadataServer");
|
|
412
|
+
}
|
|
413
|
+
_context;
|
|
414
|
+
_routers;
|
|
415
|
+
_app;
|
|
416
|
+
_opts;
|
|
417
|
+
_routerMiddleware;
|
|
418
|
+
constructor(args) {
|
|
419
|
+
const { expressSupport, context, opts } = args;
|
|
420
|
+
this._context = context;
|
|
421
|
+
this._app = expressSupport.express;
|
|
422
|
+
this._opts = opts;
|
|
423
|
+
this._routers = /* @__PURE__ */ new Map();
|
|
424
|
+
this._routerMiddleware = [];
|
|
425
|
+
}
|
|
426
|
+
getHostAndPath(url) {
|
|
427
|
+
try {
|
|
428
|
+
const urlObj = new URL(url);
|
|
429
|
+
return {
|
|
430
|
+
hostname: urlObj.hostname,
|
|
431
|
+
basePath: urlObj.pathname.replace(/\/+$/, "")
|
|
432
|
+
};
|
|
433
|
+
} catch (error) {
|
|
434
|
+
logger.error(`Invalid URL provided: ${url}`, error);
|
|
435
|
+
throw new Error(`Invalid URL provided: ${url}`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
async down() {
|
|
439
|
+
this._routerMiddleware.forEach((middleware) => {
|
|
440
|
+
const index = this._app._router.stack.findIndex((layer) => layer.handle === middleware);
|
|
441
|
+
if (index !== -1) {
|
|
442
|
+
this._app._router.stack.splice(index, 1);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
this._routerMiddleware = [];
|
|
446
|
+
this._routers.clear();
|
|
447
|
+
}
|
|
448
|
+
async up() {
|
|
449
|
+
await this.down();
|
|
450
|
+
const metadataEndpoints = await this._context.agent.oidfStoreListMetadata({
|
|
451
|
+
storeId: this._opts?.storeId,
|
|
452
|
+
namespace: this._opts?.namespace
|
|
453
|
+
});
|
|
454
|
+
const filteredEndpoints = metadataEndpoints.filter((endpoint) => endpoint.enabled !== false);
|
|
455
|
+
this.hostEndpoints(filteredEndpoints);
|
|
456
|
+
}
|
|
457
|
+
hostEndpoints = /* @__PURE__ */ __name((metadataEndpoints) => {
|
|
458
|
+
logger.debug("metadataEndpoints", metadataEndpoints);
|
|
459
|
+
const endpointsByHost = /* @__PURE__ */ new Map();
|
|
460
|
+
metadataEndpoints.forEach((endpoint) => {
|
|
461
|
+
const { hostname, basePath } = this.getHostAndPath(endpoint.baseUrl);
|
|
462
|
+
if (!endpointsByHost.has(hostname)) {
|
|
463
|
+
endpointsByHost.set(hostname, []);
|
|
464
|
+
}
|
|
465
|
+
endpointsByHost.get(hostname)?.push({
|
|
466
|
+
basePath,
|
|
467
|
+
endpoint
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
endpointsByHost.forEach((endpoints, hostname) => {
|
|
471
|
+
const router = import_express.default.Router();
|
|
472
|
+
logger.debug("assigning OIDF metadata router to", hostname);
|
|
473
|
+
this._routers.set(hostname, router);
|
|
474
|
+
endpoints.forEach(({ basePath, endpoint }) => {
|
|
475
|
+
const federationPath = basePath + FederationEndpoints.WELL_KNOWN_OPENID_FEDERATION;
|
|
476
|
+
logger.debug("mapping OIDF metadata HTTP GET to", federationPath);
|
|
477
|
+
router.get(federationPath, async (request, response) => {
|
|
478
|
+
try {
|
|
479
|
+
const asciiData = Buffer.from(endpoint.jwt, "ascii");
|
|
480
|
+
response.setHeader("Content-Type", "application/entity-statement+jwt");
|
|
481
|
+
return response.send(asciiData);
|
|
482
|
+
} catch (error) {
|
|
483
|
+
logger.error("Error processing federation metadata request:", error);
|
|
484
|
+
return response.status(500).send("Internal server error");
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
const middleware = /* @__PURE__ */ __name((request, response, next) => {
|
|
489
|
+
const forwardedHost = request.headers["x-forwarded-host"]?.toString()?.split(":")[0];
|
|
490
|
+
const reqHostname = forwardedHost ?? request.hostname;
|
|
491
|
+
if (reqHostname === hostname) {
|
|
492
|
+
router(request, response, next);
|
|
493
|
+
} else {
|
|
494
|
+
next();
|
|
495
|
+
}
|
|
496
|
+
}, "middleware");
|
|
497
|
+
this._routerMiddleware.push(middleware);
|
|
498
|
+
this._app.use(middleware);
|
|
499
|
+
});
|
|
500
|
+
}, "hostEndpoints");
|
|
501
|
+
static async init(args) {
|
|
502
|
+
const { expressSupport, context, opts } = args;
|
|
503
|
+
const oidfMetadataServer = new _OIDFMetadataServer({
|
|
504
|
+
context,
|
|
505
|
+
expressSupport,
|
|
506
|
+
opts
|
|
507
|
+
});
|
|
508
|
+
await oidfMetadataServer.up();
|
|
509
|
+
return oidfMetadataServer;
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
// src/index.ts
|
|
514
|
+
var logger = import_ssi_types.Loggers.DEFAULT.options("sphereon:oidf-metadata-server", {
|
|
515
|
+
defaultLogLevel: import_ssi_types.LogLevel.DEBUG,
|
|
516
|
+
methods: [
|
|
517
|
+
import_ssi_types.LogMethod.CONSOLE,
|
|
518
|
+
import_ssi_types.LogMethod.DEBUG_PKG
|
|
519
|
+
]
|
|
520
|
+
}).get("sphereon:oidf-metadata-server");
|
|
521
|
+
var schema = require_plugin_schema();
|
|
522
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../plugin.schema.json","../src/index.ts","../src/oidf-metadata-store.ts","../src/types/metadata-server.ts","../src/oidf-metadata-server.ts"],"sourcesContent":["{\n \"IOIDFMetadataStore\": {\n \"components\": {\n \"schemas\": {\n \"IFederationMetadataClearArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"storeId\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n },\n \"IFederationMetadataGetArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"storeId\": {\n \"type\": \"string\"\n },\n \"namespace\": {\n \"type\": \"string\"\n },\n \"correlationId\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"correlationId\"],\n \"additionalProperties\": false\n },\n \"OptionalOpenidFederationMetadata\": {\n \"anyOf\": [\n {\n \"$ref\": \"#/components/schemas/OpenidFederationMetadata\"\n },\n {\n \"not\": {}\n }\n ]\n },\n \"OpenidFederationMetadata\": {\n \"type\": \"object\",\n \"properties\": {\n \"baseUrl\": {\n \"type\": \"string\"\n },\n \"jwt\": {\n \"type\": \"string\"\n },\n \"enabled\": {\n \"type\": \"boolean\"\n }\n },\n \"required\": [\"baseUrl\", \"jwt\"],\n \"additionalProperties\": false\n },\n \"FederationMetadataExistsArgs\": {\n \"$ref\": \"#/components/schemas/IFederationMetadataGetArgs\"\n },\n \"IMetadataImportArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"metadataType\": {\n \"$ref\": \"#/components/schemas/MetadataType\"\n }\n },\n \"required\": [\"metadataType\"],\n \"additionalProperties\": false\n },\n \"MetadataType\": {\n \"type\": \"string\",\n \"enum\": [\"issuer\", \"authorizationServer\", \"openidFederation\"]\n },\n \"IFederationMetadataListArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"storeId\": {\n \"type\": \"string\"\n },\n \"namespace\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n },\n \"IFederationMetadataPersistArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"metadataType\": {\n \"$ref\": \"#/components/schemas/MetadataType\"\n },\n \"correlationId\": {\n \"type\": \"string\"\n },\n \"metadata\": {\n \"$ref\": \"#/components/schemas/OpenidFederationMetadata\"\n },\n \"overwriteExisting\": {\n \"type\": \"boolean\"\n },\n \"validation\": {\n \"type\": \"boolean\"\n },\n \"ttl\": {\n \"type\": \"number\"\n },\n \"storeId\": {\n \"type\": \"string\"\n },\n \"namespace\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"correlationId\", \"metadata\", \"metadataType\"],\n \"additionalProperties\": false\n },\n \"OptionalOpenidFederationValueData\": {\n \"anyOf\": [\n {\n \"$ref\": \"#/components/schemas/IValueData<OpenidFederationMetadata>\"\n },\n {\n \"not\": {}\n }\n ]\n },\n \"IValueData<OpenidFederationMetadata>\": {\n \"type\": \"object\",\n \"properties\": {\n \"value\": {\n \"$ref\": \"#/components/schemas/OpenidFederationMetadata\"\n },\n \"expires\": {\n \"type\": \"number\"\n }\n },\n \"additionalProperties\": false,\n \"description\": \"This is how the store will actually store the value. It contains an optional `expires` property, which indicates when the value would expire\"\n },\n \"FederationMetadataRemoveArgs\": {\n \"$ref\": \"#/components/schemas/IFederationMetadataGetArgs\"\n }\n },\n \"methods\": {\n \"oidfStoreClearAllMetadata\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IFederationMetadataClearArgs\"\n },\n \"returnType\": {\n \"type\": \"boolean\"\n }\n },\n \"oidfStoreGetMetadata\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IFederationMetadataGetArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/OptionalOpenidFederationMetadata\"\n }\n },\n \"oidfStoreHasMetadata\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/FederationMetadataExistsArgs\"\n },\n \"returnType\": {\n \"type\": \"boolean\"\n }\n },\n \"oidfStoreImportMetadatas\": {\n \"description\": \"\",\n \"arguments\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/IMetadataImportArgs\"\n }\n },\n \"returnType\": {\n \"type\": \"boolean\"\n }\n },\n \"oidfStoreListMetadata\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IFederationMetadataListArgs\"\n },\n \"returnType\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/OpenidFederationMetadata\"\n }\n }\n },\n \"oidfStorePersistMetadata\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IFederationMetadataPersistArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/OptionalOpenidFederationValueData\"\n }\n },\n \"oidfStoreRemoveMetadata\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/FederationMetadataRemoveArgs\"\n },\n \"returnType\": {\n \"type\": \"boolean\"\n }\n }\n }\n }\n }\n}\n","import { Loggers, LogLevel, LogMethod } from '@sphereon/ssi-types'\n\nexport const logger = Loggers.DEFAULT.options('sphereon:oidf-metadata-server', {\n defaultLogLevel: LogLevel.DEBUG,\n methods: [LogMethod.CONSOLE, LogMethod.DEBUG_PKG],\n}).get('sphereon:oidf-metadata-server')\n\n/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\n\nexport * from './oidf-metadata-store'\nexport * from './types/metadata-store'\nexport * from './oidf-metadata-server'\n","import {\n IFederationMetadataClearArgs,\n FederationMetadataExistsArgs,\n IFederationMetadataGetArgs,\n IFederationMetadataListArgs,\n IFederationMetadataPersistArgs,\n FederationMetadataRemoveArgs,\n IFederationMetadataStoreOpts,\n IOIDFMetadataStore,\n OpenidFederationMetadata,\n OptionalOpenidFederationMetadata,\n OptionalOpenidFederationValueData,\n FederationMetadataImportArgs,\n} from './types/metadata-store'\nimport { IKeyValueStore, KeyValueStore } from '@sphereon/ssi-sdk.kv-store-temp'\nimport { IAgentPlugin } from '@veramo/core'\n\nimport { schema } from './index'\nimport { IMetadataImportArgs } from '@sphereon/ssi-types'\n\nexport class OIDFMetadataStore implements IAgentPlugin {\n private readonly defaultStoreId: string\n private readonly defaultNamespace: string\n private readonly _openidFederationMetadataStores: Map<string, IKeyValueStore<OpenidFederationMetadata>>\n\n readonly schema = schema.IOIDFMetadataStore\n readonly methods: IOIDFMetadataStore = {\n oidfStoreGetMetadata: this.oidfStoreGetMetadata.bind(this),\n oidfStoreListMetadata: this.oidfStoreListMetadata.bind(this),\n oidfStoreHasMetadata: this.oidfStoreHasMetadata.bind(this),\n oidfStorePersistMetadata: this.oidfStorePersistMetadata.bind(this),\n oidfStoreImportMetadatas: this.oidfStoreImportMetadatas.bind(this),\n oidfStoreRemoveMetadata: this.oidfStoreRemoveMetadata.bind(this),\n oidfStoreClearAllMetadata: this.oidfStoreClearAllMetadata.bind(this),\n }\n\n constructor(options?: IFederationMetadataStoreOpts) {\n this.defaultStoreId = options?.defaultStoreId ?? '_default'\n this.defaultNamespace = options?.defaultNamespace ?? 'oidFederation'\n\n if (options?.openidFederationMetadataStores && options.openidFederationMetadataStores instanceof Map) {\n this._openidFederationMetadataStores = options.openidFederationMetadataStores\n } else if (options?.openidFederationMetadataStores) {\n this._openidFederationMetadataStores = new Map().set(this.defaultStoreId, options.openidFederationMetadataStores)\n } else {\n this._openidFederationMetadataStores = new Map().set(\n this.defaultStoreId,\n new KeyValueStore({\n namespace: this.defaultNamespace,\n store: new Map<string, OpenidFederationMetadata>(),\n }),\n )\n }\n }\n\n private store(args: { stores: Map<string, IKeyValueStore<OpenidFederationMetadata>>; storeId?: string }): IKeyValueStore<OpenidFederationMetadata> {\n const storeId = this.storeIdStr({ storeId: args.storeId })\n const store = args.stores.get(storeId)\n if (!store) {\n throw Error(`Could not get federation metadata store: ${storeId}`)\n }\n return store\n }\n\n async oidfStoreGetMetadata({ correlationId, storeId, namespace }: IFederationMetadataGetArgs): Promise<OptionalOpenidFederationMetadata> {\n return this.store({\n stores: this._openidFederationMetadataStores,\n storeId,\n }).get(this.prefix({ namespace, correlationId }))\n }\n\n async oidfStoreListMetadata({ storeId, namespace }: IFederationMetadataListArgs): Promise<Array<OpenidFederationMetadata>> {\n const result = await this.store({\n stores: this._openidFederationMetadataStores,\n storeId,\n }).getMany([`${this.namespaceStr({ namespace })}`])\n return result.filter((value) => !!value)\n }\n\n async oidfStoreHasMetadata({ correlationId, storeId, namespace }: FederationMetadataExistsArgs): Promise<boolean> {\n return this.store({\n stores: this._openidFederationMetadataStores,\n storeId,\n }).has(this.prefix({ namespace, correlationId }))\n }\n\n async oidfStorePersistMetadata(args: IFederationMetadataPersistArgs): Promise<OptionalOpenidFederationValueData> {\n const namespace = this.namespaceStr(args)\n const storeId = this.storeIdStr(args)\n const { metadataType, correlationId, metadata, ttl } = args\n if (metadataType !== 'openidFederation') {\n return undefined\n }\n\n const existingOpenIdFederation = await this.store({\n stores: this._openidFederationMetadataStores,\n storeId,\n }).getAsValueData(this.prefix({ namespace, correlationId }))\n\n if (!existingOpenIdFederation.value || (existingOpenIdFederation.value && args.overwriteExisting !== false)) {\n return await this.store({\n stores: this._openidFederationMetadataStores,\n storeId,\n }).set(this.prefix({ namespace, correlationId }), metadata as OpenidFederationMetadata, ttl)\n }\n return existingOpenIdFederation\n }\n\n async oidfStoreImportMetadatas(items: Array<IMetadataImportArgs>): Promise<boolean> {\n await Promise.all(\n items.map((args) => {\n const fedArgs = args as FederationMetadataImportArgs\n return this.oidfStorePersistMetadata(fedArgs)\n }),\n )\n return true\n }\n\n async oidfStoreRemoveMetadata(args: FederationMetadataRemoveArgs): Promise<boolean> {\n const namespace = this.namespaceStr(args)\n const storeId = this.storeIdStr(args)\n\n return this.store({\n stores: this._openidFederationMetadataStores,\n storeId,\n }).delete(this.prefix({ namespace, correlationId: args.correlationId }))\n }\n\n async oidfStoreClearAllMetadata({ storeId }: IFederationMetadataClearArgs): Promise<boolean> {\n return await this.store({\n stores: this._openidFederationMetadataStores,\n storeId,\n })\n .clear()\n .then(() => true)\n }\n\n private storeIdStr({ storeId }: { storeId?: string }): string {\n return storeId ?? this.defaultStoreId\n }\n\n private namespaceStr({ namespace }: { namespace?: string }): string {\n return namespace ?? this.defaultNamespace\n }\n\n private prefix({ namespace, correlationId }: { namespace?: string; correlationId: string }): string {\n return `${this.namespaceStr({ namespace })}:${correlationId}`\n }\n}\n","import { IAgentContext } from '@veramo/core'\nimport { IOIDFMetadataStore } from './metadata-store'\n\nexport enum FederationEndpoints {\n WELL_KNOWN_OPENID_FEDERATION = '/.well-known/openid-federation',\n}\n\nexport type IRequiredContext = IAgentContext<IPlugins>\n\nexport type IPlugins = IOIDFMetadataStore\n\nexport interface FederationMetadataServerOpts {\n storeId?: string\n namespace?: string\n}\n","import { FederationEndpoints, FederationMetadataServerOpts, IRequiredContext } from './types/metadata-server'\nimport { ExpressSupport } from '@sphereon/ssi-express-support'\nimport express, { Express, Request, Response, Router } from 'express'\nimport { OpenidFederationMetadata } from './types/metadata-store'\nimport { ILayer } from 'express-serve-static-core'\nimport { logger } from './index'\n\nexport class OIDFMetadataServer {\n private readonly _context: IRequiredContext\n private readonly _routers: Map<string, express.Router>\n private readonly _app: Express\n private readonly _opts?: FederationMetadataServerOpts\n private _routerMiddleware: Array<express.RequestHandler>\n\n constructor(args: { context: IRequiredContext; expressSupport: ExpressSupport; opts?: FederationMetadataServerOpts }) {\n const { expressSupport, context, opts } = args\n this._context = context\n this._app = expressSupport.express\n this._opts = opts\n this._routers = new Map()\n this._routerMiddleware = []\n }\n\n private getHostAndPath(url: string): { hostname: string; basePath: string } {\n try {\n const urlObj = new URL(url)\n return {\n hostname: urlObj.hostname,\n basePath: urlObj.pathname.replace(/\\/+$/, ''), // Remove trailing slashes\n }\n } catch (error) {\n logger.error(`Invalid URL provided: ${url}`, error)\n throw new Error(`Invalid URL provided: ${url}`)\n }\n }\n\n public async down() {\n // Remove all mounted middleware\n this._routerMiddleware.forEach((middleware) => {\n const index = this._app._router.stack.findIndex((layer: ILayer) => layer.handle === middleware)\n if (index !== -1) {\n this._app._router.stack.splice(index, 1)\n }\n })\n\n // Clear the collections\n this._routerMiddleware = []\n this._routers.clear()\n }\n\n public async up() {\n // Clean up existing routes first\n await this.down()\n\n const metadataEndpoints = await this._context.agent.oidfStoreListMetadata({\n storeId: this._opts?.storeId,\n namespace: this._opts?.namespace,\n })\n const filteredEndpoints = metadataEndpoints.filter((endpoint) => endpoint.enabled !== false)\n this.hostEndpoints(filteredEndpoints)\n }\n\n private hostEndpoints = (metadataEndpoints: Array<OpenidFederationMetadata>) => {\n logger.debug('metadataEndpoints', metadataEndpoints)\n\n // Group endpoints by hostname\n const endpointsByHost = new Map<string, Array<{ basePath: string; endpoint: OpenidFederationMetadata }>>()\n\n metadataEndpoints.forEach((endpoint) => {\n const { hostname, basePath } = this.getHostAndPath(endpoint.baseUrl)\n\n if (!endpointsByHost.has(hostname)) {\n endpointsByHost.set(hostname, [])\n }\n endpointsByHost.get(hostname)?.push({ basePath, endpoint })\n })\n\n // Create and configure routers for each hostname\n endpointsByHost.forEach((endpoints, hostname) => {\n const router: Router = express.Router()\n logger.debug('assigning OIDF metadata router to', hostname)\n this._routers.set(hostname, router)\n\n endpoints.forEach(({ basePath, endpoint }) => {\n const federationPath = basePath + FederationEndpoints.WELL_KNOWN_OPENID_FEDERATION\n logger.debug('mapping OIDF metadata HTTP GET to', federationPath)\n\n router.get(federationPath, async (request: Request, response: Response) => {\n try {\n const asciiData = Buffer.from(endpoint.jwt, 'ascii')\n response.setHeader('Content-Type', 'application/entity-statement+jwt')\n return response.send(asciiData)\n } catch (error) {\n logger.error('Error processing federation metadata request:', error)\n return response.status(500).send('Internal server error')\n }\n })\n })\n\n // Mount the router for this hostname and keep track of the middleware\n const middleware = (request: Request, response: Response, next: express.NextFunction) => {\n const forwardedHost = request.headers['x-forwarded-host']?.toString()?.split(':')[0]\n const reqHostname = forwardedHost ?? request.hostname\n if (reqHostname === hostname) {\n router(request, response, next)\n } else {\n next()\n }\n }\n this._routerMiddleware.push(middleware)\n this._app.use(middleware)\n })\n }\n\n static async init(args: {\n context: IRequiredContext\n expressSupport: ExpressSupport\n opts?: FederationMetadataServerOpts\n }): Promise<OIDFMetadataServer> {\n const { expressSupport, context, opts } = args\n const oidfMetadataServer = new OIDFMetadataServer({ context, expressSupport, opts })\n await oidfMetadataServer.up()\n return oidfMetadataServer\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,gCAAAA,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,oBAAsB;AAAA,QACpB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,8BAAgC;AAAA,cAC9B,MAAQ;AAAA,cACR,YAAc;AAAA,gB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AAA;AAKP,IAAMC,SAASC;","names":["module","OIDFMetadataStore","defaultStoreId","defaultNamespace","_openidFederationMetadataStores","schema","IOIDFMetadataStore","methods","oidfStoreGetMetadata","bind","oidfStoreListMetadata","oidfStoreHasMetadata","oidfStorePersistMetadata","oidfStoreImportMetadatas","oidfStoreRemoveMetadata","oidfStoreClearAllMetadata","constructor","options","openidFederationMetadataStores","Map","set","KeyValueStore","namespace","store","args","storeId","storeIdStr","stores","get","Error","correlationId","prefix","result","getMany","namespaceStr","filter","value","has","metadataType","metadata","ttl","undefined","existingOpenIdFederation","getAsValueData","overwriteExisting","items","Promise","all","map","fedArgs","delete","clear","then","FederationEndpoints","OIDFMetadataServer","_context","_routers","_app","_opts","_routerMiddleware","constructor","args","expressSupport","context","opts","express","Map","getHostAndPath","url","urlObj","URL","hostname","basePath","pathname","replace","error","logger","Error","down","forEach","middleware","index","_router","stack","findIndex","layer","handle","splice","clear","up","metadataEndpoints","agent","oidfStoreListMetadata","storeId","namespace","filteredEndpoints","filter","endpoint","enabled","hostEndpoints","debug","endpointsByHost","baseUrl","has","set","get","push","endpoints","router","Router","federationPath","FederationEndpoints","WELL_KNOWN_OPENID_FEDERATION","request","response","asciiData","Buffer","from","jwt","setHeader","send","status","next","forwardedHost","headers","toString","split","reqHostname","use","init","oidfMetadataServer","logger","Loggers","DEFAULT","options","defaultLogLevel","LogLevel","DEBUG","methods","LogMethod","CONSOLE","DEBUG_PKG","get","schema","require"]}
|