@sphereon/ssi-sdk.oidf-metatdata-server 0.34.1-fix.79 → 0.34.1-next.278
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -414,10 +414,10 @@ var OIDFMetadataStore = class {
|
|
|
414
414
|
};
|
|
415
415
|
|
|
416
416
|
// src/types/metadata-server.ts
|
|
417
|
-
var FederationEndpoints = /* @__PURE__ */ function(FederationEndpoints2) {
|
|
417
|
+
var FederationEndpoints = /* @__PURE__ */ (function(FederationEndpoints2) {
|
|
418
418
|
FederationEndpoints2["WELL_KNOWN_OPENID_FEDERATION"] = "/.well-known/openid-federation";
|
|
419
419
|
return FederationEndpoints2;
|
|
420
|
-
}({});
|
|
420
|
+
})({});
|
|
421
421
|
|
|
422
422
|
// src/oidf-metadata-server.ts
|
|
423
423
|
var import_express = __toESM(require("express"), 1);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +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\": [\n \"correlationId\"\n ],\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\": [\n \"baseUrl\",\n \"jwt\"\n ],\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\": [\n \"metadataType\"\n ],\n \"additionalProperties\": false\n },\n \"MetadataType\": {\n \"type\": \"string\",\n \"enum\": [\n \"issuer\",\n \"authorizationServer\",\n \"openidFederation\"\n ]\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\": [\n \"correlationId\",\n \"metadata\",\n \"metadataType\"\n ],\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}","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,gBACZ,SAAW;AAAA,kBACT,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,c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AI,+BAAA;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"]}
|
|
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\": [\n \"correlationId\"\n ],\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\": [\n \"baseUrl\",\n \"jwt\"\n ],\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\": [\n \"metadataType\"\n ],\n \"additionalProperties\": false\n },\n \"MetadataType\": {\n \"type\": \"string\",\n \"enum\": [\n \"issuer\",\n \"authorizationServer\",\n \"openidFederation\"\n ]\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\": [\n \"correlationId\",\n \"metadata\",\n \"metadataType\"\n ],\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}","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,I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AmBzC,GAAE;AAC3B,WAAOyC;EACT;AACF;;;AH1HO,IAAMC,SAASC,yBAAQC,QAAQC,QAAQ,iCAAiC;EAC7EC,iBAAiBC,0BAASC;EAC1BC,SAAS;IAACC,2BAAUC;IAASD,2BAAUE;;AACzC,CAAA,EAAGC,IAAI,+BAAA;AAKP,IAAMC,SAASC;","names":["module","OIDFMetadataStore","defaultStoreId","defaultNamespace","_openidFederationMetadataStores","schema","IOIDFMetadataStore","methods","oidfStoreGetMetadata","bind","oidfStoreListMetadata","oidfStoreHasMetadata","oidfStorePersistMetadata","oidfStoreImportMetadatas","oidfStoreRemoveMetadata","oidfStoreClearAllMetadata","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","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"]}
|
package/dist/index.js
CHANGED
|
@@ -380,10 +380,10 @@ var OIDFMetadataStore = class {
|
|
|
380
380
|
};
|
|
381
381
|
|
|
382
382
|
// src/types/metadata-server.ts
|
|
383
|
-
var FederationEndpoints = /* @__PURE__ */ function(FederationEndpoints2) {
|
|
383
|
+
var FederationEndpoints = /* @__PURE__ */ (function(FederationEndpoints2) {
|
|
384
384
|
FederationEndpoints2["WELL_KNOWN_OPENID_FEDERATION"] = "/.well-known/openid-federation";
|
|
385
385
|
return FederationEndpoints2;
|
|
386
|
-
}({});
|
|
386
|
+
})({});
|
|
387
387
|
|
|
388
388
|
// src/oidf-metadata-server.ts
|
|
389
389
|
import express from "express";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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\": [\n \"correlationId\"\n ],\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\": [\n \"baseUrl\",\n \"jwt\"\n ],\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\": [\n \"metadataType\"\n ],\n \"additionalProperties\": false\n },\n \"MetadataType\": {\n \"type\": \"string\",\n \"enum\": [\n \"issuer\",\n \"authorizationServer\",\n \"openidFederation\"\n ]\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\": [\n \"correlationId\",\n \"metadata\",\n \"metadataType\"\n ],\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}","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;AAAA;AAAA,MACE,oBAAsB;AAAA,QACpB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,8BAAgC;AAAA,cAC9B,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,SAAW;AAAA,kBACT,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,YAC1B;AAAA,YACA,4BAA8B;AAAA,cAC5B,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,SAAW;AAAA,kBACT,MAAQ;AAAA,gBACV;AAAA,gBACA,WAAa;AAAA,kBACX,MAAQ;AAAA,gBACV;AAAA,gBACA,eAAiB;AAAA,kBACf,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,UAAY;AAAA,gBACV;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,YAC1B;AAAA,YACA,kCAAoC;AAAA,cAClC,OAAS;AAAA,gBACP;AAAA,kBACE,MAAQ;AAAA,gBACV;AAAA,gBACA;AAAA,kBACE,KAAO,CAAC;AAAA,gBACV;AAAA,cACF;AAAA,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F,CAAA;MACF,CAAA;AAGA,YAAMxC,aAAa,wBAACiC,SAAkBC,UAAoBQ,SAAAA;AACxD,cAAMC,gBAAgBV,QAAQW,QAAQ,kBAAA,GAAqBC,SAAAA,GAAYC,MAAM,GAAA,EAAK,CAAA;AAClF,cAAMC,cAAcJ,iBAAiBV,QAAQ1C;AAC7C,YAAIwD,gBAAgBxD,UAAU;AAC5BqC,iBAAOK,SAASC,UAAUQ,IAAAA;QAC5B,OAAO;AACLA,eAAAA;QACF;MACF,GARmB;AASnB,WAAK/D,kBAAkB+C,KAAK1B,UAAAA;AAC5B,WAAKvB,KAAKuE,IAAIhD,UAAAA;IAChB,CAAA;EACF,GAlDwB;EAoDxB,aAAaiD,KAAKpE,MAIc;AAC9B,UAAM,EAAEC,gBAAgBC,SAASC,KAAI,IAAKH;AAC1C,UAAMqE,qBAAqB,IAAI5E,oBAAmB;MAAES;MAASD;MAAgBE;IAAK,CAAA;AAClF,UAAMkE,mBAAmBzC,GAAE;AAC3B,WAAOyC;EACT;AACF;;;AH1HO,IAAMC,SAASC,QAAQC,QAAQC,QAAQ,iCAAiC;EAC7EC,iBAAiBC,SAASC;EAC1BC,SAAS;IAACC,UAAUC;IAASD,UAAUE;;AACzC,CAAA,EAAGC,IAAI,+BAAA;AAKP,IAAMC,SAASC;","names":["Loggers","LogLevel","LogMethod","KeyValueStore","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","express","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"]}
|
|
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\": [\n \"correlationId\"\n ],\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\": [\n \"baseUrl\",\n \"jwt\"\n ],\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\": [\n \"metadataType\"\n ],\n \"additionalProperties\": false\n },\n \"MetadataType\": {\n \"type\": \"string\",\n \"enum\": [\n \"issuer\",\n \"authorizationServer\",\n \"openidFederation\"\n ]\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\": [\n \"correlationId\",\n \"metadata\",\n \"metadataType\"\n ],\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}","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;AAAA;AAAA,MACE,oBAAsB;AAAA,QACpB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,8BAAgC;AAAA,cAC9B,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,SAAW;AAAA,kBACT,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,YAC1B;AAAA,YACA,4BAA8B;AAAA,cAC5B,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,SAAW;AAAA,kBACT,MAAQ;AAAA,gBACV;AAAA,gBACA,WAAa;AAAA,kBACX,MAAQ;AAAA,gBACV;AAAA,gBACA,eAAiB;AAAA,kBACf,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,UAAY;AAAA,gBACV;AAAA,cACF;AAAA,cAC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AA;AACnC,mBAAOL,SAASM,KAAKL,SAAAA;UACvB,SAASxC,OAAO;AACdC,mBAAOD,MAAM,iDAAiDA,KAAAA;AAC9D,mBAAOuC,SAASO,OAAO,GAAA,EAAKD,KAAK,uBAAA;UACnC;QACF,CAAA;MACF,CAAA;AAGA,YAAMxC,aAAa,wBAACiC,SAAkBC,UAAoBQ,SAAAA;AACxD,cAAMC,gBAAgBV,QAAQW,QAAQ,kBAAA,GAAqBC,SAAAA,GAAYC,MAAM,GAAA,EAAK,CAAA;AAClF,cAAMC,cAAcJ,iBAAiBV,QAAQ1C;AAC7C,YAAIwD,gBAAgBxD,UAAU;AAC5BqC,iBAAOK,SAASC,UAAUQ,IAAAA;QAC5B,OAAO;AACLA,eAAAA;QACF;MACF,GARmB;AASnB,WAAK9D,kBAAkB8C,KAAK1B,UAAAA;AAC5B,WAAKtB,KAAKsE,IAAIhD,UAAAA;IAChB,CAAA;EACF,GAlDwB;EAoDxB,aAAaiD,KAAKpE,MAIc;AAC9B,UAAM,EAAEC,gBAAgBC,SAASC,KAAI,IAAKH;AAC1C,UAAMqE,qBAAqB,IAAI3E,oBAAmB;MAAEQ;MAASD;MAAgBE;IAAK,CAAA;AAClF,UAAMkE,mBAAmBzC,GAAE;AAC3B,WAAOyC;EACT;AACF;;;AH1HO,IAAMC,SAASC,QAAQC,QAAQC,QAAQ,iCAAiC;EAC7EC,iBAAiBC,SAASC;EAC1BC,SAAS;IAACC,UAAUC;IAASD,UAAUE;;AACzC,CAAA,EAAGC,IAAI,+BAAA;AAKP,IAAMC,SAASC;","names":["Loggers","LogLevel","LogMethod","KeyValueStore","OIDFMetadataStore","defaultStoreId","defaultNamespace","_openidFederationMetadataStores","schema","IOIDFMetadataStore","methods","oidfStoreGetMetadata","bind","oidfStoreListMetadata","oidfStoreHasMetadata","oidfStorePersistMetadata","oidfStoreImportMetadatas","oidfStoreRemoveMetadata","oidfStoreClearAllMetadata","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","express","OIDFMetadataServer","_context","_routers","_app","_opts","_routerMiddleware","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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.oidf-metatdata-server",
|
|
3
|
-
"version": "0.34.1-
|
|
3
|
+
"version": "0.34.1-next.278+0eacb25b",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"generate-plugin-schema": "tsx ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@sphereon/ssi-express-support": "0.34.1-
|
|
31
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.34.1-
|
|
32
|
-
"@sphereon/ssi-types": "0.34.1-
|
|
30
|
+
"@sphereon/ssi-express-support": "0.34.1-next.278+0eacb25b",
|
|
31
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.34.1-next.278+0eacb25b",
|
|
32
|
+
"@sphereon/ssi-types": "0.34.1-next.278+0eacb25b",
|
|
33
33
|
"debug": "^4.3.5",
|
|
34
34
|
"express": "^4.19.2",
|
|
35
35
|
"semver": "^7.6.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@sphereon/ssi-sdk.agent-config": "0.34.1-
|
|
38
|
+
"@sphereon/ssi-sdk.agent-config": "0.34.1-next.278+0eacb25b",
|
|
39
39
|
"@types/express": "^4.17.21",
|
|
40
40
|
"@types/express-serve-static-core": "^4.19.5",
|
|
41
41
|
"@types/http-terminator": "^2.0.5",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"Presentation Defintion Manager",
|
|
64
64
|
"PD Manager"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "0eacb25b6e38cef88d04d696d84e3c2ebcf89ede"
|
|
67
67
|
}
|