@sphereon/ssi-sdk.oidf-metatdata-server 0.34.1-next.3 → 0.34.1-next.322

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 CHANGED
@@ -399,10 +399,10 @@ var OIDFMetadataStore = class {
399
399
  };
400
400
 
401
401
  // src/types/metadata-server.ts
402
- var FederationEndpoints = /* @__PURE__ */ function(FederationEndpoints2) {
402
+ var FederationEndpoints = /* @__PURE__ */ (function(FederationEndpoints2) {
403
403
  FederationEndpoints2["WELL_KNOWN_OPENID_FEDERATION"] = "/.well-known/openid-federation";
404
404
  return FederationEndpoints2;
405
- }({});
405
+ })({});
406
406
 
407
407
  // src/oidf-metadata-server.ts
408
408
  var import_express = __toESM(require("express"), 1);
@@ -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\": [\"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,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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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,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"]}
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,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,eAA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AAU,gBAAgB,kCAAA;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,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
@@ -365,10 +365,10 @@ var OIDFMetadataStore = class {
365
365
  };
366
366
 
367
367
  // src/types/metadata-server.ts
368
- var FederationEndpoints = /* @__PURE__ */ function(FederationEndpoints2) {
368
+ var FederationEndpoints = /* @__PURE__ */ (function(FederationEndpoints2) {
369
369
  FederationEndpoints2["WELL_KNOWN_OPENID_FEDERATION"] = "/.well-known/openid-federation";
370
370
  return FederationEndpoints2;
371
- }({});
371
+ })({});
372
372
 
373
373
  // src/oidf-metadata-server.ts
374
374
  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\": [\"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;AAAA;AAAA,M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,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"]}
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"],"m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F;;;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-next.3+6c49ea2f",
3
+ "version": "0.34.1-next.322+78f8dd31",
4
4
  "source": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -24,18 +24,18 @@
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
27
- "generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
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-next.3+6c49ea2f",
31
- "@sphereon/ssi-sdk.kv-store-temp": "0.34.1-next.3+6c49ea2f",
32
- "@sphereon/ssi-types": "0.34.1-next.3+6c49ea2f",
30
+ "@sphereon/ssi-express-support": "0.34.1-next.322+78f8dd31",
31
+ "@sphereon/ssi-sdk.kv-store-temp": "0.34.1-next.322+78f8dd31",
32
+ "@sphereon/ssi-types": "0.34.1-next.322+78f8dd31",
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-next.3+6c49ea2f",
38
+ "@sphereon/ssi-sdk.agent-config": "0.34.1-next.322+78f8dd31",
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": "6c49ea2f9c1bc61641ca2c98e3aa0a5b48018d91"
66
+ "gitHead": "78f8dd3157066ae8cf11d2ae50c8c3d8f43b8ed0"
67
67
  }