@sphereon/ssi-sdk.oidf-metatdata-server 0.34.1-next.91 → 0.36.1-feat.SSISDK.83.11
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 +5 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -20
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/plugin.schema.json +6 -21
package/dist/index.cjs
CHANGED
|
@@ -60,9 +60,7 @@ var require_plugin_schema = __commonJS({
|
|
|
60
60
|
type: "string"
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
required: [
|
|
64
|
-
"correlationId"
|
|
65
|
-
],
|
|
63
|
+
required: ["correlationId"],
|
|
66
64
|
additionalProperties: false
|
|
67
65
|
},
|
|
68
66
|
OptionalOpenidFederationMetadata: {
|
|
@@ -88,10 +86,7 @@ var require_plugin_schema = __commonJS({
|
|
|
88
86
|
type: "boolean"
|
|
89
87
|
}
|
|
90
88
|
},
|
|
91
|
-
required: [
|
|
92
|
-
"baseUrl",
|
|
93
|
-
"jwt"
|
|
94
|
-
],
|
|
89
|
+
required: ["baseUrl", "jwt"],
|
|
95
90
|
additionalProperties: false
|
|
96
91
|
},
|
|
97
92
|
FederationMetadataExistsArgs: {
|
|
@@ -104,18 +99,12 @@ var require_plugin_schema = __commonJS({
|
|
|
104
99
|
$ref: "#/components/schemas/MetadataType"
|
|
105
100
|
}
|
|
106
101
|
},
|
|
107
|
-
required: [
|
|
108
|
-
"metadataType"
|
|
109
|
-
],
|
|
102
|
+
required: ["metadataType"],
|
|
110
103
|
additionalProperties: false
|
|
111
104
|
},
|
|
112
105
|
MetadataType: {
|
|
113
106
|
type: "string",
|
|
114
|
-
enum: [
|
|
115
|
-
"issuer",
|
|
116
|
-
"authorizationServer",
|
|
117
|
-
"openidFederation"
|
|
118
|
-
]
|
|
107
|
+
enum: ["issuer", "authorizationServer", "openidFederation"]
|
|
119
108
|
},
|
|
120
109
|
IFederationMetadataListArgs: {
|
|
121
110
|
type: "object",
|
|
@@ -157,11 +146,7 @@ var require_plugin_schema = __commonJS({
|
|
|
157
146
|
type: "string"
|
|
158
147
|
}
|
|
159
148
|
},
|
|
160
|
-
required: [
|
|
161
|
-
"correlationId",
|
|
162
|
-
"metadata",
|
|
163
|
-
"metadataType"
|
|
164
|
-
],
|
|
149
|
+
required: ["correlationId", "metadata", "metadataType"],
|
|
165
150
|
additionalProperties: false
|
|
166
151
|
},
|
|
167
152
|
OptionalOpenidFederationValueData: {
|
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,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,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dC,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,eAAiB;AAAA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AgB,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
|
@@ -34,9 +34,7 @@ var require_plugin_schema = __commonJS({
|
|
|
34
34
|
type: "string"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
required: [
|
|
38
|
-
"correlationId"
|
|
39
|
-
],
|
|
37
|
+
required: ["correlationId"],
|
|
40
38
|
additionalProperties: false
|
|
41
39
|
},
|
|
42
40
|
OptionalOpenidFederationMetadata: {
|
|
@@ -62,10 +60,7 @@ var require_plugin_schema = __commonJS({
|
|
|
62
60
|
type: "boolean"
|
|
63
61
|
}
|
|
64
62
|
},
|
|
65
|
-
required: [
|
|
66
|
-
"baseUrl",
|
|
67
|
-
"jwt"
|
|
68
|
-
],
|
|
63
|
+
required: ["baseUrl", "jwt"],
|
|
69
64
|
additionalProperties: false
|
|
70
65
|
},
|
|
71
66
|
FederationMetadataExistsArgs: {
|
|
@@ -78,18 +73,12 @@ var require_plugin_schema = __commonJS({
|
|
|
78
73
|
$ref: "#/components/schemas/MetadataType"
|
|
79
74
|
}
|
|
80
75
|
},
|
|
81
|
-
required: [
|
|
82
|
-
"metadataType"
|
|
83
|
-
],
|
|
76
|
+
required: ["metadataType"],
|
|
84
77
|
additionalProperties: false
|
|
85
78
|
},
|
|
86
79
|
MetadataType: {
|
|
87
80
|
type: "string",
|
|
88
|
-
enum: [
|
|
89
|
-
"issuer",
|
|
90
|
-
"authorizationServer",
|
|
91
|
-
"openidFederation"
|
|
92
|
-
]
|
|
81
|
+
enum: ["issuer", "authorizationServer", "openidFederation"]
|
|
93
82
|
},
|
|
94
83
|
IFederationMetadataListArgs: {
|
|
95
84
|
type: "object",
|
|
@@ -131,11 +120,7 @@ var require_plugin_schema = __commonJS({
|
|
|
131
120
|
type: "string"
|
|
132
121
|
}
|
|
133
122
|
},
|
|
134
|
-
required: [
|
|
135
|
-
"correlationId",
|
|
136
|
-
"metadata",
|
|
137
|
-
"metadataType"
|
|
138
|
-
],
|
|
123
|
+
required: ["correlationId", "metadata", "metadataType"],
|
|
139
124
|
additionalProperties: false
|
|
140
125
|
},
|
|
141
126
|
OptionalOpenidFederationValueData: {
|
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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ethod","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"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,oBAAsB;AAAA,QACpB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,8BAAgC;AAAA,cAC9B,MAAQ;AAAA,cACR,YAAc;AAAA,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AAA;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.
|
|
3
|
+
"version": "0.36.1-feat.SSISDK.83.11+15665c90",
|
|
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.
|
|
31
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.
|
|
32
|
-
"@sphereon/ssi-types": "0.
|
|
30
|
+
"@sphereon/ssi-express-support": "0.36.1-feat.SSISDK.83.11+15665c90",
|
|
31
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.36.1-feat.SSISDK.83.11+15665c90",
|
|
32
|
+
"@sphereon/ssi-types": "0.36.1-feat.SSISDK.83.11+15665c90",
|
|
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.
|
|
38
|
+
"@sphereon/ssi-sdk.agent-config": "0.36.1-feat.SSISDK.83.11+15665c90",
|
|
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": "15665c90d27b72a0c3b7267375f60512d2cd4085"
|
|
67
67
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
"type": "string"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
"required": [
|
|
28
|
-
"correlationId"
|
|
29
|
-
],
|
|
27
|
+
"required": ["correlationId"],
|
|
30
28
|
"additionalProperties": false
|
|
31
29
|
},
|
|
32
30
|
"OptionalOpenidFederationMetadata": {
|
|
@@ -52,10 +50,7 @@
|
|
|
52
50
|
"type": "boolean"
|
|
53
51
|
}
|
|
54
52
|
},
|
|
55
|
-
"required": [
|
|
56
|
-
"baseUrl",
|
|
57
|
-
"jwt"
|
|
58
|
-
],
|
|
53
|
+
"required": ["baseUrl", "jwt"],
|
|
59
54
|
"additionalProperties": false
|
|
60
55
|
},
|
|
61
56
|
"FederationMetadataExistsArgs": {
|
|
@@ -68,18 +63,12 @@
|
|
|
68
63
|
"$ref": "#/components/schemas/MetadataType"
|
|
69
64
|
}
|
|
70
65
|
},
|
|
71
|
-
"required": [
|
|
72
|
-
"metadataType"
|
|
73
|
-
],
|
|
66
|
+
"required": ["metadataType"],
|
|
74
67
|
"additionalProperties": false
|
|
75
68
|
},
|
|
76
69
|
"MetadataType": {
|
|
77
70
|
"type": "string",
|
|
78
|
-
"enum": [
|
|
79
|
-
"issuer",
|
|
80
|
-
"authorizationServer",
|
|
81
|
-
"openidFederation"
|
|
82
|
-
]
|
|
71
|
+
"enum": ["issuer", "authorizationServer", "openidFederation"]
|
|
83
72
|
},
|
|
84
73
|
"IFederationMetadataListArgs": {
|
|
85
74
|
"type": "object",
|
|
@@ -121,11 +110,7 @@
|
|
|
121
110
|
"type": "string"
|
|
122
111
|
}
|
|
123
112
|
},
|
|
124
|
-
"required": [
|
|
125
|
-
"correlationId",
|
|
126
|
-
"metadata",
|
|
127
|
-
"metadataType"
|
|
128
|
-
],
|
|
113
|
+
"required": ["correlationId", "metadata", "metadataType"],
|
|
129
114
|
"additionalProperties": false
|
|
130
115
|
},
|
|
131
116
|
"OptionalOpenidFederationValueData": {
|
|
@@ -228,4 +213,4 @@
|
|
|
228
213
|
}
|
|
229
214
|
}
|
|
230
215
|
}
|
|
231
|
-
}
|
|
216
|
+
}
|