-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated oid4vci-holder and siopv2-rp to use credential-validati…
…on module for verifying credentials.
- Loading branch information
Showing
16 changed files
with
505 additions
and
246 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/credential-validation/__tests__/localAgent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { createObjects, getConfig } from '../../agent-config/dist' | ||
import { DataSource } from 'typeorm' | ||
|
||
jest.setTimeout(60000) | ||
|
||
import credentialValidationAgentLogic from './shared/credentialValidationAgentLogic' | ||
|
||
let dbConnection: Promise<DataSource> | ||
let agent: any | ||
|
||
const setup = async (): Promise<boolean> => { | ||
const config = await getConfig('packages/credential-validation/agent.yml') | ||
const { localAgent, db } = await createObjects(config, { localAgent: '/agent', db: '/dbConnection' }) | ||
agent = localAgent | ||
dbConnection = db | ||
|
||
return true | ||
} | ||
|
||
const tearDown = async (): Promise<boolean> => { | ||
await (await dbConnection).close() | ||
return true | ||
} | ||
|
||
const getAgent = () => agent | ||
const testContext = { | ||
getAgent, | ||
setup, | ||
tearDown, | ||
} | ||
|
||
describe('Local integration tests', (): void => { | ||
credentialValidationAgentLogic(testContext) | ||
}) |
70 changes: 70 additions & 0 deletions
70
packages/credential-validation/__tests__/restAgent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import 'cross-fetch/polyfill' | ||
// @ts-ignore | ||
import express, { Router } from 'express' | ||
import { Server } from 'http' | ||
import { DataSource } from 'typeorm' | ||
import { IAgent, createAgent, 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 credentialValidationAgentLogic from './shared/credentialValidationAgentLogic' | ||
import { ICredentialValidation } from '../src' | ||
jest.setTimeout(60000) | ||
|
||
const port = 4103 | ||
const basePath = '/agent' | ||
|
||
let serverAgent: IAgent | ||
let restServer: Server | ||
let dbConnection: Promise<DataSource> | ||
|
||
const getAgent = (options?: IAgentOptions) => | ||
createAgent<ICredentialValidation>({ | ||
...options, | ||
plugins: [ | ||
new AgentRestClient({ | ||
url: 'http://localhost:' + port + basePath, | ||
enabledMethods: serverAgent.availableMethods(), | ||
schema: serverAgent.getSchema(), | ||
}), | ||
], | ||
}) | ||
|
||
const setup = async (): Promise<boolean> => { | ||
const config = await getConfig('packages/credential-validation/agent.yml') | ||
const { agent, db } = await createObjects(config, { agent: '/agent', db: '/dbConnection' }) | ||
serverAgent = agent | ||
dbConnection = db | ||
|
||
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<boolean> => { | ||
restServer.close() | ||
await (await dbConnection).close() | ||
return true | ||
} | ||
|
||
const testContext = { | ||
getAgent, | ||
setup, | ||
tearDown, | ||
} | ||
|
||
describe('REST integration tests', (): void => { | ||
credentialValidationAgentLogic(testContext) | ||
}) |
142 changes: 142 additions & 0 deletions
142
packages/credential-validation/__tests__/shared/credentialValidationAgentLogic.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
version: 3.0 | ||
|
||
constants: | ||
baseUrl: http://localhost:3336 | ||
port: 3336 | ||
secretKey: 29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c | ||
methods: | ||
- cvVerifyCredential | ||
- cvVerifySchema | ||
- cvVerifyMdoc | ||
- cvVerifySDJWTCredential | ||
- cvVerifyW3CCredential | ||
|
||
dbConnection: | ||
$require: typeorm?t=function#createConnection | ||
$args: | ||
- type: sqlite | ||
database: ':memory:' | ||
synchronize: false | ||
migrationsRun: true | ||
migrations: | ||
$require: './packages/ssi-sdk-core/dist?t=function#flattenMigrations' | ||
$args: | ||
- migrations: | ||
- $require: '@veramo/data-store?t=object#migrations' | ||
- $require: './packages/data-store?t=object#DataStoreMigrations' | ||
logging: ['info', 'warn'] | ||
entities: | ||
$require: './packages/ssi-sdk-core/dist?t=function#flattenArray' | ||
$args: | ||
- items: | ||
- $require: '@veramo/data-store?t=object#Entities' | ||
- $require: './packages/data-store?t=object#DataStoreEntities' | ||
# migrations: | ||
# $require: '@veramo/data-store?t=object#migrations' | ||
# entities: | ||
# $require: '@veramo/data-store?t=object#Entities' | ||
|
||
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: :3336/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 | ||
|
||
keyManager: | ||
$require: '@sphereon/ssi-sdk-ext.key-manager#SphereonKeyManager' | ||
$args: | ||
- store: | ||
$require: '@veramo/data-store#KeyStore' | ||
$args: | ||
- $ref: /dbConnection | ||
kms: | ||
local: | ||
$require: '@sphereon/ssi-sdk-ext.kms-local#SphereonKeyManagementSystem' | ||
$args: | ||
- $require: '@veramo/data-store#PrivateKeyStore' | ||
$args: | ||
- $ref: /dbConnection | ||
- $require: '@sphereon/ssi-sdk-ext.kms-local#SecretBox' | ||
$args: | ||
- $ref: /constants/secretKey | ||
|
||
didManager: | ||
$require: '@veramo/did-manager#DIDManager' | ||
$args: | ||
- store: | ||
$require: '@veramo/data-store#DIDStore' | ||
$args: | ||
- $ref: /dbConnection | ||
defaultProvider: did:ebsi | ||
|
||
# Agent | ||
agent: | ||
$require: '@veramo/core#Agent' | ||
$args: | ||
- schemaValidation: false | ||
plugins: | ||
- $ref: /keyManager | ||
- $ref: /didManager | ||
- $require: '@veramo/core#Agent' | ||
- $require: '@veramo/data-store#DataStore' | ||
$args: | ||
- $ref: /dbConnection | ||
- $require: '@veramo/data-store#DataStoreORM' | ||
$args: | ||
- $ref: /dbConnection | ||
# - $require: '@veramo/credential-w3c#CredentialPlugin' | ||
- $require: ./packages/credential-validation/dist#CredentialValidation | ||
# - $require: ./packages/presentation-exchange/dist#PresentationExchange | ||
# - $require: ./packages/siopv2-oid4vp-op-auth/dist#DidAuthSiopOpAuthenticator | ||
# - $require: ./packages/oid4vci-holder/dist#OID4VCIHolder | ||
# - $require: ./packages/issuance-branding/dist#IssuanceBranding | ||
# $args: | ||
# - store: | ||
# $require: './packages/data-store/dist#IssuanceBrandingStore' | ||
# $args: | ||
# - $ref: /dbConnection | ||
# - $require: ./packages/contact-manager/dist#ContactManager | ||
# $args: | ||
# - store: | ||
# $require: './packages/data-store/dist#ContactStore' | ||
# $args: | ||
# - $ref: /dbConnection | ||
# $args: | ||
# - presentationSignCallback: { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.