diff --git a/.gitignore b/.gitignore index 24c1d444e..35ebad5a4 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,7 @@ test/*.js /packages/issuance-branding/plugin.schema.json /packages/oid4vci-issuer-rest-client/plugin.schema.json /packages/xstate-persistence/plugin.schema.json +/packages/oidf-client/plugin.schema.json **/.env.energyshr **/.env.local diff --git a/packages/oidf-client/__tests__/localAgent.test.ts b/packages/oidf-client/__tests__/localAgent.test.ts new file mode 100644 index 000000000..492010a6b --- /dev/null +++ b/packages/oidf-client/__tests__/localAgent.test.ts @@ -0,0 +1,30 @@ +import { createObjects, getConfig } from '../../agent-config/dist' + +jest.setTimeout(60000) + +import oidfClientAgentLogic from './shared/oidfClientAgentLogic' + +let agent: any + +const setup = async (): Promise => { + const config = await getConfig('packages/oidf-client/agent.yml') + const { localAgent } = await createObjects(config, { localAgent: '/agent' }) + agent = localAgent + + return true +} + +const tearDown = async (): Promise => { + return true +} + +const getAgent = () => agent +const testContext = { + getAgent, + setup, + tearDown, +} + +describe('Local integration tests', (): void => { + oidfClientAgentLogic(testContext) +}) diff --git a/packages/oidf-client/__tests__/restAgent.test.ts b/packages/oidf-client/__tests__/restAgent.test.ts new file mode 100644 index 000000000..cb8676cfb --- /dev/null +++ b/packages/oidf-client/__tests__/restAgent.test.ts @@ -0,0 +1,67 @@ +import 'cross-fetch/polyfill' +// @ts-ignore +import express, {Router} from 'express' +import {Server} from 'http' +import {createAgent, IAgent, IAgentOptions} from '@veramo/core' +import {AgentRestClient} from '@veramo/remote-client' +import {AgentRouter, RequestWithAgentRouter} from '@veramo/remote-server' +import {createObjects, getConfig} from '../../agent-config/dist' +import oidfClientAgentLogic from './shared/oidfClientAgentLogic' +import {IOIDFClient} from "../src"; + +jest.setTimeout(60000) + +const port = 4102 +const basePath = '/agent' + +let serverAgent: IAgent +let restServer: Server + +const getAgent = (options?: IAgentOptions) => + createAgent({ + ...options, + plugins: [ + new AgentRestClient({ + url: 'http://localhost:' + port + basePath, + enabledMethods: serverAgent.availableMethods(), + schema: serverAgent.getSchema(), + }), + ], + }) + +const setup = async (): Promise => { + const config = await getConfig('packages/oidf-client/agent.yml') + const { agent } = await createObjects(config, { agent: '/agent' }) + serverAgent = agent + + const agentRouter = AgentRouter({ + exposedMethods: serverAgent.availableMethods(), + }) + + const requestWithAgent: Router = RequestWithAgentRouter({ + agent: serverAgent, + }) + + return new Promise((resolve): void => { + const app = express() + app.use(basePath, requestWithAgent, agentRouter) + restServer = app.listen(port, (): void => { + resolve(true) + }) + }) +} + +const tearDown = async (): Promise => { + restServer.close() + return true +} + +const testContext = { + getAgent, + setup, + tearDown, +} + +describe('REST integration tests', (): void => { + oidfClientAgentLogic(testContext) +}) diff --git a/packages/oidf-client/__tests__/shared/CryptoPlatformTestCallback.ts b/packages/oidf-client/__tests__/shared/CryptoPlatformTestCallback.ts new file mode 100644 index 000000000..e0d4ce3a4 --- /dev/null +++ b/packages/oidf-client/__tests__/shared/CryptoPlatformTestCallback.ts @@ -0,0 +1,35 @@ +import { + com +} from "../../../../../OpenID-Federation/build/js/packages/openid-federation-modules-openid-federation-client"; +import * as jose from 'jose' +import ICryptoServiceCallbackJS = com.sphereon.oid.fed.client.crypto.ICryptoServiceCallbackJS; +import {JWK} from "jose"; + +type JWKS = { + keys: JWK[] +} + +export class CryptoPlatformCallback implements ICryptoServiceCallbackJS { + + async verify(jwt: string): Promise { + const decodedProtectedHeader = jose.decodeProtectedHeader(jwt) + const kid = decodedProtectedHeader.kid + + const payload = jose.decodeJwt(jwt) + + const key = (payload?.jwks as JWKS).keys.find(publicKey => publicKey.kid === kid) + + if (key === undefined || key === null) { + return false + } + + const publicKey = await jose.importJWK(key) + + const options = { + currentDate: new Date(Date.parse("Oct 14, 2024 01:00:00")) + } + + const result = await jose.jwtVerify(jwt, publicKey, options) + return result !== undefined + } +} diff --git a/packages/oidf-client/__tests__/shared/oidfClientAgentLogic.ts b/packages/oidf-client/__tests__/shared/oidfClientAgentLogic.ts new file mode 100644 index 000000000..e11545c4c --- /dev/null +++ b/packages/oidf-client/__tests__/shared/oidfClientAgentLogic.ts @@ -0,0 +1,28 @@ +import {TAgent} from '@veramo/core' +import {IOIDFClient} from "../../src"; +import {CryptoPlatformCallback} from "./CryptoPlatformTestCallback"; + +type ConfiguredAgent = TAgent + +export default (testContext: { getAgent: () => ConfiguredAgent; setup: () => Promise; tearDown: () => Promise }): void => { + describe('Credential Store Agent Plugin', (): void => { + let agent: ConfiguredAgent + + beforeAll(async (): Promise => { + await testContext.setup() + agent = testContext.getAgent() + await agent.registerCryptoServiceCallback(new CryptoPlatformCallback()) + }) + + afterAll(testContext.tearDown) + + it('should resolve trust chains', async () => { + + }) + + it('should verify JWTs', async () => { + const jwt = 'eyJraWQiOiJkZWZhdWx0UlNBU2lnbiIsInR5cCI6ImVudGl0eS1zdGF0ZW1lbnQrand0IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJodHRwczovL29pZGMucmVnaXN0cnkuc2Vydml6aWNpZS5pbnRlcm5vLmdvdi5pdCIsIm1ldGFkYXRhIjp7ImZlZGVyYXRpb25fZW50aXR5Ijp7ImZlZGVyYXRpb25fZmV0Y2hfZW5kcG9pbnQiOiJodHRwczovL29pZGMucmVnaXN0cnkuc2Vydml6aWNpZS5pbnRlcm5vLmdvdi5pdC9mZXRjaCIsImZlZGVyYXRpb25fcmVzb2x2ZV9lbmRwb2ludCI6Imh0dHBzOi8vb2lkYy5yZWdpc3RyeS5zZXJ2aXppY2llLmludGVybm8uZ292Lml0L3Jlc29sdmUiLCJmZWRlcmF0aW9uX3RydXN0X21hcmtfc3RhdHVzX2VuZHBvaW50IjoiaHR0cHM6Ly9vaWRjLnJlZ2lzdHJ5LnNlcnZpemljaWUuaW50ZXJuby5nb3YuaXQvdHJ1c3RfbWFya19zdGF0dXMiLCJmZWRlcmF0aW9uX2xpc3RfZW5kcG9pbnQiOiJodHRwczovL29pZGMucmVnaXN0cnkuc2Vydml6aWNpZS5pbnRlcm5vLmdvdi5pdC9saX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gBr7R4HDURyiixcA' + await expect(agent.verifyJwt({ jwt })).resolves.toBeTruthy() + }) + }) +} diff --git a/packages/oidf-client/agent.yml b/packages/oidf-client/agent.yml new file mode 100644 index 000000000..b4fba8bf3 --- /dev/null +++ b/packages/oidf-client/agent.yml @@ -0,0 +1,75 @@ +version: 3.0 + +constants: + baseUrl: http://localhost:3335 + port: 3335 + # please use your own X25519 key, this is only an example + secretKey: 29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c + methods: + - resolveTrustChain + - registerCryptoServiceCallback + - verifyJwt + +server: + baseUrl: + $ref: /constants/baseUrl + port: + $ref: /constants/port + use: + # CORS + - - $require: 'cors' + + # Add agent to the request object + - - $require: '@veramo/remote-server?t=function#RequestWithAgentRouter' + $args: + - agent: + $ref: /agent + + # API base path + - - /agent + - $require: '@veramo/remote-server?t=function#apiKeyAuth' + $args: + # Please configure your own API key. This is used when executing agent methods through ${baseUrl}/agent or ${baseUrl}/api-docs + - apiKey: test123 + - $require: '@veramo/remote-server?t=function#AgentRouter' + $args: + - exposedMethods: + $ref: /constants/methods + + # Open API schema + - - /open-api.json + - $require: '@veramo/remote-server?t=function#ApiSchemaRouter' + $args: + - basePath: :3335/agent + securityScheme: bearer + apiName: Agent + apiVersion: '1.0.0' + exposedMethods: + $ref: /constants/methods + + # Swagger docs + - - /api-docs + - $require: swagger-ui-express?t=object#serve + - $require: swagger-ui-express?t=function#setup + $args: + - null + - swaggerOptions: + url: '/open-api.json' + + # Execute during server initialization + init: + - $require: '@veramo/remote-server?t=function#createDefaultDid' + $args: + - agent: + $ref: /agent + baseUrl: + $ref: /constants/baseUrl + messagingServiceEndpoint: /messaging + +# Agent +agent: + $require: '@veramo/core#Agent' + $args: + - schemaValidation: false + plugins: + - $require: ./packages/oidf-client/dist#OIDFClient diff --git a/packages/oidf-client/package.json b/packages/oidf-client/package.json index d5319d76d..80bbfeac7 100644 --- a/packages/oidf-client/package.json +++ b/packages/oidf-client/package.json @@ -17,12 +17,14 @@ "dependencies": { "openid-federation-modules-openapi": "link:../../../OpenID-Federation/build/js/packages/openid-federation-modules-openapi", "openid-federation-modules-openid-federation-client": "link:../../../OpenID-Federation/build/js/packages/openid-federation-modules-openid-federation-client", - "openid-federation-modules-openid-federation-common": "link:../../../OpenID-Federation/build/js/packages/openid-federation-modules-openid-federation-common" + "openid-federation-modules-openid-federation-common": "link:../../../OpenID-Federation/build/js/packages/openid-federation-modules-openid-federation-common", + "@sphereon/ssi-types": "workspace:*" }, "devDependencies": { "@sphereon/ssi-sdk.agent-config": "workspace:*", "@veramo/remote-client": "4.2.0", - "@veramo/remote-server": "4.2.0" + "@veramo/remote-server": "4.2.0", + "jose": "5.9.4" }, "files": [ "dist/**/*", diff --git a/packages/oidf-client/tsconfig.json b/packages/oidf-client/tsconfig.json index d9a7a2ebb..d95c71b88 100644 --- a/packages/oidf-client/tsconfig.json +++ b/packages/oidf-client/tsconfig.json @@ -7,6 +7,9 @@ "esModuleInterop": true }, "references": [ + { + "path": "../ssi-types" + }, { "path": "../agent-config" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83bda3a64..c8bf663fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1461,6 +1461,9 @@ importers: packages/oidf-client: dependencies: + '@sphereon/ssi-types': + specifier: workspace:* + version: link:../ssi-types openid-federation-modules-openapi: specifier: link:../../../OpenID-Federation/build/js/packages/openid-federation-modules-openapi version: link:../../../OpenID-Federation/build/js/packages/openid-federation-modules-openapi @@ -1480,6 +1483,9 @@ importers: '@veramo/remote-server': specifier: 4.2.0 version: 4.2.0(express@4.19.2) + jose: + specifier: 5.9.4 + version: 5.9.4 packages/pd-manager: dependencies: @@ -7945,7 +7951,6 @@ packages: joi: 17.13.3 transitivePeerDependencies: - typescript - dev: true /@react-native-community/cli-debugger-ui@14.0.0: resolution: {integrity: sha512-JpfzILfU7eKE9+7AMCAwNJv70H4tJGVv3ZGFqSVoK1YHg5QkVEGsHtoNW8AsqZRS6Fj4os+Fmh+r+z1L36sPmg==} @@ -8004,7 +8009,6 @@ packages: yaml: 2.5.0 transitivePeerDependencies: - typescript - dev: true /@react-native-community/cli-platform-android@14.0.0: resolution: {integrity: sha512-nt7yVz3pGKQXnVa5MAk7zR+1n41kNKD3Hi2OgybH5tVShMBo7JQoL2ZVVH6/y/9wAwI/s7hXJgzf1OIP3sMq+Q==} @@ -8151,7 +8155,6 @@ packages: - supports-color - typescript - utf-8-validate - dev: true /@react-native/assets-registry@0.75.2: resolution: {integrity: sha512-P1dLHjpUeC0AIkDHRYcx0qLMr+p92IPWL3pmczzo6T76Qa9XzruQOYy0jittxyBK91Csn6HHQ/eit8TeXW8MVw==} @@ -8443,7 +8446,7 @@ packages: invariant: 2.2.4 nullthrows: 1.1.1 react: 18.3.1 - react-native: 0.75.2(@babel/core@7.25.2)(@babel/preset-env@7.25.3)(react@18.3.1)(typescript@5.4.2) + react-native: 0.75.2(@babel/core@7.25.2)(@babel/preset-env@7.25.3)(react@18.3.1)(typescript@5.5.3) /@rnx-kit/chromium-edge-launcher@1.0.0: resolution: {integrity: sha512-lzD84av1ZQhYUS+jsGqJiCMaJO2dn9u+RTT9n9q6D3SaKVwWqv+7AoRKqBu19bkwyE+iFRl1ymr40QS90jVFYg==} @@ -13681,7 +13684,6 @@ packages: js-yaml: 4.1.0 parse-json: 5.2.0 typescript: 5.5.3 - dev: true /crc-32@1.2.2: resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} @@ -18021,6 +18023,10 @@ packages: resolution: {integrity: sha512-3P9qfTYDVnNn642LCAqIKbTGb9a1TBxZ9ti5zEVEr48aDdflgRjhspWFb6WM4PzAfFbGMJYC4+803v8riCRAKw==} dev: true + /jose@5.9.4: + resolution: {integrity: sha512-WBBl6au1qg6OHj67yCffCgFR3BADJBXN8MdRvCgJDuMv3driV2nHr7jdGvaKX9IolosAsn+M0XRArqLXUhyJHQ==} + dev: true + /js-base64@3.7.7: resolution: {integrity: sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==} @@ -21605,7 +21611,6 @@ packages: - supports-color - typescript - utf-8-validate - dev: true /react-qr-code@2.0.15(react@18.3.1): resolution: {integrity: sha512-MkZcjEXqVKqXEIMVE0mbcGgDpkfSdd8zhuzXEl9QzYeNcw8Hq2oVIzDLWuZN2PQBwM5PWjc2S31K8Q1UbcFMfw==}